@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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","names":["defineGenerativeUIComponent","definition","type","validate","component","contract","dataSchema","createGenerativeUIContract","snapshot","data","result","createElement","createGenerativeUIRegistry","entries","components","described","describedTypes","failure","block","resolve","element","isValidElement"],"sources":["../../../src/ai/generative-ui/registry.ts"],"sourcesContent":["import { createElement, isValidElement, type ComponentType, type ReactElement } from 'react';\nimport { createGenerativeUIContract } from \"@alneas/appkit-core/ai\";\nimport type { GenerativeUIBlock, GenerativeUIObject } from \"@alneas/appkit-core/ai\";\n\n/** A pure application validator may transform JSON data into the component's typed input. */\nexport type GenerativeUIDataResult<TData> = { readonly ok: true; readonly data: TData } | { readonly ok: false };\n\n/** Safe diagnostic metadata; no raw payload, exception or validator message is exposed. */\nexport interface GenerativeUIIssue {\n readonly code: 'INVALID_DOCUMENT' | 'UNKNOWN_COMPONENT' | 'INVALID_DATA' | 'RENDER_ERROR';\n readonly blockId?: string;\n readonly type?: string;\n}\n\n/** Validated component resolution, before React renders the element. */\nexport type GenerativeUIResolution =\n | { readonly ok: true; readonly element: ReactElement }\n | { readonly ok: false; readonly issue: GenerativeUIIssue };\n\n/** Application-owned component registration produced by defineGenerativeUIComponent. */\nexport interface GenerativeUIComponent {\n readonly type: string;\n /** Optional inline draft-07 schema, enforced before the component validator. */\n readonly dataSchema?: GenerativeUIObject;\n readonly resolve: (data: GenerativeUIObject) => ReactElement | null;\n}\n\n/** Immutable registry. Create a new registry to change the permitted components. */\nexport interface GenerativeUIRegistry {\n readonly types: readonly string[];\n /** Available only when every registration supplies dataSchema (including the empty registry). */\n readonly documentSchema?: GenerativeUIObject;\n resolve(block: GenerativeUIBlock): GenerativeUIResolution;\n}\n\n/**\n * Binds a component to a pure, synchronous validator. Components receive only the\n * validated `data` prop. Callbacks, current records and credentials belong to trusted\n * application code (for example React Context), never the generated document.\n * Optional dataSchema is snapshotted and validated before the custom validator.\n * It uses the inline draft-07 subset documented by createGenerativeUIContract.\n *\n * @example\n * ```tsx\n * import { defineGenerativeUIComponent } from \"./\";\n * const greeting = defineGenerativeUIComponent({\n * type: 'greeting',\n * validate: (data) => typeof data.text === 'string'\n * ? { ok: true, data: { text: data.text } } : { ok: false },\n * component: ({ data }) => <p>{data.text}</p>,\n * });\n * ```\n */\nexport function defineGenerativeUIComponent<TData>(definition: {\n readonly type: string;\n /** Optional shared schema for model output and runtime validation. */\n readonly dataSchema?: GenerativeUIObject;\n readonly validate: (data: GenerativeUIObject) => GenerativeUIDataResult<TData>;\n readonly component: ComponentType<{ data: TData }>;\n}): GenerativeUIComponent {\n const { type, validate, component, dataSchema } = definition;\n if (!/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/.test(type) || typeof validate !== 'function' || !component) {\n throw new Error('A UI component requires a valid type, validator and component');\n }\n const contract = dataSchema !== undefined ? createGenerativeUIContract([{ type, dataSchema }]) : undefined;\n const snapshot = contract?.components[0].dataSchema;\n return Object.freeze({\n type,\n ...(snapshot ? { dataSchema: snapshot } : {}),\n resolve(data: GenerativeUIObject) {\n if (contract && !contract.validateData(type, data)) return null;\n const result = validate(data);\n return result?.ok === true ? createElement(component, { data: result.data }) : null;\n },\n });\n}\n\n/**\n * Creates an allowlist of application-defined UI components. No global registration,\n * dynamic imports, HTML evaluation or Action execution occurs. Validators must be pure;\n * their failures are isolated per block. Rendering exceptions are handled by the renderer.\n * documentSchema is available only if every component declares dataSchema; missing\n * schemas are not guessed. It covers structural validation, not custom business rules.\n */\nexport function createGenerativeUIRegistry(components: readonly GenerativeUIComponent[]): GenerativeUIRegistry {\n const entries = new Map<string, GenerativeUIComponent['resolve']>();\n for (const component of components) {\n if (!/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/.test(component.type) || typeof component.resolve !== 'function' || entries.has(component.type)) {\n throw new Error('UI component types must be valid and unique');\n }\n entries.set(component.type, component.resolve);\n }\n const described = components.filter(\n (component): component is GenerativeUIComponent & { dataSchema: GenerativeUIObject } =>\n component.dataSchema !== undefined\n );\n const contract = createGenerativeUIContract(described);\n const describedTypes = new Set(described.map(component => component.type));\n return Object.freeze({\n ...(described.length === components.length ? { documentSchema: contract.schema } : {}),\n types: Object.freeze([...entries.keys()]),\n resolve(block: GenerativeUIBlock): GenerativeUIResolution {\n const failure = (code: GenerativeUIIssue['code']): GenerativeUIResolution => ({\n ok: false,\n issue: { code, blockId: block.id, type: block.type },\n });\n const resolve = entries.get(block.type);\n if (!resolve) return failure('UNKNOWN_COMPONENT');\n try {\n if (describedTypes.has(block.type) && !contract.validateData(block.type, block.data)) return failure('INVALID_DATA');\n const element = resolve(block.data);\n return isValidElement(element) ? { ok: true, element } : failure('INVALID_DATA');\n } catch {\n return failure('INVALID_DATA');\n }\n },\n });\n}\n"],"mappings":";;;;AAqDA,SAAgBA,EAAmC,GAMzB;CACxB,IAAM,EAAE,SAAM,aAAU,cAAW,kBAAeC;CAClD,IAAI,CAAC,iCAAiC,KAAKC,CAAI,KAAK,OAAOC,KAAa,cAAc,CAACC,GACrF,MAAU,MAAM,+DAA+D;CAEjF,IAAMC,IAAWC,MAAe,KAAA,IAAiE,KAAA,IAArDC,EAA2B,CAAC;EAAE;EAAM;CAAW,CAAC,CAAC,GACvFC,IAAWH,GAAU,WAAW,EAAE,CAAC;CACzC,OAAO,OAAO,OAAO;EACnB;EACA,GAAIG,IAAW,EAAE,YAAYA,EAAS,IAAI,CAAC;EAC3C,QAAQ,GAA0B;GAChC,IAAIH,KAAY,CAACA,EAAS,aAAaH,GAAMO,CAAI,GAAG,OAAO;GAC3D,IAAMC,IAASP,EAASM,CAAI;GAC5B,OAAOC,GAAQ,OAAO,KAAOC,EAAcP,GAAW,EAAE,MAAM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","validate","component","contract","dataSchema","createGenerativeUIContract","snapshot","data","result","createElement","createGenerativeUIRegistry","entries","components","described","describedTypes","failure","block","resolve","element","isValidElement"],"sources":["../../../src/ai/generative-ui/registry.ts"],"sourcesContent":["import { createElement, isValidElement, type ComponentType, type ReactElement } from 'react';\nimport { createGenerativeUIContract } from \"@alneas/appkit-core/ai\";\nimport type { GenerativeUIBlock, GenerativeUIObject } from \"@alneas/appkit-core/ai\";\n\n/**\n * Result of a pure validator: ok true supplies typed input; ok false rejects the block.\n *\n * @typeParam TData - Input shape accepted by the registered component.\n *\n * @remarks See defineGenerativeUIComponent for a complete registration example.\n *\n * @see defineGenerativeUIComponent for the canonical usage example.\n */\nexport type GenerativeUIDataResult<TData> = {\n /** Successful validation discriminator. */\n readonly ok: true;\n /** Typed input passed to the registered component. */\n readonly data: TData;\n} | {\n /** Rejected validation discriminator; no typed input is available. */\n readonly ok: false;\n};\n\n/**\n * Safe diagnostic metadata; no raw payload, exception or validator message is exposed.\n * @see GenerativeUIRenderer for the canonical usage example.\n */\nexport interface GenerativeUIIssue {\n /** Safe failure category for document, allowlist, data or React rendering failures. */\n readonly code: 'INVALID_DOCUMENT' | 'UNKNOWN_COMPONENT' | 'INVALID_DATA' | 'RENDER_ERROR';\n /** Block identifier when failure is scoped to a block. */\n readonly blockId?: string;\n /** Requested component type when available. */\n readonly type?: string;\n}\n\n/**\n * Validated component resolution, before React renders the element.\n * @see createGenerativeUIRegistry for the canonical usage example.\n */\nexport type GenerativeUIResolution =\n | {\n /** Successful allowlist and data resolution. */\n readonly ok: true;\n /** Resolved element; React rendering may still fail later. */\n readonly element: ReactElement;\n }\n | {\n /** Failed allowlist or data resolution. */\n readonly ok: false;\n /** Safe diagnostic metadata without raw payloads or errors. */\n readonly issue: GenerativeUIIssue;\n };\n\n/**\n * Application-owned component registration produced by defineGenerativeUIComponent.\n * @see defineGenerativeUIComponent for the canonical usage example.\n */\nexport interface GenerativeUIComponent {\n /** Stable allowlist key: letter first, then up to 63 letters, digits, underscores, dots or hyphens. */\n readonly type: string;\n /** Optional inline draft-07 schema, enforced before the component validator. */\n readonly dataSchema?: GenerativeUIObject;\n /**\n * Resolve input through the registration's schema and validator.\n *\n * @param data - JSON object to validate before passing typed data to the component.\n *\n * @returns Element for accepted data, or null when validation rejects it.\n *\n * @throws Direct calls propagate validator errors; registry.resolve isolates them.\n *\n * @remarks See defineGenerativeUIComponent for registration setup.\n */\n readonly resolve: (data: GenerativeUIObject) => ReactElement | null;\n}\n\n/**\n * Immutable registry. Create a new registry to change the permitted components.\n * @see createGenerativeUIRegistry for the canonical usage example.\n */\nexport interface GenerativeUIRegistry {\n /** Frozen registration keys in insertion order. */\n readonly types: readonly string[];\n /** Available only when every registration supplies dataSchema (including the empty registry). */\n readonly documentSchema?: GenerativeUIObject;\n /**\n * Resolve one structurally valid block through the allowlist.\n *\n * @param block - Block from a validated generative UI document.\n *\n * @returns Element on success, or safe issue metadata for an unknown type or rejected data.\n *\n * @remarks Validator/registration exceptions become INVALID_DATA; component rendering happens later.\n * See createGenerativeUIRegistry for usage.\n */\n resolve(block: GenerativeUIBlock): GenerativeUIResolution;\n}\n\n/**\n * Binds a component to a pure, synchronous validator. Components receive only the\n * validated `data` prop. Callbacks, current records and credentials belong to trusted\n * application code (for example React Context), never the generated document.\n * Optional dataSchema is snapshotted and validated before the custom validator.\n * It uses the inline draft-07 subset documented by createGenerativeUIContract.\n *\n *\n * @typeParam TData - Validated input shape passed to the registered React component.\n *\n * @param definition - Unique type name, pure synchronous validator, component and optional schema.\n *\n * @returns Frozen registration for createGenerativeUIRegistry; resolve returns null on invalid data.\n *\n * @throws For an invalid type name, missing validator/component or unsupported data schema.\n *\n * @remarks Requires React. The registration itself needs no context or CSS; supplied\n * components own their provider/style requirements. Validator exceptions are caught by\n * registry resolution, but can escape direct registration.resolve calls.\n *\n * @example\n * ```tsx\n * import { defineGenerativeUIComponent } from \"@alneas/appkit-react/ai/generative-ui\";\n * const greeting = defineGenerativeUIComponent<{ text: string }>({\n * type: 'greeting',\n * validate: (data) => typeof data.text === 'string'\n * ? { ok: true, data: { text: data.text } } : { ok: false },\n * component: ({ data }) => <p>{data.text}</p>,\n * });\n * ```\n */\nexport function defineGenerativeUIComponent<TData>(definition: {\n /** Allowlist name with the same syntax as GenerativeUIComponent.type. */\n readonly type: string;\n /** Optional shared schema for model output and runtime validation. */\n readonly dataSchema?: GenerativeUIObject;\n /**\n * Pure synchronous conversion from JSON to typed input; return ok false to reject.\n * @param data - JSON object to validate/transform synchronously.\n *\n * @returns ok true with typed component input, or ok false to reject this block.\n */\n readonly validate: (data: GenerativeUIObject) => GenerativeUIDataResult<TData>;\n /** Trusted React component receiving only validated data; owns its context/style requirements. */\n readonly component: ComponentType<{\n /** Validated input returned by the registration validator. */\n data: TData;\n }>;\n}): GenerativeUIComponent {\n const { type, validate, component, dataSchema } = definition;\n if (!/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/.test(type) || typeof validate !== 'function' || !component) {\n throw new Error('A UI component requires a valid type, validator and component');\n }\n const contract = dataSchema !== undefined ? createGenerativeUIContract([{ type, dataSchema }]) : undefined;\n const snapshot = contract?.components[0].dataSchema;\n return Object.freeze({\n type,\n ...(snapshot ? { dataSchema: snapshot } : {}),\n resolve(data: GenerativeUIObject) {\n if (contract && !contract.validateData(type, data)) return null;\n const result = validate(data);\n return result?.ok === true ? createElement(component, { data: result.data }) : null;\n },\n });\n}\n\n/**\n * Creates an allowlist of application-defined UI components. No global registration,\n * dynamic imports, HTML evaluation or Action execution occurs. Validators must be pure;\n * their failures are isolated per block. Rendering exceptions are handled by the renderer.\n * documentSchema is available only if every component declares dataSchema; missing\n * schemas are not guessed. It covers structural validation, not custom business rules.\n *\n * @param components - Registrations with distinct, valid allowlist names; an empty list is permitted.\n *\n * @returns Frozen registry with insertion-ordered types and an optional document schema.\n *\n * @throws For invalid/duplicate names, missing resolve functions or invalid declared schemas.\n *\n * @example\n * ```ts\n * import { createGenerativeUIRegistry } from '@alneas/appkit-react/ai/generative-ui';\n * const registry = createGenerativeUIRegistry([]);\n * const result = registry.resolve({ id: 'missing', type: 'unknown', data: {} });\n * // result.ok is false: no component is registered.\n * ```\n */\nexport function createGenerativeUIRegistry(components: readonly GenerativeUIComponent[]): GenerativeUIRegistry {\n const entries = new Map<string, GenerativeUIComponent['resolve']>();\n for (const component of components) {\n if (!/^[A-Za-z][A-Za-z0-9_.-]{0,63}$/.test(component.type) || typeof component.resolve !== 'function' || entries.has(component.type)) {\n throw new Error('UI component types must be valid and unique');\n }\n entries.set(component.type, component.resolve);\n }\n const described = components.filter(\n (component): component is GenerativeUIComponent & { dataSchema: GenerativeUIObject } =>\n component.dataSchema !== undefined\n );\n const contract = createGenerativeUIContract(described);\n const describedTypes = new Set(described.map(component => component.type));\n return Object.freeze({\n ...(described.length === components.length ? { documentSchema: contract.schema } : {}),\n types: Object.freeze([...entries.keys()]),\n resolve(block: GenerativeUIBlock): GenerativeUIResolution {\n const failure = (code: GenerativeUIIssue['code']): GenerativeUIResolution => ({\n ok: false,\n issue: { code, blockId: block.id, type: block.type },\n });\n const resolve = entries.get(block.type);\n if (!resolve) return failure('UNKNOWN_COMPONENT');\n try {\n if (describedTypes.has(block.type) && !contract.validateData(block.type, block.data)) return failure('INVALID_DATA');\n const element = resolve(block.data);\n return isValidElement(element) ? { ok: true, element } : failure('INVALID_DATA');\n } catch {\n return failure('INVALID_DATA');\n }\n },\n });\n}\n"],"mappings":";;;;AAkIA,SAAgBA,EAAmC,GAiBzB;CACxB,IAAM,EAAE,SAAM,aAAU,cAAW,kBAAeC;CAClD,IAAI,CAAC,iCAAiC,KAAKC,CAAI,KAAK,OAAOC,KAAa,cAAc,CAACC,GACrF,MAAU,MAAM,+DAA+D;CAEjF,IAAMC,IAAWC,MAAe,KAAA,IAAiE,KAAA,IAArDC,EAA2B,CAAC;EAAE;EAAM;CAAW,CAAC,CAAC,GACvFC,IAAWH,GAAU,WAAW,EAAE,CAAC;CACzC,OAAO,OAAO,OAAO;EACn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MG,IAAUD,EAAQD,EAAM,IAAI;IAClC,OAAOG,EAAeD,CAAO,IAAI;KAAE,IAAI;KAAM;IAAQ,IAAIH,EAAQ,cAAc;GACjF,QAAQ;IACN,OAAOA,EAAQ,cAAc;GAC/B;EACF;CACF,CAAC;AACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProposalFieldReview.cjs","names":["react_jsx_runtime","LABELS","DiffBadge","className","decision","labels","ProposalDecisionButtons","field","allowReset","isSelected","value","buttonClassName","testId","onDecisionChange","ProposalFieldReview","change","beforeLabel","formatValue","afterLabel","error"],"sources":["../../../src/ai/proposal/ProposalFieldReview.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldDecision, SupportedPrimitive } from \"@alneas/appkit-core/ai\";\n\n/** Localized labels for a review decision. */\nexport type ProposalDecisionLabels = Record<FieldDecision, string>;\nconst LABELS: ProposalDecisionLabels = { pending: '未判断', accepted: '採用', rejected: '却下' };\n\n/** Props for DiffBadge. */\nexport interface DiffBadgeProps {\n decision: FieldDecision;\n labels?: Partial<ProposalDecisionLabels>;\n className?: string;\n}\n\n/** Displays review selection without implying that a change has been applied or saved. */\nexport function DiffBadge({ decision, labels, className }: DiffBadgeProps) {\n return (\n <span\n className={className ?? 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border'}\n data-decision={decision}\n >\n {labels?.[decision] ?? LABELS[decision]}\n </span>\n );\n}\n\n/** Controlled accept/reject/reset controls shared by card and field layouts. */\nexport interface ProposalDecisionButtonsProps {\n field: string;\n decision: FieldDecision;\n onDecisionChange: (decision: FieldDecision) => void;\n disabled?: boolean;\n labels?: Partial<ProposalDecisionLabels>;\n /** Enables returning a single field to pending. */\n allowReset?: boolean;\n testId?: string;\n buttonClassName?: (selected: boolean) => string;\n}\n\n/** Emits decisions only; does not mutate form values or apply a proposal. */\nexport function ProposalDecisionButtons({\n field,\n decision,\n onDecisionChange,\n disabled,\n labels,\n allowReset = false,\n testId,\n buttonClassName,\n}: ProposalDecisionButtonsProps) {\n const values: FieldDecision[] = allowReset ? ['accepted', 'rejected', 'pending'] : ['accepted', 'rejected'];\n return (\n <div role=\"group\" aria-label={field} className=\"inline-flex flex-wrap gap-1\">\n {values.map(value => {\n const isSelected = decision === value;\n const defaultClass = isSelected\n ? 'px-2 py-1 text-xs rounded bg-neutral-900 text-white dark:bg-white dark:text-neutral-900'\n : 'px-2 py-1 text-xs rounded border border-neutral-300 dark:border-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800';\n return (\n <button\n key={value}\n type=\"button\"\n disabled={disabled}\n aria-pressed={isSelected}\n className={buttonClassName ? buttonClassName(isSelected) : defaultClass}\n data-testid={\n testId\n ? `${testId}-${value === 'accepted' ? 'accept' : value === 'rejected' ? 'reject' : 'reset'}-${field}`\n : undefined\n }\n onClick={() => onDecisionChange(value)}\n >\n {labels?.[value] ?? LABELS[value]}\n </button>\n );\n })}\n </div>\n );\n}\n\n/** Controlled inline proposal review, suitable beside an existing form field or table cell. */\nexport interface ProposalFieldReviewProps {\n change: {\n readonly field: string;\n readonly label?: string;\n readonly before: SupportedPrimitive;\n readonly after: SupportedPrimitive;\n readonly reason?: string;\n };\n decision: FieldDecision;\n onDecisionChange: (decision: FieldDecision) => void;\n disabled?: boolean;\n labels?: Partial<ProposalDecisionLabels>;\n beforeLabel?: string;\n afterLabel?: string;\n formatValue?: (value: SupportedPrimitive) => ReactNode;\n error?: string;\n className?: string;\n}\n\n/**\n * Renders a field's proposed values, reason, decision and optional validation message.\n */\nexport function ProposalFieldReview({\n change,\n decision,\n onDecisionChange,\n disabled,\n labels,\n beforeLabel = '変更前',\n afterLabel = '提案値',\n formatValue = value => (value === null ? 'null' : String(value)),\n error,\n className,\n}: ProposalFieldReviewProps) {\n return (\n <section aria-label={change.label ?? change.field} className={className} data-proposal-field={change.field}>\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium\">{change.label ?? change.field}</span>\n <DiffBadge decision={decision} labels={labels} />\n </div>\n <dl className=\"grid grid-cols-2 gap-2 text-sm my-2\">\n <div>\n <dt className=\"text-neutral-500 text-xs\">{beforeLabel}</dt>\n <dd>{formatValue(change.before)}</dd>\n </div>\n <div>\n <dt className=\"text-neutral-500 text-xs\">{afterLabel}</dt>\n <dd>{formatValue(change.after)}</dd>\n </div>\n </dl>\n {change.reason && <p className=\"text-xs text-neutral-500 my-1\">{change.reason}</p>}\n <ProposalDecisionButtons\n field={change.field}\n decision={decision}\n onDecisionChange={onDecisionChange}\n disabled={disabled}\n labels={labels}\n allowReset\n />\n {error && (\n <p role=\"alert\" className=\"text-sm text-red-600 mt-1\">\n {error}\n </p>\n )}\n </section>\n );\n}\n"],"mappings":"A,mHAKA,IAAMC,EAAiC,CAAE,QAAS,MAAO,SAAU,KAAM,SAAU,IAAK,EAUxF,SAAgBC,EAAU,CAAE,WAAU,SAAQ,aAA6B,CACzE,OACE,EAAAF,EAAA,IAAA,CAAC,OAAD,CACE,UAAWG,GAAa,0EACxB,gBAAeC,EAEd,SAAAC,IAASD,IAAaH,EAAOG,EAC1B,CAAA,CAEV,CAgBA,SAAgBE,EAAwB,CACtC,QACA,WACA,mBACA,WACA,SACA,aAAa,GACb,SACA,mBAC+B,CAE/B,OACE,EAAAN,EAAA,IAAA,CAAC,MAAD,CAAK,KAAK,QAAQ,aAAYO,EAAO,UAAU,8BAC5C,UAH2BC,EAAa,CAAC,WAAY,WAAY,SAAS,EAAI,CAAC,WAAY,UAAU,EAAA,CAG9F,IAAI,GAAS,CACnB,IAAMC,EAAaL,IAAaM,EAIhC,OACE,EAAAV,EAAA,IAAA,CAAC,SAAD,CAEE,KAAK,SACK,WACV,eAAcS,EACd,UAAWE,EAAkBA,EAAgBF,CAAU,EATtCA,EACjB,0FACA,6HAQA,cACEG,EACI,GAAGA,EAAO,GAAGF,IAAU,WAAa,SAAWA,IAAU,WAAa,SAAW,QAAQ,GAAGH,IAC5F,IAAA,GAEN,YAAeM,EAAiBH,CAAK,EAEpC,SAAAL,IAASK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,mBACR,WACF,SACR,WAAA,EACD,CAAA,EACAI,IACC,EAAAnB,EAAA,IAAA,CAAC,IAAD,CAAG,KAAK,QAAQ,UAAU,4BACvB,SAAAmB,CACA,CAAA,CAEE,C,EAEb,C"}
|
|
1
|
+
{"version":3,"file":"ProposalFieldReview.cjs","names":["react_jsx_runtime","LABELS","DiffBadge","className","decision","labels","ProposalDecisionButtons","field","allowReset","isSelected","value","buttonClassName","testId","onDecisionChange","ProposalFieldReview","change","beforeLabel","formatValue","afterLabel","error"],"sources":["../../../src/ai/proposal/ProposalFieldReview.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldDecision, SupportedPrimitive } from \"@alneas/appkit-core/ai\";\n\n/**\n * Display labels for pending, accepted and rejected decisions.\n *\n * @see ProposalFieldReview for controlled usage.\n */\nexport type ProposalDecisionLabels = Record<FieldDecision, string>;\nconst LABELS: ProposalDecisionLabels = { pending: '未判断', accepted: '採用', rejected: '却下' };\n\n/**\n * Decision display settings for DiffBadge; see its usage example.\n *\n * @see DiffBadge for the canonical usage example.\n */\nexport interface DiffBadgeProps {\n /**\n * Current review choice; no save/apply status is implied.\n */\n decision: FieldDecision;\n /**\n * Optional per-choice localized text; omitted values use Japanese defaults.\n */\n labels?: Partial<ProposalDecisionLabels>;\n /**\n * Optional replacement classes; omission uses compact bordered badge classes.\n */\n className?: string;\n}\n\n/**\n * Displays the current review choice without implying persistence.\n *\n * @param props - Controlled state, optional labels/style settings and callbacks.\n *\n * @returns Span carrying data-decision and a localized label.\n *\n * @remarks Import Appkit styles for utility-class styling; no context provider is required.\n * Callbacks and formatters are synchronous and their errors propagate. Host code owns\n * review state and persistence; these controls do not apply changes automatically.\n *\n * @example\n * ```tsx\n * import { useState } from 'react';\n * import '@alneas/appkit-react/styles';\n * import { DiffBadge, type FieldDecision } from '@alneas/appkit-react/ai/proposal';\n * export function FieldReview() {\n * const [decision, setDecision] = useState<FieldDecision>('pending');\n * return <DiffBadge decision=\"pending\" />;\n * }\n * ```\n */\nexport function DiffBadge({ decision, labels, className }: DiffBadgeProps) {\n return (\n <span\n className={className ?? 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border'}\n data-decision={decision}\n >\n {labels?.[decision] ?? LABELS[decision]}\n </span>\n );\n}\n\n/**\n * Controlled choice inputs; see ProposalDecisionButtons for usage.\n *\n * @see ProposalDecisionButtons for the canonical usage example.\n */\nexport interface ProposalDecisionButtonsProps {\n /**\n * Field key used as group aria-label and optional test-ID suffix.\n */\n field: string;\n /**\n * Current externally controlled choice.\n */\n decision: FieldDecision;\n /**\n * Synchronous callback receiving the clicked choice; the host must update decision.\n *\n * @param decision - Clicked pending/accepted/rejected choice.\n *\n * @returns No value; the host schedules its controlled state update.\n */\n onDecisionChange: (decision: FieldDecision) => void;\n /**\n * Disable every choice button; defaults to false/undefined.\n */\n disabled?: boolean;\n /**\n * Optional per-choice text; unspecified values use Japanese defaults.\n */\n labels?: Partial<ProposalDecisionLabels>;\n /**\n * Include a pending/reset choice; defaults to false.\n */\n allowReset?: boolean;\n /**\n * Optional prefix for {prefix}-accept/reject/reset-{field} test IDs.\n */\n testId?: string;\n /**\n * Optional synchronous class factory receiving whether this button is selected; replaces default button styling.\n */\n buttonClassName?: (selected: boolean) => string;\n}\n\n/**\n * Emits controlled accept/reject and optional reset choices.\n *\n * @param props - Controlled state, optional labels/style settings and callbacks.\n *\n * @returns Button group; no form values or proposals are mutated.\n *\n * @remarks Import Appkit styles for utility-class styling; no context provider is required.\n * Callbacks and formatters are synchronous and their errors propagate. Host code owns\n * review state and persistence; these controls do not apply changes automatically.\n *\n * @example\n * ```tsx\n * import { useState } from 'react';\n * import '@alneas/appkit-react/styles';\n * import { ProposalDecisionButtons, type FieldDecision } from '@alneas/appkit-react/ai/proposal';\n * export function FieldReview() {\n * const [decision, setDecision] = useState<FieldDecision>('pending');\n * return <ProposalDecisionButtons field=\"title\" decision={decision} onDecisionChange={setDecision} />;\n * }\n * ```\n */\nexport function ProposalDecisionButtons({\n field,\n decision,\n onDecisionChange,\n disabled,\n labels,\n allowReset = false,\n testId,\n buttonClassName,\n}: ProposalDecisionButtonsProps) {\n const values: FieldDecision[] = allowReset ? ['accepted', 'rejected', 'pending'] : ['accepted', 'rejected'];\n return (\n <div role=\"group\" aria-label={field} className=\"inline-flex flex-wrap gap-1\">\n {values.map(value => {\n const isSelected = decision === value;\n const defaultClass = isSelected\n ? 'px-2 py-1 text-xs rounded bg-neutral-900 text-white dark:bg-white dark:text-neutral-900'\n : 'px-2 py-1 text-xs rounded border border-neutral-300 dark:border-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800';\n return (\n <button\n key={value}\n type=\"button\"\n disabled={disabled}\n aria-pressed={isSelected}\n className={buttonClassName ? buttonClassName(isSelected) : defaultClass}\n data-testid={\n testId\n ? `${testId}-${value === 'accepted' ? 'accept' : value === 'rejected' ? 'reject' : 'reset'}-${field}`\n : undefined\n }\n onClick={() => onDecisionChange(value)}\n >\n {labels?.[value] ?? LABELS[value]}\n </button>\n );\n })}\n </div>\n );\n}\n\n/**\n * Controlled field-diff presentation; see ProposalFieldReview for usage.\n *\n * @see ProposalFieldReview for the canonical usage example.\n */\nexport interface ProposalFieldReviewProps {\n /**\n * Field identity, before/after primitive values and optional display reason.\n */\n change: {\n /**\n * Stable field identifier used in the section data attribute.\n */\n readonly field: string;\n /**\n * Optional display label; omission uses the field identifier.\n */\n readonly label?: string;\n /**\n * Original supported primitive value.\n */\n readonly before: SupportedPrimitive;\n /**\n * Proposed supported primitive value.\n */\n readonly after: SupportedPrimitive;\n /**\n * Optional explanatory text displayed below the diff.\n */\n readonly reason?: string;\n };\n /**\n * Externally controlled field choice.\n */\n decision: FieldDecision;\n /**\n * Synchronous choice callback; update host state to reflect the selection.\n *\n * @param decision - Clicked pending/accepted/rejected choice.\n *\n * @returns No value; the host schedules its controlled state update.\n */\n onDecisionChange: (decision: FieldDecision) => void;\n /**\n * Disable review choice buttons; defaults to false/undefined.\n */\n disabled?: boolean;\n /**\n * Optional decision-text overrides; unspecified values use Japanese defaults.\n */\n labels?: Partial<ProposalDecisionLabels>;\n /**\n * Before-value caption, default Japanese label for previous value.\n */\n beforeLabel?: string;\n /**\n * After-value caption, default Japanese label for proposed value.\n */\n afterLabel?: string;\n /**\n * Synchronous value renderer; defaults to null text for null and String(value) otherwise.\n */\n formatValue?: (value: SupportedPrimitive) => ReactNode;\n /**\n * Optional validation message shown with role alert.\n */\n error?: string;\n /**\n * Optional classes on the outer section.\n */\n className?: string;\n}\n\n/**\n * Renders before/after values, reason, controlled choices and optional validation feedback.\n *\n * @param props - Controlled state, optional labels/style settings and callbacks.\n *\n * @returns Section with data-proposal-field and review controls.\n *\n * @remarks Import Appkit styles for utility-class styling; no context provider is required.\n * Callbacks and formatters are synchronous and their errors propagate. Host code owns\n * review state and persistence; these controls do not apply changes automatically.\n *\n * @example\n * ```tsx\n * import { useState } from 'react';\n * import '@alneas/appkit-react/styles';\n * import { ProposalFieldReview, type FieldDecision } from '@alneas/appkit-react/ai/proposal';\n * export function FieldReview() {\n * const [decision, setDecision] = useState<FieldDecision>('pending');\n * return <ProposalFieldReview change={{ field: 'title', before: 'Old', after: 'New' }} decision={decision} onDecisionChange={setDecision} />;\n * }\n * ```\n */\nexport function ProposalFieldReview({\n change,\n decision,\n onDecisionChange,\n disabled,\n labels,\n beforeLabel = '変更前',\n afterLabel = '提案値',\n formatValue = value => (value === null ? 'null' : String(value)),\n error,\n className,\n}: ProposalFieldReviewProps) {\n return (\n <section aria-label={change.label ?? change.field} className={className} data-proposal-field={change.field}>\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium\">{change.label ?? change.field}</span>\n <DiffBadge decision={decision} labels={labels} />\n </div>\n <dl className=\"grid grid-cols-2 gap-2 text-sm my-2\">\n <div>\n <dt className=\"text-neutral-500 text-xs\">{beforeLabel}</dt>\n <dd>{formatValue(change.before)}</dd>\n </div>\n <div>\n <dt className=\"text-neutral-500 text-xs\">{afterLabel}</dt>\n <dd>{formatValue(change.after)}</dd>\n </div>\n </dl>\n {change.reason && <p className=\"text-xs text-neutral-500 my-1\">{change.reason}</p>}\n <ProposalDecisionButtons\n field={change.field}\n decision={decision}\n onDecisionChange={onDecisionChange}\n disabled={disabled}\n labels={labels}\n allowReset\n />\n {error && (\n <p role=\"alert\" className=\"text-sm text-red-600 mt-1\">\n {error}\n </p>\n )}\n </section>\n );\n}\n"],"mappings":"A,mHASA,IAAMC,EAAiC,CAAE,QAAS,MAAO,SAAU,KAAM,SAAU,IAAK,EA4CxF,SAAgBC,EAAU,CAAE,WAAU,SAAQ,aAA6B,CACzE,OACE,EAAAF,EAAA,IAAA,CAAC,OAAD,CACE,UAAWG,GAAa,0EACxB,gBAAeC,EAEd,SAAAC,IAASD,IAAaH,EAAOG,EAC1B,CAAA,CAEV,CAoEA,SAAgBE,EAAwB,CACtC,QACA,WACA,mBACA,WACA,SACA,aAAa,GACb,SACA,mBAC+B,CAE/B,OACE,EAAAN,EAAA,IAAA,CAAC,MAAD,CAAK,KAAK,QAAQ,aAAYO,EAAO,UAAU,8BAC5C,UAH2BC,EAAa,CAAC,WAAY,WAAY,SAAS,EAAI,CAAC,WAAY,UAAU,EAAA,CAG9F,IAAI,GAAS,CACnB,IAAMC,EAAaL,IAAaM,EAIhC,OACE,EAAAV,EAAA,IAAA,CAAC,SAAD,CAEE,KAAK,SACK,WACV,eAAcS,EACd,UAAWE,EAAkBA,EAAgBF,CAAU,EATtCA,EACjB,0FACA,6HAQA,cACEG,EACI,GAAGA,EAAO,GAAGF,IAAU,WAAa,SAAWA,IAAU,WAAa,SAAW,QAAQ,GAAGH,IAC5F,IAAA,GAEN,YAAeM,EAAiBH,CAAK,EAEpC,SAAAL,IAASK,IAAUT,EAAOS,EACrB,EAbDA,CAaC,CAEZ,CAAC,CACE,CAAA,CAET,CAiGA,SAAgBI,EAAoB,CAClC,SACA,WACA,mBACA,WACA,SACA,cAAc,MACd,aAAa,MACb,cAAc,GAAUJ,IAAU,KAAO,OAAS,OAA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|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FieldDecision, SupportedPrimitive } from '@alneas/appkit-core/ai';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Display labels for pending, accepted and rejected decisions.
|
|
5
|
+
*
|
|
6
|
+
* @see ProposalFieldReview for controlled usage.
|
|
7
|
+
*/
|
|
4
8
|
export type ProposalDecisionLabels = Record<FieldDecision, string>;
|
|
5
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Decision display settings for DiffBadge; see its usage example.
|
|
11
|
+
*
|
|
12
|
+
* @see DiffBadge for the canonical usage example.
|
|
13
|
+
*/
|
|
6
14
|
export interface DiffBadgeProps {
|
|
15
|
+
/**
|
|
16
|
+
* Current review choice; no save/apply status is implied.
|
|
17
|
+
*/
|
|
7
18
|
decision: FieldDecision;
|
|
19
|
+
/**
|
|
20
|
+
* Optional per-choice localized text; omitted values use Japanese defaults.
|
|
21
|
+
*/
|
|
8
22
|
labels?: Partial<ProposalDecisionLabels>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional replacement classes; omission uses compact bordered badge classes.
|
|
25
|
+
*/
|
|
9
26
|
className?: string;
|
|
10
27
|
}
|
|
11
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Displays the current review choice without implying persistence.
|
|
30
|
+
*
|
|
31
|
+
* @param props - Controlled state, optional labels/style settings and callbacks.
|
|
32
|
+
*
|
|
33
|
+
* @returns Span carrying data-decision and a localized label.
|
|
34
|
+
*
|
|
35
|
+
* @remarks Import Appkit styles for utility-class styling; no context provider is required.
|
|
36
|
+
* Callbacks and formatters are synchronous and their errors propagate. Host code owns
|
|
37
|
+
* review state and persistence; these controls do not apply changes automatically.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { useState } from 'react';
|
|
42
|
+
* import '@alneas/appkit-react/styles';
|
|
43
|
+
* import { DiffBadge, type FieldDecision } from '@alneas/appkit-react/ai/proposal';
|
|
44
|
+
* export function FieldReview() {
|
|
45
|
+
* const [decision, setDecision] = useState<FieldDecision>('pending');
|
|
46
|
+
* return <DiffBadge decision="pending" />;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
12
50
|
export declare function DiffBadge({ decision, labels, className }: DiffBadgeProps): import('react').JSX.Element;
|
|
13
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Controlled choice inputs; see ProposalDecisionButtons for usage.
|
|
53
|
+
*
|
|
54
|
+
* @see ProposalDecisionButtons for the canonical usage example.
|
|
55
|
+
*/
|
|
14
56
|
export interface ProposalDecisionButtonsProps {
|
|
57
|
+
/**
|
|
58
|
+
* Field key used as group aria-label and optional test-ID suffix.
|
|
59
|
+
*/
|
|
15
60
|
field: string;
|
|
61
|
+
/**
|
|
62
|
+
* Current externally controlled choice.
|
|
63
|
+
*/
|
|
16
64
|
decision: FieldDecision;
|
|
65
|
+
/**
|
|
66
|
+
* Synchronous callback receiving the clicked choice; the host must update decision.
|
|
67
|
+
*
|
|
68
|
+
* @param decision - Clicked pending/accepted/rejected choice.
|
|
69
|
+
*
|
|
70
|
+
* @returns No value; the host schedules its controlled state update.
|
|
71
|
+
*/
|
|
17
72
|
onDecisionChange: (decision: FieldDecision) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Disable every choice button; defaults to false/undefined.
|
|
75
|
+
*/
|
|
18
76
|
disabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Optional per-choice text; unspecified values use Japanese defaults.
|
|
79
|
+
*/
|
|
19
80
|
labels?: Partial<ProposalDecisionLabels>;
|
|
20
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Include a pending/reset choice; defaults to false.
|
|
83
|
+
*/
|
|
21
84
|
allowReset?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Optional prefix for {prefix}-accept/reject/reset-{field} test IDs.
|
|
87
|
+
*/
|
|
22
88
|
testId?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional synchronous class factory receiving whether this button is selected; replaces default button styling.
|
|
91
|
+
*/
|
|
23
92
|
buttonClassName?: (selected: boolean) => string;
|
|
24
93
|
}
|
|
25
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Emits controlled accept/reject and optional reset choices.
|
|
96
|
+
*
|
|
97
|
+
* @param props - Controlled state, optional labels/style settings and callbacks.
|
|
98
|
+
*
|
|
99
|
+
* @returns Button group; no form values or proposals are mutated.
|
|
100
|
+
*
|
|
101
|
+
* @remarks Import Appkit styles for utility-class styling; no context provider is required.
|
|
102
|
+
* Callbacks and formatters are synchronous and their errors propagate. Host code owns
|
|
103
|
+
* review state and persistence; these controls do not apply changes automatically.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* import { useState } from 'react';
|
|
108
|
+
* import '@alneas/appkit-react/styles';
|
|
109
|
+
* import { ProposalDecisionButtons, type FieldDecision } from '@alneas/appkit-react/ai/proposal';
|
|
110
|
+
* export function FieldReview() {
|
|
111
|
+
* const [decision, setDecision] = useState<FieldDecision>('pending');
|
|
112
|
+
* return <ProposalDecisionButtons field="title" decision={decision} onDecisionChange={setDecision} />;
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
26
116
|
export declare function ProposalDecisionButtons({ field, decision, onDecisionChange, disabled, labels, allowReset, testId, buttonClassName, }: ProposalDecisionButtonsProps): import('react').JSX.Element;
|
|
27
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Controlled field-diff presentation; see ProposalFieldReview for usage.
|
|
119
|
+
*
|
|
120
|
+
* @see ProposalFieldReview for the canonical usage example.
|
|
121
|
+
*/
|
|
28
122
|
export interface ProposalFieldReviewProps {
|
|
123
|
+
/**
|
|
124
|
+
* Field identity, before/after primitive values and optional display reason.
|
|
125
|
+
*/
|
|
29
126
|
change: {
|
|
127
|
+
/**
|
|
128
|
+
* Stable field identifier used in the section data attribute.
|
|
129
|
+
*/
|
|
30
130
|
readonly field: string;
|
|
131
|
+
/**
|
|
132
|
+
* Optional display label; omission uses the field identifier.
|
|
133
|
+
*/
|
|
31
134
|
readonly label?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Original supported primitive value.
|
|
137
|
+
*/
|
|
32
138
|
readonly before: SupportedPrimitive;
|
|
139
|
+
/**
|
|
140
|
+
* Proposed supported primitive value.
|
|
141
|
+
*/
|
|
33
142
|
readonly after: SupportedPrimitive;
|
|
143
|
+
/**
|
|
144
|
+
* Optional explanatory text displayed below the diff.
|
|
145
|
+
*/
|
|
34
146
|
readonly reason?: string;
|
|
35
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Externally controlled field choice.
|
|
150
|
+
*/
|
|
36
151
|
decision: FieldDecision;
|
|
152
|
+
/**
|
|
153
|
+
* Synchronous choice callback; update host state to reflect the selection.
|
|
154
|
+
*
|
|
155
|
+
* @param decision - Clicked pending/accepted/rejected choice.
|
|
156
|
+
*
|
|
157
|
+
* @returns No value; the host schedules its controlled state update.
|
|
158
|
+
*/
|
|
37
159
|
onDecisionChange: (decision: FieldDecision) => void;
|
|
160
|
+
/**
|
|
161
|
+
* Disable review choice buttons; defaults to false/undefined.
|
|
162
|
+
*/
|
|
38
163
|
disabled?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Optional decision-text overrides; unspecified values use Japanese defaults.
|
|
166
|
+
*/
|
|
39
167
|
labels?: Partial<ProposalDecisionLabels>;
|
|
168
|
+
/**
|
|
169
|
+
* Before-value caption, default Japanese label for previous value.
|
|
170
|
+
*/
|
|
40
171
|
beforeLabel?: string;
|
|
172
|
+
/**
|
|
173
|
+
* After-value caption, default Japanese label for proposed value.
|
|
174
|
+
*/
|
|
41
175
|
afterLabel?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Synchronous value renderer; defaults to null text for null and String(value) otherwise.
|
|
178
|
+
*/
|
|
42
179
|
formatValue?: (value: SupportedPrimitive) => ReactNode;
|
|
180
|
+
/**
|
|
181
|
+
* Optional validation message shown with role alert.
|
|
182
|
+
*/
|
|
43
183
|
error?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Optional classes on the outer section.
|
|
186
|
+
*/
|
|
44
187
|
className?: string;
|
|
45
188
|
}
|
|
46
189
|
/**
|
|
47
|
-
* Renders
|
|
190
|
+
* Renders before/after values, reason, controlled choices and optional validation feedback.
|
|
191
|
+
*
|
|
192
|
+
* @param props - Controlled state, optional labels/style settings and callbacks.
|
|
193
|
+
*
|
|
194
|
+
* @returns Section with data-proposal-field and review controls.
|
|
195
|
+
*
|
|
196
|
+
* @remarks Import Appkit styles for utility-class styling; no context provider is required.
|
|
197
|
+
* Callbacks and formatters are synchronous and their errors propagate. Host code owns
|
|
198
|
+
* review state and persistence; these controls do not apply changes automatically.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```tsx
|
|
202
|
+
* import { useState } from 'react';
|
|
203
|
+
* import '@alneas/appkit-react/styles';
|
|
204
|
+
* import { ProposalFieldReview, type FieldDecision } from '@alneas/appkit-react/ai/proposal';
|
|
205
|
+
* export function FieldReview() {
|
|
206
|
+
* const [decision, setDecision] = useState<FieldDecision>('pending');
|
|
207
|
+
* return <ProposalFieldReview change={{ field: 'title', before: 'Old', after: 'New' }} decision={decision} onDecisionChange={setDecision} />;
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
48
210
|
*/
|
|
49
211
|
export declare function ProposalFieldReview({ change, decision, onDecisionChange, disabled, labels, beforeLabel, afterLabel, formatValue, error, className, }: ProposalFieldReviewProps): import('react').JSX.Element;
|
|
@@ -1,49 +1,211 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { FieldDecision, SupportedPrimitive } from '@alneas/appkit-core/ai';
|
|
3
|
-
/**
|
|
3
|
+
/**
|
|
4
|
+
* Display labels for pending, accepted and rejected decisions.
|
|
5
|
+
*
|
|
6
|
+
* @see ProposalFieldReview for controlled usage.
|
|
7
|
+
*/
|
|
4
8
|
export type ProposalDecisionLabels = Record<FieldDecision, string>;
|
|
5
|
-
/**
|
|
9
|
+
/**
|
|
10
|
+
* Decision display settings for DiffBadge; see its usage example.
|
|
11
|
+
*
|
|
12
|
+
* @see DiffBadge for the canonical usage example.
|
|
13
|
+
*/
|
|
6
14
|
export interface DiffBadgeProps {
|
|
15
|
+
/**
|
|
16
|
+
* Current review choice; no save/apply status is implied.
|
|
17
|
+
*/
|
|
7
18
|
decision: FieldDecision;
|
|
19
|
+
/**
|
|
20
|
+
* Optional per-choice localized text; omitted values use Japanese defaults.
|
|
21
|
+
*/
|
|
8
22
|
labels?: Partial<ProposalDecisionLabels>;
|
|
23
|
+
/**
|
|
24
|
+
* Optional replacement classes; omission uses compact bordered badge classes.
|
|
25
|
+
*/
|
|
9
26
|
className?: string;
|
|
10
27
|
}
|
|
11
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Displays the current review choice without implying persistence.
|
|
30
|
+
*
|
|
31
|
+
* @param props - Controlled state, optional labels/style settings and callbacks.
|
|
32
|
+
*
|
|
33
|
+
* @returns Span carrying data-decision and a localized label.
|
|
34
|
+
*
|
|
35
|
+
* @remarks Import Appkit styles for utility-class styling; no context provider is required.
|
|
36
|
+
* Callbacks and formatters are synchronous and their errors propagate. Host code owns
|
|
37
|
+
* review state and persistence; these controls do not apply changes automatically.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```tsx
|
|
41
|
+
* import { useState } from 'react';
|
|
42
|
+
* import '@alneas/appkit-react/styles';
|
|
43
|
+
* import { DiffBadge, type FieldDecision } from '@alneas/appkit-react/ai/proposal';
|
|
44
|
+
* export function FieldReview() {
|
|
45
|
+
* const [decision, setDecision] = useState<FieldDecision>('pending');
|
|
46
|
+
* return <DiffBadge decision="pending" />;
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
12
50
|
export declare function DiffBadge({ decision, labels, className }: DiffBadgeProps): import('react').JSX.Element;
|
|
13
|
-
/**
|
|
51
|
+
/**
|
|
52
|
+
* Controlled choice inputs; see ProposalDecisionButtons for usage.
|
|
53
|
+
*
|
|
54
|
+
* @see ProposalDecisionButtons for the canonical usage example.
|
|
55
|
+
*/
|
|
14
56
|
export interface ProposalDecisionButtonsProps {
|
|
57
|
+
/**
|
|
58
|
+
* Field key used as group aria-label and optional test-ID suffix.
|
|
59
|
+
*/
|
|
15
60
|
field: string;
|
|
61
|
+
/**
|
|
62
|
+
* Current externally controlled choice.
|
|
63
|
+
*/
|
|
16
64
|
decision: FieldDecision;
|
|
65
|
+
/**
|
|
66
|
+
* Synchronous callback receiving the clicked choice; the host must update decision.
|
|
67
|
+
*
|
|
68
|
+
* @param decision - Clicked pending/accepted/rejected choice.
|
|
69
|
+
*
|
|
70
|
+
* @returns No value; the host schedules its controlled state update.
|
|
71
|
+
*/
|
|
17
72
|
onDecisionChange: (decision: FieldDecision) => void;
|
|
73
|
+
/**
|
|
74
|
+
* Disable every choice button; defaults to false/undefined.
|
|
75
|
+
*/
|
|
18
76
|
disabled?: boolean;
|
|
77
|
+
/**
|
|
78
|
+
* Optional per-choice text; unspecified values use Japanese defaults.
|
|
79
|
+
*/
|
|
19
80
|
labels?: Partial<ProposalDecisionLabels>;
|
|
20
|
-
/**
|
|
81
|
+
/**
|
|
82
|
+
* Include a pending/reset choice; defaults to false.
|
|
83
|
+
*/
|
|
21
84
|
allowReset?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Optional prefix for {prefix}-accept/reject/reset-{field} test IDs.
|
|
87
|
+
*/
|
|
22
88
|
testId?: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional synchronous class factory receiving whether this button is selected; replaces default button styling.
|
|
91
|
+
*/
|
|
23
92
|
buttonClassName?: (selected: boolean) => string;
|
|
24
93
|
}
|
|
25
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* Emits controlled accept/reject and optional reset choices.
|
|
96
|
+
*
|
|
97
|
+
* @param props - Controlled state, optional labels/style settings and callbacks.
|
|
98
|
+
*
|
|
99
|
+
* @returns Button group; no form values or proposals are mutated.
|
|
100
|
+
*
|
|
101
|
+
* @remarks Import Appkit styles for utility-class styling; no context provider is required.
|
|
102
|
+
* Callbacks and formatters are synchronous and their errors propagate. Host code owns
|
|
103
|
+
* review state and persistence; these controls do not apply changes automatically.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* import { useState } from 'react';
|
|
108
|
+
* import '@alneas/appkit-react/styles';
|
|
109
|
+
* import { ProposalDecisionButtons, type FieldDecision } from '@alneas/appkit-react/ai/proposal';
|
|
110
|
+
* export function FieldReview() {
|
|
111
|
+
* const [decision, setDecision] = useState<FieldDecision>('pending');
|
|
112
|
+
* return <ProposalDecisionButtons field="title" decision={decision} onDecisionChange={setDecision} />;
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
26
116
|
export declare function ProposalDecisionButtons({ field, decision, onDecisionChange, disabled, labels, allowReset, testId, buttonClassName, }: ProposalDecisionButtonsProps): import('react').JSX.Element;
|
|
27
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Controlled field-diff presentation; see ProposalFieldReview for usage.
|
|
119
|
+
*
|
|
120
|
+
* @see ProposalFieldReview for the canonical usage example.
|
|
121
|
+
*/
|
|
28
122
|
export interface ProposalFieldReviewProps {
|
|
123
|
+
/**
|
|
124
|
+
* Field identity, before/after primitive values and optional display reason.
|
|
125
|
+
*/
|
|
29
126
|
change: {
|
|
127
|
+
/**
|
|
128
|
+
* Stable field identifier used in the section data attribute.
|
|
129
|
+
*/
|
|
30
130
|
readonly field: string;
|
|
131
|
+
/**
|
|
132
|
+
* Optional display label; omission uses the field identifier.
|
|
133
|
+
*/
|
|
31
134
|
readonly label?: string;
|
|
135
|
+
/**
|
|
136
|
+
* Original supported primitive value.
|
|
137
|
+
*/
|
|
32
138
|
readonly before: SupportedPrimitive;
|
|
139
|
+
/**
|
|
140
|
+
* Proposed supported primitive value.
|
|
141
|
+
*/
|
|
33
142
|
readonly after: SupportedPrimitive;
|
|
143
|
+
/**
|
|
144
|
+
* Optional explanatory text displayed below the diff.
|
|
145
|
+
*/
|
|
34
146
|
readonly reason?: string;
|
|
35
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* Externally controlled field choice.
|
|
150
|
+
*/
|
|
36
151
|
decision: FieldDecision;
|
|
152
|
+
/**
|
|
153
|
+
* Synchronous choice callback; update host state to reflect the selection.
|
|
154
|
+
*
|
|
155
|
+
* @param decision - Clicked pending/accepted/rejected choice.
|
|
156
|
+
*
|
|
157
|
+
* @returns No value; the host schedules its controlled state update.
|
|
158
|
+
*/
|
|
37
159
|
onDecisionChange: (decision: FieldDecision) => void;
|
|
160
|
+
/**
|
|
161
|
+
* Disable review choice buttons; defaults to false/undefined.
|
|
162
|
+
*/
|
|
38
163
|
disabled?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* Optional decision-text overrides; unspecified values use Japanese defaults.
|
|
166
|
+
*/
|
|
39
167
|
labels?: Partial<ProposalDecisionLabels>;
|
|
168
|
+
/**
|
|
169
|
+
* Before-value caption, default Japanese label for previous value.
|
|
170
|
+
*/
|
|
40
171
|
beforeLabel?: string;
|
|
172
|
+
/**
|
|
173
|
+
* After-value caption, default Japanese label for proposed value.
|
|
174
|
+
*/
|
|
41
175
|
afterLabel?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Synchronous value renderer; defaults to null text for null and String(value) otherwise.
|
|
178
|
+
*/
|
|
42
179
|
formatValue?: (value: SupportedPrimitive) => ReactNode;
|
|
180
|
+
/**
|
|
181
|
+
* Optional validation message shown with role alert.
|
|
182
|
+
*/
|
|
43
183
|
error?: string;
|
|
184
|
+
/**
|
|
185
|
+
* Optional classes on the outer section.
|
|
186
|
+
*/
|
|
44
187
|
className?: string;
|
|
45
188
|
}
|
|
46
189
|
/**
|
|
47
|
-
* Renders
|
|
190
|
+
* Renders before/after values, reason, controlled choices and optional validation feedback.
|
|
191
|
+
*
|
|
192
|
+
* @param props - Controlled state, optional labels/style settings and callbacks.
|
|
193
|
+
*
|
|
194
|
+
* @returns Section with data-proposal-field and review controls.
|
|
195
|
+
*
|
|
196
|
+
* @remarks Import Appkit styles for utility-class styling; no context provider is required.
|
|
197
|
+
* Callbacks and formatters are synchronous and their errors propagate. Host code owns
|
|
198
|
+
* review state and persistence; these controls do not apply changes automatically.
|
|
199
|
+
*
|
|
200
|
+
* @example
|
|
201
|
+
* ```tsx
|
|
202
|
+
* import { useState } from 'react';
|
|
203
|
+
* import '@alneas/appkit-react/styles';
|
|
204
|
+
* import { ProposalFieldReview, type FieldDecision } from '@alneas/appkit-react/ai/proposal';
|
|
205
|
+
* export function FieldReview() {
|
|
206
|
+
* const [decision, setDecision] = useState<FieldDecision>('pending');
|
|
207
|
+
* return <ProposalFieldReview change={{ field: 'title', before: 'Old', after: 'New' }} decision={decision} onDecisionChange={setDecision} />;
|
|
208
|
+
* }
|
|
209
|
+
* ```
|
|
48
210
|
*/
|
|
49
211
|
export declare function ProposalFieldReview({ change, decision, onDecisionChange, disabled, labels, beforeLabel, afterLabel, formatValue, error, className, }: ProposalFieldReviewProps): import('react').JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProposalFieldReview.js","names":["LABELS","DiffBadge","className","decision","labels","ProposalDecisionButtons","field","allowReset","isSelected","value","buttonClassName","testId","onDecisionChange","ProposalFieldReview","change","beforeLabel","formatValue","afterLabel","error"],"sources":["../../../src/ai/proposal/ProposalFieldReview.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldDecision, SupportedPrimitive } from \"@alneas/appkit-core/ai\";\n\n/** Localized labels for a review decision. */\nexport type ProposalDecisionLabels = Record<FieldDecision, string>;\nconst LABELS: ProposalDecisionLabels = { pending: '未判断', accepted: '採用', rejected: '却下' };\n\n/** Props for DiffBadge. */\nexport interface DiffBadgeProps {\n decision: FieldDecision;\n labels?: Partial<ProposalDecisionLabels>;\n className?: string;\n}\n\n/** Displays review selection without implying that a change has been applied or saved. */\nexport function DiffBadge({ decision, labels, className }: DiffBadgeProps) {\n return (\n <span\n className={className ?? 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border'}\n data-decision={decision}\n >\n {labels?.[decision] ?? LABELS[decision]}\n </span>\n );\n}\n\n/** Controlled accept/reject/reset controls shared by card and field layouts. */\nexport interface ProposalDecisionButtonsProps {\n field: string;\n decision: FieldDecision;\n onDecisionChange: (decision: FieldDecision) => void;\n disabled?: boolean;\n labels?: Partial<ProposalDecisionLabels>;\n /** Enables returning a single field to pending. */\n allowReset?: boolean;\n testId?: string;\n buttonClassName?: (selected: boolean) => string;\n}\n\n/** Emits decisions only; does not mutate form values or apply a proposal. */\nexport function ProposalDecisionButtons({\n field,\n decision,\n onDecisionChange,\n disabled,\n labels,\n allowReset = false,\n testId,\n buttonClassName,\n}: ProposalDecisionButtonsProps) {\n const values: FieldDecision[] = allowReset ? ['accepted', 'rejected', 'pending'] : ['accepted', 'rejected'];\n return (\n <div role=\"group\" aria-label={field} className=\"inline-flex flex-wrap gap-1\">\n {values.map(value => {\n const isSelected = decision === value;\n const defaultClass = isSelected\n ? 'px-2 py-1 text-xs rounded bg-neutral-900 text-white dark:bg-white dark:text-neutral-900'\n : 'px-2 py-1 text-xs rounded border border-neutral-300 dark:border-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800';\n return (\n <button\n key={value}\n type=\"button\"\n disabled={disabled}\n aria-pressed={isSelected}\n className={buttonClassName ? buttonClassName(isSelected) : defaultClass}\n data-testid={\n testId\n ? `${testId}-${value === 'accepted' ? 'accept' : value === 'rejected' ? 'reject' : 'reset'}-${field}`\n : undefined\n }\n onClick={() => onDecisionChange(value)}\n >\n {labels?.[value] ?? LABELS[value]}\n </button>\n );\n })}\n </div>\n );\n}\n\n/** Controlled inline proposal review, suitable beside an existing form field or table cell. */\nexport interface ProposalFieldReviewProps {\n change: {\n readonly field: string;\n readonly label?: string;\n readonly before: SupportedPrimitive;\n readonly after: SupportedPrimitive;\n readonly reason?: string;\n };\n decision: FieldDecision;\n onDecisionChange: (decision: FieldDecision) => void;\n disabled?: boolean;\n labels?: Partial<ProposalDecisionLabels>;\n beforeLabel?: string;\n afterLabel?: string;\n formatValue?: (value: SupportedPrimitive) => ReactNode;\n error?: string;\n className?: string;\n}\n\n/**\n * Renders a field's proposed values, reason, decision and optional validation message.\n */\nexport function ProposalFieldReview({\n change,\n decision,\n onDecisionChange,\n disabled,\n labels,\n beforeLabel = '変更前',\n afterLabel = '提案値',\n formatValue = value => (value === null ? 'null' : String(value)),\n error,\n className,\n}: ProposalFieldReviewProps) {\n return (\n <section aria-label={change.label ?? change.field} className={className} data-proposal-field={change.field}>\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium\">{change.label ?? change.field}</span>\n <DiffBadge decision={decision} labels={labels} />\n </div>\n <dl className=\"grid grid-cols-2 gap-2 text-sm my-2\">\n <div>\n <dt className=\"text-neutral-500 text-xs\">{beforeLabel}</dt>\n <dd>{formatValue(change.before)}</dd>\n </div>\n <div>\n <dt className=\"text-neutral-500 text-xs\">{afterLabel}</dt>\n <dd>{formatValue(change.after)}</dd>\n </div>\n </dl>\n {change.reason && <p className=\"text-xs text-neutral-500 my-1\">{change.reason}</p>}\n <ProposalDecisionButtons\n field={change.field}\n decision={decision}\n onDecisionChange={onDecisionChange}\n disabled={disabled}\n labels={labels}\n allowReset\n />\n {error && (\n <p role=\"alert\" className=\"text-sm text-red-600 mt-1\">\n {error}\n </p>\n )}\n </section>\n );\n}\n"],"mappings":";;;AAKA,IAAMA,IAAiC;CAAE,SAAS;CAAO,UAAU;CAAM,UAAU;AAAK;AAUxF,SAAgBC,EAAU,EAAE,aAAU,WAAQ,gBAA6B;CACzE,OACE,kBAAC,QAAD;EACE,WAAWC,KAAa;EACxB,iBAAeC;EAEd,UAAAC,IAASD,MAAaH,EAAOG;CAC1B,CAAA;AAEV;AAgBA,SAAgBE,EAAwB,EACtC,UACA,aACA,qBACA,aACA,WACA,gBAAa,IACb,WAC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GACzD,kBAAC,MAAD,EAAA,UAAKD,EAAYF,EAAO,KAAK,EAAM,CAAA,CAChC,EAAA,CAAA,CACH;;GACHA,EAAO,UAAU,kBAAC,KAAD;IAAG,WAAU;IAAiC,UAAAA,EAAO;GAAU,CAAA;GACjF,kBAACT,GAAD;IACE,OAAOS,EAAO;IACJ;IACQ;IACR;IACF;IACR,YAAA;GACD,CAAA;GACAI,KACC,kBAAC,KAAD;IAAG,MAAK;IAAQ,WAAU;IACvB,UAAAA;GACA,CAAA;EAEE;;AAEb"}
|
|
1
|
+
{"version":3,"file":"ProposalFieldReview.js","names":["LABELS","DiffBadge","className","decision","labels","ProposalDecisionButtons","field","allowReset","isSelected","value","buttonClassName","testId","onDecisionChange","ProposalFieldReview","change","beforeLabel","formatValue","afterLabel","error"],"sources":["../../../src/ai/proposal/ProposalFieldReview.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport type { FieldDecision, SupportedPrimitive } from \"@alneas/appkit-core/ai\";\n\n/**\n * Display labels for pending, accepted and rejected decisions.\n *\n * @see ProposalFieldReview for controlled usage.\n */\nexport type ProposalDecisionLabels = Record<FieldDecision, string>;\nconst LABELS: ProposalDecisionLabels = { pending: '未判断', accepted: '採用', rejected: '却下' };\n\n/**\n * Decision display settings for DiffBadge; see its usage example.\n *\n * @see DiffBadge for the canonical usage example.\n */\nexport interface DiffBadgeProps {\n /**\n * Current review choice; no save/apply status is implied.\n */\n decision: FieldDecision;\n /**\n * Optional per-choice localized text; omitted values use Japanese defaults.\n */\n labels?: Partial<ProposalDecisionLabels>;\n /**\n * Optional replacement classes; omission uses compact bordered badge classes.\n */\n className?: string;\n}\n\n/**\n * Displays the current review choice without implying persistence.\n *\n * @param props - Controlled state, optional labels/style settings and callbacks.\n *\n * @returns Span carrying data-decision and a localized label.\n *\n * @remarks Import Appkit styles for utility-class styling; no context provider is required.\n * Callbacks and formatters are synchronous and their errors propagate. Host code owns\n * review state and persistence; these controls do not apply changes automatically.\n *\n * @example\n * ```tsx\n * import { useState } from 'react';\n * import '@alneas/appkit-react/styles';\n * import { DiffBadge, type FieldDecision } from '@alneas/appkit-react/ai/proposal';\n * export function FieldReview() {\n * const [decision, setDecision] = useState<FieldDecision>('pending');\n * return <DiffBadge decision=\"pending\" />;\n * }\n * ```\n */\nexport function DiffBadge({ decision, labels, className }: DiffBadgeProps) {\n return (\n <span\n className={className ?? 'inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border'}\n data-decision={decision}\n >\n {labels?.[decision] ?? LABELS[decision]}\n </span>\n );\n}\n\n/**\n * Controlled choice inputs; see ProposalDecisionButtons for usage.\n *\n * @see ProposalDecisionButtons for the canonical usage example.\n */\nexport interface ProposalDecisionButtonsProps {\n /**\n * Field key used as group aria-label and optional test-ID suffix.\n */\n field: string;\n /**\n * Current externally controlled choice.\n */\n decision: FieldDecision;\n /**\n * Synchronous callback receiving the clicked choice; the host must update decision.\n *\n * @param decision - Clicked pending/accepted/rejected choice.\n *\n * @returns No value; the host schedules its controlled state update.\n */\n onDecisionChange: (decision: FieldDecision) => void;\n /**\n * Disable every choice button; defaults to false/undefined.\n */\n disabled?: boolean;\n /**\n * Optional per-choice text; unspecified values use Japanese defaults.\n */\n labels?: Partial<ProposalDecisionLabels>;\n /**\n * Include a pending/reset choice; defaults to false.\n */\n allowReset?: boolean;\n /**\n * Optional prefix for {prefix}-accept/reject/reset-{field} test IDs.\n */\n testId?: string;\n /**\n * Optional synchronous class factory receiving whether this button is selected; replaces default button styling.\n */\n buttonClassName?: (selected: boolean) => string;\n}\n\n/**\n * Emits controlled accept/reject and optional reset choices.\n *\n * @param props - Controlled state, optional labels/style settings and callbacks.\n *\n * @returns Button group; no form values or proposals are mutated.\n *\n * @remarks Import Appkit styles for utility-class styling; no context provider is required.\n * Callbacks and formatters are synchronous and their errors propagate. Host code owns\n * review state and persistence; these controls do not apply changes automatically.\n *\n * @example\n * ```tsx\n * import { useState } from 'react';\n * import '@alneas/appkit-react/styles';\n * import { ProposalDecisionButtons, type FieldDecision } from '@alneas/appkit-react/ai/proposal';\n * export function FieldReview() {\n * const [decision, setDecision] = useState<FieldDecision>('pending');\n * return <ProposalDecisionButtons field=\"title\" decision={decision} onDecisionChange={setDecision} />;\n * }\n * ```\n */\nexport function ProposalDecisionButtons({\n field,\n decision,\n onDecisionChange,\n disabled,\n labels,\n allowReset = false,\n testId,\n buttonClassName,\n}: ProposalDecisionButtonsProps) {\n const values: FieldDecision[] = allowReset ? ['accepted', 'rejected', 'pending'] : ['accepted', 'rejected'];\n return (\n <div role=\"group\" aria-label={field} className=\"inline-flex flex-wrap gap-1\">\n {values.map(value => {\n const isSelected = decision === value;\n const defaultClass = isSelected\n ? 'px-2 py-1 text-xs rounded bg-neutral-900 text-white dark:bg-white dark:text-neutral-900'\n : 'px-2 py-1 text-xs rounded border border-neutral-300 dark:border-neutral-700 hover:bg-neutral-100 dark:hover:bg-neutral-800';\n return (\n <button\n key={value}\n type=\"button\"\n disabled={disabled}\n aria-pressed={isSelected}\n className={buttonClassName ? buttonClassName(isSelected) : defaultClass}\n data-testid={\n testId\n ? `${testId}-${value === 'accepted' ? 'accept' : value === 'rejected' ? 'reject' : 'reset'}-${field}`\n : undefined\n }\n onClick={() => onDecisionChange(value)}\n >\n {labels?.[value] ?? LABELS[value]}\n </button>\n );\n })}\n </div>\n );\n}\n\n/**\n * Controlled field-diff presentation; see ProposalFieldReview for usage.\n *\n * @see ProposalFieldReview for the canonical usage example.\n */\nexport interface ProposalFieldReviewProps {\n /**\n * Field identity, before/after primitive values and optional display reason.\n */\n change: {\n /**\n * Stable field identifier used in the section data attribute.\n */\n readonly field: string;\n /**\n * Optional display label; omission uses the field identifier.\n */\n readonly label?: string;\n /**\n * Original supported primitive value.\n */\n readonly before: SupportedPrimitive;\n /**\n * Proposed supported primitive value.\n */\n readonly after: SupportedPrimitive;\n /**\n * Optional explanatory text displayed below the diff.\n */\n readonly reason?: string;\n };\n /**\n * Externally controlled field choice.\n */\n decision: FieldDecision;\n /**\n * Synchronous choice callback; update host state to reflect the selection.\n *\n * @param decision - Clicked pending/accepted/rejected choice.\n *\n * @returns No value; the host schedules its controlled state update.\n */\n onDecisionChange: (decision: FieldDecision) => void;\n /**\n * Disable review choice buttons; defaults to false/undefined.\n */\n disabled?: boolean;\n /**\n * Optional decision-text overrides; unspecified values use Japanese defaults.\n */\n labels?: Partial<ProposalDecisionLabels>;\n /**\n * Before-value caption, default Japanese label for previous value.\n */\n beforeLabel?: string;\n /**\n * After-value caption, default Japanese label for proposed value.\n */\n afterLabel?: string;\n /**\n * Synchronous value renderer; defaults to null text for null and String(value) otherwise.\n */\n formatValue?: (value: SupportedPrimitive) => ReactNode;\n /**\n * Optional validation message shown with role alert.\n */\n error?: string;\n /**\n * Optional classes on the outer section.\n */\n className?: string;\n}\n\n/**\n * Renders before/after values, reason, controlled choices and optional validation feedback.\n *\n * @param props - Controlled state, optional labels/style settings and callbacks.\n *\n * @returns Section with data-proposal-field and review controls.\n *\n * @remarks Import Appkit styles for utility-class styling; no context provider is required.\n * Callbacks and formatters are synchronous and their errors propagate. Host code owns\n * review state and persistence; these controls do not apply changes automatically.\n *\n * @example\n * ```tsx\n * import { useState } from 'react';\n * import '@alneas/appkit-react/styles';\n * import { ProposalFieldReview, type FieldDecision } from '@alneas/appkit-react/ai/proposal';\n * export function FieldReview() {\n * const [decision, setDecision] = useState<FieldDecision>('pending');\n * return <ProposalFieldReview change={{ field: 'title', before: 'Old', after: 'New' }} decision={decision} onDecisionChange={setDecision} />;\n * }\n * ```\n */\nexport function ProposalFieldReview({\n change,\n decision,\n onDecisionChange,\n disabled,\n labels,\n beforeLabel = '変更前',\n afterLabel = '提案値',\n formatValue = value => (value === null ? 'null' : String(value)),\n error,\n className,\n}: ProposalFieldReviewProps) {\n return (\n <section aria-label={change.label ?? change.field} className={className} data-proposal-field={change.field}>\n <div className=\"flex items-center gap-2\">\n <span className=\"font-medium\">{change.label ?? change.field}</span>\n <DiffBadge decision={decision} labels={labels} />\n </div>\n <dl className=\"grid grid-cols-2 gap-2 text-sm my-2\">\n <div>\n <dt className=\"text-neutral-500 text-xs\">{beforeLabel}</dt>\n <dd>{formatValue(change.before)}</dd>\n </div>\n <div>\n <dt className=\"text-neutral-500 text-xs\">{afterLabel}</dt>\n <dd>{formatValue(change.after)}</dd>\n </div>\n </dl>\n {change.reason && <p className=\"text-xs text-neutral-500 my-1\">{change.reason}</p>}\n <ProposalDecisionButtons\n field={change.field}\n decision={decision}\n onDecisionChange={onDecisionChange}\n disabled={disabled}\n labels={labels}\n allowReset\n />\n {error && (\n <p role=\"alert\" className=\"text-sm text-red-600 mt-1\">\n {error}\n </p>\n )}\n </section>\n );\n}\n"],"mappings":";;;AASA,IAAMA,IAAiC;CAAE,SAAS;CAAO,UAAU;CAAM,UAAU;AAAK;AA4CxF,SAAgBC,EAAU,EAAE,aAAU,WAAQ,gBAA6B;CACzE,OACE,kBAAC,QAAD;EACE,WAAWC,KAAa;EACxB,iBAAeC;EAEd,UAAAC,IAASD,MAAaH,EAAOG;CAC1B,CAAA;AAEV;AAoEA,SAAgBE,EAAwB,EACtC,UACA,aACA,qBACA,aACA,WACA,gBAAa,IACb,WACA,sBAC+B;CAE/B,OACE,kBAAC,OAAD;EAAK,MAAK;EAAQ,cAAYC;EAAO,WAAU;EAC5C,WAH2BC,IAAa;GAAC;GAAY;GAAY;EAAS,IAAI,CAAC,YAAY,UAAU,EAAA,CAG9F,KAAI,MAAS;GACnB,IAAMC,IAAaL,MAAaM;GAIhC,OACE,kBAAC,UAAD;IAEE,MAAK;IACK;IACV,gBAAcD;IACd,WAAWE,IAAkBA,EAAgBF,CAAU,IATtCA,IACjB,4FACA;IAQA,eACEG,IACI,GAAGA,EAAO,GAAGF,MAAU,aAAa,WAAWA,MAAU,aAAa,WAAW,QAAQ,GAAGH,MAC5F,KAAA;IAEN,eAAeM,EAAiBH,CAAK;IAEpC,UAAAL,IAASK,MAAUT,EAAOS;GACrB,GAbDA,CAaC;EAEZ,CAAC;CACE,CAAA;AA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