@rangka/client 0.1.1 → 0.1.3

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 (317) hide show
  1. package/dist/App.d.ts.map +1 -1
  2. package/dist/App.js +7 -1
  3. package/dist/App.js.map +1 -1
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +2 -0
  7. package/dist/index.js.map +1 -1
  8. package/dist/main.d.ts.map +1 -1
  9. package/dist/main.js +20 -0
  10. package/dist/main.js.map +1 -1
  11. package/dist/shell/assets/index-63v1sBS3.css +1 -0
  12. package/dist/shell/assets/index-Dh7K40cQ.js +8634 -0
  13. package/dist/shell/assets/vendor-query-B2cydN5j.js +1 -0
  14. package/dist/shell/assets/vendor-radix-BJxYPxPb.js +69 -0
  15. package/dist/shell/assets/vendor-router-ET_myMt5.js +17 -0
  16. package/dist/shell/index.html +5 -2
  17. package/dist/theme.css +82 -0
  18. package/dist/widgets/components/lazy-manifest.d.ts +11 -0
  19. package/dist/widgets/components/lazy-manifest.d.ts.map +1 -0
  20. package/dist/widgets/components/lazy-manifest.js +32 -0
  21. package/dist/widgets/components/lazy-manifest.js.map +1 -0
  22. package/dist/widgets/components/register.js +12 -12
  23. package/dist/widgets/components/register.js.map +1 -1
  24. package/dist/widgets/loader.d.ts +3 -0
  25. package/dist/widgets/loader.d.ts.map +1 -0
  26. package/dist/widgets/loader.js +73 -0
  27. package/dist/widgets/loader.js.map +1 -0
  28. package/dist/widgets/renderer/LazyWidget.d.ts +8 -0
  29. package/dist/widgets/renderer/LazyWidget.d.ts.map +1 -0
  30. package/dist/widgets/renderer/LazyWidget.js +31 -0
  31. package/dist/widgets/renderer/LazyWidget.js.map +1 -0
  32. package/dist/widgets/renderer/WidgetErrorBoundary.d.ts +17 -0
  33. package/dist/widgets/renderer/WidgetErrorBoundary.d.ts.map +1 -0
  34. package/dist/widgets/renderer/WidgetErrorBoundary.js +18 -0
  35. package/dist/widgets/renderer/WidgetErrorBoundary.js.map +1 -0
  36. package/dist/widgets/renderer/WidgetRenderer.d.ts.map +1 -1
  37. package/dist/widgets/renderer/WidgetRenderer.js +8 -6
  38. package/dist/widgets/renderer/WidgetRenderer.js.map +1 -1
  39. package/package.json +7 -4
  40. package/.claude/skills/add-widget/SKILL.md +0 -101
  41. package/.turbo/turbo-build.log +0 -29
  42. package/CHANGELOG.md +0 -25
  43. package/CLAUDE.md +0 -236
  44. package/components.json +0 -25
  45. package/dist/components/ui/chart.d.ts +0 -45
  46. package/dist/components/ui/chart.d.ts.map +0 -1
  47. package/dist/components/ui/chart.js +0 -119
  48. package/dist/components/ui/chart.js.map +0 -1
  49. package/dist/shell/assets/index--35CAvcP.js +0 -8715
  50. package/dist/shell/assets/index-COLmoPYo.css +0 -1
  51. package/index.html +0 -12
  52. package/src/App.tsx +0 -44
  53. package/src/__tests__/setup.ts +0 -1
  54. package/src/api/auth.ts +0 -41
  55. package/src/api/boot.ts +0 -10
  56. package/src/api/client.ts +0 -26
  57. package/src/api/paths.ts +0 -3
  58. package/src/api/token.ts +0 -13
  59. package/src/auth/LoginForm.tsx +0 -67
  60. package/src/auth/SessionExpired.tsx +0 -24
  61. package/src/auth/SetupForm.tsx +0 -76
  62. package/src/boot/BootGate.tsx +0 -35
  63. package/src/boot/BootProvider.tsx +0 -28
  64. package/src/boot/types.ts +0 -9
  65. package/src/boot/useBoot.ts +0 -111
  66. package/src/components/Icon.tsx +0 -17
  67. package/src/components/ui/accordion.tsx +0 -82
  68. package/src/components/ui/alert-dialog.tsx +0 -180
  69. package/src/components/ui/alert.tsx +0 -76
  70. package/src/components/ui/aspect-ratio.tsx +0 -9
  71. package/src/components/ui/avatar.tsx +0 -94
  72. package/src/components/ui/badge.tsx +0 -45
  73. package/src/components/ui/breadcrumb.tsx +0 -104
  74. package/src/components/ui/button-group.tsx +0 -78
  75. package/src/components/ui/button.tsx +0 -65
  76. package/src/components/ui/calendar.tsx +0 -187
  77. package/src/components/ui/card.tsx +0 -85
  78. package/src/components/ui/carousel.tsx +0 -229
  79. package/src/components/ui/chart.tsx +0 -339
  80. package/src/components/ui/checkbox.tsx +0 -27
  81. package/src/components/ui/collapsible.tsx +0 -21
  82. package/src/components/ui/combobox.tsx +0 -275
  83. package/src/components/ui/command.tsx +0 -178
  84. package/src/components/ui/context-menu.tsx +0 -242
  85. package/src/components/ui/dialog.tsx +0 -146
  86. package/src/components/ui/direction.tsx +0 -20
  87. package/src/components/ui/drawer.tsx +0 -118
  88. package/src/components/ui/dropdown-menu.tsx +0 -247
  89. package/src/components/ui/empty.tsx +0 -94
  90. package/src/components/ui/field.tsx +0 -224
  91. package/src/components/ui/hover-card.tsx +0 -36
  92. package/src/components/ui/input-group.tsx +0 -142
  93. package/src/components/ui/input-otp.tsx +0 -86
  94. package/src/components/ui/input.tsx +0 -19
  95. package/src/components/ui/item.tsx +0 -182
  96. package/src/components/ui/kbd.tsx +0 -26
  97. package/src/components/ui/label.tsx +0 -19
  98. package/src/components/ui/menubar.tsx +0 -260
  99. package/src/components/ui/native-select.tsx +0 -55
  100. package/src/components/ui/navigation-menu.tsx +0 -160
  101. package/src/components/ui/pagination.tsx +0 -112
  102. package/src/components/ui/popover.tsx +0 -74
  103. package/src/components/ui/progress.tsx +0 -31
  104. package/src/components/ui/radio-group.tsx +0 -42
  105. package/src/components/ui/resizable.tsx +0 -42
  106. package/src/components/ui/scroll-area.tsx +0 -53
  107. package/src/components/ui/select.tsx +0 -185
  108. package/src/components/ui/separator.tsx +0 -26
  109. package/src/components/ui/sheet.tsx +0 -128
  110. package/src/components/ui/sidebar.tsx +0 -669
  111. package/src/components/ui/skeleton.tsx +0 -13
  112. package/src/components/ui/slider.tsx +0 -54
  113. package/src/components/ui/sonner.tsx +0 -43
  114. package/src/components/ui/spinner.tsx +0 -16
  115. package/src/components/ui/switch.tsx +0 -33
  116. package/src/components/ui/table.tsx +0 -87
  117. package/src/components/ui/tabs.tsx +0 -80
  118. package/src/components/ui/textarea.tsx +0 -18
  119. package/src/components/ui/toggle-group.tsx +0 -86
  120. package/src/components/ui/toggle.tsx +0 -44
  121. package/src/components/ui/tooltip.tsx +0 -53
  122. package/src/context/MetaContext.tsx +0 -22
  123. package/src/context/ModuleContext.tsx +0 -62
  124. package/src/context/PermissionsContext.tsx +0 -39
  125. package/src/context/ShellProviders.tsx +0 -33
  126. package/src/context/UserContext.tsx +0 -16
  127. package/src/data/QueryProvider.tsx +0 -7
  128. package/src/data/queryClient.ts +0 -18
  129. package/src/data/useModelMeta.ts +0 -17
  130. package/src/data/useMutation.ts +0 -60
  131. package/src/data/useRecord.ts +0 -29
  132. package/src/data/useSource.ts +0 -112
  133. package/src/hooks/use-mobile.ts +0 -19
  134. package/src/index.css +0 -260
  135. package/src/index.ts +0 -16
  136. package/src/lib/utils.ts +0 -6
  137. package/src/main.tsx +0 -17
  138. package/src/router/NotFound.tsx +0 -8
  139. package/src/router/RouterProvider.tsx +0 -7
  140. package/src/router/buildRouteTree.tsx +0 -63
  141. package/src/router/createShellRouter.ts +0 -9
  142. package/src/router/hooks.ts +0 -43
  143. package/src/shell/CommandPalette.tsx +0 -76
  144. package/src/shell/ConfirmDialog.tsx +0 -34
  145. package/src/shell/ConfirmProvider.tsx +0 -56
  146. package/src/shell/DrawerContext.tsx +0 -44
  147. package/src/shell/HeaderActions.tsx +0 -31
  148. package/src/shell/ModuleSelectorPage.tsx +0 -149
  149. package/src/shell/PageOutlet.tsx +0 -21
  150. package/src/shell/ShellContext.tsx +0 -45
  151. package/src/shell/ShellDevTools.tsx +0 -153
  152. package/src/shell/ShellLayout.tsx +0 -231
  153. package/src/shell/Toast.tsx +0 -58
  154. package/src/shell/ToastProvider.tsx +0 -60
  155. package/src/shell/app-sidebar/AppSidebar.tsx +0 -44
  156. package/src/shell/app-sidebar/ModuleSwitcher.tsx +0 -87
  157. package/src/shell/app-sidebar/NavMain.tsx +0 -64
  158. package/src/shell/app-sidebar/NavUser.tsx +0 -97
  159. package/src/shell/app-sidebar/SearchMenu.tsx +0 -22
  160. package/src/shell/app-sidebar/index.ts +0 -8
  161. package/src/shell/app-sidebar/types.ts +0 -38
  162. package/src/shell/types.ts +0 -6
  163. package/src/shell/useBreadcrumbs.ts +0 -42
  164. package/src/studio/bridge.ts +0 -125
  165. package/src/studio/index.ts +0 -3
  166. package/src/studio/overlay.ts +0 -47
  167. package/src/studio/types.ts +0 -32
  168. package/src/studio/walker.ts +0 -48
  169. package/src/vite-env.d.ts +0 -1
  170. package/src/widgets/__tests__/action-edge-cases.test.ts +0 -281
  171. package/src/widgets/__tests__/action.test.ts +0 -236
  172. package/src/widgets/__tests__/attachment-widget.test.tsx +0 -85
  173. package/src/widgets/__tests__/attachments-widget.test.tsx +0 -109
  174. package/src/widgets/__tests__/binding.test.ts +0 -76
  175. package/src/widgets/__tests__/button-widget.test.tsx +0 -145
  176. package/src/widgets/__tests__/checkbox-widget.test.tsx +0 -158
  177. package/src/widgets/__tests__/code-widget.test.tsx +0 -64
  178. package/src/widgets/__tests__/computed-widget.test.tsx +0 -62
  179. package/src/widgets/__tests__/condition-edge-cases.test.ts +0 -120
  180. package/src/widgets/__tests__/condition.test.ts +0 -221
  181. package/src/widgets/__tests__/context.test.ts +0 -99
  182. package/src/widgets/__tests__/data-widget.test.tsx +0 -204
  183. package/src/widgets/__tests__/datepicker-widget.test.tsx +0 -66
  184. package/src/widgets/__tests__/datetime-widget.test.tsx +0 -67
  185. package/src/widgets/__tests__/drawer-widget.test.tsx +0 -149
  186. package/src/widgets/__tests__/dynamic-link-widget.test.tsx +0 -52
  187. package/src/widgets/__tests__/edge-cases.test.ts +0 -232
  188. package/src/widgets/__tests__/evaluator.test.ts +0 -107
  189. package/src/widgets/__tests__/functions.test.ts +0 -147
  190. package/src/widgets/__tests__/grid-widget.test.tsx +0 -137
  191. package/src/widgets/__tests__/hooks.test.tsx +0 -249
  192. package/src/widgets/__tests__/icon-widget.test.tsx +0 -129
  193. package/src/widgets/__tests__/input-widget.test.tsx +0 -264
  194. package/src/widgets/__tests__/integration.test.ts +0 -116
  195. package/src/widgets/__tests__/json-widget.test.tsx +0 -70
  196. package/src/widgets/__tests__/link-widget.test.tsx +0 -92
  197. package/src/widgets/__tests__/many-to-many-widget.test.tsx +0 -93
  198. package/src/widgets/__tests__/modal-widget.test.tsx +0 -148
  199. package/src/widgets/__tests__/money-widget.test.tsx +0 -97
  200. package/src/widgets/__tests__/parser.test.ts +0 -171
  201. package/src/widgets/__tests__/reactive-variables.test.ts +0 -383
  202. package/src/widgets/__tests__/renderer.test.tsx +0 -300
  203. package/src/widgets/__tests__/repeat-widget.test.tsx +0 -229
  204. package/src/widgets/__tests__/select-widget.test.tsx +0 -231
  205. package/src/widgets/__tests__/sequence-widget.test.tsx +0 -58
  206. package/src/widgets/__tests__/shell-integration.test.tsx +0 -1343
  207. package/src/widgets/__tests__/split-widget.test.tsx +0 -133
  208. package/src/widgets/__tests__/state-edge-cases.test.ts +0 -118
  209. package/src/widgets/__tests__/state.test.ts +0 -106
  210. package/src/widgets/__tests__/table-data-binding.test.tsx +0 -482
  211. package/src/widgets/__tests__/table-filter-popover.test.tsx +0 -486
  212. package/src/widgets/__tests__/table-search.test.tsx +0 -305
  213. package/src/widgets/__tests__/table-widget.test.tsx +0 -509
  214. package/src/widgets/__tests__/textarea-widget.test.tsx +0 -105
  215. package/src/widgets/__tests__/tracker-validator-edge-cases.test.ts +0 -242
  216. package/src/widgets/__tests__/tracker.test.ts +0 -133
  217. package/src/widgets/__tests__/tree-widget.test.tsx +0 -97
  218. package/src/widgets/__tests__/use-model-source.test.ts +0 -67
  219. package/src/widgets/__tests__/validator.test.ts +0 -208
  220. package/src/widgets/action/dispatcher.ts +0 -334
  221. package/src/widgets/action/index.ts +0 -2
  222. package/src/widgets/binding/index.ts +0 -2
  223. package/src/widgets/binding/resolver.ts +0 -61
  224. package/src/widgets/components/AttachmentWidget.tsx +0 -111
  225. package/src/widgets/components/AttachmentsWidget.tsx +0 -121
  226. package/src/widgets/components/BadgeWidget.tsx +0 -35
  227. package/src/widgets/components/ButtonWidget.tsx +0 -43
  228. package/src/widgets/components/CardWidget.tsx +0 -68
  229. package/src/widgets/components/CheckboxWidget.tsx +0 -39
  230. package/src/widgets/components/CodeWidget.tsx +0 -44
  231. package/src/widgets/components/ColumnWidget.tsx +0 -22
  232. package/src/widgets/components/ComputedWidget.tsx +0 -49
  233. package/src/widgets/components/DataWidget.tsx +0 -189
  234. package/src/widgets/components/DatePickerWidget.tsx +0 -73
  235. package/src/widgets/components/DatetimeWidget.tsx +0 -160
  236. package/src/widgets/components/DividerWidget.tsx +0 -37
  237. package/src/widgets/components/DrawerWidget.tsx +0 -52
  238. package/src/widgets/components/DynamicLinkWidget.tsx +0 -130
  239. package/src/widgets/components/GridWidget.tsx +0 -134
  240. package/src/widgets/components/GroupWidget.tsx +0 -111
  241. package/src/widgets/components/IconWidget.tsx +0 -29
  242. package/src/widgets/components/ImageWidget.tsx +0 -28
  243. package/src/widgets/components/InputWidget.tsx +0 -70
  244. package/src/widgets/components/JsonWidget.tsx +0 -78
  245. package/src/widgets/components/LinkWidget.tsx +0 -99
  246. package/src/widgets/components/ManyToManyWidget.tsx +0 -125
  247. package/src/widgets/components/ModalWidget.tsx +0 -52
  248. package/src/widgets/components/MoneyWidget.tsx +0 -80
  249. package/src/widgets/components/RepeatWidget.tsx +0 -66
  250. package/src/widgets/components/ScrollAreaWidget.tsx +0 -40
  251. package/src/widgets/components/SectionWidget.tsx +0 -78
  252. package/src/widgets/components/SelectWidget.tsx +0 -63
  253. package/src/widgets/components/SequenceWidget.tsx +0 -32
  254. package/src/widgets/components/SpacerWidget.tsx +0 -29
  255. package/src/widgets/components/SplitWidget.tsx +0 -60
  256. package/src/widgets/components/StackWidget.tsx +0 -44
  257. package/src/widgets/components/TableWidget.tsx +0 -366
  258. package/src/widgets/components/TextWidget.tsx +0 -44
  259. package/src/widgets/components/TextareaWidget.tsx +0 -49
  260. package/src/widgets/components/TreeWidget.tsx +0 -109
  261. package/src/widgets/components/index.ts +0 -30
  262. package/src/widgets/components/register.ts +0 -93
  263. package/src/widgets/components/table/CellRenderers.tsx +0 -83
  264. package/src/widgets/components/table/TablePagination.tsx +0 -45
  265. package/src/widgets/components/table/TableToolbar.tsx +0 -285
  266. package/src/widgets/components/table/filter-operators.ts +0 -134
  267. package/src/widgets/components/table/index.ts +0 -11
  268. package/src/widgets/condition/evaluator.ts +0 -57
  269. package/src/widgets/condition/index.ts +0 -1
  270. package/src/widgets/context/builder.ts +0 -99
  271. package/src/widgets/context/index.ts +0 -8
  272. package/src/widgets/context/types.ts +0 -37
  273. package/src/widgets/data/index.ts +0 -5
  274. package/src/widgets/data/useModelQuery.ts +0 -116
  275. package/src/widgets/data/useModelRecord.ts +0 -37
  276. package/src/widgets/expression/evaluator.ts +0 -100
  277. package/src/widgets/expression/functions.ts +0 -131
  278. package/src/widgets/expression/index.ts +0 -13
  279. package/src/widgets/expression/parser.ts +0 -229
  280. package/src/widgets/expression/types.ts +0 -45
  281. package/src/widgets/form/FormContext.ts +0 -29
  282. package/src/widgets/form/FormProvider.tsx +0 -84
  283. package/src/widgets/form/FormWidget.tsx +0 -42
  284. package/src/widgets/form/index.ts +0 -4
  285. package/src/widgets/form/useFormState.ts +0 -127
  286. package/src/widgets/form/useFormSubmit.ts +0 -90
  287. package/src/widgets/form/useFormValidation.ts +0 -62
  288. package/src/widgets/hooks/index.ts +0 -8
  289. package/src/widgets/hooks/useAction.ts +0 -83
  290. package/src/widgets/hooks/useBind.ts +0 -34
  291. package/src/widgets/hooks/useCondition.ts +0 -21
  292. package/src/widgets/hooks/useDataQuery.ts +0 -48
  293. package/src/widgets/hooks/useExpression.ts +0 -14
  294. package/src/widgets/hooks/usePageState.ts +0 -21
  295. package/src/widgets/hooks/useSurfaceContext.ts +0 -11
  296. package/src/widgets/hooks/useWidgetContext.ts +0 -14
  297. package/src/widgets/index.ts +0 -80
  298. package/src/widgets/lib/layout-props.ts +0 -135
  299. package/src/widgets/reactivity/index.ts +0 -11
  300. package/src/widgets/reactivity/tracker.ts +0 -139
  301. package/src/widgets/reactivity/variables.ts +0 -213
  302. package/src/widgets/registry.ts +0 -41
  303. package/src/widgets/renderer/SlotRenderer.tsx +0 -47
  304. package/src/widgets/renderer/WidgetRenderer.tsx +0 -191
  305. package/src/widgets/renderer/index.ts +0 -4
  306. package/src/widgets/shell/WidgetSlotRenderer.tsx +0 -73
  307. package/src/widgets/shell/index.ts +0 -4
  308. package/src/widgets/shell/useActionHandlers.ts +0 -170
  309. package/src/widgets/state/index.ts +0 -2
  310. package/src/widgets/state/store.ts +0 -96
  311. package/src/widgets/types.ts +0 -28
  312. package/src/widgets/validation/index.ts +0 -2
  313. package/src/widgets/validation/validator.ts +0 -140
  314. package/tsconfig.json +0 -27
  315. package/tsconfig.tsbuildinfo +0 -1
  316. package/vite.config.ts +0 -21
  317. package/vitest.config.ts +0 -16
