@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,231 +0,0 @@
1
- import React, { useCallback, useEffect, useMemo } from 'react';
2
- import type { ReactNode } from 'react';
3
- import { XIcon } from 'lucide-react';
4
- import {
5
- SidebarProvider,
6
- SidebarInset,
7
- SidebarTrigger,
8
- Sidebar,
9
- SidebarHeader,
10
- SidebarContent,
11
- } from '@/components/ui/sidebar';
12
- import { Separator } from '@/components/ui/separator';
13
- import {
14
- Breadcrumb,
15
- BreadcrumbList,
16
- BreadcrumbItem,
17
- BreadcrumbLink,
18
- BreadcrumbPage,
19
- BreadcrumbSeparator,
20
- } from '@/components/ui/breadcrumb';
21
- import { Button } from '@/components/ui/button';
22
- import { Icon } from '@/components/Icon';
23
- import { AppSidebar } from './app-sidebar/index.js';
24
- import type { AppSidebarNavSection, AppSidebarModule } from './app-sidebar/types.js';
25
- import { CommandPalette } from './CommandPalette.js';
26
- import { HeaderActions } from './HeaderActions.js';
27
- import { ShellDevTools } from './ShellDevTools.js';
28
- import { DrawerProvider, useDrawer } from './DrawerContext.js';
29
- import { ShellAPIProvider } from './ShellContext.js';
30
- import { useMeta } from '../context/MetaContext.js';
31
- import { useModule } from '../context/ModuleContext.js';
32
- import { useBootContext } from '../boot/BootProvider.js';
33
- import { useRouter, useRouterState } from '@tanstack/react-router';
34
- import { useBreadcrumbs } from './useBreadcrumbs.js';
35
- import type { NavigationTree } from '@rangka/shared';
36
-
37
- function ShellLayoutInner({ children }: { children: ReactNode }) {
38
- const router = useRouter();
39
- const currentPath = useRouterState({ select: (s) => s.location.pathname });
40
- const { navigation, pages } = useMeta();
41
- const { activeModule, setActiveModule, clearActiveModule } = useModule();
42
- const { state } = useBootContext();
43
- const { state: drawerState, closeDrawer } = useDrawer();
44
-
45
- useEffect(() => {
46
- const pathModule = currentPath.split('/').filter(Boolean)[0];
47
- if (pathModule && navigation.some((n: NavigationTree) => n.module === pathModule)) {
48
- setActiveModule(pathModule);
49
- } else if (currentPath === '/') {
50
- clearActiveModule();
51
- }
52
- }, [currentPath, navigation, setActiveModule, clearActiveModule]);
53
-
54
- const handleNavigate = useCallback(
55
- (path: string) => {
56
- router.navigate({ to: path });
57
- },
58
- [router],
59
- );
60
-
61
- const currentPage = useMemo(() => {
62
- const parts = currentPath.split('/').filter(Boolean);
63
- if (parts.length >= 2) {
64
- const pageKey = `${parts[0]}.${parts[1]}`;
65
- return pages.find((p) => p.key === pageKey);
66
- }
67
- return undefined;
68
- }, [currentPath, pages]);
69
-
70
- const crumbs = useBreadcrumbs(currentPath, navigation, pages);
71
-
72
- const handleAction = useCallback((action: string) => {
73
- document.dispatchEvent(new CustomEvent('rangka:action', { detail: { action }, bubbles: true }));
74
- }, []);
75
-
76
- const headerActions = currentPage?.actions?.length ? (
77
- <HeaderActions actions={currentPage.actions} onAction={handleAction} />
78
- ) : undefined;
79
-
80
- const modules: AppSidebarModule[] = navigation.map((mod: NavigationTree) => ({
81
- name: mod.module,
82
- label: mod.label,
83
- icon: mod.icon ? <Icon name={mod.icon} size={14} /> : undefined,
84
- }));
85
-
86
- const sidebarNavigation: AppSidebarNavSection[] = useMemo(() => {
87
- const activeNav = activeModule
88
- ? navigation.filter((mod: NavigationTree) => mod.module === activeModule)
89
- : [];
90
- return activeNav.flatMap((mod: NavigationTree) =>
91
- mod.sections.map((section) => ({
92
- title: section.section,
93
- icon: section.items[0]?.icon ? <Icon name={section.items[0].icon} /> : undefined,
94
- items: section.items.map((item) => ({
95
- title: item.label,
96
- url: '/' + item.page.replace('.', '/'),
97
- })),
98
- })),
99
- );
100
- }, [activeModule, navigation]);
101
-
102
- const handleModuleSwitch = useCallback(
103
- (moduleName: string) => {
104
- setActiveModule(moduleName);
105
- const mod = navigation.find((n: NavigationTree) => n.module === moduleName);
106
- const firstPage = mod?.sections[0]?.items[0]?.page;
107
- if (firstPage) {
108
- router.navigate({ to: '/' + firstPage.replace('.', '/') });
109
- }
110
- },
111
- [navigation, router, setActiveModule],
112
- );
113
-
114
- const handleAllModules = useCallback(() => {
115
- clearActiveModule();
116
- router.navigate({ to: '/' });
117
- }, [clearActiveModule, router]);
118
-
119
- const handleLogout = useCallback(() => {
120
- document.dispatchEvent(new CustomEvent('rangka:logout'));
121
- }, []);
122
-
123
- const handlePreferences = useCallback(() => {
124
- router.navigate({ to: '/preferences' });
125
- }, [router]);
126
-
127
- const user =
128
- state.status === 'ready'
129
- ? { name: state.data.user.name, email: state.data.user.email }
130
- : undefined;
131
-
132
- const handleSearch = useCallback(() => {
133
- document.dispatchEvent(new KeyboardEvent('keydown', { key: 'k', ctrlKey: true }));
134
- }, []);
135
-
136
- const isModuleSelectorPage = !activeModule;
137
-
138
- return (
139
- <SidebarProvider className="h-svh !min-h-0">
140
- <AppSidebar
141
- modules={modules}
142
- activeModule={activeModule ?? undefined}
143
- onModuleSwitch={handleModuleSwitch}
144
- onAllModules={handleAllModules}
145
- onSearch={handleSearch}
146
- navigation={sidebarNavigation}
147
- currentPath={currentPath}
148
- onNavigate={handleNavigate}
149
- user={user}
150
- onLogout={handleLogout}
151
- onPreferences={handlePreferences}
152
- />
153
- <SidebarInset className="overflow-hidden">
154
- <header className="flex h-12 shrink-0 items-center gap-2 border-b border-border bg-background px-4">
155
- <SidebarTrigger className="-ml-1" />
156
- {isModuleSelectorPage ? (
157
- <>
158
- <Separator orientation="vertical" className="mr-2" />
159
- <span className="text-sm font-medium">Select Module</span>
160
- </>
161
- ) : (
162
- <>
163
- <Separator orientation="vertical" className="mr-2" />
164
- <Breadcrumb>
165
- <BreadcrumbList>
166
- {crumbs.map((crumb, i) => {
167
- const isLast = i === crumbs.length - 1;
168
- return (
169
- <React.Fragment key={crumb.path ?? crumb.label}>
170
- <BreadcrumbItem>
171
- {!isLast ? (
172
- <BreadcrumbLink
173
- asChild
174
- onClick={(e: React.MouseEvent) => {
175
- e.preventDefault();
176
- if (crumb.path) handleNavigate(crumb.path);
177
- }}
178
- >
179
- <a href={crumb.path ?? '#'}>{crumb.label}</a>
180
- </BreadcrumbLink>
181
- ) : (
182
- <BreadcrumbPage>{crumb.label}</BreadcrumbPage>
183
- )}
184
- </BreadcrumbItem>
185
- {!isLast && <BreadcrumbSeparator />}
186
- </React.Fragment>
187
- );
188
- })}
189
- </BreadcrumbList>
190
- </Breadcrumb>
191
- {headerActions && (
192
- <div className="ml-auto flex items-center gap-2">{headerActions}</div>
193
- )}
194
- </>
195
- )}
196
- </header>
197
- <main className="flex-1 overflow-auto bg-muted">{children}</main>
198
- </SidebarInset>
199
-
200
- {drawerState.open && (
201
- <Sidebar side="right" collapsible="none" className="w-80 border-l">
202
- <SidebarHeader className="flex flex-row items-center justify-between border-b px-4 py-3">
203
- <div>
204
- {drawerState.title && <h3 className="text-sm font-medium">{drawerState.title}</h3>}
205
- {drawerState.description && (
206
- <p className="text-xs text-muted-foreground">{drawerState.description}</p>
207
- )}
208
- </div>
209
- <Button variant="ghost" size="icon-sm" onClick={closeDrawer} aria-label="Close panel">
210
- <XIcon />
211
- </Button>
212
- </SidebarHeader>
213
- <SidebarContent className="p-4">{drawerState.content}</SidebarContent>
214
- </Sidebar>
215
- )}
216
-
217
- <CommandPalette />
218
- <ShellDevTools />
219
- </SidebarProvider>
220
- );
221
- }
222
-
223
- export function ShellLayout({ children }: { children: ReactNode }) {
224
- return (
225
- <DrawerProvider>
226
- <ShellAPIProvider>
227
- <ShellLayoutInner>{children}</ShellLayoutInner>
228
- </ShellAPIProvider>
229
- </DrawerProvider>
230
- );
231
- }
@@ -1,58 +0,0 @@
1
- import { useEffect, useRef, type ElementType } from 'react';
2
- import { InfoIcon, CheckCircleIcon, AlertTriangleIcon, AlertCircleIcon, XIcon } from 'lucide-react';
3
- import { cn } from '@/lib/utils';
4
-
5
- export type ToastType = 'info' | 'success' | 'warning' | 'error';
6
-
7
- export interface ToastProps {
8
- message: string;
9
- type: ToastType;
10
- onDismiss: () => void;
11
- }
12
-
13
- const iconMap: Record<ToastType, ElementType> = {
14
- info: InfoIcon,
15
- success: CheckCircleIcon,
16
- warning: AlertTriangleIcon,
17
- error: AlertCircleIcon,
18
- };
19
-
20
- const colorMap: Record<ToastType, string> = {
21
- info: 'border-blue-200 bg-blue-50 text-blue-900 dark:border-blue-800 dark:bg-blue-950 dark:text-blue-100',
22
- success:
23
- 'border-green-200 bg-green-50 text-green-900 dark:border-green-800 dark:bg-green-950 dark:text-green-100',
24
- warning:
25
- 'border-yellow-200 bg-yellow-50 text-yellow-900 dark:border-yellow-800 dark:bg-yellow-950 dark:text-yellow-100',
26
- error:
27
- 'border-red-200 bg-red-50 text-red-900 dark:border-red-800 dark:bg-red-950 dark:text-red-100',
28
- };
29
-
30
- export function Toast({ message, type, onDismiss }: ToastProps) {
31
- const timerRef = useRef<ReturnType<typeof setTimeout>>(undefined);
32
- const IconComp = iconMap[type];
33
-
34
- useEffect(() => {
35
- timerRef.current = setTimeout(onDismiss, 4000);
36
- return () => clearTimeout(timerRef.current);
37
- }, [onDismiss]);
38
-
39
- return (
40
- <div
41
- className={cn(
42
- 'pointer-events-auto flex items-center gap-2 rounded-md border px-3 py-2 text-sm shadow-sm',
43
- colorMap[type],
44
- )}
45
- role="alert"
46
- >
47
- <IconComp className="size-4 shrink-0" />
48
- <span className="flex-1">{message}</span>
49
- <button
50
- onClick={onDismiss}
51
- className="shrink-0 rounded-sm p-0.5 opacity-70 hover:opacity-100"
52
- aria-label="Dismiss"
53
- >
54
- <XIcon className="size-3.5" />
55
- </button>
56
- </div>
57
- );
58
- }
@@ -1,60 +0,0 @@
1
- import { useCallback, useEffect, useRef, useState } from 'react';
2
- import type { ReactNode } from 'react';
3
- import { Toast } from './Toast.js';
4
- import type { ToastType } from './ShellContext.js';
5
-
6
- interface ToastItem {
7
- id: string;
8
- message: string;
9
- type: ToastType;
10
- }
11
-
12
- let idCounter = 0;
13
-
14
- export function ToastProvider({ children }: { children: ReactNode }) {
15
- const [toasts, setToasts] = useState<ToastItem[]>([]);
16
- const containerRef = useRef<HTMLDivElement>(null);
17
-
18
- const addToast = useCallback((message: string, type: ToastType) => {
19
- const id = String(++idCounter);
20
- setToasts((prev) => {
21
- const next = [...prev, { id, message, type }];
22
- if (next.length > 5) return next.slice(next.length - 5);
23
- return next;
24
- });
25
- }, []);
26
-
27
- const removeToast = useCallback((id: string) => {
28
- setToasts((prev) => prev.filter((t) => t.id !== id));
29
- }, []);
30
-
31
- useEffect(() => {
32
- const handler = (e: Event) => {
33
- const { message, type } = (e as CustomEvent).detail;
34
- addToast(message, type ?? 'info');
35
- };
36
- document.addEventListener('rangka:toast', handler);
37
- return () => document.removeEventListener('rangka:toast', handler);
38
- }, [addToast]);
39
-
40
- return (
41
- <>
42
- {children}
43
- <div
44
- ref={containerRef}
45
- aria-live="polite"
46
- role="status"
47
- className="fixed bottom-4 right-4 z-[100] flex flex-col gap-2 pointer-events-none"
48
- >
49
- {toasts.map((toast) => (
50
- <Toast
51
- key={toast.id}
52
- message={toast.message}
53
- type={toast.type}
54
- onDismiss={() => removeToast(toast.id)}
55
- />
56
- ))}
57
- </div>
58
- </>
59
- );
60
- }
@@ -1,44 +0,0 @@
1
- import { Sidebar, SidebarHeader, SidebarContent, SidebarFooter } from '@/components/ui/sidebar';
2
- import { ModuleSwitcher } from './ModuleSwitcher';
3
- import { SearchMenu } from './SearchMenu';
4
- import { NavMain } from './NavMain';
5
- import { NavUser } from './NavUser';
6
- import type { AppSidebarProps } from './types';
7
-
8
- export function AppSidebar({
9
- modules,
10
- activeModule,
11
- onModuleSwitch,
12
- onAllModules,
13
- onSearch,
14
- navigation,
15
- currentPath,
16
- onNavigate,
17
- user,
18
- onLogout,
19
- onPreferences,
20
- }: AppSidebarProps) {
21
- return (
22
- <Sidebar collapsible="offcanvas">
23
- <SidebarHeader>
24
- <ModuleSwitcher
25
- modules={modules}
26
- activeModule={activeModule}
27
- onModuleSwitch={onModuleSwitch}
28
- onAllModules={onAllModules}
29
- />
30
- {onSearch && <SearchMenu onSearch={onSearch} />}
31
- </SidebarHeader>
32
- <SidebarContent>
33
- {navigation.length > 0 && (
34
- <NavMain sections={navigation} currentPath={currentPath} onNavigate={onNavigate} />
35
- )}
36
- </SidebarContent>
37
- {user && (
38
- <SidebarFooter>
39
- <NavUser user={user} onLogout={onLogout} onPreferences={onPreferences} />
40
- </SidebarFooter>
41
- )}
42
- </Sidebar>
43
- );
44
- }
@@ -1,87 +0,0 @@
1
- import { ChevronsUpDownIcon, LayoutGridIcon } from 'lucide-react';
2
- import {
3
- SidebarMenu,
4
- SidebarMenuItem,
5
- SidebarMenuButton,
6
- useSidebar,
7
- } from '@/components/ui/sidebar';
8
- import {
9
- DropdownMenu,
10
- DropdownMenuContent,
11
- DropdownMenuItem,
12
- DropdownMenuSeparator,
13
- DropdownMenuTrigger,
14
- } from '@/components/ui/dropdown-menu';
15
- import type { AppSidebarModule } from './types';
16
-
17
- interface ModuleSwitcherProps {
18
- modules: AppSidebarModule[];
19
- activeModule?: string;
20
- onModuleSwitch: (name: string) => void;
21
- onAllModules?: () => void;
22
- }
23
-
24
- export function ModuleSwitcher({
25
- modules,
26
- activeModule,
27
- onModuleSwitch,
28
- onAllModules,
29
- }: ModuleSwitcherProps) {
30
- const { isMobile } = useSidebar();
31
- const active = modules.find((m) => m.name === activeModule) ?? modules[0];
32
-
33
- if (!active) return null;
34
-
35
- return (
36
- <SidebarMenu>
37
- <SidebarMenuItem>
38
- <DropdownMenu>
39
- <DropdownMenuTrigger asChild>
40
- <SidebarMenuButton
41
- size="lg"
42
- className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
43
- >
44
- <div className="flex aspect-square size-8 items-center justify-center rounded-lg bg-sidebar-primary text-sidebar-primary-foreground">
45
- {active.icon ?? <span className="text-xs font-bold">{active.label[0]}</span>}
46
- </div>
47
- <div className="grid flex-1 text-left text-sm leading-tight">
48
- <span className="truncate font-medium">{active.label}</span>
49
- </div>
50
- <ChevronsUpDownIcon className="ml-auto" />
51
- </SidebarMenuButton>
52
- </DropdownMenuTrigger>
53
- <DropdownMenuContent
54
- className="w-[--radix-dropdown-menu-trigger-width] min-w-48"
55
- align="start"
56
- side={isMobile ? 'bottom' : 'bottom'}
57
- sideOffset={4}
58
- >
59
- {modules.map((mod) => (
60
- <DropdownMenuItem
61
- key={mod.name}
62
- onClick={() => onModuleSwitch(mod.name)}
63
- className="gap-2 p-2"
64
- >
65
- <div className="flex size-6 items-center justify-center rounded-md border">
66
- {mod.icon ?? <span className="text-xs">{mod.label[0]}</span>}
67
- </div>
68
- {mod.label}
69
- </DropdownMenuItem>
70
- ))}
71
- {onAllModules && (
72
- <>
73
- <DropdownMenuSeparator />
74
- <DropdownMenuItem onClick={onAllModules} className="gap-2 p-2">
75
- <div className="flex size-6 items-center justify-center rounded-md border bg-transparent">
76
- <LayoutGridIcon />
77
- </div>
78
- All modules
79
- </DropdownMenuItem>
80
- </>
81
- )}
82
- </DropdownMenuContent>
83
- </DropdownMenu>
84
- </SidebarMenuItem>
85
- </SidebarMenu>
86
- );
87
- }
@@ -1,64 +0,0 @@
1
- import { ChevronRightIcon } from 'lucide-react';
2
- import {
3
- SidebarGroup,
4
- SidebarMenu,
5
- SidebarMenuItem,
6
- SidebarMenuButton,
7
- SidebarMenuSub,
8
- SidebarMenuSubButton,
9
- SidebarMenuSubItem,
10
- } from '@/components/ui/sidebar';
11
- import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible';
12
- import type { AppSidebarNavSection } from './types';
13
-
14
- interface NavMainProps {
15
- sections: AppSidebarNavSection[];
16
- currentPath: string;
17
- onNavigate: (url: string) => void;
18
- }
19
-
20
- export function NavMain({ sections, currentPath, onNavigate }: NavMainProps) {
21
- return (
22
- <SidebarGroup>
23
- <SidebarMenu>
24
- {sections.map((section) => (
25
- <Collapsible
26
- key={section.title}
27
- asChild
28
- defaultOpen={section.items.some((item) => currentPath === item.url)}
29
- className="group/collapsible"
30
- >
31
- <SidebarMenuItem>
32
- <CollapsibleTrigger asChild>
33
- <SidebarMenuButton tooltip={section.title}>
34
- {section.icon}
35
- <span>{section.title}</span>
36
- <ChevronRightIcon className="ml-auto transition-transform duration-200 group-data-[state=open]/collapsible:rotate-90" />
37
- </SidebarMenuButton>
38
- </CollapsibleTrigger>
39
- <CollapsibleContent>
40
- <SidebarMenuSub>
41
- {section.items.map((item) => (
42
- <SidebarMenuSubItem key={item.url}>
43
- <SidebarMenuSubButton asChild isActive={currentPath === item.url}>
44
- <a
45
- href={item.url}
46
- onClick={(e) => {
47
- e.preventDefault();
48
- onNavigate(item.url);
49
- }}
50
- >
51
- <span>{item.title}</span>
52
- </a>
53
- </SidebarMenuSubButton>
54
- </SidebarMenuSubItem>
55
- ))}
56
- </SidebarMenuSub>
57
- </CollapsibleContent>
58
- </SidebarMenuItem>
59
- </Collapsible>
60
- ))}
61
- </SidebarMenu>
62
- </SidebarGroup>
63
- );
64
- }
@@ -1,97 +0,0 @@
1
- import { ChevronsUpDownIcon, LogOutIcon, SettingsIcon } from 'lucide-react';
2
- import {
3
- SidebarMenu,
4
- SidebarMenuItem,
5
- SidebarMenuButton,
6
- useSidebar,
7
- } from '@/components/ui/sidebar';
8
- import {
9
- DropdownMenu,
10
- DropdownMenuContent,
11
- DropdownMenuItem,
12
- DropdownMenuLabel,
13
- DropdownMenuSeparator,
14
- DropdownMenuTrigger,
15
- } from '@/components/ui/dropdown-menu';
16
- import { Avatar, AvatarFallback, AvatarImage } from '@/components/ui/avatar';
17
- import type { AppSidebarUser } from './types';
18
-
19
- function getInitials(name: string): string {
20
- return name
21
- .split(' ')
22
- .map((w) => w[0])
23
- .filter(Boolean)
24
- .slice(0, 2)
25
- .join('')
26
- .toUpperCase();
27
- }
28
-
29
- interface NavUserProps {
30
- user: AppSidebarUser;
31
- onLogout?: () => void;
32
- onPreferences?: () => void;
33
- }
34
-
35
- export function NavUser({ user, onLogout, onPreferences }: NavUserProps) {
36
- const { isMobile: _isMobile } = useSidebar();
37
-
38
- return (
39
- <SidebarMenu>
40
- <SidebarMenuItem>
41
- <DropdownMenu>
42
- <DropdownMenuTrigger asChild>
43
- <SidebarMenuButton
44
- size="lg"
45
- className="data-[state=open]:bg-sidebar-accent data-[state=open]:text-sidebar-accent-foreground"
46
- >
47
- <Avatar className="h-8 w-8 rounded-lg">
48
- {user.avatar && <AvatarImage src={user.avatar} alt={user.name} />}
49
- <AvatarFallback className="rounded-lg">{getInitials(user.name)}</AvatarFallback>
50
- </Avatar>
51
- <div className="grid flex-1 text-left text-sm leading-tight">
52
- <span className="truncate font-medium">{user.name}</span>
53
- <span className="truncate text-xs">{user.email}</span>
54
- </div>
55
- <ChevronsUpDownIcon className="ml-auto size-4" />
56
- </SidebarMenuButton>
57
- </DropdownMenuTrigger>
58
- <DropdownMenuContent
59
- className="w-[--radix-dropdown-menu-trigger-width] min-w-48"
60
- side="top"
61
- align="start"
62
- sideOffset={4}
63
- >
64
- <DropdownMenuLabel className="p-0 font-normal">
65
- <div className="flex items-center gap-2 px-1 py-1.5 text-left text-sm">
66
- <Avatar className="h-8 w-8 rounded-lg">
67
- {user.avatar && <AvatarImage src={user.avatar} alt={user.name} />}
68
- <AvatarFallback className="rounded-lg">{getInitials(user.name)}</AvatarFallback>
69
- </Avatar>
70
- <div className="grid flex-1 text-left text-sm leading-tight">
71
- <span className="truncate font-medium">{user.name}</span>
72
- <span className="truncate text-xs">{user.email}</span>
73
- </div>
74
- </div>
75
- </DropdownMenuLabel>
76
- <DropdownMenuSeparator />
77
- {onPreferences && (
78
- <DropdownMenuItem onClick={onPreferences}>
79
- <SettingsIcon />
80
- Preferences
81
- </DropdownMenuItem>
82
- )}
83
- {onLogout && (
84
- <>
85
- <DropdownMenuSeparator />
86
- <DropdownMenuItem onClick={onLogout}>
87
- <LogOutIcon />
88
- Log out
89
- </DropdownMenuItem>
90
- </>
91
- )}
92
- </DropdownMenuContent>
93
- </DropdownMenu>
94
- </SidebarMenuItem>
95
- </SidebarMenu>
96
- );
97
- }
@@ -1,22 +0,0 @@
1
- import { SearchIcon } from 'lucide-react';
2
- import { SidebarMenu, SidebarMenuItem, SidebarMenuButton } from '@/components/ui/sidebar';
3
-
4
- interface SearchMenuProps {
5
- onSearch: () => void;
6
- }
7
-
8
- export function SearchMenu({ onSearch }: SearchMenuProps) {
9
- return (
10
- <SidebarMenu>
11
- <SidebarMenuItem>
12
- <SidebarMenuButton onClick={onSearch} tooltip="Search">
13
- <SearchIcon />
14
- <span>Search</span>
15
- <kbd className="ml-auto rounded border border-sidebar-border bg-sidebar px-1.5 py-0.5 text-[10px] font-medium text-sidebar-foreground/70">
16
- Ctrl K
17
- </kbd>
18
- </SidebarMenuButton>
19
- </SidebarMenuItem>
20
- </SidebarMenu>
21
- );
22
- }
@@ -1,8 +0,0 @@
1
- export { AppSidebar } from './AppSidebar';
2
- export type {
3
- AppSidebarProps,
4
- AppSidebarModule,
5
- AppSidebarNavSection,
6
- AppSidebarNavItem,
7
- AppSidebarUser,
8
- } from './types';