@rangka/client 0.1.0 → 0.1.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.
- package/dist/App.d.ts.map +1 -1
- package/dist/App.js +7 -1
- package/dist/App.js.map +1 -1
- package/dist/components/ui/input-group.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +20 -0
- package/dist/main.js.map +1 -1
- package/dist/shell/assets/AttachmentWidget-BTTGroHP.js +1 -0
- package/dist/shell/assets/AttachmentsWidget-DZgvmO9P.js +1 -0
- package/dist/shell/assets/BadgeWidget-DN6GsAAG.js +1 -0
- package/dist/shell/assets/CardWidget-qX-UvqJh.js +1 -0
- package/dist/shell/assets/CheckboxWidget-CYPZ85ih.js +1 -0
- package/dist/shell/assets/CodeWidget-DnVtHG1d.js +1 -0
- package/dist/shell/assets/ColumnWidget-CYmFCVOf.js +1 -0
- package/dist/shell/assets/ComputedWidget-BQApkfir.js +1 -0
- package/dist/shell/assets/DatePickerWidget-pEusSy9D.js +1 -0
- package/dist/shell/assets/DatetimeWidget-M0fEGDTD.js +1 -0
- package/dist/shell/assets/DividerWidget-hXVGhIKC.js +1 -0
- package/dist/shell/assets/DrawerWidget-DynL7EIy.js +1 -0
- package/dist/shell/assets/DynamicLinkWidget-ChMJ5DAf.js +1 -0
- package/dist/shell/assets/IconWidget-Cgo9txq1.js +1 -0
- package/dist/shell/assets/ImageWidget-YUv1_OQK.js +1 -0
- package/dist/shell/assets/JsonWidget-RHUHhXHJ.js +1 -0
- package/dist/shell/assets/LinkWidget-CIu7qmb2.js +1 -0
- package/dist/shell/assets/ManyToManyWidget-DCQnygvZ.js +1 -0
- package/dist/shell/assets/ModalWidget-FggzYaS2.js +1 -0
- package/dist/shell/assets/MoneyWidget-CKjOSucD.js +1 -0
- package/dist/shell/assets/RepeatWidget-Dfp4zW4d.js +1 -0
- package/dist/shell/assets/ScrollAreaWidget-CdFdf4rv.js +1 -0
- package/dist/shell/assets/SequenceWidget-DIXHZslz.js +1 -0
- package/dist/shell/assets/SpacerWidget-BgM4dC6x.js +1 -0
- package/dist/shell/assets/SplitWidget-_mcQkjQk.js +1 -0
- package/dist/shell/assets/StackWidget-BI_VIreo.js +1 -0
- package/dist/shell/assets/TableWidget-DuIvd6qR.js +1 -0
- package/dist/shell/assets/TextareaWidget-CATua7Ls.js +1 -0
- package/dist/shell/assets/TreeWidget-BoHlhfza.js +1 -0
- package/dist/shell/assets/calendar-DqckiKt1.js +1 -0
- package/dist/shell/assets/index-63v1sBS3.css +1 -0
- package/dist/shell/assets/index-D1wStSrO.js +8635 -0
- package/dist/shell/assets/popover-DywIKFaQ.js +1 -0
- package/dist/shell/assets/textarea-BVCZevA6.js +1 -0
- package/dist/shell/assets/useSurfaceContext-kzu9770H.js +1 -0
- package/dist/shell/assets/vendor-query-dRdWN_eK.js +1 -0
- package/dist/shell/assets/vendor-radix-D-Trh8JA.js +69 -0
- package/dist/shell/assets/vendor-router-B1WM9yRc.js +17 -0
- package/dist/shell/index.html +5 -2
- package/dist/theme.css +82 -0
- package/dist/widgets/components/lazy-manifest.d.ts +11 -0
- package/dist/widgets/components/lazy-manifest.d.ts.map +1 -0
- package/dist/widgets/components/lazy-manifest.js +32 -0
- package/dist/widgets/components/lazy-manifest.js.map +1 -0
- package/dist/widgets/components/register.d.ts.map +1 -1
- package/dist/widgets/components/register.js +0 -58
- package/dist/widgets/components/register.js.map +1 -1
- package/dist/widgets/loader.d.ts +3 -0
- package/dist/widgets/loader.d.ts.map +1 -0
- package/dist/widgets/loader.js +99 -0
- package/dist/widgets/loader.js.map +1 -0
- package/dist/widgets/renderer/LazyWidget.d.ts +8 -0
- package/dist/widgets/renderer/LazyWidget.d.ts.map +1 -0
- package/dist/widgets/renderer/LazyWidget.js +31 -0
- package/dist/widgets/renderer/LazyWidget.js.map +1 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.d.ts +17 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.d.ts.map +1 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.js +18 -0
- package/dist/widgets/renderer/WidgetErrorBoundary.js.map +1 -0
- package/dist/widgets/renderer/WidgetRenderer.d.ts.map +1 -1
- package/dist/widgets/renderer/WidgetRenderer.js +8 -6
- package/dist/widgets/renderer/WidgetRenderer.js.map +1 -1
- package/package.json +7 -4
- package/.claude/skills/add-widget/SKILL.md +0 -101
- package/.turbo/turbo-build.log +0 -29
- package/CHANGELOG.md +0 -18
- package/CLAUDE.md +0 -236
- package/components.json +0 -25
- package/dist/components/ui/chart.d.ts +0 -45
- package/dist/components/ui/chart.d.ts.map +0 -1
- package/dist/components/ui/chart.js +0 -119
- package/dist/components/ui/chart.js.map +0 -1
- package/dist/shell/assets/index--35CAvcP.js +0 -8715
- package/dist/shell/assets/index-COLmoPYo.css +0 -1
- package/index.html +0 -12
- package/src/App.tsx +0 -44
- package/src/__tests__/setup.ts +0 -1
- package/src/api/auth.ts +0 -41
- package/src/api/boot.ts +0 -10
- package/src/api/client.ts +0 -26
- package/src/api/paths.ts +0 -3
- package/src/api/token.ts +0 -13
- package/src/auth/LoginForm.tsx +0 -67
- package/src/auth/SessionExpired.tsx +0 -24
- package/src/auth/SetupForm.tsx +0 -76
- package/src/boot/BootGate.tsx +0 -35
- package/src/boot/BootProvider.tsx +0 -28
- package/src/boot/types.ts +0 -9
- package/src/boot/useBoot.ts +0 -111
- package/src/components/Icon.tsx +0 -17
- package/src/components/ui/accordion.tsx +0 -82
- package/src/components/ui/alert-dialog.tsx +0 -180
- package/src/components/ui/alert.tsx +0 -76
- package/src/components/ui/aspect-ratio.tsx +0 -9
- package/src/components/ui/avatar.tsx +0 -94
- package/src/components/ui/badge.tsx +0 -45
- package/src/components/ui/breadcrumb.tsx +0 -104
- package/src/components/ui/button-group.tsx +0 -78
- package/src/components/ui/button.tsx +0 -65
- package/src/components/ui/calendar.tsx +0 -187
- package/src/components/ui/card.tsx +0 -85
- package/src/components/ui/carousel.tsx +0 -229
- package/src/components/ui/chart.tsx +0 -339
- package/src/components/ui/checkbox.tsx +0 -27
- package/src/components/ui/collapsible.tsx +0 -21
- package/src/components/ui/combobox.tsx +0 -275
- package/src/components/ui/command.tsx +0 -178
- package/src/components/ui/context-menu.tsx +0 -242
- package/src/components/ui/dialog.tsx +0 -146
- package/src/components/ui/direction.tsx +0 -20
- package/src/components/ui/drawer.tsx +0 -118
- package/src/components/ui/dropdown-menu.tsx +0 -247
- package/src/components/ui/empty.tsx +0 -94
- package/src/components/ui/field.tsx +0 -224
- package/src/components/ui/hover-card.tsx +0 -36
- package/src/components/ui/input-group.tsx +0 -142
- package/src/components/ui/input-otp.tsx +0 -86
- package/src/components/ui/input.tsx +0 -19
- package/src/components/ui/item.tsx +0 -182
- package/src/components/ui/kbd.tsx +0 -26
- package/src/components/ui/label.tsx +0 -19
- package/src/components/ui/menubar.tsx +0 -260
- package/src/components/ui/native-select.tsx +0 -55
- package/src/components/ui/navigation-menu.tsx +0 -160
- package/src/components/ui/pagination.tsx +0 -112
- package/src/components/ui/popover.tsx +0 -74
- package/src/components/ui/progress.tsx +0 -31
- package/src/components/ui/radio-group.tsx +0 -42
- package/src/components/ui/resizable.tsx +0 -42
- package/src/components/ui/scroll-area.tsx +0 -53
- package/src/components/ui/select.tsx +0 -185
- package/src/components/ui/separator.tsx +0 -26
- package/src/components/ui/sheet.tsx +0 -128
- package/src/components/ui/sidebar.tsx +0 -669
- package/src/components/ui/skeleton.tsx +0 -13
- package/src/components/ui/slider.tsx +0 -54
- package/src/components/ui/sonner.tsx +0 -43
- package/src/components/ui/spinner.tsx +0 -16
- package/src/components/ui/switch.tsx +0 -33
- package/src/components/ui/table.tsx +0 -87
- package/src/components/ui/tabs.tsx +0 -80
- package/src/components/ui/textarea.tsx +0 -18
- package/src/components/ui/toggle-group.tsx +0 -86
- package/src/components/ui/toggle.tsx +0 -44
- package/src/components/ui/tooltip.tsx +0 -53
- package/src/context/MetaContext.tsx +0 -22
- package/src/context/ModuleContext.tsx +0 -62
- package/src/context/PermissionsContext.tsx +0 -39
- package/src/context/ShellProviders.tsx +0 -33
- package/src/context/UserContext.tsx +0 -16
- package/src/data/QueryProvider.tsx +0 -7
- package/src/data/queryClient.ts +0 -18
- package/src/data/useModelMeta.ts +0 -17
- package/src/data/useMutation.ts +0 -60
- package/src/data/useRecord.ts +0 -29
- package/src/data/useSource.ts +0 -112
- package/src/hooks/use-mobile.ts +0 -19
- package/src/index.css +0 -260
- package/src/index.ts +0 -16
- package/src/lib/utils.ts +0 -6
- package/src/main.tsx +0 -17
- package/src/router/NotFound.tsx +0 -8
- package/src/router/RouterProvider.tsx +0 -7
- package/src/router/buildRouteTree.tsx +0 -63
- package/src/router/createShellRouter.ts +0 -9
- package/src/router/hooks.ts +0 -43
- package/src/shell/CommandPalette.tsx +0 -76
- package/src/shell/ConfirmDialog.tsx +0 -34
- package/src/shell/ConfirmProvider.tsx +0 -56
- package/src/shell/DrawerContext.tsx +0 -44
- package/src/shell/HeaderActions.tsx +0 -31
- package/src/shell/ModuleSelectorPage.tsx +0 -149
- package/src/shell/PageOutlet.tsx +0 -21
- package/src/shell/ShellContext.tsx +0 -45
- package/src/shell/ShellDevTools.tsx +0 -153
- package/src/shell/ShellLayout.tsx +0 -231
- package/src/shell/Toast.tsx +0 -58
- package/src/shell/ToastProvider.tsx +0 -60
- package/src/shell/app-sidebar/AppSidebar.tsx +0 -44
- package/src/shell/app-sidebar/ModuleSwitcher.tsx +0 -87
- package/src/shell/app-sidebar/NavMain.tsx +0 -64
- package/src/shell/app-sidebar/NavUser.tsx +0 -97
- package/src/shell/app-sidebar/SearchMenu.tsx +0 -22
- package/src/shell/app-sidebar/index.ts +0 -8
- package/src/shell/app-sidebar/types.ts +0 -38
- package/src/shell/types.ts +0 -6
- package/src/shell/useBreadcrumbs.ts +0 -42
- package/src/studio/bridge.ts +0 -125
- package/src/studio/index.ts +0 -3
- package/src/studio/overlay.ts +0 -47
- package/src/studio/types.ts +0 -32
- package/src/studio/walker.ts +0 -48
- package/src/vite-env.d.ts +0 -1
- package/src/widgets/__tests__/action-edge-cases.test.ts +0 -281
- package/src/widgets/__tests__/action.test.ts +0 -236
- package/src/widgets/__tests__/attachment-widget.test.tsx +0 -85
- package/src/widgets/__tests__/attachments-widget.test.tsx +0 -109
- package/src/widgets/__tests__/binding.test.ts +0 -76
- package/src/widgets/__tests__/button-widget.test.tsx +0 -145
- package/src/widgets/__tests__/checkbox-widget.test.tsx +0 -158
- package/src/widgets/__tests__/code-widget.test.tsx +0 -64
- package/src/widgets/__tests__/computed-widget.test.tsx +0 -62
- package/src/widgets/__tests__/condition-edge-cases.test.ts +0 -120
- package/src/widgets/__tests__/condition.test.ts +0 -221
- package/src/widgets/__tests__/context.test.ts +0 -99
- package/src/widgets/__tests__/data-widget.test.tsx +0 -204
- package/src/widgets/__tests__/datepicker-widget.test.tsx +0 -66
- package/src/widgets/__tests__/datetime-widget.test.tsx +0 -67
- package/src/widgets/__tests__/drawer-widget.test.tsx +0 -149
- package/src/widgets/__tests__/dynamic-link-widget.test.tsx +0 -52
- package/src/widgets/__tests__/edge-cases.test.ts +0 -232
- package/src/widgets/__tests__/evaluator.test.ts +0 -107
- package/src/widgets/__tests__/functions.test.ts +0 -147
- package/src/widgets/__tests__/grid-widget.test.tsx +0 -137
- package/src/widgets/__tests__/hooks.test.tsx +0 -249
- package/src/widgets/__tests__/icon-widget.test.tsx +0 -129
- package/src/widgets/__tests__/input-widget.test.tsx +0 -264
- package/src/widgets/__tests__/integration.test.ts +0 -116
- package/src/widgets/__tests__/json-widget.test.tsx +0 -70
- package/src/widgets/__tests__/link-widget.test.tsx +0 -92
- package/src/widgets/__tests__/many-to-many-widget.test.tsx +0 -93
- package/src/widgets/__tests__/modal-widget.test.tsx +0 -148
- package/src/widgets/__tests__/money-widget.test.tsx +0 -97
- package/src/widgets/__tests__/parser.test.ts +0 -171
- package/src/widgets/__tests__/reactive-variables.test.ts +0 -383
- package/src/widgets/__tests__/renderer.test.tsx +0 -300
- package/src/widgets/__tests__/repeat-widget.test.tsx +0 -229
- package/src/widgets/__tests__/select-widget.test.tsx +0 -231
- package/src/widgets/__tests__/sequence-widget.test.tsx +0 -58
- package/src/widgets/__tests__/shell-integration.test.tsx +0 -1343
- package/src/widgets/__tests__/split-widget.test.tsx +0 -133
- package/src/widgets/__tests__/state-edge-cases.test.ts +0 -118
- package/src/widgets/__tests__/state.test.ts +0 -106
- package/src/widgets/__tests__/table-data-binding.test.tsx +0 -482
- package/src/widgets/__tests__/table-filter-popover.test.tsx +0 -486
- package/src/widgets/__tests__/table-search.test.tsx +0 -305
- package/src/widgets/__tests__/table-widget.test.tsx +0 -509
- package/src/widgets/__tests__/textarea-widget.test.tsx +0 -105
- package/src/widgets/__tests__/tracker-validator-edge-cases.test.ts +0 -242
- package/src/widgets/__tests__/tracker.test.ts +0 -133
- package/src/widgets/__tests__/tree-widget.test.tsx +0 -97
- package/src/widgets/__tests__/use-model-source.test.ts +0 -67
- package/src/widgets/__tests__/validator.test.ts +0 -208
- package/src/widgets/action/dispatcher.ts +0 -334
- package/src/widgets/action/index.ts +0 -2
- package/src/widgets/binding/index.ts +0 -2
- package/src/widgets/binding/resolver.ts +0 -61
- package/src/widgets/components/AttachmentWidget.tsx +0 -111
- package/src/widgets/components/AttachmentsWidget.tsx +0 -121
- package/src/widgets/components/BadgeWidget.tsx +0 -35
- package/src/widgets/components/ButtonWidget.tsx +0 -43
- package/src/widgets/components/CardWidget.tsx +0 -68
- package/src/widgets/components/CheckboxWidget.tsx +0 -39
- package/src/widgets/components/CodeWidget.tsx +0 -44
- package/src/widgets/components/ColumnWidget.tsx +0 -22
- package/src/widgets/components/ComputedWidget.tsx +0 -49
- package/src/widgets/components/DataWidget.tsx +0 -189
- package/src/widgets/components/DatePickerWidget.tsx +0 -73
- package/src/widgets/components/DatetimeWidget.tsx +0 -160
- package/src/widgets/components/DividerWidget.tsx +0 -37
- package/src/widgets/components/DrawerWidget.tsx +0 -52
- package/src/widgets/components/DynamicLinkWidget.tsx +0 -130
- package/src/widgets/components/GridWidget.tsx +0 -134
- package/src/widgets/components/GroupWidget.tsx +0 -111
- package/src/widgets/components/IconWidget.tsx +0 -29
- package/src/widgets/components/ImageWidget.tsx +0 -28
- package/src/widgets/components/InputWidget.tsx +0 -70
- package/src/widgets/components/JsonWidget.tsx +0 -78
- package/src/widgets/components/LinkWidget.tsx +0 -99
- package/src/widgets/components/ManyToManyWidget.tsx +0 -125
- package/src/widgets/components/ModalWidget.tsx +0 -52
- package/src/widgets/components/MoneyWidget.tsx +0 -80
- package/src/widgets/components/RepeatWidget.tsx +0 -66
- package/src/widgets/components/ScrollAreaWidget.tsx +0 -40
- package/src/widgets/components/SectionWidget.tsx +0 -78
- package/src/widgets/components/SelectWidget.tsx +0 -63
- package/src/widgets/components/SequenceWidget.tsx +0 -32
- package/src/widgets/components/SpacerWidget.tsx +0 -29
- package/src/widgets/components/SplitWidget.tsx +0 -60
- package/src/widgets/components/StackWidget.tsx +0 -44
- package/src/widgets/components/TableWidget.tsx +0 -366
- package/src/widgets/components/TextWidget.tsx +0 -44
- package/src/widgets/components/TextareaWidget.tsx +0 -49
- package/src/widgets/components/TreeWidget.tsx +0 -109
- package/src/widgets/components/index.ts +0 -30
- package/src/widgets/components/register.ts +0 -93
- package/src/widgets/components/table/CellRenderers.tsx +0 -83
- package/src/widgets/components/table/TablePagination.tsx +0 -45
- package/src/widgets/components/table/TableToolbar.tsx +0 -285
- package/src/widgets/components/table/filter-operators.ts +0 -134
- package/src/widgets/components/table/index.ts +0 -11
- package/src/widgets/condition/evaluator.ts +0 -57
- package/src/widgets/condition/index.ts +0 -1
- package/src/widgets/context/builder.ts +0 -99
- package/src/widgets/context/index.ts +0 -8
- package/src/widgets/context/types.ts +0 -37
- package/src/widgets/data/index.ts +0 -5
- package/src/widgets/data/useModelQuery.ts +0 -116
- package/src/widgets/data/useModelRecord.ts +0 -37
- package/src/widgets/expression/evaluator.ts +0 -100
- package/src/widgets/expression/functions.ts +0 -131
- package/src/widgets/expression/index.ts +0 -13
- package/src/widgets/expression/parser.ts +0 -229
- package/src/widgets/expression/types.ts +0 -45
- package/src/widgets/form/FormContext.ts +0 -29
- package/src/widgets/form/FormProvider.tsx +0 -84
- package/src/widgets/form/FormWidget.tsx +0 -42
- package/src/widgets/form/index.ts +0 -4
- package/src/widgets/form/useFormState.ts +0 -127
- package/src/widgets/form/useFormSubmit.ts +0 -90
- package/src/widgets/form/useFormValidation.ts +0 -62
- package/src/widgets/hooks/index.ts +0 -8
- package/src/widgets/hooks/useAction.ts +0 -83
- package/src/widgets/hooks/useBind.ts +0 -34
- package/src/widgets/hooks/useCondition.ts +0 -21
- package/src/widgets/hooks/useDataQuery.ts +0 -48
- package/src/widgets/hooks/useExpression.ts +0 -14
- package/src/widgets/hooks/usePageState.ts +0 -21
- package/src/widgets/hooks/useSurfaceContext.ts +0 -11
- package/src/widgets/hooks/useWidgetContext.ts +0 -14
- package/src/widgets/index.ts +0 -80
- package/src/widgets/lib/layout-props.ts +0 -135
- package/src/widgets/reactivity/index.ts +0 -11
- package/src/widgets/reactivity/tracker.ts +0 -139
- package/src/widgets/reactivity/variables.ts +0 -213
- package/src/widgets/registry.ts +0 -41
- package/src/widgets/renderer/SlotRenderer.tsx +0 -47
- package/src/widgets/renderer/WidgetRenderer.tsx +0 -191
- package/src/widgets/renderer/index.ts +0 -4
- package/src/widgets/shell/WidgetSlotRenderer.tsx +0 -73
- package/src/widgets/shell/index.ts +0 -4
- package/src/widgets/shell/useActionHandlers.ts +0 -170
- package/src/widgets/state/index.ts +0 -2
- package/src/widgets/state/store.ts +0 -96
- package/src/widgets/types.ts +0 -28
- package/src/widgets/validation/index.ts +0 -2
- package/src/widgets/validation/validator.ts +0 -140
- package/tsconfig.json +0 -27
- package/tsconfig.tsbuildinfo +0 -1
- package/vite.config.ts +0 -21
- package/vitest.config.ts +0 -16
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { createContext, useContext, type ReactNode } from 'react';
|
|
2
|
-
import type { BootUser } from '@rangka/shared';
|
|
3
|
-
|
|
4
|
-
const UserContext = createContext<BootUser | null>(null);
|
|
5
|
-
|
|
6
|
-
export function UserProvider({ user, children }: { user: BootUser; children: ReactNode }) {
|
|
7
|
-
return <UserContext.Provider value={user}>{children}</UserContext.Provider>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useCurrentUser(): BootUser {
|
|
11
|
-
const ctx = useContext(UserContext);
|
|
12
|
-
if (!ctx) {
|
|
13
|
-
throw new Error('useCurrentUser must be used within a UserProvider');
|
|
14
|
-
}
|
|
15
|
-
return ctx;
|
|
16
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { QueryClientProvider } from '@tanstack/react-query';
|
|
2
|
-
import type { QueryClient } from '@tanstack/react-query';
|
|
3
|
-
import type { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
export function QueryProvider({ client, children }: { client: QueryClient; children: ReactNode }) {
|
|
6
|
-
return <QueryClientProvider client={client}>{children}</QueryClientProvider>;
|
|
7
|
-
}
|
package/src/data/queryClient.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
2
|
-
|
|
3
|
-
export function createQueryClient(onSessionExpired: () => void): QueryClient {
|
|
4
|
-
return new QueryClient({
|
|
5
|
-
defaultOptions: {
|
|
6
|
-
queries: {
|
|
7
|
-
retry: (failureCount, error) => {
|
|
8
|
-
if (error instanceof Response && error.status === 401) {
|
|
9
|
-
onSessionExpired();
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
return failureCount < 3;
|
|
13
|
-
},
|
|
14
|
-
staleTime: 30_000,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
}
|
package/src/data/useModelMeta.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import type { ModelMeta } from '@rangka/shared';
|
|
3
|
-
import { useMeta as useMetaContext } from '../context/MetaContext.js';
|
|
4
|
-
|
|
5
|
-
export interface UseModelMetaResult {
|
|
6
|
-
modelMeta: ModelMeta | undefined;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function useModelMeta(model: string | undefined): UseModelMetaResult {
|
|
10
|
-
const { models } = useMetaContext();
|
|
11
|
-
|
|
12
|
-
return useMemo(() => {
|
|
13
|
-
if (!model) return { modelMeta: undefined };
|
|
14
|
-
const meta = models[model];
|
|
15
|
-
return { modelMeta: meta };
|
|
16
|
-
}, [model, models]);
|
|
17
|
-
}
|
package/src/data/useMutation.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { useMutation as useTanstackMutation, useQueryClient } from '@tanstack/react-query';
|
|
2
|
-
import { apiClient } from '../api/client.js';
|
|
3
|
-
import { modelToPath } from '../api/paths.js';
|
|
4
|
-
|
|
5
|
-
export interface UseMutationResult {
|
|
6
|
-
create: (data: Record<string, unknown>) => Promise<unknown>;
|
|
7
|
-
update: (id: string, data: Record<string, unknown>) => Promise<unknown>;
|
|
8
|
-
remove: (id: string) => Promise<void>;
|
|
9
|
-
isLoading: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function useMutation(model: string): UseMutationResult {
|
|
13
|
-
const queryClient = useQueryClient();
|
|
14
|
-
const basePath = modelToPath(model);
|
|
15
|
-
|
|
16
|
-
const invalidate = () => {
|
|
17
|
-
queryClient.invalidateQueries({ queryKey: ['model', model] });
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const createMutation = useTanstackMutation({
|
|
21
|
-
mutationFn: async (data: Record<string, unknown>) => {
|
|
22
|
-
const response = await apiClient(basePath, {
|
|
23
|
-
method: 'POST',
|
|
24
|
-
body: JSON.stringify(data),
|
|
25
|
-
});
|
|
26
|
-
if (!response.ok) throw response;
|
|
27
|
-
return response.json();
|
|
28
|
-
},
|
|
29
|
-
onSuccess: invalidate,
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const updateMutation = useTanstackMutation({
|
|
33
|
-
mutationFn: async ({ id, data }: { id: string; data: Record<string, unknown> }) => {
|
|
34
|
-
const response = await apiClient(`${basePath}/${id}`, {
|
|
35
|
-
method: 'PUT',
|
|
36
|
-
body: JSON.stringify(data),
|
|
37
|
-
});
|
|
38
|
-
if (!response.ok) throw response;
|
|
39
|
-
return response.json();
|
|
40
|
-
},
|
|
41
|
-
onSuccess: invalidate,
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const removeMutation = useTanstackMutation({
|
|
45
|
-
mutationFn: async (id: string) => {
|
|
46
|
-
const response = await apiClient(`${basePath}/${id}`, {
|
|
47
|
-
method: 'DELETE',
|
|
48
|
-
});
|
|
49
|
-
if (!response.ok) throw response;
|
|
50
|
-
},
|
|
51
|
-
onSuccess: invalidate,
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
return {
|
|
55
|
-
create: (data) => createMutation.mutateAsync(data),
|
|
56
|
-
update: (id, data) => updateMutation.mutateAsync({ id, data }),
|
|
57
|
-
remove: (id) => removeMutation.mutateAsync(id),
|
|
58
|
-
isLoading: createMutation.isPending || updateMutation.isPending || removeMutation.isPending,
|
|
59
|
-
};
|
|
60
|
-
}
|
package/src/data/useRecord.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
-
import { apiClient } from '../api/client.js';
|
|
3
|
-
import { modelToPath } from '../api/paths.js';
|
|
4
|
-
|
|
5
|
-
export interface UseRecordResult<T = unknown> {
|
|
6
|
-
data: T | undefined;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function useRecord<T = unknown>(
|
|
11
|
-
model: string,
|
|
12
|
-
id: string | null | undefined,
|
|
13
|
-
): UseRecordResult<T> {
|
|
14
|
-
const query = useQuery<T>({
|
|
15
|
-
queryKey: ['model', model, id],
|
|
16
|
-
queryFn: async () => {
|
|
17
|
-
const path = `${modelToPath(model)}/${id}`;
|
|
18
|
-
const response = await apiClient(path);
|
|
19
|
-
if (!response.ok) throw response;
|
|
20
|
-
return response.json() as Promise<T>;
|
|
21
|
-
},
|
|
22
|
-
enabled: !!id,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
data: query.data,
|
|
27
|
-
isLoading: query.isLoading,
|
|
28
|
-
};
|
|
29
|
-
}
|
package/src/data/useSource.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { useState, useCallback } from 'react';
|
|
2
|
-
import { useQuery } from '@tanstack/react-query';
|
|
3
|
-
import { apiClient } from '../api/client.js';
|
|
4
|
-
import { modelToPath } from '../api/paths.js';
|
|
5
|
-
|
|
6
|
-
export interface UseSourceOptions {
|
|
7
|
-
model?: string;
|
|
8
|
-
endpoint?: string;
|
|
9
|
-
params?: Record<string, unknown>;
|
|
10
|
-
page?: number;
|
|
11
|
-
pageSize?: number;
|
|
12
|
-
sort?: string;
|
|
13
|
-
filter?: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export interface UseSourceResult<T = unknown> {
|
|
17
|
-
data: T[] | undefined;
|
|
18
|
-
isLoading: boolean;
|
|
19
|
-
pagination: { total?: number; page: number; pageSize: number } | undefined;
|
|
20
|
-
setPage: (page: number) => void;
|
|
21
|
-
setPageSize: (size: number) => void;
|
|
22
|
-
setSort: (sort: string | undefined) => void;
|
|
23
|
-
setFilter: (field: string, value: string | undefined) => void;
|
|
24
|
-
clearFilters: () => void;
|
|
25
|
-
sortParam: string | undefined;
|
|
26
|
-
filterParams: Record<string, string>;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function useSource<T = unknown>(options: UseSourceOptions): UseSourceResult<T> {
|
|
30
|
-
const { model, endpoint, params } = options;
|
|
31
|
-
const path = endpoint ?? (model ? modelToPath(model) : '');
|
|
32
|
-
|
|
33
|
-
const [page, setPage] = useState(options.page ?? 1);
|
|
34
|
-
const [pageSize, setPageSize] = useState(options.pageSize ?? 20);
|
|
35
|
-
const [sortParam, setSortParam] = useState<string | undefined>(options.sort);
|
|
36
|
-
const [filterParams, setFilterParams] = useState<Record<string, string>>(options.filter ?? {});
|
|
37
|
-
|
|
38
|
-
const allParams: Record<string, unknown> = {
|
|
39
|
-
...params,
|
|
40
|
-
page: String(page),
|
|
41
|
-
pageSize: String(pageSize),
|
|
42
|
-
};
|
|
43
|
-
if (sortParam) {
|
|
44
|
-
allParams.sort = sortParam;
|
|
45
|
-
}
|
|
46
|
-
for (const [field, value] of Object.entries(filterParams)) {
|
|
47
|
-
allParams[`filter[${field}]`] = value;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const queryKey = model ? ['model', model, allParams] : ['endpoint', endpoint, allParams];
|
|
51
|
-
|
|
52
|
-
const query = useQuery<{ data: T[]; total?: number } | T[]>({
|
|
53
|
-
queryKey,
|
|
54
|
-
queryFn: async () => {
|
|
55
|
-
const url = new URL(path, window.location.origin);
|
|
56
|
-
for (const [key, value] of Object.entries(allParams)) {
|
|
57
|
-
url.searchParams.set(key, String(value));
|
|
58
|
-
}
|
|
59
|
-
const response = await apiClient(url.pathname + url.search);
|
|
60
|
-
if (!response.ok) throw response;
|
|
61
|
-
return response.json();
|
|
62
|
-
},
|
|
63
|
-
enabled: !!path,
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const rawData = query.data;
|
|
67
|
-
let data: T[] | undefined;
|
|
68
|
-
let total: number | undefined;
|
|
69
|
-
|
|
70
|
-
if (rawData && !Array.isArray(rawData) && 'data' in rawData) {
|
|
71
|
-
data = rawData.data;
|
|
72
|
-
total = rawData.total;
|
|
73
|
-
} else if (Array.isArray(rawData)) {
|
|
74
|
-
data = rawData;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const setFilterField = useCallback((field: string, value: string | undefined) => {
|
|
78
|
-
setFilterParams((prev) => {
|
|
79
|
-
const next = { ...prev };
|
|
80
|
-
if (value === undefined || value === '') {
|
|
81
|
-
delete next[field];
|
|
82
|
-
} else {
|
|
83
|
-
next[field] = value;
|
|
84
|
-
}
|
|
85
|
-
return next;
|
|
86
|
-
});
|
|
87
|
-
setPage(1);
|
|
88
|
-
}, []);
|
|
89
|
-
|
|
90
|
-
const clearFilters = useCallback(() => {
|
|
91
|
-
setFilterParams({});
|
|
92
|
-
setPage(1);
|
|
93
|
-
}, []);
|
|
94
|
-
|
|
95
|
-
const handleSetPageSize = useCallback((size: number) => {
|
|
96
|
-
setPageSize(size);
|
|
97
|
-
setPage(1);
|
|
98
|
-
}, []);
|
|
99
|
-
|
|
100
|
-
return {
|
|
101
|
-
data,
|
|
102
|
-
isLoading: query.isLoading,
|
|
103
|
-
pagination: { total, page, pageSize },
|
|
104
|
-
setPage,
|
|
105
|
-
setPageSize: handleSetPageSize,
|
|
106
|
-
setSort: setSortParam,
|
|
107
|
-
setFilter: setFilterField,
|
|
108
|
-
clearFilters,
|
|
109
|
-
sortParam,
|
|
110
|
-
filterParams,
|
|
111
|
-
};
|
|
112
|
-
}
|
package/src/hooks/use-mobile.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
const MOBILE_BREAKPOINT = 768;
|
|
4
|
-
|
|
5
|
-
export function useIsMobile() {
|
|
6
|
-
const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined);
|
|
7
|
-
|
|
8
|
-
React.useEffect(() => {
|
|
9
|
-
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
10
|
-
const onChange = () => {
|
|
11
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
12
|
-
};
|
|
13
|
-
mql.addEventListener('change', onChange);
|
|
14
|
-
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
15
|
-
return () => mql.removeEventListener('change', onChange);
|
|
16
|
-
}, []);
|
|
17
|
-
|
|
18
|
-
return !!isMobile;
|
|
19
|
-
}
|
package/src/index.css
DELETED
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
@import 'tailwindcss';
|
|
2
|
-
@import 'tw-animate-css';
|
|
3
|
-
@import 'shadcn/tailwind.css';
|
|
4
|
-
@import '@fontsource-variable/inter';
|
|
5
|
-
@import 'tw-animate-css';
|
|
6
|
-
@import 'shadcn/tailwind.css';
|
|
7
|
-
@import '@fontsource-variable/inter';
|
|
8
|
-
@import 'tw-animate-css';
|
|
9
|
-
@import 'shadcn/tailwind.css';
|
|
10
|
-
@import '@fontsource-variable/inter';
|
|
11
|
-
|
|
12
|
-
@custom-variant dark (&:is(.dark *));
|
|
13
|
-
|
|
14
|
-
@source "../src";
|
|
15
|
-
|
|
16
|
-
@keyframes page-enter {
|
|
17
|
-
from {
|
|
18
|
-
opacity: 0;
|
|
19
|
-
transform: translateY(4px);
|
|
20
|
-
}
|
|
21
|
-
to {
|
|
22
|
-
opacity: 1;
|
|
23
|
-
transform: translateY(0);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@theme inline {
|
|
28
|
-
--animate-page-enter: page-enter 150ms ease-out;
|
|
29
|
-
--font-heading: var(--font-sans);
|
|
30
|
-
|
|
31
|
-
--font-sans: 'Inter Variable', sans-serif;
|
|
32
|
-
|
|
33
|
-
--color-sidebar-ring: var(--sidebar-ring);
|
|
34
|
-
|
|
35
|
-
--color-sidebar-border: var(--sidebar-border);
|
|
36
|
-
|
|
37
|
-
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
|
38
|
-
|
|
39
|
-
--color-sidebar-accent: var(--sidebar-accent);
|
|
40
|
-
|
|
41
|
-
--color-sidebar-primary-foreground: var(--sidebar-primary-foreground);
|
|
42
|
-
|
|
43
|
-
--color-sidebar-primary: var(--sidebar-primary);
|
|
44
|
-
|
|
45
|
-
--color-sidebar-foreground: var(--sidebar-foreground);
|
|
46
|
-
|
|
47
|
-
--color-sidebar: var(--sidebar);
|
|
48
|
-
|
|
49
|
-
--color-chart-5: var(--chart-5);
|
|
50
|
-
|
|
51
|
-
--color-chart-4: var(--chart-4);
|
|
52
|
-
|
|
53
|
-
--color-chart-3: var(--chart-3);
|
|
54
|
-
|
|
55
|
-
--color-chart-2: var(--chart-2);
|
|
56
|
-
|
|
57
|
-
--color-chart-1: var(--chart-1);
|
|
58
|
-
|
|
59
|
-
--color-ring: var(--ring);
|
|
60
|
-
|
|
61
|
-
--color-input: var(--input);
|
|
62
|
-
|
|
63
|
-
--color-border: var(--border);
|
|
64
|
-
|
|
65
|
-
--color-destructive: var(--destructive);
|
|
66
|
-
|
|
67
|
-
--color-accent-foreground: var(--accent-foreground);
|
|
68
|
-
|
|
69
|
-
--color-accent: var(--accent);
|
|
70
|
-
|
|
71
|
-
--color-muted-foreground: var(--muted-foreground);
|
|
72
|
-
|
|
73
|
-
--color-muted: var(--muted);
|
|
74
|
-
|
|
75
|
-
--color-secondary-foreground: var(--secondary-foreground);
|
|
76
|
-
|
|
77
|
-
--color-secondary: var(--secondary);
|
|
78
|
-
|
|
79
|
-
--color-primary-foreground: var(--primary-foreground);
|
|
80
|
-
|
|
81
|
-
--color-primary: var(--primary);
|
|
82
|
-
|
|
83
|
-
--color-popover-foreground: var(--popover-foreground);
|
|
84
|
-
|
|
85
|
-
--color-popover: var(--popover);
|
|
86
|
-
|
|
87
|
-
--color-card-foreground: var(--card-foreground);
|
|
88
|
-
|
|
89
|
-
--color-card: var(--card);
|
|
90
|
-
|
|
91
|
-
--color-foreground: var(--foreground);
|
|
92
|
-
|
|
93
|
-
--color-background: var(--background);
|
|
94
|
-
|
|
95
|
-
--radius-sm: calc(var(--radius) * 0.6);
|
|
96
|
-
|
|
97
|
-
--radius-md: calc(var(--radius) * 0.8);
|
|
98
|
-
|
|
99
|
-
--radius-lg: var(--radius);
|
|
100
|
-
|
|
101
|
-
--radius-xl: calc(var(--radius) * 1.4);
|
|
102
|
-
|
|
103
|
-
--radius-2xl: calc(var(--radius) * 1.8);
|
|
104
|
-
|
|
105
|
-
--radius-3xl: calc(var(--radius) * 2.2);
|
|
106
|
-
|
|
107
|
-
--radius-4xl: calc(var(--radius) * 2.6);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
:root {
|
|
111
|
-
--background: oklch(1 0 0);
|
|
112
|
-
|
|
113
|
-
--foreground: oklch(0.145 0 0);
|
|
114
|
-
|
|
115
|
-
--card: oklch(1 0 0);
|
|
116
|
-
|
|
117
|
-
--card-foreground: oklch(0.145 0 0);
|
|
118
|
-
|
|
119
|
-
--popover: oklch(1 0 0);
|
|
120
|
-
|
|
121
|
-
--popover-foreground: oklch(0.145 0 0);
|
|
122
|
-
|
|
123
|
-
--primary: oklch(0.5 0.134 242.749);
|
|
124
|
-
|
|
125
|
-
--primary-foreground: oklch(0.977 0.013 236.62);
|
|
126
|
-
|
|
127
|
-
--secondary: oklch(0.967 0.001 286.375);
|
|
128
|
-
|
|
129
|
-
--secondary-foreground: oklch(0.21 0.006 285.885);
|
|
130
|
-
|
|
131
|
-
--muted: oklch(0.97 0 0);
|
|
132
|
-
|
|
133
|
-
--muted-foreground: oklch(0.556 0 0);
|
|
134
|
-
|
|
135
|
-
--accent: oklch(0.5 0.134 242.749);
|
|
136
|
-
|
|
137
|
-
--accent-foreground: oklch(0.977 0.013 236.62);
|
|
138
|
-
|
|
139
|
-
--destructive: oklch(0.577 0.245 27.325);
|
|
140
|
-
|
|
141
|
-
--border: oklch(0.922 0 0);
|
|
142
|
-
|
|
143
|
-
--input: oklch(0.8 0 0);
|
|
144
|
-
|
|
145
|
-
--ring: oklch(0.708 0 0);
|
|
146
|
-
|
|
147
|
-
--chart-1: oklch(0.809 0.105 251.813);
|
|
148
|
-
|
|
149
|
-
--chart-2: oklch(0.623 0.214 259.815);
|
|
150
|
-
|
|
151
|
-
--chart-3: oklch(0.546 0.245 262.881);
|
|
152
|
-
|
|
153
|
-
--chart-4: oklch(0.488 0.243 264.376);
|
|
154
|
-
|
|
155
|
-
--chart-5: oklch(0.424 0.199 265.638);
|
|
156
|
-
|
|
157
|
-
--radius: 0.625rem;
|
|
158
|
-
|
|
159
|
-
--sidebar: oklch(0.985 0 0);
|
|
160
|
-
|
|
161
|
-
--sidebar-foreground: oklch(0.145 0 0);
|
|
162
|
-
|
|
163
|
-
--sidebar-primary: oklch(0.588 0.158 241.966);
|
|
164
|
-
|
|
165
|
-
--sidebar-primary-foreground: oklch(0.977 0.013 236.62);
|
|
166
|
-
|
|
167
|
-
--sidebar-accent: oklch(0.97 0 0);
|
|
168
|
-
|
|
169
|
-
--sidebar-accent-foreground: oklch(0.205 0 0);
|
|
170
|
-
|
|
171
|
-
--sidebar-border: oklch(0.922 0 0);
|
|
172
|
-
|
|
173
|
-
--sidebar-ring: oklch(0.708 0 0);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
.dark {
|
|
177
|
-
--background: oklch(0.145 0 0);
|
|
178
|
-
|
|
179
|
-
--foreground: oklch(0.985 0 0);
|
|
180
|
-
|
|
181
|
-
--card: oklch(0.205 0 0);
|
|
182
|
-
|
|
183
|
-
--card-foreground: oklch(0.985 0 0);
|
|
184
|
-
|
|
185
|
-
--popover: oklch(0.205 0 0);
|
|
186
|
-
|
|
187
|
-
--popover-foreground: oklch(0.985 0 0);
|
|
188
|
-
|
|
189
|
-
--primary: oklch(0.443 0.11 240.79);
|
|
190
|
-
|
|
191
|
-
--primary-foreground: oklch(0.977 0.013 236.62);
|
|
192
|
-
|
|
193
|
-
--secondary: oklch(0.274 0.006 286.033);
|
|
194
|
-
|
|
195
|
-
--secondary-foreground: oklch(0.985 0 0);
|
|
196
|
-
|
|
197
|
-
--muted: oklch(0.269 0 0);
|
|
198
|
-
|
|
199
|
-
--muted-foreground: oklch(0.708 0 0);
|
|
200
|
-
|
|
201
|
-
--accent: oklch(0.443 0.11 240.79);
|
|
202
|
-
|
|
203
|
-
--accent-foreground: oklch(0.977 0.013 236.62);
|
|
204
|
-
|
|
205
|
-
--destructive: oklch(0.704 0.191 22.216);
|
|
206
|
-
|
|
207
|
-
--border: oklch(1 0 0 / 10%);
|
|
208
|
-
|
|
209
|
-
--input: oklch(1 0 0 / 25%);
|
|
210
|
-
|
|
211
|
-
--ring: oklch(0.556 0 0);
|
|
212
|
-
|
|
213
|
-
--chart-1: oklch(0.809 0.105 251.813);
|
|
214
|
-
|
|
215
|
-
--chart-2: oklch(0.623 0.214 259.815);
|
|
216
|
-
|
|
217
|
-
--chart-3: oklch(0.546 0.245 262.881);
|
|
218
|
-
|
|
219
|
-
--chart-4: oklch(0.488 0.243 264.376);
|
|
220
|
-
|
|
221
|
-
--chart-5: oklch(0.424 0.199 265.638);
|
|
222
|
-
|
|
223
|
-
--sidebar: oklch(0.205 0 0);
|
|
224
|
-
|
|
225
|
-
--sidebar-foreground: oklch(0.985 0 0);
|
|
226
|
-
|
|
227
|
-
--sidebar-primary: oklch(0.685 0.169 237.323);
|
|
228
|
-
|
|
229
|
-
--sidebar-primary-foreground: oklch(0.293 0.066 243.157);
|
|
230
|
-
|
|
231
|
-
--sidebar-accent: oklch(0.269 0 0);
|
|
232
|
-
|
|
233
|
-
--sidebar-accent-foreground: oklch(0.985 0 0);
|
|
234
|
-
|
|
235
|
-
--sidebar-border: oklch(1 0 0 / 10%);
|
|
236
|
-
|
|
237
|
-
--sidebar-ring: oklch(0.556 0 0);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
@layer base {
|
|
241
|
-
* {
|
|
242
|
-
@apply border-border outline-ring/50;
|
|
243
|
-
}
|
|
244
|
-
body {
|
|
245
|
-
@apply bg-background text-foreground;
|
|
246
|
-
}
|
|
247
|
-
html {
|
|
248
|
-
@apply text-base font-sans;
|
|
249
|
-
font-size: 17px;
|
|
250
|
-
}
|
|
251
|
-
button,
|
|
252
|
-
a,
|
|
253
|
-
[role='button'],
|
|
254
|
-
[role='menuitem'],
|
|
255
|
-
[role='option'],
|
|
256
|
-
[data-slot='sidebar-menu-button'],
|
|
257
|
-
[data-slot='sidebar-menu-sub-button'] {
|
|
258
|
-
cursor: pointer;
|
|
259
|
-
}
|
|
260
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { useNavigate, useParams, useRoute, useSearchParams } from './router/hooks.js';
|
|
2
|
-
export { useSource, type UseSourceOptions, type UseSourceResult } from './data/useSource.js';
|
|
3
|
-
export { useRecord, type UseRecordResult } from './data/useRecord.js';
|
|
4
|
-
export { useMutation, type UseMutationResult } from './data/useMutation.js';
|
|
5
|
-
export { useModelMeta } from './data/useModelMeta.js';
|
|
6
|
-
export { useCurrentUser } from './context/UserContext.js';
|
|
7
|
-
export { usePermissions, type PermissionsApi } from './context/PermissionsContext.js';
|
|
8
|
-
export { useMeta, type MetaData } from './context/MetaContext.js';
|
|
9
|
-
export { useShell, type ShellAPI, type ToastType } from './shell/ShellContext.js';
|
|
10
|
-
export { App } from './App.js';
|
|
11
|
-
export {
|
|
12
|
-
WidgetSlotRenderer,
|
|
13
|
-
useActionHandlers,
|
|
14
|
-
type UseActionHandlersOptions,
|
|
15
|
-
type WidgetSlotRendererProps,
|
|
16
|
-
} from './widgets/shell/index.js';
|
package/src/lib/utils.ts
DELETED
package/src/main.tsx
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { StrictMode } from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import './index.css';
|
|
4
|
-
import { App } from './App.js';
|
|
5
|
-
import { registerBuiltInWidgets } from './widgets/components/register.js';
|
|
6
|
-
|
|
7
|
-
registerBuiltInWidgets();
|
|
8
|
-
|
|
9
|
-
createRoot(document.getElementById('root')!).render(
|
|
10
|
-
<StrictMode>
|
|
11
|
-
<App />
|
|
12
|
-
</StrictMode>,
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
if (window.parent !== window) {
|
|
16
|
-
import('./studio/index.js');
|
|
17
|
-
}
|
package/src/router/NotFound.tsx
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { RouterProvider as TanstackRouterProvider } from '@tanstack/react-router';
|
|
2
|
-
import type { Router } from '@tanstack/react-router';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
5
|
-
export function RouterProvider({ router }: { router: Router<any, any, any, any> }) {
|
|
6
|
-
return <TanstackRouterProvider router={router} />;
|
|
7
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { PageDefinition } from '@rangka/shared';
|
|
2
|
-
import { createRootRoute, createRoute, Outlet, type AnyRoute } from '@tanstack/react-router';
|
|
3
|
-
import { PageOutlet } from '../shell/PageOutlet.js';
|
|
4
|
-
import { ShellLayout } from '../shell/ShellLayout.js';
|
|
5
|
-
import { ModuleSelectorPage } from '../shell/ModuleSelectorPage.js';
|
|
6
|
-
|
|
7
|
-
function RootLayout() {
|
|
8
|
-
return (
|
|
9
|
-
<ShellLayout>
|
|
10
|
-
<Outlet />
|
|
11
|
-
</ShellLayout>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function pageKeyToPath(key: string): string {
|
|
16
|
-
return '/' + key.replace(/\./g, '/');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function buildRouteTree(pages: PageDefinition[]) {
|
|
20
|
-
const rootRoute = createRootRoute({
|
|
21
|
-
component: RootLayout,
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const indexRoute = createRoute({
|
|
25
|
-
getParentRoute: () => rootRoute,
|
|
26
|
-
path: '/',
|
|
27
|
-
component: ModuleSelectorPage,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const childRoutes: AnyRoute[] = [indexRoute];
|
|
31
|
-
|
|
32
|
-
childRoutes.push(
|
|
33
|
-
...pages.map((page) => {
|
|
34
|
-
const path = page.path ?? pageKeyToPath(page.key);
|
|
35
|
-
const pageKey = page.key;
|
|
36
|
-
return createRoute({
|
|
37
|
-
getParentRoute: () => rootRoute,
|
|
38
|
-
path,
|
|
39
|
-
component: () => PageOutlet({ pageKey }),
|
|
40
|
-
});
|
|
41
|
-
}),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const notFoundRoute = createRoute({
|
|
45
|
-
getParentRoute: () => rootRoute,
|
|
46
|
-
path: '*',
|
|
47
|
-
component: NotFound,
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
childRoutes.push(notFoundRoute);
|
|
51
|
-
rootRoute.addChildren(childRoutes);
|
|
52
|
-
|
|
53
|
-
return rootRoute;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function NotFound() {
|
|
57
|
-
return (
|
|
58
|
-
<div role="alert">
|
|
59
|
-
<h1>Page not found</h1>
|
|
60
|
-
<p>The page you are looking for does not exist.</p>
|
|
61
|
-
</div>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { PageDefinition } from '@rangka/shared';
|
|
2
|
-
import { createRouter, type Router } from '@tanstack/react-router';
|
|
3
|
-
import { buildRouteTree } from './buildRouteTree.jsx';
|
|
4
|
-
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
6
|
-
export function createShellRouter(pages: PageDefinition[]): Router<any, any, any, any> {
|
|
7
|
-
const routeTree = buildRouteTree(pages);
|
|
8
|
-
return createRouter({ routeTree });
|
|
9
|
-
}
|