@@ -1,229 +0,0 @@
1
- import * as React from 'react';
2
- import useEmblaCarousel, { type UseEmblaCarouselType } from 'embla-carousel-react';
3
-
4
- import { cn } from '@/lib/utils';
5
- import { Button } from '@/components/ui/button';
6
- import { ChevronLeftIcon, ChevronRightIcon } from 'lucide-react';
7
-
8
- type CarouselApi = UseEmblaCarouselType[1];
9
- type UseCarouselParameters = Parameters<typeof useEmblaCarousel>;
10
- type CarouselOptions = UseCarouselParameters[0];
11
- type CarouselPlugin = UseCarouselParameters[1];
12
-
13
- type CarouselProps = {
14
- opts?: CarouselOptions;
15
- plugins?: CarouselPlugin;
16
- orientation?: 'horizontal' | 'vertical';
17
- setApi?: (api: CarouselApi) => void;
18
- };
19
-
20
- type CarouselContextProps = {
21
- carouselRef: ReturnType<typeof useEmblaCarousel>[0];
22
- api: ReturnType<typeof useEmblaCarousel>[1];
23
- scrollPrev: () => void;
24
- scrollNext: () => void;
25
- canScrollPrev: boolean;
26
- canScrollNext: boolean;
27
- } & CarouselProps;
28
-
29
- const CarouselContext = React.createContext<CarouselContextProps | null>(null);
30
-
31
- function useCarousel() {
32
- const context = React.useContext(CarouselContext);
33
-
34
- if (!context) {
35
- throw new Error('useCarousel must be used within a <Carousel />');
36
- }
37
-
38
- return context;
39
- }
40
-
41
- function Carousel({
42
- orientation = 'horizontal',
43
- opts,
44
- setApi,
45
- plugins,
46
- className,
47
- children,
48
- ...props
49
- }: React.ComponentProps<'div'> & CarouselProps) {
50
- const [carouselRef, api] = useEmblaCarousel(
51
- {
52
- ...opts,
53
- axis: orientation === 'horizontal' ? 'x' : 'y',
54
- },
55
- plugins,
56
- );
57
- const [canScrollPrev, setCanScrollPrev] = React.useState(false);
58
- const [canScrollNext, setCanScrollNext] = React.useState(false);
59
-
60
- const onSelect = React.useCallback((api: CarouselApi) => {
61
- if (!api) return;
62
- setCanScrollPrev(api.canScrollPrev());
63
- setCanScrollNext(api.canScrollNext());
64
- }, []);
65
-
66
- const scrollPrev = React.useCallback(() => {
67
- api?.scrollPrev();
68
- }, [api]);
69
-
70
- const scrollNext = React.useCallback(() => {
71
- api?.scrollNext();
72
- }, [api]);
73
-
74
- const handleKeyDown = React.useCallback(
75
- (event: React.KeyboardEvent<HTMLDivElement>) => {
76
- if (event.key === 'ArrowLeft') {
77
- event.preventDefault();
78
- scrollPrev();
79
- } else if (event.key === 'ArrowRight') {
80
- event.preventDefault();
81
- scrollNext();
82
- }
83
- },
84
- [scrollPrev, scrollNext],
85
- );
86
-
87
- React.useEffect(() => {
88
- if (!api || !setApi) return;
89
- setApi(api);
90
- }, [api, setApi]);
91
-
92
- React.useEffect(() => {
93
- if (!api) return;
94
- onSelect(api);
95
- api.on('reInit', onSelect);
96
- api.on('select', onSelect);
97
-
98
- return () => {
99
- api?.off('select', onSelect);
100
- };
101
- }, [api, onSelect]);
102
-
103
- return (
104
- <CarouselContext.Provider
105
- value={{
106
- carouselRef,
107
- api: api,
108
- opts,
109
- orientation: orientation || (opts?.axis === 'y' ? 'vertical' : 'horizontal'),
110
- scrollPrev,
111
- scrollNext,
112
- canScrollPrev,
113
- canScrollNext,
114
- }}
115
- >
116
- <div
117
- onKeyDownCapture={handleKeyDown}
118
- className={cn('relative', className)}
119
- role="region"
120
- aria-roledescription="carousel"
121
- data-slot="carousel"
122
- {...props}
123
- >
124
- {children}
125
- </div>
126
- </CarouselContext.Provider>
127
- );
128
- }
129
-
130
- function CarouselContent({ className, ...props }: React.ComponentProps<'div'>) {
131
- const { carouselRef, orientation } = useCarousel();
132
-
133
- return (
134
- <div ref={carouselRef} className="overflow-hidden" data-slot="carousel-content">
135
- <div
136
- className={cn('flex', orientation === 'horizontal' ? '-ml-4' : '-mt-4 flex-col', className)}
137
- {...props}
138
- />
139
- </div>
140
- );
141
- }
142
-
143
- function CarouselItem({ className, ...props }: React.ComponentProps<'div'>) {
144
- const { orientation } = useCarousel();
145
-
146
- return (
147
- <div
148
- role="group"
149
- aria-roledescription="slide"
150
- data-slot="carousel-item"
151
- className={cn(
152
- 'min-w-0 shrink-0 grow-0 basis-full',
153
- orientation === 'horizontal' ? 'pl-4' : 'pt-4',
154
- className,
155
- )}
156
- {...props}
157
- />
158
- );
159
- }
160
-
161
- function CarouselPrevious({
162
- className,
163
- variant = 'outline',
164
- size = 'icon-sm',
165
- ...props
166
- }: React.ComponentProps<typeof Button>) {
167
- const { orientation, scrollPrev, canScrollPrev } = useCarousel();
168
-
169
- return (
170
- <Button
171
- data-slot="carousel-previous"
172
- variant={variant}
173
- size={size}
174
- className={cn(
175
- 'absolute touch-manipulation',
176
- orientation === 'horizontal'
177
- ? 'top-1/2 -left-12 -translate-y-1/2'
178
- : '-top-12 left-1/2 -translate-x-1/2 rotate-90',
179
- className,
180
- )}
181
- disabled={!canScrollPrev}
182
- onClick={scrollPrev}
183
- {...props}
184
- >
185
- <ChevronLeftIcon />
186
- <span className="sr-only">Previous slide</span>
187
- </Button>
188
- );
189
- }
190
-
191
- function CarouselNext({
192
- className,
193
- variant = 'outline',
194
- size = 'icon-sm',
195
- ...props
196
- }: React.ComponentProps<typeof Button>) {
197
- const { orientation, scrollNext, canScrollNext } = useCarousel();
198
-
199
- return (
200
- <Button
201
- data-slot="carousel-next"
202
- variant={variant}
203
- size={size}
204
- className={cn(
205
- 'absolute touch-manipulation',
206
- orientation === 'horizontal'
207
- ? 'top-1/2 -right-12 -translate-y-1/2'
208
- : '-bottom-12 left-1/2 -translate-x-1/2 rotate-90',
209
- className,
210
- )}
211
- disabled={!canScrollNext}
212
- onClick={scrollNext}
213
- {...props}
214
- >
215
- <ChevronRightIcon />
216
- <span className="sr-only">Next slide</span>
217
- </Button>
218
- );
219
- }
220
-
221
- export {
222
- type CarouselApi,
223
- Carousel,
224
- CarouselContent,
225
- CarouselItem,
226
- CarouselPrevious,
227
- CarouselNext,
228
- useCarousel,
229
- };
@@ -1,339 +0,0 @@
1
- 'use client';
2
-
3
- import * as React from 'react';
4
- import * as RechartsPrimitive from 'recharts';
5
- import type { TooltipValueType } from 'recharts';
6
-
7
- import { cn } from '@/lib/utils';
8
-
9
- // Format: { THEME_NAME: CSS_SELECTOR }
10
- const THEMES = { light: '', dark: '.dark' } as const;
11
-
12
- const INITIAL_DIMENSION = { width: 320, height: 200 } as const;
13
- type TooltipNameType = number | string;
14
-
15
- export type ChartConfig = Record<
16
- string,
17
- {
18
- label?: React.ReactNode;
19
- icon?: React.ComponentType;
20
- } & (
21
- | { color?: string; theme?: never }
22
- | { color?: never; theme: Record<keyof typeof THEMES, string> }
23
- )
24
- >;
25
-
26
- type ChartContextProps = {
27
- config: ChartConfig;
28
- };
29
-
30
- const ChartContext = React.createContext<ChartContextProps | null>(null);
31
-
32
- function useChart() {
33
- const context = React.useContext(ChartContext);
34
-
35
- if (!context) {
36
- throw new Error('useChart must be used within a <ChartContainer />');
37
- }
38
-
39
- return context;
40
- }
41
-
42
- function ChartContainer({
43
- id,
44
- className,
45
- children,
46
- config,
47
- initialDimension = INITIAL_DIMENSION,
48
- ...props
49
- }: React.ComponentProps<'div'> & {
50
- config: ChartConfig;
51
- children: React.ComponentProps<typeof RechartsPrimitive.ResponsiveContainer>['children'];
52
- initialDimension?: {
53
- width: number;
54
- height: number;
55
- };
56
- }) {
57
- const uniqueId = React.useId();
58
- const chartId = `chart-${id ?? uniqueId.replace(/:/g, '')}`;
59
-
60
- return (
61
- <ChartContext.Provider value={{ config }}>
62
- <div
63
- data-slot="chart"
64
- data-chart={chartId}
65
- className={cn(
66
- "flex aspect-video justify-center text-xs [&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
67
- className,
68
- )}
69
- {...props}
70
- >
71
- <ChartStyle id={chartId} config={config} />
72
- <RechartsPrimitive.ResponsiveContainer initialDimension={initialDimension}>
73
- {children}
74
- </RechartsPrimitive.ResponsiveContainer>
75
- </div>
76
- </ChartContext.Provider>
77
- );
78
- }
79
-
80
- const ChartStyle = ({ id, config }: { id: string; config: ChartConfig }) => {
81
- const colorConfig = Object.entries(config).filter(([, config]) => config.theme ?? config.color);
82
-
83
- if (!colorConfig.length) {
84
- return null;
85
- }
86
-
87
- return (
88
- <style
89
- dangerouslySetInnerHTML={{
90
- __html: Object.entries(THEMES)
91
- .map(
92
- ([theme, prefix]) => `
93
- ${prefix} [data-chart=${id}] {
94
- ${colorConfig
95
- .map(([key, itemConfig]) => {
96
- const color = itemConfig.theme?.[theme as keyof typeof itemConfig.theme] ?? itemConfig.color;
97
- return color ? ` --color-${key}: ${color};` : null;
98
- })
99
- .join('\n')}
100
- }
101
- `,
102
- )
103
- .join('\n'),
104
- }}
105
- />
106
- );
107
- };
108
-
109
- const ChartTooltip = RechartsPrimitive.Tooltip;
110
-
111
- function ChartTooltipContent({
112
- active,
113
- payload,
114
- className,
115
- indicator = 'dot',
116
- hideLabel = false,
117
- hideIndicator = false,
118
- label,
119
- labelFormatter,
120
- labelClassName,
121
- formatter,
122
- color,
123
- nameKey,
124
- labelKey,
125
- }: React.ComponentProps<typeof RechartsPrimitive.Tooltip> &
126
- React.ComponentProps<'div'> & {
127
- hideLabel?: boolean;
128
- hideIndicator?: boolean;
129
- indicator?: 'line' | 'dot' | 'dashed';
130
- nameKey?: string;
131
- labelKey?: string;
132
- } & Omit<
133
- RechartsPrimitive.DefaultTooltipContentProps<TooltipValueType, TooltipNameType>,
134
- 'accessibilityLayer'
135
- >) {
136
- const { config } = useChart();
137
-
138
- const tooltipLabel = React.useMemo(() => {
139
- if (hideLabel || !payload?.length) {
140
- return null;
141
- }
142
-
143
- const [item] = payload;
144
- const key = `${labelKey ?? item?.dataKey ?? item?.name ?? 'value'}`;
145
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
146
- const value =
147
- !labelKey && typeof label === 'string' ? (config[label]?.label ?? label) : itemConfig?.label;
148
-
149
- if (labelFormatter) {
150
- return (
151
- <div className={cn('font-medium', labelClassName)}>{labelFormatter(value, payload)}</div>
152
- );
153
- }
154
-
155
- if (!value) {
156
- return null;
157
- }
158
-
159
- return <div className={cn('font-medium', labelClassName)}>{value}</div>;
160
- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
161
-
162
- if (!active || !payload?.length) {
163
- return null;
164
- }
165
-
166
- const nestLabel = payload.length === 1 && indicator !== 'dot';
167
-
168
- return (
169
- <div
170
- className={cn(
171
- 'grid min-w-32 items-start gap-1.5 rounded-none border border-border/50 bg-background px-2.5 py-1.5 text-xs shadow-xl',
172
- className,
173
- )}
174
- >
175
- {!nestLabel ? tooltipLabel : null}
176
- <div className="grid gap-1.5">
177
- {payload
178
- .filter((item) => item.type !== 'none')
179
- .map((item, index) => {
180
- const key = `${nameKey ?? item.name ?? item.dataKey ?? 'value'}`;
181
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
182
- const indicatorColor = color ?? item.payload?.fill ?? item.color;
183
-
184
- return (
185
- <div
186
- key={index}
187
- className={cn(
188
- 'flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5 [&>svg]:text-muted-foreground',
189
- indicator === 'dot' && 'items-center',
190
- )}
191
- >
192
- {formatter && item?.value !== undefined && item.name ? (
193
- formatter(item.value, item.name, item, index, item.payload)
194
- ) : (
195
- <>
196
- {itemConfig?.icon ? (
197
- <itemConfig.icon />
198
- ) : (
199
- !hideIndicator && (
200
- <div
201
- className={cn(
202
- 'shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)',
203
- {
204
- 'h-2.5 w-2.5': indicator === 'dot',
205
- 'w-1': indicator === 'line',
206
- 'w-0 border-[1.5px] border-dashed bg-transparent':
207
- indicator === 'dashed',
208
- 'my-0.5': nestLabel && indicator === 'dashed',
209
- },
210
- )}
211
- style={
212
- {
213
- '--color-bg': indicatorColor,
214
- '--color-border': indicatorColor,
215
- } as React.CSSProperties
216
- }
217
- />
218
- )
219
- )}
220
- <div
221
- className={cn(
222
- 'flex flex-1 justify-between leading-none',
223
- nestLabel ? 'items-end' : 'items-center',
224
- )}
225
- >
226
- <div className="grid gap-1.5">
227
- {nestLabel ? tooltipLabel : null}
228
- <span className="text-muted-foreground">
229
- {itemConfig?.label ?? item.name}
230
- </span>
231
- </div>
232
- {item.value != null && (
233
- <span className="font-mono font-medium text-foreground tabular-nums">
234
- {typeof item.value === 'number'
235
- ? item.value.toLocaleString()
236
- : String(item.value)}
237
- </span>
238
- )}
239
- </div>
240
- </>
241
- )}
242
- </div>
243
- );
244
- })}
245
- </div>
246
- </div>
247
- );
248
- }
249
-
250
- const ChartLegend = RechartsPrimitive.Legend;
251
-
252
- function ChartLegendContent({
253
- className,
254
- hideIcon = false,
255
- payload,
256
- verticalAlign = 'bottom',
257
- nameKey,
258
- }: React.ComponentProps<'div'> & {
259
- hideIcon?: boolean;
260
- nameKey?: string;
261
- } & RechartsPrimitive.DefaultLegendContentProps) {
262
- const { config } = useChart();
263
-
264
- if (!payload?.length) {
265
- return null;
266
- }
267
-
268
- return (
269
- <div
270
- className={cn(
271
- 'flex items-center justify-center gap-4',
272
- verticalAlign === 'top' ? 'pb-3' : 'pt-3',
273
- className,
274
- )}
275
- >
276
- {payload
277
- .filter((item) => item.type !== 'none')
278
- .map((item, index) => {
279
- const key = `${nameKey ?? item.dataKey ?? 'value'}`;
280
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
281
-
282
- return (
283
- <div
284
- key={index}
285
- className={cn(
286
- 'flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3 [&>svg]:text-muted-foreground',
287
- )}
288
- >
289
- {itemConfig?.icon && !hideIcon ? (
290
- <itemConfig.icon />
291
- ) : (
292
- <div
293
- className="h-2 w-2 shrink-0 rounded-[2px]"
294
- style={{
295
- backgroundColor: item.color,
296
- }}
297
- />
298
- )}
299
- {itemConfig?.label}
300
- </div>
301
- );
302
- })}
303
- </div>
304
- );
305
- }
306
-
307
- function getPayloadConfigFromPayload(config: ChartConfig, payload: unknown, key: string) {
308
- if (typeof payload !== 'object' || payload === null) {
309
- return undefined;
310
- }
311
-
312
- const payloadPayload =
313
- 'payload' in payload && typeof payload.payload === 'object' && payload.payload !== null
314
- ? payload.payload
315
- : undefined;
316
-
317
- let configLabelKey: string = key;
318
-
319
- if (key in payload && typeof payload[key as keyof typeof payload] === 'string') {
320
- configLabelKey = payload[key as keyof typeof payload] as string;
321
- } else if (
322
- payloadPayload &&
323
- key in payloadPayload &&
324
- typeof payloadPayload[key as keyof typeof payloadPayload] === 'string'
325
- ) {
326
- configLabelKey = payloadPayload[key as keyof typeof payloadPayload] as string;
327
- }
328
-
329
- return configLabelKey in config ? config[configLabelKey] : config[key];
330
- }
331
-
332
- export {
333
- ChartContainer,
334
- ChartTooltip,
335
- ChartTooltipContent,
336
- ChartLegend,
337
- ChartLegendContent,
338
- ChartStyle,
339
- };
@@ -1,27 +0,0 @@
1
- import * as React from 'react';
2
- import { Checkbox as CheckboxPrimitive } from 'radix-ui';
3
-
4
- import { cn } from '@/lib/utils';
5
- import { CheckIcon } from 'lucide-react';
6
-
7
- function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
8
- return (
9
- <CheckboxPrimitive.Root
10
- data-slot="checkbox"
11
- className={cn(
12
- 'peer relative flex size-4 shrink-0 items-center justify-center rounded-none border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary',
13
- className,
14
- )}
15
- {...props}
16
- >
17
- <CheckboxPrimitive.Indicator
18
- data-slot="checkbox-indicator"
19
- className="grid place-content-center text-current transition-none [&>svg]:size-3.5"
20
- >
21
- <CheckIcon />
22
- </CheckboxPrimitive.Indicator>
23
- </CheckboxPrimitive.Root>
24
- );
25
- }
26
-
27
- export { Checkbox };
@@ -1,21 +0,0 @@
1
- 'use client';
2
-
3
- import { Collapsible as CollapsiblePrimitive } from 'radix-ui';
4
-
5
- function Collapsible({ ...props }: React.ComponentProps<typeof CollapsiblePrimitive.Root>) {
6
- return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
7
- }
8
-
9
- function CollapsibleTrigger({
10
- ...props
11
- }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>) {
12
- return <CollapsiblePrimitive.CollapsibleTrigger data-slot="collapsible-trigger" {...props} />;
13
- }
14
-
15
- function CollapsibleContent({
16
- ...props
17
- }: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>) {
18
- return <CollapsiblePrimitive.CollapsibleContent data-slot="collapsible-content" {...props} />;
19
- }
20
-
21
- export { Collapsible, CollapsibleTrigger, CollapsibleContent };