@alneas/appkit-react 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +53 -0
- package/README.md +85 -15
- package/consumer-ai/SKILL.md +12 -0
- package/consumer-ai/api-index.json +103754 -0
- package/consumer-ai/package-context.json +409 -0
- package/dist/ai/action/ExecutionHistory.cjs.map +1 -1
- package/dist/ai/action/ExecutionHistory.d.cts +32 -2
- package/dist/ai/action/ExecutionHistory.d.ts +32 -2
- package/dist/ai/action/ExecutionHistory.js.map +1 -1
- package/dist/ai/action/ScreenActionContext.cjs.map +1 -1
- package/dist/ai/action/ScreenActionContext.d.cts +15 -2
- package/dist/ai/action/ScreenActionContext.d.ts +15 -2
- package/dist/ai/action/ScreenActionContext.js.map +1 -1
- package/dist/ai/action/context.cjs.map +1 -1
- package/dist/ai/action/context.d.cts +19 -3
- package/dist/ai/action/context.d.ts +19 -3
- package/dist/ai/action/context.js.map +1 -1
- package/dist/ai/action/types.d.cts +35 -3
- package/dist/ai/action/types.d.ts +35 -3
- package/dist/ai/action/use-execution-session.cjs.map +1 -1
- package/dist/ai/action/use-execution-session.d.cts +17 -1
- package/dist/ai/action/use-execution-session.d.ts +17 -1
- package/dist/ai/action/use-execution-session.js.map +1 -1
- package/dist/ai/action/use-screen-action-registry.cjs.map +1 -1
- package/dist/ai/action/use-screen-action-registry.d.cts +77 -8
- package/dist/ai/action/use-screen-action-registry.d.ts +77 -8
- package/dist/ai/action/use-screen-action-registry.js.map +1 -1
- package/dist/ai/action/use-screen-action.cjs.map +1 -1
- package/dist/ai/action/use-screen-action.d.cts +23 -6
- package/dist/ai/action/use-screen-action.d.ts +23 -6
- package/dist/ai/action/use-screen-action.js.map +1 -1
- package/dist/ai/action/use-screen-context.cjs.map +1 -1
- package/dist/ai/action/use-screen-context.d.cts +42 -5
- package/dist/ai/action/use-screen-context.d.ts +42 -5
- package/dist/ai/action/use-screen-context.js.map +1 -1
- package/dist/ai/ai-chat/transport.cjs.map +1 -1
- package/dist/ai/ai-chat/transport.d.cts +35 -8
- package/dist/ai/ai-chat/transport.d.ts +35 -8
- package/dist/ai/ai-chat/transport.js.map +1 -1
- package/dist/ai/generative-ui/GenerativeUIRenderer.cjs.map +1 -1
- package/dist/ai/generative-ui/GenerativeUIRenderer.d.cts +21 -3
- package/dist/ai/generative-ui/GenerativeUIRenderer.d.ts +21 -3
- package/dist/ai/generative-ui/GenerativeUIRenderer.js.map +1 -1
- package/dist/ai/generative-ui/error-boundary.cjs.map +1 -1
- package/dist/ai/generative-ui/error-boundary.d.cts +98 -2
- package/dist/ai/generative-ui/error-boundary.d.ts +98 -2
- package/dist/ai/generative-ui/error-boundary.js.map +1 -1
- package/dist/ai/generative-ui/registry.cjs.map +1 -1
- package/dist/ai/generative-ui/registry.d.cts +96 -7
- package/dist/ai/generative-ui/registry.d.ts +96 -7
- package/dist/ai/generative-ui/registry.js.map +1 -1
- package/dist/ai/proposal/ProposalFieldReview.cjs.map +1 -1
- package/dist/ai/proposal/ProposalFieldReview.d.cts +170 -8
- package/dist/ai/proposal/ProposalFieldReview.d.ts +170 -8
- package/dist/ai/proposal/ProposalFieldReview.js.map +1 -1
- package/dist/ai/proposal/types.d.cts +97 -26
- package/dist/ai/proposal/types.d.ts +97 -26
- package/dist/ai/proposal/use-proposal-batch-review.cjs.map +1 -1
- package/dist/ai/proposal/use-proposal-batch-review.d.cts +133 -7
- package/dist/ai/proposal/use-proposal-batch-review.d.ts +133 -7
- package/dist/ai/proposal/use-proposal-batch-review.js.map +1 -1
- package/dist/ai/proposal/use-proposal-review.cjs.map +1 -1
- package/dist/ai/proposal/use-proposal-review.d.cts +47 -5
- package/dist/ai/proposal/use-proposal-review.d.ts +47 -5
- package/dist/ai/proposal/use-proposal-review.js.map +1 -1
- package/dist/avatar.svg +1 -0
- package/dist/consumer-ai/SKILL.md +6 -0
- package/dist/consumer-ai/api-index.json +103754 -0
- package/dist/consumer-ai/package-context.json +5 -3
- package/dist/mockServiceWorker.js +361 -0
- package/dist/styles.css +1 -1
- package/dist/tools/components/auth/AuthForms.cjs.map +1 -1
- package/dist/tools/components/auth/AuthForms.d.cts +131 -81
- package/dist/tools/components/auth/AuthForms.d.ts +131 -81
- package/dist/tools/components/auth/AuthForms.js.map +1 -1
- package/dist/tools/components/auth/AuthGuard.cjs.map +1 -1
- package/dist/tools/components/auth/AuthGuard.d.cts +31 -4
- package/dist/tools/components/auth/AuthGuard.d.ts +31 -4
- package/dist/tools/components/auth/AuthGuard.js.map +1 -1
- package/dist/tools/components/auth/AuthProvider.cjs.map +1 -1
- package/dist/tools/components/auth/AuthProvider.d.cts +39 -42
- package/dist/tools/components/auth/AuthProvider.d.ts +39 -42
- package/dist/tools/components/auth/AuthProvider.js.map +1 -1
- package/dist/tools/components/auth/ProtectedRoute.cjs.map +1 -1
- package/dist/tools/components/auth/ProtectedRoute.d.cts +75 -60
- package/dist/tools/components/auth/ProtectedRoute.d.ts +75 -60
- package/dist/tools/components/auth/ProtectedRoute.js.map +1 -1
- package/dist/tools/components/auth/SignInButton.cjs.map +1 -1
- package/dist/tools/components/auth/SignInButton.d.cts +26 -18
- package/dist/tools/components/auth/SignInButton.d.ts +26 -18
- package/dist/tools/components/auth/SignInButton.js.map +1 -1
- package/dist/tools/components/auth/UserProfileProvider.cjs.map +1 -1
- package/dist/tools/components/auth/UserProfileProvider.d.cts +48 -20
- package/dist/tools/components/auth/UserProfileProvider.d.ts +48 -20
- package/dist/tools/components/auth/UserProfileProvider.js.map +1 -1
- package/dist/tools/components/auth/adapters/better-auth-adapter.cjs.map +1 -1
- package/dist/tools/components/auth/adapters/better-auth-adapter.d.cts +371 -51
- package/dist/tools/components/auth/adapters/better-auth-adapter.d.ts +371 -51
- package/dist/tools/components/auth/adapters/better-auth-adapter.js.map +1 -1
- package/dist/tools/components/auth/adapters/mock-adapter.cjs.map +1 -1
- package/dist/tools/components/auth/adapters/mock-adapter.d.cts +149 -28
- package/dist/tools/components/auth/adapters/mock-adapter.d.ts +149 -28
- package/dist/tools/components/auth/adapters/mock-adapter.js.map +1 -1
- package/dist/tools/components/auth/auth-session.cjs.map +1 -1
- package/dist/tools/components/auth/auth-session.d.cts +147 -1
- package/dist/tools/components/auth/auth-session.d.ts +147 -1
- package/dist/tools/components/auth/auth-session.js.map +1 -1
- package/dist/tools/components/auth/session-cache.cjs.map +1 -1
- package/dist/tools/components/auth/session-cache.d.cts +88 -24
- package/dist/tools/components/auth/session-cache.d.ts +88 -24
- package/dist/tools/components/auth/session-cache.js.map +1 -1
- package/dist/tools/components/auth/types.cjs.map +1 -1
- package/dist/tools/components/auth/types.d.cts +329 -106
- package/dist/tools/components/auth/types.d.ts +329 -106
- package/dist/tools/components/auth/types.js.map +1 -1
- package/dist/tools/components/auth/useAuth.cjs.map +1 -1
- package/dist/tools/components/auth/useAuth.d.cts +110 -17
- package/dist/tools/components/auth/useAuth.d.ts +110 -17
- package/dist/tools/components/auth/useAuth.js.map +1 -1
- package/dist/tools/components/auth/useAuthGuard.cjs.map +1 -1
- package/dist/tools/components/auth/useAuthGuard.d.cts +49 -38
- package/dist/tools/components/auth/useAuthGuard.d.ts +49 -38
- package/dist/tools/components/auth/useAuthGuard.js.map +1 -1
- package/dist/tools/components/auth/useRoleCheck.cjs.map +1 -1
- package/dist/tools/components/auth/useRoleCheck.d.cts +48 -1
- package/dist/tools/components/auth/useRoleCheck.d.ts +48 -1
- package/dist/tools/components/auth/useRoleCheck.js.map +1 -1
- package/dist/tools/components/auth/useUserProfile.cjs.map +1 -1
- package/dist/tools/components/auth/useUserProfile.d.cts +66 -1
- package/dist/tools/components/auth/useUserProfile.d.ts +66 -1
- package/dist/tools/components/auth/useUserProfile.js.map +1 -1
- package/dist/tools/components/barcode/BarcodeGenerator.cjs.map +1 -1
- package/dist/tools/components/barcode/BarcodeGenerator.d.cts +32 -18
- package/dist/tools/components/barcode/BarcodeGenerator.d.ts +32 -18
- package/dist/tools/components/barcode/BarcodeGenerator.js.map +1 -1
- package/dist/tools/components/barcode/QRCodeGenerator.cjs +1 -1
- package/dist/tools/components/barcode/QRCodeGenerator.cjs.map +1 -1
- package/dist/tools/components/barcode/QRCodeGenerator.d.cts +20 -13
- package/dist/tools/components/barcode/QRCodeGenerator.d.ts +20 -13
- package/dist/tools/components/barcode/QRCodeGenerator.js +1 -1
- package/dist/tools/components/barcode/QRCodeGenerator.js.map +1 -1
- package/dist/tools/components/barcode/QRCodeScanner.cjs.map +1 -1
- package/dist/tools/components/barcode/QRCodeScanner.d.cts +32 -1
- package/dist/tools/components/barcode/QRCodeScanner.d.ts +32 -1
- package/dist/tools/components/barcode/QRCodeScanner.js.map +1 -1
- package/dist/tools/components/calendar/ResourceCalendar.cjs.map +1 -1
- package/dist/tools/components/calendar/ResourceCalendar.d.cts +17 -42
- package/dist/tools/components/calendar/ResourceCalendar.d.ts +17 -42
- package/dist/tools/components/calendar/ResourceCalendar.js.map +1 -1
- package/dist/tools/components/calendar/views/ResourceView.cjs +1 -1
- package/dist/tools/components/calendar/views/ResourceView.cjs.map +1 -1
- package/dist/tools/components/calendar/views/ResourceView.js +2 -2
- package/dist/tools/components/calendar/views/ResourceView.js.map +1 -1
- package/dist/tools/components/chart/ComposedChart.cjs.map +1 -1
- package/dist/tools/components/chart/ComposedChart.d.cts +54 -1
- package/dist/tools/components/chart/ComposedChart.d.ts +54 -1
- package/dist/tools/components/chart/ComposedChart.js.map +1 -1
- package/dist/tools/components/chart/SimpleAreaChart.cjs.map +1 -1
- package/dist/tools/components/chart/SimpleAreaChart.d.cts +41 -1
- package/dist/tools/components/chart/SimpleAreaChart.d.ts +41 -1
- package/dist/tools/components/chart/SimpleAreaChart.js.map +1 -1
- package/dist/tools/components/chart/SimpleBarChart.cjs.map +1 -1
- package/dist/tools/components/chart/SimpleBarChart.d.cts +34 -24
- package/dist/tools/components/chart/SimpleBarChart.d.ts +34 -24
- package/dist/tools/components/chart/SimpleBarChart.js.map +1 -1
- package/dist/tools/components/chart/SimpleLineChart.cjs.map +1 -1
- package/dist/tools/components/chart/SimpleLineChart.d.cts +31 -28
- package/dist/tools/components/chart/SimpleLineChart.d.ts +31 -28
- package/dist/tools/components/chart/SimpleLineChart.js.map +1 -1
- package/dist/tools/components/chart/SimplePieChart.cjs.map +1 -1
- package/dist/tools/components/chart/SimplePieChart.d.cts +28 -22
- package/dist/tools/components/chart/SimplePieChart.d.ts +28 -22
- package/dist/tools/components/chart/SimplePieChart.js.map +1 -1
- package/dist/tools/components/chart/SimpleRadarChart.cjs.map +1 -1
- package/dist/tools/components/chart/SimpleRadarChart.d.cts +38 -1
- package/dist/tools/components/chart/SimpleRadarChart.d.ts +38 -1
- package/dist/tools/components/chart/SimpleRadarChart.js.map +1 -1
- package/dist/tools/components/chart/SimpleScatterChart.cjs.map +1 -1
- package/dist/tools/components/chart/SimpleScatterChart.d.cts +44 -1
- package/dist/tools/components/chart/SimpleScatterChart.d.ts +44 -1
- package/dist/tools/components/chart/SimpleScatterChart.js.map +1 -1
- package/dist/tools/components/chart/StackedBarChart.cjs.map +1 -1
- package/dist/tools/components/chart/StackedBarChart.d.cts +38 -1
- package/dist/tools/components/chart/StackedBarChart.d.ts +38 -1
- package/dist/tools/components/chart/StackedBarChart.js.map +1 -1
- package/dist/tools/components/data-table/data-table.cjs +1 -1
- package/dist/tools/components/data-table/data-table.cjs.map +1 -1
- package/dist/tools/components/data-table/data-table.js +286 -263
- package/dist/tools/components/data-table/data-table.js.map +1 -1
- package/dist/tools/components/data-table/table-utils.cjs.map +1 -1
- package/dist/tools/components/data-table/table-utils.d.cts +45 -35
- package/dist/tools/components/data-table/table-utils.d.ts +45 -35
- package/dist/tools/components/data-table/table-utils.js.map +1 -1
- package/dist/tools/components/editable-table/editable-table.cjs +1 -1
- package/dist/tools/components/editable-table/editable-table.cjs.map +1 -1
- package/dist/tools/components/editable-table/editable-table.js +15 -2
- package/dist/tools/components/editable-table/editable-table.js.map +1 -1
- package/dist/tools/components/error/ErrorDialog.cjs +1 -1
- package/dist/tools/components/error/ErrorDialog.cjs.map +1 -1
- package/dist/tools/components/error/ErrorDialog.js +1 -1
- package/dist/tools/components/error/ErrorDialog.js.map +1 -1
- package/dist/tools/components/error/ErrorInline.cjs +1 -1
- package/dist/tools/components/error/ErrorInline.cjs.map +1 -1
- package/dist/tools/components/error/ErrorInline.js +1 -1
- package/dist/tools/components/error/ErrorInline.js.map +1 -1
- package/dist/tools/components/error/ErrorNotification.cjs +1 -1
- package/dist/tools/components/error/ErrorNotification.cjs.map +1 -1
- package/dist/tools/components/error/ErrorNotification.js +10 -10
- package/dist/tools/components/error/ErrorNotification.js.map +1 -1
- package/dist/tools/components/file-browser/FilePreview.cjs +1 -1
- package/dist/tools/components/file-browser/FilePreview.cjs.map +1 -1
- package/dist/tools/components/file-browser/FilePreview.js +28 -26
- package/dist/tools/components/file-browser/FilePreview.js.map +1 -1
- package/dist/tools/components/filter/filter.cjs.map +1 -1
- package/dist/tools/components/filter/filter.d.cts +23 -34
- package/dist/tools/components/filter/filter.d.ts +23 -34
- package/dist/tools/components/filter/filter.js.map +1 -1
- package/dist/tools/components/form/EnhancedDetailPage.cjs.map +1 -1
- package/dist/tools/components/form/EnhancedDetailPage.d.cts +47 -42
- package/dist/tools/components/form/EnhancedDetailPage.d.ts +47 -42
- package/dist/tools/components/form/EnhancedDetailPage.js.map +1 -1
- package/dist/tools/components/form/form-grid.cjs.map +1 -1
- package/dist/tools/components/form/form-grid.d.cts +44 -22
- package/dist/tools/components/form/form-grid.d.ts +44 -22
- package/dist/tools/components/form/form-grid.js.map +1 -1
- package/dist/tools/components/gantt/GanttChart.cjs +1 -1
- package/dist/tools/components/gantt/GanttChart.cjs.map +1 -1
- package/dist/tools/components/gantt/GanttChart.d.cts +20 -1
- package/dist/tools/components/gantt/GanttChart.d.ts +20 -1
- package/dist/tools/components/gantt/GanttChart.js +3 -0
- package/dist/tools/components/gantt/GanttChart.js.map +1 -1
- package/dist/tools/components/gantt/components/GanttTaskBar.cjs +1 -1
- package/dist/tools/components/gantt/components/GanttTaskBar.cjs.map +1 -1
- package/dist/tools/components/gantt/components/GanttTaskBar.js +2 -1
- package/dist/tools/components/gantt/components/GanttTaskBar.js.map +1 -1
- package/dist/tools/components/header/header.cjs +1 -1
- package/dist/tools/components/header/header.cjs.map +1 -1
- package/dist/tools/components/header/header.d.cts +103 -40
- package/dist/tools/components/header/header.d.ts +103 -40
- package/dist/tools/components/header/header.js +1 -1
- package/dist/tools/components/header/header.js.map +1 -1
- package/dist/tools/components/i18n/LanguageSwitcher.cjs.map +1 -1
- package/dist/tools/components/i18n/LanguageSwitcher.d.cts +18 -14
- package/dist/tools/components/i18n/LanguageSwitcher.d.ts +18 -14
- package/dist/tools/components/i18n/LanguageSwitcher.js.map +1 -1
- package/dist/tools/components/kanban/KanbanBoard.cjs +1 -1
- package/dist/tools/components/kanban/KanbanBoard.cjs.map +1 -1
- package/dist/tools/components/kanban/KanbanBoard.d.cts +16 -34
- package/dist/tools/components/kanban/KanbanBoard.d.ts +16 -34
- package/dist/tools/components/kanban/KanbanBoard.js +3 -0
- package/dist/tools/components/kanban/KanbanBoard.js.map +1 -1
- package/dist/tools/components/kanban/KanbanColumn.cjs +1 -1
- package/dist/tools/components/kanban/KanbanColumn.cjs.map +1 -1
- package/dist/tools/components/kanban/KanbanColumn.js +1 -1
- package/dist/tools/components/kanban/KanbanColumn.js.map +1 -1
- package/dist/tools/components/kanban/kanban-compound.cjs +1 -1
- package/dist/tools/components/kanban/kanban-compound.cjs.map +1 -1
- package/dist/tools/components/kanban/kanban-compound.js +4 -1
- package/dist/tools/components/kanban/kanban-compound.js.map +1 -1
- package/dist/tools/components/kanban/kanban-primitives.cjs +1 -1
- package/dist/tools/components/kanban/kanban-primitives.cjs.map +1 -1
- package/dist/tools/components/kanban/kanban-primitives.js +0 -1
- package/dist/tools/components/kanban/kanban-primitives.js.map +1 -1
- package/dist/tools/components/priority-queue/PriorityCard.cjs +1 -1
- package/dist/tools/components/priority-queue/PriorityCard.cjs.map +1 -1
- package/dist/tools/components/priority-queue/PriorityCard.js +3 -1
- package/dist/tools/components/priority-queue/PriorityCard.js.map +1 -1
- package/dist/tools/components/sidebar/SmartSidebar.cjs.map +1 -1
- package/dist/tools/components/sidebar/SmartSidebar.d.cts +41 -43
- package/dist/tools/components/sidebar/SmartSidebar.d.ts +41 -43
- package/dist/tools/components/sidebar/SmartSidebar.js.map +1 -1
- package/dist/tools/components/splash/SplashScreen.cjs.map +1 -1
- package/dist/tools/components/splash/SplashScreen.d.cts +43 -68
- package/dist/tools/components/splash/SplashScreen.d.ts +43 -68
- package/dist/tools/components/splash/SplashScreen.js.map +1 -1
- package/dist/tools/components/workflow/WorkflowStatusPanel.cjs +1 -1
- package/dist/tools/components/workflow/WorkflowStatusPanel.cjs.map +1 -1
- package/dist/tools/components/workflow/WorkflowStatusPanel.js +2 -2
- package/dist/tools/components/workflow/WorkflowStatusPanel.js.map +1 -1
- package/dist/tools/lib/data-access/data-access-context.cjs.map +1 -1
- package/dist/tools/lib/data-access/data-access-context.d.cts +15 -6
- package/dist/tools/lib/data-access/data-access-context.d.ts +15 -6
- package/dist/tools/lib/data-access/data-access-context.js.map +1 -1
- package/dist/tools/lib/data-access/react-query-provider.cjs.map +1 -1
- package/dist/tools/lib/data-access/react-query-provider.d.cts +19 -2
- package/dist/tools/lib/data-access/react-query-provider.d.ts +19 -2
- package/dist/tools/lib/data-access/react-query-provider.js.map +1 -1
- package/dist/tools/lib/data-access/react-query.cjs.map +1 -1
- package/dist/tools/lib/data-access/react-query.d.cts +365 -90
- package/dist/tools/lib/data-access/react-query.d.ts +365 -90
- package/dist/tools/lib/data-access/react-query.js.map +1 -1
- package/dist/tools/lib/error/AppError.cjs.map +1 -1
- package/dist/tools/lib/error/AppError.d.cts +157 -63
- package/dist/tools/lib/error/AppError.d.ts +157 -63
- package/dist/tools/lib/error/AppError.js.map +1 -1
- package/dist/tools/lib/hooks/useAsyncWithTimeout.cjs.map +1 -1
- package/dist/tools/lib/hooks/useAsyncWithTimeout.d.cts +79 -26
- package/dist/tools/lib/hooks/useAsyncWithTimeout.d.ts +79 -26
- package/dist/tools/lib/hooks/useAsyncWithTimeout.js.map +1 -1
- package/dist/tools/lib/hooks/useError.cjs.map +1 -1
- package/dist/tools/lib/hooks/useError.d.cts +51 -16
- package/dist/tools/lib/hooks/useError.d.ts +51 -16
- package/dist/tools/lib/hooks/useError.js.map +1 -1
- package/dist/tools/lib/schema/ajv.cjs +1 -1
- package/dist/tools/lib/schema/ajv.cjs.map +1 -1
- package/dist/tools/lib/schema/ajv.d.cts +19 -8
- package/dist/tools/lib/schema/ajv.d.ts +19 -8
- package/dist/tools/lib/schema/ajv.js +2 -1
- package/dist/tools/lib/schema/ajv.js.map +1 -1
- package/dist/tools/lib/state/error-store.cjs.map +1 -1
- package/dist/tools/lib/state/error-store.d.cts +61 -10
- package/dist/tools/lib/state/error-store.d.ts +61 -10
- package/dist/tools/lib/state/error-store.js.map +1 -1
- package/dist/tools/lib/state/store-factory.cjs.map +1 -1
- package/dist/tools/lib/state/store-factory.d.cts +25 -4
- package/dist/tools/lib/state/store-factory.d.ts +25 -4
- package/dist/tools/lib/state/store-factory.js.map +1 -1
- package/dist/tools/lib/state/ui-store.cjs.map +1 -1
- package/dist/tools/lib/state/ui-store.d.cts +39 -0
- package/dist/tools/lib/state/ui-store.d.ts +39 -0
- package/dist/tools/lib/state/ui-store.js.map +1 -1
- package/dist/ui/components/theme/theme-context.cjs.map +1 -1
- package/dist/ui/components/theme/theme-context.d.cts +171 -1
- package/dist/ui/components/theme/theme-context.d.ts +171 -1
- package/dist/ui/components/theme/theme-context.js.map +1 -1
- package/dist/ui/components/theme/theme-provider.cjs.map +1 -1
- package/dist/ui/components/theme/theme-provider.d.cts +31 -19
- package/dist/ui/components/theme/theme-provider.d.ts +31 -19
- package/dist/ui/components/theme/theme-provider.js.map +1 -1
- package/dist/ui/components/theme/theme-script.cjs.map +1 -1
- package/dist/ui/components/theme/theme-script.d.cts +16 -1
- package/dist/ui/components/theme/theme-script.d.ts +16 -1
- package/dist/ui/components/theme/theme-script.js.map +1 -1
- package/dist/ui/components/theme/theme-switcher.cjs +1 -1
- package/dist/ui/components/theme/theme-switcher.cjs.map +1 -1
- package/dist/ui/components/theme/theme-switcher.d.cts +82 -13
- package/dist/ui/components/theme/theme-switcher.d.ts +82 -13
- package/dist/ui/components/theme/theme-switcher.js +8 -0
- package/dist/ui/components/theme/theme-switcher.js.map +1 -1
- package/dist/ui/components/ui/accordion.cjs.map +1 -1
- package/dist/ui/components/ui/accordion.d.cts +60 -0
- package/dist/ui/components/ui/accordion.d.ts +60 -0
- package/dist/ui/components/ui/accordion.js.map +1 -1
- package/dist/ui/components/ui/adjustable-pane.cjs.map +1 -1
- package/dist/ui/components/ui/adjustable-pane.d.cts +44 -26
- package/dist/ui/components/ui/adjustable-pane.d.ts +44 -26
- package/dist/ui/components/ui/adjustable-pane.js.map +1 -1
- package/dist/ui/components/ui/alert-dialog.cjs.map +1 -1
- package/dist/ui/components/ui/alert-dialog.d.cts +179 -2
- package/dist/ui/components/ui/alert-dialog.d.ts +179 -2
- package/dist/ui/components/ui/alert-dialog.js.map +1 -1
- package/dist/ui/components/ui/alert.cjs.map +1 -1
- package/dist/ui/components/ui/alert.d.cts +52 -4
- package/dist/ui/components/ui/alert.d.ts +52 -4
- package/dist/ui/components/ui/alert.js.map +1 -1
- package/dist/ui/components/ui/aspect-ratio.cjs.map +1 -1
- package/dist/ui/components/ui/aspect-ratio.d.cts +16 -1
- package/dist/ui/components/ui/aspect-ratio.d.ts +16 -1
- package/dist/ui/components/ui/aspect-ratio.js.map +1 -1
- package/dist/ui/components/ui/avatar.cjs.map +1 -1
- package/dist/ui/components/ui/avatar.d.cts +87 -3
- package/dist/ui/components/ui/avatar.d.ts +87 -3
- package/dist/ui/components/ui/avatar.js.map +1 -1
- package/dist/ui/components/ui/badge-components.cjs.map +1 -1
- package/dist/ui/components/ui/badge-components.d.cts +13 -1
- package/dist/ui/components/ui/badge-components.d.ts +13 -1
- package/dist/ui/components/ui/badge-components.js.map +1 -1
- package/dist/ui/components/ui/badge-variants.cjs.map +1 -1
- package/dist/ui/components/ui/badge-variants.d.cts +15 -0
- package/dist/ui/components/ui/badge-variants.d.ts +15 -0
- package/dist/ui/components/ui/badge-variants.js.map +1 -1
- package/dist/ui/components/ui/breadcrumb.cjs.map +1 -1
- package/dist/ui/components/ui/breadcrumb.d.cts +91 -7
- package/dist/ui/components/ui/breadcrumb.d.ts +91 -7
- package/dist/ui/components/ui/breadcrumb.js.map +1 -1
- package/dist/ui/components/ui/button-components.cjs.map +1 -1
- package/dist/ui/components/ui/button-components.d.cts +18 -6
- package/dist/ui/components/ui/button-components.d.ts +18 -6
- package/dist/ui/components/ui/button-components.js.map +1 -1
- package/dist/ui/components/ui/button-group-components.cjs.map +1 -1
- package/dist/ui/components/ui/button-group-components.d.cts +39 -3
- package/dist/ui/components/ui/button-group-components.d.ts +39 -3
- package/dist/ui/components/ui/button-group-components.js.map +1 -1
- package/dist/ui/components/ui/button-group-variants.cjs.map +1 -1
- package/dist/ui/components/ui/button-group-variants.d.cts +15 -0
- package/dist/ui/components/ui/button-group-variants.d.ts +15 -0
- package/dist/ui/components/ui/button-group-variants.js.map +1 -1
- package/dist/ui/components/ui/button-variants.cjs.map +1 -1
- package/dist/ui/components/ui/button-variants.d.cts +13 -2
- package/dist/ui/components/ui/button-variants.d.ts +13 -2
- package/dist/ui/components/ui/button-variants.js.map +1 -1
- package/dist/ui/components/ui/card.cjs.map +1 -1
- package/dist/ui/components/ui/card.d.cts +106 -2
- package/dist/ui/components/ui/card.d.ts +106 -2
- package/dist/ui/components/ui/card.js.map +1 -1
- package/dist/ui/components/ui/checkbox-group.cjs.map +1 -1
- package/dist/ui/components/ui/checkbox-group.d.cts +13 -1
- package/dist/ui/components/ui/checkbox-group.d.ts +13 -1
- package/dist/ui/components/ui/checkbox-group.js.map +1 -1
- package/dist/ui/components/ui/checkbox.cjs.map +1 -1
- package/dist/ui/components/ui/checkbox.d.cts +17 -6
- package/dist/ui/components/ui/checkbox.d.ts +17 -6
- package/dist/ui/components/ui/checkbox.js.map +1 -1
- package/dist/ui/components/ui/collapsible.cjs.map +1 -1
- package/dist/ui/components/ui/collapsible.d.cts +39 -3
- package/dist/ui/components/ui/collapsible.d.ts +39 -3
- package/dist/ui/components/ui/collapsible.js.map +1 -1
- package/dist/ui/components/ui/combobox-components.cjs.map +1 -1
- package/dist/ui/components/ui/combobox-components.d.cts +209 -14
- package/dist/ui/components/ui/combobox-components.d.ts +209 -14
- package/dist/ui/components/ui/combobox-components.js.map +1 -1
- package/dist/ui/components/ui/combobox-hooks.cjs.map +1 -1
- package/dist/ui/components/ui/combobox-hooks.d.cts +13 -1
- package/dist/ui/components/ui/combobox-hooks.d.ts +13 -1
- package/dist/ui/components/ui/combobox-hooks.js.map +1 -1
- package/dist/ui/components/ui/command.cjs.map +1 -1
- package/dist/ui/components/ui/command.d.cts +132 -9
- package/dist/ui/components/ui/command.d.ts +132 -9
- package/dist/ui/components/ui/command.js.map +1 -1
- package/dist/ui/components/ui/context-menu.cjs.map +1 -1
- package/dist/ui/components/ui/context-menu.d.cts +233 -2
- package/dist/ui/components/ui/context-menu.d.ts +233 -2
- package/dist/ui/components/ui/context-menu.js.map +1 -1
- package/dist/ui/components/ui/dialog.cjs.map +1 -1
- package/dist/ui/components/ui/dialog.d.cts +157 -5
- package/dist/ui/components/ui/dialog.d.ts +157 -5
- package/dist/ui/components/ui/dialog.js.map +1 -1
- package/dist/ui/components/ui/drawer.cjs.map +1 -1
- package/dist/ui/components/ui/drawer.d.cts +130 -10
- package/dist/ui/components/ui/drawer.d.ts +130 -10
- package/dist/ui/components/ui/drawer.js.map +1 -1
- package/dist/ui/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/ui/components/ui/dropdown-menu.d.cts +225 -6
- package/dist/ui/components/ui/dropdown-menu.d.ts +225 -6
- package/dist/ui/components/ui/dropdown-menu.js.map +1 -1
- package/dist/ui/components/ui/empty.cjs.map +1 -1
- package/dist/ui/components/ui/empty.d.cts +78 -6
- package/dist/ui/components/ui/empty.d.ts +78 -6
- package/dist/ui/components/ui/empty.js.map +1 -1
- package/dist/ui/components/ui/field.cjs.map +1 -1
- package/dist/ui/components/ui/field.d.cts +180 -6
- package/dist/ui/components/ui/field.d.ts +180 -6
- package/dist/ui/components/ui/field.js.map +1 -1
- package/dist/ui/components/ui/file-icon.cjs.map +1 -1
- package/dist/ui/components/ui/file-icon.d.cts +32 -4
- package/dist/ui/components/ui/file-icon.d.ts +32 -4
- package/dist/ui/components/ui/file-icon.js.map +1 -1
- package/dist/ui/components/ui/hover-card.cjs.map +1 -1
- package/dist/ui/components/ui/hover-card.d.cts +39 -3
- package/dist/ui/components/ui/hover-card.d.ts +39 -3
- package/dist/ui/components/ui/hover-card.js.map +1 -1
- package/dist/ui/components/ui/input-group.cjs.map +1 -1
- package/dist/ui/components/ui/input-group.d.cts +84 -6
- package/dist/ui/components/ui/input-group.d.ts +84 -6
- package/dist/ui/components/ui/input-group.js.map +1 -1
- package/dist/ui/components/ui/input-otp.cjs.map +1 -1
- package/dist/ui/components/ui/input-otp.d.cts +58 -4
- package/dist/ui/components/ui/input-otp.d.ts +58 -4
- package/dist/ui/components/ui/input-otp.js.map +1 -1
- package/dist/ui/components/ui/input.cjs.map +1 -1
- package/dist/ui/components/ui/input.d.cts +18 -10
- package/dist/ui/components/ui/input.d.ts +18 -10
- package/dist/ui/components/ui/input.js.map +1 -1
- package/dist/ui/components/ui/item.cjs.map +1 -1
- package/dist/ui/components/ui/item.d.cts +130 -10
- package/dist/ui/components/ui/item.d.ts +130 -10
- package/dist/ui/components/ui/item.js.map +1 -1
- package/dist/ui/components/ui/kbd.cjs.map +1 -1
- package/dist/ui/components/ui/kbd.d.cts +26 -2
- package/dist/ui/components/ui/kbd.d.ts +26 -2
- package/dist/ui/components/ui/kbd.js.map +1 -1
- package/dist/ui/components/ui/label.cjs.map +1 -1
- package/dist/ui/components/ui/label.d.cts +15 -0
- package/dist/ui/components/ui/label.d.ts +15 -0
- package/dist/ui/components/ui/label.js.map +1 -1
- package/dist/ui/components/ui/layout.cjs +1 -1
- package/dist/ui/components/ui/layout.cjs.map +1 -1
- package/dist/ui/components/ui/layout.d.cts +45 -11
- package/dist/ui/components/ui/layout.d.ts +45 -11
- package/dist/ui/components/ui/layout.js +22 -20
- package/dist/ui/components/ui/layout.js.map +1 -1
- package/dist/ui/components/ui/menubar.cjs.map +1 -1
- package/dist/ui/components/ui/menubar.d.cts +220 -16
- package/dist/ui/components/ui/menubar.d.ts +220 -16
- package/dist/ui/components/ui/menubar.js.map +1 -1
- package/dist/ui/components/ui/meter.cjs.map +1 -1
- package/dist/ui/components/ui/meter.d.cts +52 -4
- package/dist/ui/components/ui/meter.d.ts +52 -4
- package/dist/ui/components/ui/meter.js.map +1 -1
- package/dist/ui/components/ui/mobile-form-variants.cjs.map +1 -1
- package/dist/ui/components/ui/mobile-form-variants.d.cts +30 -0
- package/dist/ui/components/ui/mobile-form-variants.d.ts +30 -0
- package/dist/ui/components/ui/mobile-form-variants.js.map +1 -1
- package/dist/ui/components/ui/mobile-form.cjs.map +1 -1
- package/dist/ui/components/ui/mobile-form.d.cts +186 -9
- package/dist/ui/components/ui/mobile-form.d.ts +186 -9
- package/dist/ui/components/ui/mobile-form.js.map +1 -1
- package/dist/ui/components/ui/navigation-menu-components.cjs.map +1 -1
- package/dist/ui/components/ui/navigation-menu-components.d.cts +104 -8
- package/dist/ui/components/ui/navigation-menu-components.d.ts +104 -8
- package/dist/ui/components/ui/navigation-menu-components.js.map +1 -1
- package/dist/ui/components/ui/navigation-menu-variants.cjs.map +1 -1
- package/dist/ui/components/ui/navigation-menu-variants.d.cts +15 -0
- package/dist/ui/components/ui/navigation-menu-variants.d.ts +15 -0
- package/dist/ui/components/ui/navigation-menu-variants.js.map +1 -1
- package/dist/ui/components/ui/number-field.cjs.map +1 -1
- package/dist/ui/components/ui/number-field.d.cts +78 -6
- package/dist/ui/components/ui/number-field.d.ts +78 -6
- package/dist/ui/components/ui/number-field.js.map +1 -1
- package/dist/ui/components/ui/pagination.cjs.map +1 -1
- package/dist/ui/components/ui/pagination.d.cts +99 -7
- package/dist/ui/components/ui/pagination.d.ts +99 -7
- package/dist/ui/components/ui/pagination.js.map +1 -1
- package/dist/ui/components/ui/password-input.cjs.map +1 -1
- package/dist/ui/components/ui/password-input.d.cts +10 -7
- package/dist/ui/components/ui/password-input.d.ts +10 -7
- package/dist/ui/components/ui/password-input.js.map +1 -1
- package/dist/ui/components/ui/popover.cjs.map +1 -1
- package/dist/ui/components/ui/popover.d.cts +86 -2
- package/dist/ui/components/ui/popover.d.ts +86 -2
- package/dist/ui/components/ui/popover.js.map +1 -1
- package/dist/ui/components/ui/progress.cjs.map +1 -1
- package/dist/ui/components/ui/progress.d.cts +72 -2
- package/dist/ui/components/ui/progress.d.ts +72 -2
- package/dist/ui/components/ui/progress.js.map +1 -1
- package/dist/ui/components/ui/radio-card.cjs.map +1 -1
- package/dist/ui/components/ui/radio-card.d.cts +32 -4
- package/dist/ui/components/ui/radio-card.d.ts +32 -4
- package/dist/ui/components/ui/radio-card.js.map +1 -1
- package/dist/ui/components/ui/radio-group.cjs.map +1 -1
- package/dist/ui/components/ui/radio-group.d.cts +28 -2
- package/dist/ui/components/ui/radio-group.d.ts +28 -2
- package/dist/ui/components/ui/radio-group.js.map +1 -1
- package/dist/ui/components/ui/resizable.cjs.map +1 -1
- package/dist/ui/components/ui/resizable.d.cts +42 -3
- package/dist/ui/components/ui/resizable.d.ts +42 -3
- package/dist/ui/components/ui/resizable.js.map +1 -1
- package/dist/ui/components/ui/responsive-list.cjs.map +1 -1
- package/dist/ui/components/ui/responsive-list.d.cts +176 -13
- package/dist/ui/components/ui/responsive-list.d.ts +176 -13
- package/dist/ui/components/ui/responsive-list.js.map +1 -1
- package/dist/ui/components/ui/scroll-area.cjs.map +1 -1
- package/dist/ui/components/ui/scroll-area.d.cts +28 -1
- package/dist/ui/components/ui/scroll-area.d.ts +28 -1
- package/dist/ui/components/ui/scroll-area.js.map +1 -1
- package/dist/ui/components/ui/searchable-select-input.cjs.map +1 -1
- package/dist/ui/components/ui/searchable-select-input.d.cts +199 -49
- package/dist/ui/components/ui/searchable-select-input.d.ts +199 -49
- package/dist/ui/components/ui/searchable-select-input.js.map +1 -1
- package/dist/ui/components/ui/select.cjs.map +1 -1
- package/dist/ui/components/ui/select.d.cts +205 -40
- package/dist/ui/components/ui/select.d.ts +205 -40
- package/dist/ui/components/ui/select.js.map +1 -1
- package/dist/ui/components/ui/separator.cjs.map +1 -1
- package/dist/ui/components/ui/separator.d.cts +13 -2
- package/dist/ui/components/ui/separator.d.ts +13 -2
- package/dist/ui/components/ui/separator.js.map +1 -1
- package/dist/ui/components/ui/sheet.cjs.map +1 -1
- package/dist/ui/components/ui/sheet.d.cts +128 -3
- package/dist/ui/components/ui/sheet.d.ts +128 -3
- package/dist/ui/components/ui/sheet.js.map +1 -1
- package/dist/ui/components/ui/skeleton.cjs.map +1 -1
- package/dist/ui/components/ui/skeleton.d.cts +13 -1
- package/dist/ui/components/ui/skeleton.d.ts +13 -1
- package/dist/ui/components/ui/skeleton.js.map +1 -1
- package/dist/ui/components/ui/slider.cjs.map +1 -1
- package/dist/ui/components/ui/slider.d.cts +13 -7
- package/dist/ui/components/ui/slider.d.ts +13 -7
- package/dist/ui/components/ui/slider.js.map +1 -1
- package/dist/ui/components/ui/spinner.cjs.map +1 -1
- package/dist/ui/components/ui/spinner.d.cts +13 -1
- package/dist/ui/components/ui/spinner.d.ts +13 -1
- package/dist/ui/components/ui/spinner.js.map +1 -1
- package/dist/ui/components/ui/switch.cjs.map +1 -1
- package/dist/ui/components/ui/switch.d.cts +26 -0
- package/dist/ui/components/ui/switch.d.ts +26 -0
- package/dist/ui/components/ui/switch.js.map +1 -1
- package/dist/ui/components/ui/table.cjs.map +1 -1
- package/dist/ui/components/ui/table.d.cts +118 -2
- package/dist/ui/components/ui/table.d.ts +118 -2
- package/dist/ui/components/ui/table.js.map +1 -1
- package/dist/ui/components/ui/tabs-components.cjs.map +1 -1
- package/dist/ui/components/ui/tabs-components.d.cts +52 -5
- package/dist/ui/components/ui/tabs-components.d.ts +52 -5
- package/dist/ui/components/ui/tabs-components.js.map +1 -1
- package/dist/ui/components/ui/tabs-variants.cjs.map +1 -1
- package/dist/ui/components/ui/tabs-variants.d.cts +15 -0
- package/dist/ui/components/ui/tabs-variants.d.ts +15 -0
- package/dist/ui/components/ui/tabs-variants.js.map +1 -1
- package/dist/ui/components/ui/textarea.cjs.map +1 -1
- package/dist/ui/components/ui/textarea.d.cts +23 -0
- package/dist/ui/components/ui/textarea.d.ts +23 -0
- package/dist/ui/components/ui/textarea.js.map +1 -1
- package/dist/ui/components/ui/toast.cjs.map +1 -1
- package/dist/ui/components/ui/toast.d.cts +136 -0
- package/dist/ui/components/ui/toast.d.ts +136 -0
- package/dist/ui/components/ui/toast.js.map +1 -1
- package/dist/ui/components/ui/toaster.cjs.map +1 -1
- package/dist/ui/components/ui/toaster.d.cts +12 -3
- package/dist/ui/components/ui/toaster.d.ts +12 -3
- package/dist/ui/components/ui/toaster.js.map +1 -1
- package/dist/ui/components/ui/toggle-components.cjs.map +1 -1
- package/dist/ui/components/ui/toggle-components.d.cts +15 -0
- package/dist/ui/components/ui/toggle-components.d.ts +15 -0
- package/dist/ui/components/ui/toggle-components.js.map +1 -1
- package/dist/ui/components/ui/toggle-group.cjs.map +1 -1
- package/dist/ui/components/ui/toggle-group.d.cts +33 -0
- package/dist/ui/components/ui/toggle-group.d.ts +33 -0
- package/dist/ui/components/ui/toggle-group.js.map +1 -1
- package/dist/ui/components/ui/toggle-variants.cjs.map +1 -1
- package/dist/ui/components/ui/toggle-variants.d.cts +15 -0
- package/dist/ui/components/ui/toggle-variants.d.ts +15 -0
- package/dist/ui/components/ui/toggle-variants.js.map +1 -1
- package/dist/ui/components/ui/toolbar.cjs.map +1 -1
- package/dist/ui/components/ui/toolbar.d.cts +94 -7
- package/dist/ui/components/ui/toolbar.d.ts +94 -7
- package/dist/ui/components/ui/toolbar.js.map +1 -1
- package/dist/ui/components/ui/tooltip.cjs.map +1 -1
- package/dist/ui/components/ui/tooltip.d.cts +54 -3
- package/dist/ui/components/ui/tooltip.d.ts +54 -3
- package/dist/ui/components/ui/tooltip.js.map +1 -1
- package/dist/ui/lib/hooks/use-gps.cjs.map +1 -1
- package/dist/ui/lib/hooks/use-gps.d.cts +29 -4
- package/dist/ui/lib/hooks/use-gps.d.ts +29 -4
- package/dist/ui/lib/hooks/use-gps.js.map +1 -1
- package/dist/ui/lib/hooks/use-is-client.cjs.map +1 -1
- package/dist/ui/lib/hooks/use-is-client.d.cts +11 -2
- package/dist/ui/lib/hooks/use-is-client.d.ts +11 -2
- package/dist/ui/lib/hooks/use-is-client.js.map +1 -1
- package/dist/ui/lib/hooks/use-keyboard-shortcut.cjs.map +1 -1
- package/dist/ui/lib/hooks/use-keyboard-shortcut.d.cts +48 -18
- package/dist/ui/lib/hooks/use-keyboard-shortcut.d.ts +48 -18
- package/dist/ui/lib/hooks/use-keyboard-shortcut.js.map +1 -1
- package/dist/ui/lib/hooks/use-mobile.cjs.map +1 -1
- package/dist/ui/lib/hooks/use-mobile.d.cts +11 -3
- package/dist/ui/lib/hooks/use-mobile.d.ts +11 -3
- package/dist/ui/lib/hooks/use-mobile.js.map +1 -1
- package/dist/ui/lib/hooks/use-toast.cjs.map +1 -1
- package/dist/ui/lib/hooks/use-toast.d.cts +184 -15
- package/dist/ui/lib/hooks/use-toast.d.ts +184 -15
- package/dist/ui/lib/hooks/use-toast.js.map +1 -1
- package/dist/ui/lib/ime-utils.cjs.map +1 -1
- package/dist/ui/lib/ime-utils.d.cts +40 -13
- package/dist/ui/lib/ime-utils.d.ts +40 -13
- package/dist/ui/lib/ime-utils.js.map +1 -1
- package/dist/ui/lib/utils.cjs.map +1 -1
- package/dist/ui/lib/utils.d.cts +9 -6
- package/dist/ui/lib/utils.d.ts +9 -6
- package/dist/ui/lib/utils.js.map +1 -1
- package/docs/ai.md +34 -1
- package/docs/exports.md +5 -1
- package/docs/index.md +89 -16
- package/docs/migration.md +268 -0
- package/docs/request-form.md +4 -1
- package/docs/tools.md +4 -1
- package/docs/ui.md +4 -1
- package/llms-full.txt +499 -36
- package/llms.txt +4 -0
- package/package.json +35 -5
|
@@ -1,112 +1,127 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { BaseProfile } from './types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Route display restrictions and client redirects.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam T - Profile shape extending BaseProfile; defaults to BaseProfile.
|
|
7
|
+
*
|
|
8
|
+
* @see ProtectedRoute for provider setup and semantics.
|
|
9
|
+
*/
|
|
3
10
|
export interface ProtectedRouteProps<T extends BaseProfile = BaseProfile> {
|
|
11
|
+
/**
|
|
12
|
+
* Content rendered only after loading and successful display checks.
|
|
13
|
+
*/
|
|
4
14
|
children: React.ReactNode;
|
|
5
15
|
/**
|
|
6
|
-
*
|
|
7
|
-
* @default '/login'
|
|
16
|
+
* Unauthenticated redirect destination; defaults to /login.
|
|
8
17
|
*/
|
|
9
18
|
loginPath?: string;
|
|
10
19
|
/**
|
|
11
|
-
*
|
|
12
|
-
* @default undefined (リダイレクトしない)
|
|
20
|
+
* Optional denied-access destination; omission renders unauthorizedFallback.
|
|
13
21
|
*/
|
|
14
22
|
unauthorizedPath?: string;
|
|
15
23
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @example ['admin', 'manager']
|
|
24
|
+
* Any one listed role must match; omission or an empty array skips role restriction.
|
|
18
25
|
*/
|
|
19
26
|
roles?: string[];
|
|
20
27
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @default 'role'
|
|
28
|
+
* Profile scalar/array role property; defaults to role.
|
|
23
29
|
*/
|
|
24
30
|
roleField?: keyof T;
|
|
25
31
|
/**
|
|
26
|
-
*
|
|
27
|
-
* @example (profile) => profile?.subscription === 'premium'
|
|
32
|
+
* Additional synchronous predicate receiving the profile or null; must pass after role checks. Thrown errors propagate from render.
|
|
28
33
|
*/
|
|
29
34
|
condition?: (profile: T | null) => boolean;
|
|
30
35
|
/**
|
|
31
|
-
*
|
|
36
|
+
* Loading content; defaults to null.
|
|
32
37
|
*/
|
|
33
38
|
fallback?: React.ReactNode;
|
|
34
39
|
/**
|
|
35
|
-
*
|
|
40
|
+
* Denied-access content when unauthorizedPath is omitted; defaults to null.
|
|
36
41
|
*/
|
|
37
42
|
unauthorizedFallback?: React.ReactNode;
|
|
38
43
|
/**
|
|
39
|
-
*
|
|
40
|
-
* @example (path) => navigate(path)
|
|
44
|
+
* Optional synchronous navigation callback receiving the destination; omission assigns window.location.href.
|
|
41
45
|
*/
|
|
42
46
|
onRedirect?: (path: string) => void;
|
|
43
47
|
}
|
|
44
48
|
/**
|
|
45
|
-
*
|
|
49
|
+
* Renders or redirects according to current auth, optional roles and an optional predicate.
|
|
46
50
|
*
|
|
47
|
-
*
|
|
51
|
+
* @typeParam T - Profile shape used by roleField and condition; defaults to BaseProfile.
|
|
48
52
|
*
|
|
49
|
-
* @
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
* </ProtectedRoute>
|
|
60
|
-
*
|
|
61
|
-
* // カスタム条件
|
|
62
|
-
* <ProtectedRoute
|
|
63
|
-
* condition={(profile) => profile?.plan === 'premium'}
|
|
64
|
-
* unauthorizedPath="/upgrade"
|
|
65
|
-
* >
|
|
66
|
-
* <PremiumPage />
|
|
67
|
-
* </ProtectedRoute>
|
|
68
|
-
* ```
|
|
69
|
-
*/
|
|
70
|
-
export declare function ProtectedRoute<T extends BaseProfile = BaseProfile>({ children, loginPath, unauthorizedPath, roles, roleField, condition, fallback, unauthorizedFallback, onRedirect, }: ProtectedRouteProps<T>): React.JSX.Element | null;
|
|
71
|
-
/**
|
|
72
|
-
* ロールベースの表示制御フック
|
|
53
|
+
* @param props - Children, access predicates, loading/denial content and navigation settings.
|
|
54
|
+
*
|
|
55
|
+
* @returns Loading fallback, permitted children, denied fallback or null while redirecting.
|
|
56
|
+
*
|
|
57
|
+
* @throws Error without AuthProvider; condition errors propagate during rendering.
|
|
58
|
+
*
|
|
59
|
+
* @remarks Requires AuthProvider inside QueryClientProvider. UserProfileProvider is optional
|
|
60
|
+
* but needed for profile-based roles. Redirects run in effects; missing profiles fail a
|
|
61
|
+
* nonempty role restriction. This uses display user state without isSessionVerified;
|
|
62
|
+
* backend authorization is still required. No CSS is required.
|
|
73
63
|
*
|
|
74
64
|
* @example
|
|
75
65
|
* ```tsx
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
* </div>
|
|
84
|
-
* );
|
|
66
|
+
* import type { ReactNode } from 'react';
|
|
67
|
+
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
68
|
+
* import { AuthProvider, ProtectedRoute, type AuthAdapter } from '@alneas/appkit-react/tools/auth';
|
|
69
|
+
*
|
|
70
|
+
* function Content() { return <ProtectedRoute><span>Account</span></ProtectedRoute>; }
|
|
71
|
+
* export function Example({ adapter, queryClient }: { adapter: AuthAdapter; queryClient: QueryClient }) {
|
|
72
|
+
* return <QueryClientProvider client={queryClient}><AuthProvider adapter={adapter}><Content /></AuthProvider></QueryClientProvider>;
|
|
85
73
|
* }
|
|
86
74
|
* ```
|
|
87
75
|
*/
|
|
76
|
+
export declare function ProtectedRoute<T extends BaseProfile = BaseProfile>({ children, loginPath, unauthorizedPath, roles, roleField, condition, fallback, unauthorizedFallback, onRedirect, }: ProtectedRouteProps<T>): React.JSX.Element | null;
|
|
88
77
|
/**
|
|
89
|
-
*
|
|
78
|
+
* Conditional display settings; see ShowFor for usage.
|
|
90
79
|
*
|
|
91
|
-
* @
|
|
92
|
-
* ```tsx
|
|
93
|
-
* <ShowFor roles={['admin']}>
|
|
94
|
-
* <AdminOnlyContent />
|
|
95
|
-
* </ShowFor>
|
|
80
|
+
* @typeParam T - Profile shape extending BaseProfile; defaults to BaseProfile.
|
|
96
81
|
*
|
|
97
|
-
*
|
|
98
|
-
* <PremiumContent />
|
|
99
|
-
* </ShowFor>
|
|
100
|
-
* ```
|
|
82
|
+
* @see ShowFor for the canonical usage example.
|
|
101
83
|
*/
|
|
102
84
|
export interface ShowForProps<T extends BaseProfile = BaseProfile> {
|
|
85
|
+
/**
|
|
86
|
+
* Content to render when all supplied checks pass.
|
|
87
|
+
*/
|
|
103
88
|
children: React.ReactNode;
|
|
89
|
+
/**
|
|
90
|
+
* Any one role must match; omission or empty array imposes no restriction.
|
|
91
|
+
*/
|
|
104
92
|
roles?: string[];
|
|
93
|
+
/**
|
|
94
|
+
* Profile role property; defaults to role.
|
|
95
|
+
*/
|
|
105
96
|
roleField?: keyof T;
|
|
97
|
+
/**
|
|
98
|
+
* Optional synchronous predicate receiving the current profile or null.
|
|
99
|
+
*/
|
|
106
100
|
condition?: (profile: T | null) => boolean;
|
|
101
|
+
/**
|
|
102
|
+
* Content when a check fails; defaults to null.
|
|
103
|
+
*/
|
|
107
104
|
fallback?: React.ReactNode;
|
|
108
105
|
}
|
|
109
106
|
/**
|
|
110
|
-
*
|
|
107
|
+
* Conditionally displays children using profile roles and an optional predicate.
|
|
108
|
+
*
|
|
109
|
+
* @typeParam T - Profile shape extending BaseProfile; defaults to BaseProfile.
|
|
110
|
+
*
|
|
111
|
+
* @param props - Role checks, profile predicate, children and optional fallback.
|
|
112
|
+
*
|
|
113
|
+
* @returns Children when checks pass; otherwise fallback, defaulting to null.
|
|
114
|
+
*
|
|
115
|
+
* @throws Predicate errors propagate from render.
|
|
116
|
+
*
|
|
117
|
+
* @remarks UserProfileProvider supplies profile data but is optional; without it profile
|
|
118
|
+
* is null. With no restrictions children render even without a profile. Does not redirect,
|
|
119
|
+
* wait for loading, verify authentication or enforce backend access. No CSS is required.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```tsx
|
|
123
|
+
* import { ShowFor } from '@alneas/appkit-react/tools/auth';
|
|
124
|
+
* export function RoleLabel() { return <ShowFor roles={['admin']}><span>Admin controls</span></ShowFor>; }
|
|
125
|
+
* ```
|
|
111
126
|
*/
|
|
112
127
|
export declare function ShowFor<T extends BaseProfile = BaseProfile>({ children, roles, roleField, condition, fallback, }: ShowForProps<T>): React.JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtectedRoute.js","names":["_Fragment","ProtectedRoute","isAuthLoading","useAuth","profile","isProfileLoading","profileContext","useUserProfile","isLoading","isAuthenticated","user","isAuthorized","roles","userRole","roleField","role","condition","useEffect","performRedirect","onRedirect","path","unauthorizedPath","loginPath","Fragment","fallback","unauthorizedFallback","ShowFor","useRoleCheck","hasAnyRole"],"sources":["../../../../src/tools/components/auth/ProtectedRoute.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useAuth } from './useAuth';\nimport { useUserProfile } from './useUserProfile';\nimport { useRoleCheck } from './useRoleCheck';\nimport { BaseProfile } from './types';\n\nexport interface ProtectedRouteProps<T extends BaseProfile = BaseProfile> {\n children: React.ReactNode;\n
|
|
1
|
+
{"version":3,"file":"ProtectedRoute.js","names":["_Fragment","ProtectedRoute","isAuthLoading","useAuth","profile","isProfileLoading","profileContext","useUserProfile","isLoading","isAuthenticated","user","isAuthorized","roles","userRole","roleField","role","condition","useEffect","performRedirect","onRedirect","path","unauthorizedPath","loginPath","Fragment","fallback","unauthorizedFallback","ShowFor","useRoleCheck","hasAnyRole"],"sources":["../../../../src/tools/components/auth/ProtectedRoute.tsx"],"sourcesContent":["import React, { useEffect } from 'react';\nimport { useAuth } from './useAuth';\nimport { useUserProfile } from './useUserProfile';\nimport { useRoleCheck } from './useRoleCheck';\nimport { BaseProfile } from './types';\n\n/**\n * Route display restrictions and client redirects.\n *\n * @typeParam T - Profile shape extending BaseProfile; defaults to BaseProfile.\n *\n * @see ProtectedRoute for provider setup and semantics.\n */\nexport interface ProtectedRouteProps<T extends BaseProfile = BaseProfile> {\n /**\n * Content rendered only after loading and successful display checks.\n */\n children: React.ReactNode;\n /**\n * Unauthenticated redirect destination; defaults to /login.\n */\n loginPath?: string;\n /**\n * Optional denied-access destination; omission renders unauthorizedFallback.\n */\n unauthorizedPath?: string;\n /**\n * Any one listed role must match; omission or an empty array skips role restriction.\n */\n roles?: string[];\n /**\n * Profile scalar/array role property; defaults to role.\n */\n roleField?: keyof T;\n /**\n * Additional synchronous predicate receiving the profile or null; must pass after role checks. Thrown errors propagate from render.\n */\n condition?: (profile: T | null) => boolean;\n /**\n * Loading content; defaults to null.\n */\n fallback?: React.ReactNode;\n /**\n * Denied-access content when unauthorizedPath is omitted; defaults to null.\n */\n unauthorizedFallback?: React.ReactNode;\n /**\n * Optional synchronous navigation callback receiving the destination; omission assigns window.location.href.\n */\n onRedirect?: (path: string) => void;\n}\n\n/**\n * Renders or redirects according to current auth, optional roles and an optional predicate.\n *\n * @typeParam T - Profile shape used by roleField and condition; defaults to BaseProfile.\n *\n * @param props - Children, access predicates, loading/denial content and navigation settings.\n *\n * @returns Loading fallback, permitted children, denied fallback or null while redirecting.\n *\n * @throws Error without AuthProvider; condition errors propagate during rendering.\n *\n * @remarks Requires AuthProvider inside QueryClientProvider. UserProfileProvider is optional\n * but needed for profile-based roles. Redirects run in effects; missing profiles fail a\n * nonempty role restriction. This uses display user state without isSessionVerified;\n * backend authorization is still required. No CSS is required.\n *\n * @example\n * ```tsx\n * import type { ReactNode } from 'react';\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n * import { AuthProvider, ProtectedRoute, type AuthAdapter } from '@alneas/appkit-react/tools/auth';\n *\n * function Content() { return <ProtectedRoute><span>Account</span></ProtectedRoute>; }\n * export function Example({ adapter, queryClient }: { adapter: AuthAdapter; queryClient: QueryClient }) {\n * return <QueryClientProvider client={queryClient}><AuthProvider adapter={adapter}><Content /></AuthProvider></QueryClientProvider>;\n * }\n * ```\n */\nexport function ProtectedRoute<T extends BaseProfile = BaseProfile>({\n children,\n loginPath = '/login',\n unauthorizedPath,\n roles,\n roleField = 'role' as keyof T,\n condition,\n fallback = null,\n unauthorizedFallback = null,\n onRedirect,\n}: ProtectedRouteProps<T>) {\n const { user, isLoading: isAuthLoading } = useAuth();\n\n // UserProfileProvider はオプショナル\n let profile: T | null = null;\n let isProfileLoading = false;\n\n try {\n const profileContext = useUserProfile<T>();\n profile = profileContext.profile;\n isProfileLoading = profileContext.isLoading;\n } catch {\n // UserProfileProvider が存在しない場合は無視\n }\n\n const isLoading = isAuthLoading || isProfileLoading;\n\n // 認証チェック\n const isAuthenticated = !!user;\n\n // ロールチェック\n const hasRequiredRole = (): boolean => {\n if (!roles || roles.length === 0) return true;\n if (!profile) return false;\n\n const userRole = profile[roleField];\n if (Array.isArray(userRole)) {\n // ユーザーが複数ロールを持つ場合\n return roles.some((role) => userRole.includes(role));\n }\n return roles.includes(userRole as string);\n };\n\n // カスタム条件チェック\n const meetsCondition = (): boolean => {\n if (!condition) return true;\n return condition(profile);\n };\n\n // 認可チェック (ロール + 条件)\n const isAuthorized = hasRequiredRole() && meetsCondition();\n\n // リダイレクト処理 (useEffect内でのみwindow操作)\n useEffect(() => {\n if (isLoading) return;\n\n const performRedirect = (path: string) => {\n if (onRedirect) {\n onRedirect(path);\n } else {\n window.location.href = path;\n }\n };\n\n if (!isAuthenticated) {\n performRedirect(loginPath);\n return;\n }\n\n if (!isAuthorized && unauthorizedPath) {\n performRedirect(unauthorizedPath);\n }\n }, [isLoading, isAuthenticated, isAuthorized, loginPath, unauthorizedPath, onRedirect]);\n\n // ローディング中\n if (isLoading) {\n return <>{fallback}</>;\n }\n\n // 未認証\n if (!isAuthenticated) {\n return null; // リダイレクト処理中\n }\n\n // 認可エラー\n if (!isAuthorized) {\n if (unauthorizedPath) {\n return null; // リダイレクト処理中\n }\n return <>{unauthorizedFallback}</>;\n }\n\n // 認証・認可OK\n return <>{children}</>;\n}\n\n/**\n * Conditional display settings; see ShowFor for usage.\n *\n * @typeParam T - Profile shape extending BaseProfile; defaults to BaseProfile.\n *\n * @see ShowFor for the canonical usage example.\n */\nexport interface ShowForProps<T extends BaseProfile = BaseProfile> {\n /**\n * Content to render when all supplied checks pass.\n */\n children: React.ReactNode;\n /**\n * Any one role must match; omission or empty array imposes no restriction.\n */\n roles?: string[];\n /**\n * Profile role property; defaults to role.\n */\n roleField?: keyof T;\n /**\n * Optional synchronous predicate receiving the current profile or null.\n */\n condition?: (profile: T | null) => boolean;\n /**\n * Content when a check fails; defaults to null.\n */\n fallback?: React.ReactNode;\n}\n\n/**\n * Conditionally displays children using profile roles and an optional predicate.\n *\n * @typeParam T - Profile shape extending BaseProfile; defaults to BaseProfile.\n *\n * @param props - Role checks, profile predicate, children and optional fallback.\n *\n * @returns Children when checks pass; otherwise fallback, defaulting to null.\n *\n * @throws Predicate errors propagate from render.\n *\n * @remarks UserProfileProvider supplies profile data but is optional; without it profile\n * is null. With no restrictions children render even without a profile. Does not redirect,\n * wait for loading, verify authentication or enforce backend access. No CSS is required.\n *\n * @example\n * ```tsx\n * import { ShowFor } from '@alneas/appkit-react/tools/auth';\n * export function RoleLabel() { return <ShowFor roles={['admin']}><span>Admin controls</span></ShowFor>; }\n * ```\n */\nexport function ShowFor<T extends BaseProfile = BaseProfile>({\n children,\n roles,\n roleField = 'role' as keyof T,\n condition,\n fallback = null,\n}: ShowForProps<T>) {\n const { hasAnyRole, profile } = useRoleCheck<T>(roleField);\n\n const shouldShow = (): boolean => {\n if (roles && roles.length > 0) {\n if (!hasAnyRole(roles)) return false;\n }\n if (condition) {\n if (!condition(profile)) return false;\n }\n return true;\n };\n\n return shouldShow() ? <>{children}</> : <>{fallback}</>;\n}\n"],"mappings":";;;;;;;AAgFA,SAAgBC,EAAoD,EAClE,aACA,eAAY,UACZ,qBACA,UACA,eAAY,QACZ,cACA,cAAW,MACX,0BAAuB,MACvB,iBACyB;CACzB,IAAM,EAAE,SAAM,WAAWC,MAAkBC,EAAQ,GAG/CC,IAAoB,MACpBC,IAAmB;CAEvB,IAAI;EACF,IAAMC,IAAiBC,EAAkB;EAEzC,AADA,IAAUD,EAAe,SACzB,IAAmBA,EAAe;CACpC,QAAQ,CAER;CAEA,IAAME,IAAYN,KAAiBG,GAG7BI,IAAkB,CAAC,CAACC,GAsBpBC,WAnBiC;EACrC,IAAI,CAACC,KAASA,EAAM,WAAW,GAAG,OAAO;EACzC,IAAI,CAACR,GAAS,OAAO;EAErB,IAAMS,IAAWT,EAAQU;EAKzB,OAJI,MAAM,QAAQD,CAAQ,IAEjBD,EAAM,MAAM,MAASC,EAAS,SAASE,CAAI,CAAC,IAE9CH,EAAM,SAASC,CAAkB;CAC1C,EASqB,CAAgB,MALnC,CAAKG,KACEA,EAAUZ,CAAO;CA+C1B,OAxCAa,QAAgB;EACd,IAAIT,GAAW;EAEf,IAAMU,KAAmB,MAAiB;GACxC,AAAIC,IACFA,EAAWC,CAAI,IAEf,OAAO,SAAS,OAAOA;EAE3B;EAEA,AAAKX,IAKD,CAACE,KAAgBU,KACnBH,EAAgBG,CAAgB,IALhCH,EAAgBI,CAAS;CAO7B,GAAG;EAACd;EAAWC;EAAiBE;EAAcW;EAAWD;EAAkBF;CAAU,CAAC,GAGlFX,IACK,kBAAAR,GAAA,EAAA,UAAGwB,EAAW,CAAA,IAIlBf,IAKAE,IAQE,kBAAAX,GAAA,EAAG,YAAW,CAAA,IAPfqB,IACK,OAEF,kBAAArB,GAAA,EAAA,UAAGyB,EAAuB,CAAA,IAR1B;AAaX;AAqDA,SAAgBC,EAA6C,EAC3D,aACA,UACA,eAAY,QACZ,cACA,cAAW,QACO;CAClB,IAAM,EAAE,eAAY,eAAYC,EAAgBb,CAAS;CAYzD,OATMF,KAASA,EAAM,SAAS,KACtB,CAACgB,EAAWhB,CAAK,KAEnBI,KACE,CAACA,EAAUZ,CAAO,IAKc,kBAAAJ,GAAA,EAAA,UAAGwB,EAAW,CAAA,IAAhC,kBAAAxB,GAAA,EAAG,YAAW,CAAA;AACtC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInButton.cjs","names":["useAuth","useState","useIsClient","Dialog","DialogTrigger","Button","DialogContent","Tabs","DialogHeader","TabsList","TabsTrigger","TabsContent","LoginForm","RegisterForm","_Fragment","DialogTitle","require_ui_components_ui_button_components","require_ui_components_ui_dialog","require_ui_components_ui_tabs_components","require_ui_lib_hooks_use_is_client","require_signin1","require_signup1","require_tools_components_auth_useAuth","require_tools_components_auth_AuthForms","react_jsx_runtime","react","SignInButton","open","setOpen","tab","setTab","user","nextOpen","mode","v","registerFields"],"sources":["../../../../src/tools/components/auth/SignInButton.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAuth } from './useAuth';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/tabs';\nimport { LoginForm, RegisterForm, type RegisterFieldConfig, type RegisterExtraField } from './AuthForms';\nimport * as m from '../../paraglide/messages.js';\nimport { useIsClient } from '../../lib/hooks/use-is-client';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"SignInButton.cjs","names":["useAuth","useState","useIsClient","Dialog","DialogTrigger","Button","DialogContent","Tabs","DialogHeader","TabsList","TabsTrigger","TabsContent","LoginForm","RegisterForm","_Fragment","DialogTitle","require_ui_components_ui_button_components","require_ui_components_ui_dialog","require_ui_components_ui_tabs_components","require_ui_lib_hooks_use_is_client","require_signin1","require_signup1","require_tools_components_auth_useAuth","require_tools_components_auth_AuthForms","react_jsx_runtime","react","SignInButton","open","setOpen","tab","setTab","user","nextOpen","mode","v","registerFields"],"sources":["../../../../src/tools/components/auth/SignInButton.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAuth } from './useAuth';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/tabs';\nimport { LoginForm, RegisterForm, type RegisterFieldConfig, type RegisterExtraField } from './AuthForms';\nimport * as m from '../../paraglide/messages.js';\nimport { useIsClient } from '../../lib/hooks/use-is-client';\n\n/**\n * Opens a login dialog or tabbed login/registration dialog for signed-out users.\n *\n * @param props - Dialog mode and optional registration field configuration.\n *\n * @returns Sign-in button/dialog after client mount; null during SSR or when a user exists.\n *\n * @throws Error without AuthProvider.\n *\n * @remarks Requires AuthProvider inside QueryClientProvider and Appkit styles. Defaults\n * to login mode with a Google OAuth button (shown only if adapter support exists).\n * Combined mode provides login/register tabs; successful email login/registration closes\n * the dialog. Each opening resets the selected tab to login.\n *\n * @example\n * ```tsx\n * import '@alneas/appkit-react/styles';\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n * import { AuthProvider, SignInButton, type AuthAdapter } from '@alneas/appkit-react/tools/auth';\n * export function FormExample({ adapter, queryClient }: { adapter: AuthAdapter; queryClient: QueryClient }) {\n * return <QueryClientProvider client={queryClient}><AuthProvider adapter={adapter}><SignInButton mode=\"combined\" /></AuthProvider></QueryClientProvider>;\n * }\n * ```\n */\nexport function SignInButton({\n mode = 'login',\n registerFields,\n extraFields,\n}: {\n /**\n * Dialog contents: login by default, combined adds registration tabs.\n */\n mode?: 'login' | 'combined';\n /**\n * Built-in registration input overrides, used only in combined mode.\n */\n registerFields?: RegisterFieldConfig;\n /**\n * Additional locally validated registration inputs, used only in combined mode; not saved by RegisterForm.\n */\n extraFields?: RegisterExtraField[];\n}) {\n const { user } = useAuth();\n const [open, setOpen] = useState(false);\n const [tab, setTab] = useState<'login' | 'register'>('login');\n const isClient = useIsClient();\n\n if (!isClient) return null;\n if (user) return null;\n\n return (\n <Dialog\n open={open}\n onOpenChange={(nextOpen) => {\n setOpen(nextOpen);\n if (nextOpen) setTab('login');\n }}\n >\n <DialogTrigger\n render={<Button variant='secondary' size='sm' className='transition-colors' />}\n >\n {m.signIn()}\n </DialogTrigger>\n <DialogContent className='sm:max-w-md'>\n {mode === 'combined' ? (\n <Tabs value={tab} onValueChange={(v) => setTab(v as 'login' | 'register')}>\n <DialogHeader>\n <TabsList className='grid w-full grid-cols-2'>\n <TabsTrigger value='login'>{m.signIn()}</TabsTrigger>\n <TabsTrigger value='register'>{m.signUp()}</TabsTrigger>\n </TabsList>\n </DialogHeader>\n <TabsContent value='login'>\n <LoginForm\n onSuccess={() => setOpen(false)}\n onRegisterClick={() => setTab('register')}\n showRegisterLink\n />\n </TabsContent>\n <TabsContent value='register'>\n <RegisterForm\n onSuccess={() => setOpen(false)}\n fields={registerFields}\n extraFields={extraFields}\n onLoginClick={() => setTab('login')}\n showLoginLink\n />\n </TabsContent>\n </Tabs>\n ) : (\n <>\n <DialogHeader>\n <DialogTitle>{m.signIn()}</DialogTitle>\n </DialogHeader>\n <LoginForm\n onSuccess={() => setOpen(false)}\n socialProviders={[{ provider: 'google', label: 'Googleでログイン' }]}\n />\n </>\n )}\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":"A,ugBAiCA,SAAgB0B,EAAa,CAC3B,OAAO,QACP,iBACA,eAcC,CACD,GAAM,CAAE,QAAS1B,EAAAA,QAAQ,EACnB,CAAC2B,EAAMC,IAAA,EAAW3B,EAAAA,SAAAA,CAAS,EAAK,EAChC,CAAC4B,EAAKC,IAAA,EAAU7B,EAAAA,SAAAA,CAA+B,OAAO,EAM5D,MAHI,CAFaC,EAAAA,YAEZ,GACD6B,EAAa,MAGf,EAAAP,EAAA,KAAA,CAACrB,EAAAA,OAAD,CACQ,OACN,aAAe,GAAa,CAC1ByB,EAAQI,CAAQ,EACZA,GAAUF,EAAO,OAAO,CAC9B,EALF,SAAA,EAOE,EAAAN,EAAA,IAAA,CAACpB,EAAAA,cAAD,CACE,QAAQ,EAAAoB,EAAA,IAAA,CAACnB,EAAAA,OAAD,CAAQ,QAAQ,YAAY,KAAK,KAAK,UAAU,mBAAqB,CAAA,EAE5E,SAAAe,EAAA,OAAS,CACG,CAAA,GACf,EAAAI,EAAA,IAAA,CAAClB,EAAAA,cAAD,CAAe,UAAU,cACtB,SAAA2B,IAAS,YACR,EAAAT,EAAA,KAAA,CAACjB,EAAAA,KAAD,CAAM,MAAOsB,EAAK,cAAgB,GAAMC,EAAOI,CAAyB,EAAxE,SAAA,EACE,EAAAV,EAAA,IAAA,CAAChB,EAAAA,aAAD,CAAA,UACE,EAAAgB,EAAA,KAAA,CAACf,EAAAA,SAAD,CAAU,UAAU,0BAApB,SAAA,EACE,EAAAe,EAAA,IAAA,CAACd,EAAAA,YAAD,CAAa,MAAM,QAAS,SAAAU,EAAA,OAAS,CAAe,CAAA,GACpD,EAAAI,EAAA,IAAA,CAACd,EAAAA,YAAD,CAAa,MAAM,WAAY,SAAAW,EAAA,OAAS,CAAe,CAAA,CAC/C,CACE,CAAA,CAAA,CAAA,GACd,EAAAG,EAAA,IAAA,CAACb,EAAAA,YAAD,CAAa,MAAM,QACjB,UAAA,EAAAa,EAAA,IAAA,CAACZ,EAAAA,UAAD,CACE,cAAiBgB,EAAQ,EAAK,EAC9B,oBAAuBE,EAAO,UAAU,EACxC,iBAAA,EACD,CAAA,CACU,CAAA,GACb,EAAAN,EAAA,IAAA,CAACb,EAAAA,YAAD,CAAa,MAAM,WACjB,UAAA,EAAAa,EAAA,IAAA,CAACX,EAAAA,aAAD,CACE,cAAiBe,EAAQ,EAAK,EAC9B,OAAQO,EACK,cACb,iBAAoBL,EAAO,OAAO,EAClC,cAAA,EACD,CAAA,CACU,CAAA,CACT,CAEN,CAAA,GAAA,EAAAN,EAAA,KAAA,CAAAV,EAAAA,SAAA,CAAA,SAAA,EACE,EAAAU,EAAA,IAAA,CAAChB,EAAAA,aAAD,CAAA,UACE,EAAAgB,EAAA,IAAA,CAACT,EAAAA,YAAD,CAAA,SAAAK,EAAA,OAAuB,CAAe,CAAA,CAC1B,CAAA,GACd,EAAAI,EAAA,IAAA,CAACZ,EAAAA,UAAD,CACE,cAAiBgB,EAAQ,EAAK,EAC9B,gBAAiB,CAAC,CAAE,SAAU,SAAU,MAAO,aAAc,CAAC,CAC/D,CAAA,CACD,CAAA,CAAA,CAES,CAAA,CACT,C,EAEZ,C"}
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import { RegisterFieldConfig, RegisterExtraField } from './AuthForms.cjs';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Opens a login dialog or tabbed login/registration dialog for signed-out users.
|
|
4
4
|
*
|
|
5
|
-
* @param props -
|
|
6
|
-
* @param props.mode - 表示モード。`'login'` はログインのみ、`'combined'` はログイン/登録のタブ切り替え
|
|
7
|
-
* @param props.registerFields - 登録フォームの既存フィールドカスタマイズ(mode='combined' 時)
|
|
8
|
-
* @param props.extraFields - 登録フォームの追加フィールド(mode='combined' 時)
|
|
5
|
+
* @param props - Dialog mode and optional registration field configuration.
|
|
9
6
|
*
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* <SignInButton />
|
|
7
|
+
* @returns Sign-in button/dialog after client mount; null during SSR or when a user exists.
|
|
8
|
+
*
|
|
9
|
+
* @throws Error without AuthProvider.
|
|
14
10
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* @remarks Requires AuthProvider inside QueryClientProvider and Appkit styles. Defaults
|
|
12
|
+
* to login mode with a Google OAuth button (shown only if adapter support exists).
|
|
13
|
+
* Combined mode provides login/register tabs; successful email login/registration closes
|
|
14
|
+
* the dialog. Each opening resets the selected tab to login.
|
|
17
15
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import '@alneas/appkit-react/styles';
|
|
19
|
+
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
20
|
+
* import { AuthProvider, SignInButton, type AuthAdapter } from '@alneas/appkit-react/tools/auth';
|
|
21
|
+
* export function FormExample({ adapter, queryClient }: { adapter: AuthAdapter; queryClient: QueryClient }) {
|
|
22
|
+
* return <QueryClientProvider client={queryClient}><AuthProvider adapter={adapter}><SignInButton mode="combined" /></AuthProvider></QueryClientProvider>;
|
|
23
|
+
* }
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
export declare function SignInButton({ mode, registerFields, extraFields, }: {
|
|
27
|
+
/**
|
|
28
|
+
* Dialog contents: login by default, combined adds registration tabs.
|
|
29
|
+
*/
|
|
28
30
|
mode?: 'login' | 'combined';
|
|
31
|
+
/**
|
|
32
|
+
* Built-in registration input overrides, used only in combined mode.
|
|
33
|
+
*/
|
|
29
34
|
registerFields?: RegisterFieldConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Additional locally validated registration inputs, used only in combined mode; not saved by RegisterForm.
|
|
37
|
+
*/
|
|
30
38
|
extraFields?: RegisterExtraField[];
|
|
31
39
|
}): import('react').JSX.Element | null;
|
|
@@ -1,31 +1,39 @@
|
|
|
1
1
|
import { RegisterFieldConfig, RegisterExtraField } from './AuthForms.js';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Opens a login dialog or tabbed login/registration dialog for signed-out users.
|
|
4
4
|
*
|
|
5
|
-
* @param props -
|
|
6
|
-
* @param props.mode - 表示モード。`'login'` はログインのみ、`'combined'` はログイン/登録のタブ切り替え
|
|
7
|
-
* @param props.registerFields - 登録フォームの既存フィールドカスタマイズ(mode='combined' 時)
|
|
8
|
-
* @param props.extraFields - 登録フォームの追加フィールド(mode='combined' 時)
|
|
5
|
+
* @param props - Dialog mode and optional registration field configuration.
|
|
9
6
|
*
|
|
10
|
-
* @
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* <SignInButton />
|
|
7
|
+
* @returns Sign-in button/dialog after client mount; null during SSR or when a user exists.
|
|
8
|
+
*
|
|
9
|
+
* @throws Error without AuthProvider.
|
|
14
10
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
11
|
+
* @remarks Requires AuthProvider inside QueryClientProvider and Appkit styles. Defaults
|
|
12
|
+
* to login mode with a Google OAuth button (shown only if adapter support exists).
|
|
13
|
+
* Combined mode provides login/register tabs; successful email login/registration closes
|
|
14
|
+
* the dialog. Each opening resets the selected tab to login.
|
|
17
15
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```tsx
|
|
18
|
+
* import '@alneas/appkit-react/styles';
|
|
19
|
+
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
20
|
+
* import { AuthProvider, SignInButton, type AuthAdapter } from '@alneas/appkit-react/tools/auth';
|
|
21
|
+
* export function FormExample({ adapter, queryClient }: { adapter: AuthAdapter; queryClient: QueryClient }) {
|
|
22
|
+
* return <QueryClientProvider client={queryClient}><AuthProvider adapter={adapter}><SignInButton mode="combined" /></AuthProvider></QueryClientProvider>;
|
|
23
|
+
* }
|
|
25
24
|
* ```
|
|
26
25
|
*/
|
|
27
26
|
export declare function SignInButton({ mode, registerFields, extraFields, }: {
|
|
27
|
+
/**
|
|
28
|
+
* Dialog contents: login by default, combined adds registration tabs.
|
|
29
|
+
*/
|
|
28
30
|
mode?: 'login' | 'combined';
|
|
31
|
+
/**
|
|
32
|
+
* Built-in registration input overrides, used only in combined mode.
|
|
33
|
+
*/
|
|
29
34
|
registerFields?: RegisterFieldConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Additional locally validated registration inputs, used only in combined mode; not saved by RegisterForm.
|
|
37
|
+
*/
|
|
30
38
|
extraFields?: RegisterExtraField[];
|
|
31
39
|
}): import('react').JSX.Element | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignInButton.js","names":["m.signIn","m.signUp","_Fragment","signin1","signup1","SignInButton","useAuth","open","setOpen","useState","tab","setTab","useIsClient","user","Dialog","nextOpen","DialogTrigger","Button","DialogContent","mode","Tabs","v","DialogHeader","TabsList","TabsTrigger","TabsContent","LoginForm","RegisterForm","registerFields","Fragment","DialogTitle"],"sources":["../../../../src/tools/components/auth/SignInButton.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAuth } from './useAuth';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/tabs';\nimport { LoginForm, RegisterForm, type RegisterFieldConfig, type RegisterExtraField } from './AuthForms';\nimport * as m from '../../paraglide/messages.js';\nimport { useIsClient } from '../../lib/hooks/use-is-client';\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"SignInButton.js","names":["m.signIn","m.signUp","_Fragment","signin1","signup1","SignInButton","useAuth","open","setOpen","useState","tab","setTab","useIsClient","user","Dialog","nextOpen","DialogTrigger","Button","DialogContent","mode","Tabs","v","DialogHeader","TabsList","TabsTrigger","TabsContent","LoginForm","RegisterForm","registerFields","Fragment","DialogTitle"],"sources":["../../../../src/tools/components/auth/SignInButton.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAuth } from './useAuth';\nimport { Button } from '../ui/button';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from '../ui/dialog';\nimport { Tabs, TabsList, TabsTrigger, TabsContent } from '../ui/tabs';\nimport { LoginForm, RegisterForm, type RegisterFieldConfig, type RegisterExtraField } from './AuthForms';\nimport * as m from '../../paraglide/messages.js';\nimport { useIsClient } from '../../lib/hooks/use-is-client';\n\n/**\n * Opens a login dialog or tabbed login/registration dialog for signed-out users.\n *\n * @param props - Dialog mode and optional registration field configuration.\n *\n * @returns Sign-in button/dialog after client mount; null during SSR or when a user exists.\n *\n * @throws Error without AuthProvider.\n *\n * @remarks Requires AuthProvider inside QueryClientProvider and Appkit styles. Defaults\n * to login mode with a Google OAuth button (shown only if adapter support exists).\n * Combined mode provides login/register tabs; successful email login/registration closes\n * the dialog. Each opening resets the selected tab to login.\n *\n * @example\n * ```tsx\n * import '@alneas/appkit-react/styles';\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n * import { AuthProvider, SignInButton, type AuthAdapter } from '@alneas/appkit-react/tools/auth';\n * export function FormExample({ adapter, queryClient }: { adapter: AuthAdapter; queryClient: QueryClient }) {\n * return <QueryClientProvider client={queryClient}><AuthProvider adapter={adapter}><SignInButton mode=\"combined\" /></AuthProvider></QueryClientProvider>;\n * }\n * ```\n */\nexport function SignInButton({\n mode = 'login',\n registerFields,\n extraFields,\n}: {\n /**\n * Dialog contents: login by default, combined adds registration tabs.\n */\n mode?: 'login' | 'combined';\n /**\n * Built-in registration input overrides, used only in combined mode.\n */\n registerFields?: RegisterFieldConfig;\n /**\n * Additional locally validated registration inputs, used only in combined mode; not saved by RegisterForm.\n */\n extraFields?: RegisterExtraField[];\n}) {\n const { user } = useAuth();\n const [open, setOpen] = useState(false);\n const [tab, setTab] = useState<'login' | 'register'>('login');\n const isClient = useIsClient();\n\n if (!isClient) return null;\n if (user) return null;\n\n return (\n <Dialog\n open={open}\n onOpenChange={(nextOpen) => {\n setOpen(nextOpen);\n if (nextOpen) setTab('login');\n }}\n >\n <DialogTrigger\n render={<Button variant='secondary' size='sm' className='transition-colors' />}\n >\n {m.signIn()}\n </DialogTrigger>\n <DialogContent className='sm:max-w-md'>\n {mode === 'combined' ? (\n <Tabs value={tab} onValueChange={(v) => setTab(v as 'login' | 'register')}>\n <DialogHeader>\n <TabsList className='grid w-full grid-cols-2'>\n <TabsTrigger value='login'>{m.signIn()}</TabsTrigger>\n <TabsTrigger value='register'>{m.signUp()}</TabsTrigger>\n </TabsList>\n </DialogHeader>\n <TabsContent value='login'>\n <LoginForm\n onSuccess={() => setOpen(false)}\n onRegisterClick={() => setTab('register')}\n showRegisterLink\n />\n </TabsContent>\n <TabsContent value='register'>\n <RegisterForm\n onSuccess={() => setOpen(false)}\n fields={registerFields}\n extraFields={extraFields}\n onLoginClick={() => setTab('login')}\n showLoginLink\n />\n </TabsContent>\n </Tabs>\n ) : (\n <>\n <DialogHeader>\n <DialogTitle>{m.signIn()}</DialogTitle>\n </DialogHeader>\n <LoginForm\n onSuccess={() => setOpen(false)}\n socialProviders={[{ provider: 'google', label: 'Googleでログイン' }]}\n />\n </>\n )}\n </DialogContent>\n </Dialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAiCA,SAAgBK,EAAa,EAC3B,UAAO,SACP,mBACA,kBAcC;CACD,IAAM,EAAE,YAASC,EAAQ,GACnB,CAACC,GAAMC,KAAWC,EAAS,EAAK,GAChC,CAACC,GAAKC,KAAUF,EAA+B,OAAO;CAM5D,OAHI,CAFaG,EAEZ,KACDC,IAAa,OAGf,kBAACC,GAAD;EACQ;EACN,eAAe,MAAa;GAE1B,AADAN,EAAQO,CAAQ,GACZA,KAAUJ,EAAO,OAAO;EAC9B;EALF,UAAA,CAOE,kBAACK,GAAD;GACE,QAAQ,kBAACC,GAAD;IAAQ,SAAQ;IAAY,MAAK;IAAK,WAAU;GAAqB,CAAA;GAE5E,UAAAjB,EAAS;EACG,CAAA,GACf,kBAACkB,GAAD;GAAe,WAAU;GACtB,UAAAC,MAAS,aACR,kBAACC,GAAD;IAAM,OAAOV;IAAK,gBAAgB,MAAMC,EAAOU,CAAyB;IAAxE,UAAA;KACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD;MAAU,WAAU;MAApB,UAAA,CACE,kBAACC,GAAD;OAAa,OAAM;OAAS,UAAAxB,EAAS;MAAe,CAAA,GACpD,kBAACwB,GAAD;OAAa,OAAM;OAAY,UAAAvB,EAAS;MAAe,CAAA,CAC/C;KACE,CAAA,EAAA,CAAA;KACd,kBAACwB,GAAD;MAAa,OAAM;MACjB,UAAA,kBAACC,GAAD;OACE,iBAAiBlB,EAAQ,EAAK;OAC9B,uBAAuBG,EAAO,UAAU;OACxC,kBAAA;MACD,CAAA;KACU,CAAA;KACb,kBAACc,GAAD;MAAa,OAAM;MACjB,UAAA,kBAACE,GAAD;OACE,iBAAiBnB,EAAQ,EAAK;OAC9B,QAAQoB;OACK;OACb,oBAAoBjB,EAAO,OAAO;OAClC,eAAA;MACD,CAAA;KACU,CAAA;IACT;GAEN,CAAA,IAAA,kBAAAT,GAAA,EAAA,UAAA,CACE,kBAACoB,GAAD,EAAA,UACE,kBAACQ,GAAD,EAAA,UAAc9B,EAAS,EAAe,CAAA,EAC1B,CAAA,GACd,kBAAC0B,GAAD;IACE,iBAAiBlB,EAAQ,EAAK;IAC9B,iBAAiB,CAAC;KAAE,UAAU;KAAU,OAAO;IAAc,CAAC;GAC/D,CAAA,CACD,EAAA,CAAA;EAES,CAAA,CACT;;AAEZ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfileProvider.cjs","names":["useAuth","useQueryClient","useMemo","useQuery","useMutation","useCallback","ProfileContext","require_runtime","require_tools_components_auth_useAuth","require_tools_components_auth_useUserProfile","react_jsx_runtime","react","_tanstack_react_query","UserProfileProvider","isAuthLoading","queryClient","queryKey","adapter","user","profile","isProfileLoading","profileData","createIfNotExists","defaultProfileData","currentProfile","isLoading","updateMutation","updatePayload","updates","updatedProfile","deleteMutation","updateProfile","refreshProfile","refetch","deleteProfile","contextValue","error"],"sources":["../../../../src/tools/components/auth/UserProfileProvider.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useAuth } from './useAuth';\nimport { ProfileAdapter, BaseProfile } from './types';\nimport { ProfileContext } from './useUserProfile';\n\nexport interface UserProfileProviderProps<T extends BaseProfile> {\n children: React.ReactNode;\n /**
|
|
1
|
+
{"version":3,"file":"UserProfileProvider.cjs","names":["useAuth","useQueryClient","useMemo","useQuery","useMutation","useCallback","ProfileContext","require_runtime","require_tools_components_auth_useAuth","require_tools_components_auth_useUserProfile","react_jsx_runtime","react","_tanstack_react_query","UserProfileProvider","isAuthLoading","queryClient","queryKey","adapter","user","profile","isProfileLoading","profileData","createIfNotExists","defaultProfileData","currentProfile","isLoading","updateMutation","updatePayload","updates","updatedProfile","deleteMutation","updateProfile","refreshProfile","refetch","deleteProfile","contextValue","error"],"sources":["../../../../src/tools/components/auth/UserProfileProvider.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from 'react';\nimport { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';\nimport { useAuth } from './useAuth';\nimport { ProfileAdapter, BaseProfile } from './types';\nimport { ProfileContext } from './useUserProfile';\n\n/**\n * Configuration for UserProfileProvider; see its provider example.\n *\n * @typeParam T - Application profile extending BaseProfile with its persisted fields.\n *\n * @see UserProfileProvider for the canonical usage example.\n */\nexport interface UserProfileProviderProps<T extends BaseProfile> {\n /** Descendants that consume the profile context. */\n children: React.ReactNode;\n /** Host-supplied persistence operations and collection name. */\n adapter: ProfileAdapter<T>;\n /** Additional fields passed to adapter.create when a profile is missing. */\n defaultProfileData?: Partial<T>;\n /** Create a missing profile after authentication; defaults to true. */\n createIfNotExists?: boolean;\n}\n\n/**\n * Loads and manages the authenticated user's profile through a host adapter.\n *\n *\n * @typeParam T - Persisted profile shape extending BaseProfile.\n *\n * @param props - Children, host persistence adapter and optional creation settings.\n *\n * @returns Profile context around the children; query and mutation errors are exposed in context.\n *\n * @remarks Requires outer QueryClientProvider and AuthProvider. Queries use\n * [adapter.tableName, 'detail', user.id]. Creation defaults to enabled; adapter.create\n * receives defaultProfileData. Updates add updated_at and refresh the detail cache;\n * updates/deletes invalidate collection list queries. Mutations reject if no profile\n * exists or the adapter fails. Query errors remain in context. No CSS is required.\n * The host implements ProfileAdapter and enforces access in its backend.\n *\n * @example\n * ```tsx\n * import type { ReactNode } from 'react';\n * import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\n * import {\n * AuthProvider, UserProfileProvider,\n * type AuthAdapter, type BaseProfile, type ProfileAdapter,\n * } from '@alneas/appkit-react/tools/auth';\n * interface MyProfile extends BaseProfile { name: string; }\n * // Supply real host adapters; Appkit does not provide a Supabase profile factory.\n * export function ProfileRoot({ authAdapter, profileAdapter, queryClient, children }: {\n * authAdapter: AuthAdapter;\n * profileAdapter: ProfileAdapter<MyProfile>;\n * queryClient: QueryClient;\n * children: ReactNode;\n * }) {\n * return (\n * <QueryClientProvider client={queryClient}>\n * <AuthProvider adapter={authAdapter}>\n * <UserProfileProvider adapter={profileAdapter} createIfNotExists>\n * {children}\n * </UserProfileProvider>\n * </AuthProvider>\n * </QueryClientProvider>\n * );\n * }\n * ```\n */\nexport function UserProfileProvider<T extends BaseProfile>({\n children,\n adapter,\n defaultProfileData,\n createIfNotExists = true,\n}: UserProfileProviderProps<T>) {\n const { user, isLoading: isAuthLoading } = useAuth();\n const queryClient = useQueryClient();\n\n // Cache key aligned with data-access: [tableName, 'detail', id]\n const queryKey = useMemo(\n () => [adapter.tableName, 'detail', user?.id],\n [adapter.tableName, user?.id],\n );\n\n // Query to fetch or create the profile\n const {\n data: profile = null,\n isLoading: isProfileLoading,\n error,\n refetch,\n } = useQuery({\n queryKey,\n queryFn: async (): Promise<T | null> => {\n if (!user) return null;\n\n // Try fetching the profile\n let profileData = await adapter.get(user.id);\n\n // If it doesn't exist, and createIfNotExists is true, create it\n if (!profileData && createIfNotExists) {\n profileData = await adapter.create(user.id, user, defaultProfileData);\n }\n\n return profileData;\n },\n enabled: !isAuthLoading && !!user,\n });\n\n const currentProfile = user ? (profile ?? null) : null;\n const isLoading = isAuthLoading || (!!user && isProfileLoading);\n\n // Mutation to update the profile\n const updateMutation = useMutation({\n mutationFn: async (updates: Partial<T>): Promise<T> => {\n if (!currentProfile) {\n throw new Error('No profile to update');\n }\n const updatePayload: Partial<T> = {\n ...updates,\n updated_at: new Date().toISOString() as T['updated_at'],\n };\n return adapter.update(currentProfile.id, updatePayload);\n },\n onSuccess: (updatedProfile) => {\n queryClient.setQueryData(queryKey, updatedProfile);\n // Invalidate list queries for this collection to keep any list views fresh\n queryClient.invalidateQueries({ queryKey: [adapter.tableName, 'list'] });\n },\n });\n\n // Mutation to delete the profile\n const deleteMutation = useMutation({\n mutationFn: async (): Promise<void> => {\n if (!currentProfile) {\n throw new Error('No profile to delete');\n }\n await adapter.delete(currentProfile.id);\n },\n onSuccess: () => {\n queryClient.setQueryData(queryKey, null);\n queryClient.invalidateQueries({ queryKey: [adapter.tableName, 'list'] });\n },\n });\n\n const updateProfile = useCallback(\n async (updates: Partial<T>): Promise<T> => {\n return updateMutation.mutateAsync(updates);\n },\n [updateMutation],\n );\n\n const refreshProfile = useCallback(async () => {\n if (!user) return;\n await refetch();\n }, [user, refetch]);\n\n const deleteProfile = useCallback(async (): Promise<void> => {\n await deleteMutation.mutateAsync();\n }, [deleteMutation]);\n\n const contextValue = {\n profile: currentProfile,\n isLoading,\n error: (error || updateMutation.error || deleteMutation.error) as Error | null,\n updateProfile: updateProfile as unknown as (\n updates: Partial<BaseProfile>,\n ) => Promise<BaseProfile>,\n refreshProfile,\n deleteProfile,\n };\n\n return <ProfileContext.Provider value={contextValue}>{children}</ProfileContext.Provider>;\n}\n"],"mappings":"A,sTAqEA,SAAgBa,EAA2C,CACzD,WACA,UACA,qBACA,oBAAoB,IACU,CAC9B,GAAM,CAAE,OAAM,UAAWC,GAAkBd,EAAAA,QAAQ,EAC7Ce,GAAA,EAAcd,EAAAA,eAAAA,CAAe,EAG7Be,GAAA,EAAWd,EAAAA,QAAAA,KACT,CAACe,EAAQ,UAAW,SAAUC,GAAM,EAAE,EAC5C,CAACD,EAAQ,UAAWC,GAAM,EAAE,CAC9B,EAGM,CACJ,KAAMC,EAAU,KAChB,UAAWC,EACX,QACA,YAAA,EACEjB,EAAAA,SAAAA,CAAS,CACX,WACA,QAAS,SAA+B,CACtC,GAAI,CAACe,EAAM,OAAO,KAGlB,IAAIG,EAAc,MAAMJ,EAAQ,IAAIC,EAAK,EAAE,EAO3C,MAJI,CAACG,GAAeC,IAClB,EAAc,MAAML,EAAQ,OAAOC,EAAK,GAAIA,EAAMK,CAAkB,GAG/DF,CACT,EACA,QAAS,CAACP,GAAiB,CAAC,CAACI,CAC/B,CAAC,EAEKM,EAAiBN,EAAQC,GAAW,KAAQ,KAC5CM,EAAYX,GAAkB,CAAC,CAACI,GAAQE,EAGxCM,GAAA,EAAiBtB,EAAAA,YAAAA,CAAY,CACjC,WAAY,KAAO,IAAoC,CACrD,GAAI,CAACoB,EACH,MAAU,MAAM,sBAAsB,EAExC,IAAMG,EAA4B,CAChC,GAAGC,EACH,WAAY,IAAI,KAAK,CAAA,CAAE,YAAY,CACrC,EACA,OAAOX,EAAQ,OAAOO,EAAe,GAAIG,CAAa,CACxD,EACA,UAAY,GAAmB,CAC7BZ,EAAY,aAAaC,EAAUa,CAAc,EAEjDd,EAAY,kBAAkB,CAAE,SAAU,CAACE,EAAQ,UAAW,MAAM,CAAE,CAAC,CACzE,CACF,CAAC,EAGKa,GAAA,EAAiB1B,EAAAA,YAAAA,CAAY,CACjC,WAAY,SAA2B,CACrC,GAAI,CAACoB,EACH,MAAU,MAAM,sBAAsB,EAExC,MAAMP,EAAQ,OAAOO,EAAe,EAAE,CACxC,EACA,cAAiB,CACfT,EAAY,aAAaC,EAAU,IAAI,EACvCD,EAAY,kBAAkB,CAAE,SAAU,CAACE,EAAQ,UAAW,MAAM,CAAE,CAAC,CACzE,CACF,CAAC,EAEKc,GAAA,EAAgB1B,EAAAA,YAAAA,CACpB,KAAO,IACEqB,EAAe,YAAYE,CAAO,EAE3C,CAACF,CAAc,CACjB,EAEMM,GAAA,EAAiB3B,EAAAA,YAAAA,CAAY,SAAY,CACxCa,GACL,MAAMe,EAAQ,CAChB,EAAG,CAACf,EAAMe,CAAO,CAAC,EAEZC,GAAA,EAAgB7B,EAAAA,YAAAA,CAAY,SAA2B,CAC3D,MAAMyB,EAAe,YAAY,CACnC,EAAG,CAACA,CAAc,CAAC,EAEbK,EAAe,CACnB,QAASX,EACT,YACA,MAAQY,GAASV,EAAe,OAASI,EAAe,MACzC,gBAGf,iBACA,eACF,EAEA,OAAO,EAAApB,EAAA,IAAA,CAACJ,EAAAA,eAAe,SAAhB,CAAyB,MAAO6B,EAAe,UAAkC,CAAA,CAC1F,C"}
|
|
@@ -1,37 +1,65 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { ProfileAdapter, BaseProfile } from './types.cjs';
|
|
3
|
+
/**
|
|
4
|
+
* Configuration for UserProfileProvider; see its provider example.
|
|
5
|
+
*
|
|
6
|
+
* @typeParam T - Application profile extending BaseProfile with its persisted fields.
|
|
7
|
+
*
|
|
8
|
+
* @see UserProfileProvider for the canonical usage example.
|
|
9
|
+
*/
|
|
3
10
|
export interface UserProfileProviderProps<T extends BaseProfile> {
|
|
11
|
+
/** Descendants that consume the profile context. */
|
|
4
12
|
children: React.ReactNode;
|
|
5
|
-
/**
|
|
13
|
+
/** Host-supplied persistence operations and collection name. */
|
|
6
14
|
adapter: ProfileAdapter<T>;
|
|
7
|
-
/**
|
|
15
|
+
/** Additional fields passed to adapter.create when a profile is missing. */
|
|
8
16
|
defaultProfileData?: Partial<T>;
|
|
9
|
-
/**
|
|
17
|
+
/** Create a missing profile after authentication; defaults to true. */
|
|
10
18
|
createIfNotExists?: boolean;
|
|
11
19
|
}
|
|
12
20
|
/**
|
|
13
|
-
*
|
|
21
|
+
* Loads and manages the authenticated user's profile through a host adapter.
|
|
22
|
+
*
|
|
14
23
|
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
24
|
+
* @typeParam T - Persisted profile shape extending BaseProfile.
|
|
25
|
+
*
|
|
26
|
+
* @param props - Children, host persistence adapter and optional creation settings.
|
|
27
|
+
*
|
|
28
|
+
* @returns Profile context around the children; query and mutation errors are exposed in context.
|
|
29
|
+
*
|
|
30
|
+
* @remarks Requires outer QueryClientProvider and AuthProvider. Queries use
|
|
31
|
+
* [adapter.tableName, 'detail', user.id]. Creation defaults to enabled; adapter.create
|
|
32
|
+
* receives defaultProfileData. Updates add updated_at and refresh the detail cache;
|
|
33
|
+
* updates/deletes invalidate collection list queries. Mutations reject if no profile
|
|
34
|
+
* exists or the adapter fails. Query errors remain in context. No CSS is required.
|
|
35
|
+
* The host implements ProfileAdapter and enforces access in its backend.
|
|
17
36
|
*
|
|
18
37
|
* @example
|
|
19
38
|
* ```tsx
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
39
|
+
* import type { ReactNode } from 'react';
|
|
40
|
+
* import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
41
|
+
* import {
|
|
42
|
+
* AuthProvider, UserProfileProvider,
|
|
43
|
+
* type AuthAdapter, type BaseProfile, type ProfileAdapter,
|
|
44
|
+
* } from '@alneas/appkit-react/tools/auth';
|
|
45
|
+
* interface MyProfile extends BaseProfile { name: string; }
|
|
46
|
+
* // Supply real host adapters; Appkit does not provide a Supabase profile factory.
|
|
47
|
+
* export function ProfileRoot({ authAdapter, profileAdapter, queryClient, children }: {
|
|
48
|
+
* authAdapter: AuthAdapter;
|
|
49
|
+
* profileAdapter: ProfileAdapter<MyProfile>;
|
|
50
|
+
* queryClient: QueryClient;
|
|
51
|
+
* children: ReactNode;
|
|
52
|
+
* }) {
|
|
53
|
+
* return (
|
|
54
|
+
* <QueryClientProvider client={queryClient}>
|
|
55
|
+
* <AuthProvider adapter={authAdapter}>
|
|
56
|
+
* <UserProfileProvider adapter={profileAdapter} createIfNotExists>
|
|
57
|
+
* {children}
|
|
58
|
+
* </UserProfileProvider>
|
|
59
|
+
* </AuthProvider>
|
|
60
|
+
* </QueryClientProvider>
|
|
61
|
+
* );
|
|
24
62
|
* }
|
|
25
|
-
*
|
|
26
|
-
* const profileAdapter = createSupabaseProfileAdapter<MyProfile>(supabase, {
|
|
27
|
-
* tableName: 'profiles',
|
|
28
|
-
* });
|
|
29
|
-
*
|
|
30
|
-
* <AuthProvider adapter={authAdapter}>
|
|
31
|
-
* <UserProfileProvider adapter={profileAdapter} createIfNotExists>
|
|
32
|
-
* <App />
|
|
33
|
-
* </UserProfileProvider>
|
|
34
|
-
* </AuthProvider>
|
|
35
63
|
* ```
|
|
36
64
|
*/
|
|
37
65
|
export declare function UserProfileProvider<T extends BaseProfile>({ children, adapter, defaultProfileData, createIfNotExists, }: UserProfileProviderProps<T>): React.JSX.Element;
|