@stigmer/react 0.4.7 → 0.5.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/action-menu/ActionMenu.d.ts +64 -0
- package/action-menu/ActionMenu.d.ts.map +1 -0
- package/action-menu/ActionMenu.js +78 -0
- package/action-menu/ActionMenu.js.map +1 -0
- package/action-menu/index.d.ts +3 -0
- package/action-menu/index.d.ts.map +1 -0
- package/action-menu/index.js +2 -0
- package/action-menu/index.js.map +1 -0
- package/action-menu/types.d.ts +65 -0
- package/action-menu/types.d.ts.map +1 -0
- package/action-menu/types.js +2 -0
- package/action-menu/types.js.map +1 -0
- package/agent/AgentCreationWizard.d.ts +55 -0
- package/agent/AgentCreationWizard.d.ts.map +1 -0
- package/agent/AgentCreationWizard.js +115 -0
- package/agent/AgentCreationWizard.js.map +1 -0
- package/agent/AgentDetailView.d.ts +77 -9
- package/agent/AgentDetailView.d.ts.map +1 -1
- package/agent/AgentDetailView.js +265 -87
- package/agent/AgentDetailView.js.map +1 -1
- package/agent/index.d.ts +8 -0
- package/agent/index.d.ts.map +1 -1
- package/agent/index.js +4 -0
- package/agent/index.js.map +1 -1
- package/agent/internal/agentToInput.d.ts +12 -0
- package/agent/internal/agentToInput.d.ts.map +1 -0
- package/agent/internal/agentToInput.js +72 -0
- package/agent/internal/agentToInput.js.map +1 -0
- package/agent/steps/CapabilitiesStep.d.ts +16 -0
- package/agent/steps/CapabilitiesStep.d.ts.map +1 -0
- package/agent/steps/CapabilitiesStep.js +80 -0
- package/agent/steps/CapabilitiesStep.js.map +1 -0
- package/agent/steps/IdentityStep.d.ts +18 -0
- package/agent/steps/IdentityStep.d.ts.map +1 -0
- package/agent/steps/IdentityStep.js +43 -0
- package/agent/steps/IdentityStep.js.map +1 -0
- package/agent/steps/ReviewStep.d.ts +23 -0
- package/agent/steps/ReviewStep.d.ts.map +1 -0
- package/agent/steps/ReviewStep.js +73 -0
- package/agent/steps/ReviewStep.js.map +1 -0
- package/agent/steps/types.d.ts +35 -0
- package/agent/steps/types.d.ts.map +1 -0
- package/agent/steps/types.js +16 -0
- package/agent/steps/types.js.map +1 -0
- package/agent/useCreateAgent.d.ts +45 -0
- package/agent/useCreateAgent.d.ts.map +1 -0
- package/agent/useCreateAgent.js +50 -0
- package/agent/useCreateAgent.js.map +1 -0
- package/agent/useUpdateAgent.d.ts +24 -0
- package/agent/useUpdateAgent.d.ts.map +1 -0
- package/agent/useUpdateAgent.js +35 -0
- package/agent/useUpdateAgent.js.map +1 -0
- package/dependency-graph/DependencyGraph.d.ts +37 -0
- package/dependency-graph/DependencyGraph.d.ts.map +1 -0
- package/dependency-graph/DependencyGraph.js +88 -0
- package/dependency-graph/DependencyGraph.js.map +1 -0
- package/dependency-graph/DependencyTreeNode.d.ts +23 -0
- package/dependency-graph/DependencyTreeNode.d.ts.map +1 -0
- package/dependency-graph/DependencyTreeNode.js +99 -0
- package/dependency-graph/DependencyTreeNode.js.map +1 -0
- package/dependency-graph/index.d.ts +4 -0
- package/dependency-graph/index.d.ts.map +1 -0
- package/dependency-graph/index.js +5 -0
- package/dependency-graph/index.js.map +1 -0
- package/dependency-graph/types.d.ts +130 -0
- package/dependency-graph/types.d.ts.map +1 -0
- package/dependency-graph/types.js +2 -0
- package/dependency-graph/types.js.map +1 -0
- package/dependency-graph/useDependencyGraph.d.ts +27 -0
- package/dependency-graph/useDependencyGraph.d.ts.map +1 -0
- package/dependency-graph/useDependencyGraph.js +129 -0
- package/dependency-graph/useDependencyGraph.js.map +1 -0
- package/empty-state/EmptyState.d.ts +29 -0
- package/empty-state/EmptyState.d.ts.map +1 -0
- package/empty-state/EmptyState.js +45 -0
- package/empty-state/EmptyState.js.map +1 -0
- package/empty-state/index.d.ts +4 -0
- package/empty-state/index.d.ts.map +1 -0
- package/empty-state/index.js +3 -0
- package/empty-state/index.js.map +1 -0
- package/empty-state/types.d.ts +73 -0
- package/empty-state/types.d.ts.map +1 -0
- package/empty-state/types.js +2 -0
- package/empty-state/types.js.map +1 -0
- package/empty-state/useEmptyState.d.ts +18 -0
- package/empty-state/useEmptyState.d.ts.map +1 -0
- package/empty-state/useEmptyState.js +72 -0
- package/empty-state/useEmptyState.js.map +1 -0
- package/execution/MessageThread.d.ts +1 -0
- package/execution/MessageThread.d.ts.map +1 -1
- package/execution/MessageThread.js +22 -12
- package/execution/MessageThread.js.map +1 -1
- package/execution/SetupProgress.d.ts +23 -9
- package/execution/SetupProgress.d.ts.map +1 -1
- package/execution/SetupProgress.js +30 -14
- package/execution/SetupProgress.js.map +1 -1
- package/execution/__tests__/thread-keys.test.js +82 -0
- package/execution/__tests__/thread-keys.test.js.map +1 -1
- package/feedback/StigmerToaster.d.ts +18 -0
- package/feedback/StigmerToaster.d.ts.map +1 -0
- package/feedback/StigmerToaster.js +31 -0
- package/feedback/StigmerToaster.js.map +1 -0
- package/feedback/index.d.ts +4 -0
- package/feedback/index.d.ts.map +1 -0
- package/feedback/index.js +3 -0
- package/feedback/index.js.map +1 -0
- package/feedback/toast.d.ts +14 -0
- package/feedback/toast.d.ts.map +1 -0
- package/feedback/toast.js +14 -0
- package/feedback/toast.js.map +1 -0
- package/feedback/types.d.ts +4 -0
- package/feedback/types.d.ts.map +1 -0
- package/feedback/types.js +2 -0
- package/feedback/types.js.map +1 -0
- package/index.d.ts +30 -10
- package/index.d.ts.map +1 -1
- package/index.js +29 -9
- package/index.js.map +1 -1
- package/inline-edit/InlineEditImage.d.ts +20 -0
- package/inline-edit/InlineEditImage.d.ts.map +1 -0
- package/inline-edit/InlineEditImage.js +85 -0
- package/inline-edit/InlineEditImage.js.map +1 -0
- package/inline-edit/InlineEditKeyValue.d.ts +29 -0
- package/inline-edit/InlineEditKeyValue.d.ts.map +1 -0
- package/inline-edit/InlineEditKeyValue.js +67 -0
- package/inline-edit/InlineEditKeyValue.js.map +1 -0
- package/inline-edit/InlineEditResourceList.d.ts +34 -0
- package/inline-edit/InlineEditResourceList.d.ts.map +1 -0
- package/inline-edit/InlineEditResourceList.js +99 -0
- package/inline-edit/InlineEditResourceList.js.map +1 -0
- package/inline-edit/InlineEditSelect.d.ts +18 -0
- package/inline-edit/InlineEditSelect.d.ts.map +1 -0
- package/inline-edit/InlineEditSelect.js +54 -0
- package/inline-edit/InlineEditSelect.js.map +1 -0
- package/inline-edit/InlineEditText.d.ts +23 -0
- package/inline-edit/InlineEditText.d.ts.map +1 -0
- package/inline-edit/InlineEditText.js +79 -0
- package/inline-edit/InlineEditText.js.map +1 -0
- package/inline-edit/InlineEditTextarea.d.ts +22 -0
- package/inline-edit/InlineEditTextarea.d.ts.map +1 -0
- package/inline-edit/InlineEditTextarea.js +83 -0
- package/inline-edit/InlineEditTextarea.js.map +1 -0
- package/inline-edit/index.d.ts +16 -0
- package/inline-edit/index.d.ts.map +1 -0
- package/inline-edit/index.js +8 -0
- package/inline-edit/index.js.map +1 -0
- package/inline-edit/types.d.ts +42 -0
- package/inline-edit/types.d.ts.map +1 -0
- package/inline-edit/types.js +2 -0
- package/inline-edit/types.js.map +1 -0
- package/inline-edit/useInlineFieldSave.d.ts +23 -0
- package/inline-edit/useInlineFieldSave.d.ts.map +1 -0
- package/inline-edit/useInlineFieldSave.js +44 -0
- package/inline-edit/useInlineFieldSave.js.map +1 -0
- package/internal/Tabs.d.ts +4 -38
- package/internal/Tabs.d.ts.map +1 -1
- package/internal/Tabs.js +3 -62
- package/internal/Tabs.js.map +1 -1
- package/library/ImportResourceDialog.d.ts +43 -0
- package/library/ImportResourceDialog.d.ts.map +1 -0
- package/library/ImportResourceDialog.js +90 -0
- package/library/ImportResourceDialog.js.map +1 -0
- package/library/index.d.ts +7 -4
- package/library/index.d.ts.map +1 -1
- package/library/index.js +4 -2
- package/library/index.js.map +1 -1
- package/library/serialize-resource-yaml.d.ts +53 -0
- package/library/serialize-resource-yaml.d.ts.map +1 -1
- package/library/serialize-resource-yaml.js +275 -0
- package/library/serialize-resource-yaml.js.map +1 -1
- package/library/useExportResource.d.ts +56 -0
- package/library/useExportResource.d.ts.map +1 -0
- package/library/useExportResource.js +137 -0
- package/library/useExportResource.js.map +1 -0
- package/library/useImportResource.d.ts +84 -0
- package/library/useImportResource.d.ts.map +1 -0
- package/library/useImportResource.js +188 -0
- package/library/useImportResource.js.map +1 -0
- package/mcp-server/McpServerCreationWizard.d.ts +55 -0
- package/mcp-server/McpServerCreationWizard.d.ts.map +1 -0
- package/mcp-server/McpServerCreationWizard.js +121 -0
- package/mcp-server/McpServerCreationWizard.js.map +1 -0
- package/mcp-server/McpServerDetailView.d.ts +21 -1
- package/mcp-server/McpServerDetailView.d.ts.map +1 -1
- package/mcp-server/McpServerDetailView.js +113 -20
- package/mcp-server/McpServerDetailView.js.map +1 -1
- package/mcp-server/index.d.ts +8 -0
- package/mcp-server/index.d.ts.map +1 -1
- package/mcp-server/index.js +4 -0
- package/mcp-server/index.js.map +1 -1
- package/mcp-server/internal/mcpServerToInput.d.ts +12 -0
- package/mcp-server/internal/mcpServerToInput.d.ts.map +1 -0
- package/mcp-server/internal/mcpServerToInput.js +81 -0
- package/mcp-server/internal/mcpServerToInput.js.map +1 -0
- package/mcp-server/steps/EnvironmentAuthStep.d.ts +15 -0
- package/mcp-server/steps/EnvironmentAuthStep.d.ts.map +1 -0
- package/mcp-server/steps/EnvironmentAuthStep.js +55 -0
- package/mcp-server/steps/EnvironmentAuthStep.js.map +1 -0
- package/mcp-server/steps/IdentityTransportStep.d.ts +19 -0
- package/mcp-server/steps/IdentityTransportStep.d.ts.map +1 -0
- package/mcp-server/steps/IdentityTransportStep.js +73 -0
- package/mcp-server/steps/IdentityTransportStep.js.map +1 -0
- package/mcp-server/steps/ReviewStep.d.ts +23 -0
- package/mcp-server/steps/ReviewStep.d.ts.map +1 -0
- package/mcp-server/steps/ReviewStep.js +137 -0
- package/mcp-server/steps/ReviewStep.js.map +1 -0
- package/mcp-server/steps/types.d.ts +56 -0
- package/mcp-server/steps/types.d.ts.map +1 -0
- package/mcp-server/steps/types.js +27 -0
- package/mcp-server/steps/types.js.map +1 -0
- package/mcp-server/useCreateMcpServer.d.ts +45 -0
- package/mcp-server/useCreateMcpServer.d.ts.map +1 -0
- package/mcp-server/useCreateMcpServer.js +50 -0
- package/mcp-server/useCreateMcpServer.js.map +1 -0
- package/mcp-server/useUpdateMcpServer.d.ts +24 -0
- package/mcp-server/useUpdateMcpServer.d.ts.map +1 -0
- package/mcp-server/useUpdateMcpServer.js +35 -0
- package/mcp-server/useUpdateMcpServer.js.map +1 -0
- package/models/registry.d.ts +4 -1
- package/models/registry.d.ts.map +1 -1
- package/models/registry.js +6 -2
- package/models/registry.js.map +1 -1
- package/package.json +8 -4
- package/provider.js +1 -1
- package/provider.js.map +1 -1
- package/resource-creation/CreationPicker.d.ts +60 -0
- package/resource-creation/CreationPicker.d.ts.map +1 -0
- package/resource-creation/CreationPicker.js +74 -0
- package/resource-creation/CreationPicker.js.map +1 -0
- package/resource-creation/StepIndicator.d.ts +28 -0
- package/resource-creation/StepIndicator.d.ts.map +1 -0
- package/resource-creation/StepIndicator.js +40 -0
- package/resource-creation/StepIndicator.js.map +1 -0
- package/resource-creation/TemplateCard.d.ts +24 -0
- package/resource-creation/TemplateCard.d.ts.map +1 -0
- package/resource-creation/TemplateCard.js +68 -0
- package/resource-creation/TemplateCard.js.map +1 -0
- package/resource-creation/TemplateGallery.d.ts +43 -0
- package/resource-creation/TemplateGallery.d.ts.map +1 -0
- package/resource-creation/TemplateGallery.js +78 -0
- package/resource-creation/TemplateGallery.js.map +1 -0
- package/resource-creation/WizardNav.d.ts +31 -0
- package/resource-creation/WizardNav.d.ts.map +1 -0
- package/resource-creation/WizardNav.js +29 -0
- package/resource-creation/WizardNav.js.map +1 -0
- package/resource-creation/WizardShell.d.ts +41 -0
- package/resource-creation/WizardShell.d.ts.map +1 -0
- package/resource-creation/WizardShell.js +55 -0
- package/resource-creation/WizardShell.js.map +1 -0
- package/resource-creation/index.d.ts +21 -0
- package/resource-creation/index.d.ts.map +1 -0
- package/resource-creation/index.js +14 -0
- package/resource-creation/index.js.map +1 -0
- package/resource-creation/templates/agent-templates.d.ts +15 -0
- package/resource-creation/templates/agent-templates.d.ts.map +1 -0
- package/resource-creation/templates/agent-templates.js +148 -0
- package/resource-creation/templates/agent-templates.js.map +1 -0
- package/resource-creation/templates/index.d.ts +5 -0
- package/resource-creation/templates/index.d.ts.map +1 -0
- package/resource-creation/templates/index.js +5 -0
- package/resource-creation/templates/index.js.map +1 -0
- package/resource-creation/templates/mcp-server-templates.d.ts +15 -0
- package/resource-creation/templates/mcp-server-templates.d.ts.map +1 -0
- package/resource-creation/templates/mcp-server-templates.js +92 -0
- package/resource-creation/templates/mcp-server-templates.js.map +1 -0
- package/resource-creation/templates/types.d.ts +48 -0
- package/resource-creation/templates/types.d.ts.map +1 -0
- package/resource-creation/templates/types.js +16 -0
- package/resource-creation/templates/types.js.map +1 -0
- package/resource-creation/types.d.ts +88 -0
- package/resource-creation/types.d.ts.map +1 -0
- package/resource-creation/types.js +2 -0
- package/resource-creation/types.js.map +1 -0
- package/resource-creation/useTemplateFilter.d.ts +43 -0
- package/resource-creation/useTemplateFilter.d.ts.map +1 -0
- package/resource-creation/useTemplateFilter.js +73 -0
- package/resource-creation/useTemplateFilter.js.map +1 -0
- package/resource-creation/useWizardState.d.ts +67 -0
- package/resource-creation/useWizardState.d.ts.map +1 -0
- package/resource-creation/useWizardState.js +143 -0
- package/resource-creation/useWizardState.js.map +1 -0
- package/resource-detail/ConfirmDialog.d.ts +44 -0
- package/resource-detail/ConfirmDialog.d.ts.map +1 -0
- package/resource-detail/ConfirmDialog.js +62 -0
- package/resource-detail/ConfirmDialog.js.map +1 -0
- package/resource-detail/ResourceActionBar.d.ts +42 -0
- package/resource-detail/ResourceActionBar.d.ts.map +1 -0
- package/resource-detail/ResourceActionBar.js +64 -0
- package/resource-detail/ResourceActionBar.js.map +1 -0
- package/resource-detail/ResourceDetailShell.d.ts +36 -0
- package/resource-detail/ResourceDetailShell.d.ts.map +1 -0
- package/resource-detail/ResourceDetailShell.js +65 -0
- package/resource-detail/ResourceDetailShell.js.map +1 -0
- package/resource-detail/Section.d.ts +18 -0
- package/resource-detail/Section.d.ts.map +1 -0
- package/resource-detail/Section.js +18 -0
- package/resource-detail/Section.js.map +1 -0
- package/resource-detail/index.d.ts +15 -0
- package/resource-detail/index.d.ts.map +1 -0
- package/resource-detail/index.js +10 -0
- package/resource-detail/index.js.map +1 -0
- package/resource-detail/types.d.ts +146 -0
- package/resource-detail/types.d.ts.map +1 -0
- package/resource-detail/types.js +2 -0
- package/resource-detail/types.js.map +1 -0
- package/resource-detail/useConfirmAction.d.ts +41 -0
- package/resource-detail/useConfirmAction.d.ts.map +1 -0
- package/resource-detail/useConfirmAction.js +30 -0
- package/resource-detail/useConfirmAction.js.map +1 -0
- package/resource-detail/useCopyResource.d.ts +28 -0
- package/resource-detail/useCopyResource.d.ts.map +1 -0
- package/resource-detail/useCopyResource.js +46 -0
- package/resource-detail/useCopyResource.js.map +1 -0
- package/resource-detail/useDeleteResource.d.ts +40 -0
- package/resource-detail/useDeleteResource.d.ts.map +1 -0
- package/resource-detail/useDeleteResource.js +83 -0
- package/resource-detail/useDeleteResource.js.map +1 -0
- package/resource-detail/useDetailTabs.d.ts +46 -0
- package/resource-detail/useDetailTabs.d.ts.map +1 -0
- package/resource-detail/useDetailTabs.js +47 -0
- package/resource-detail/useDetailTabs.js.map +1 -0
- package/resource-workbench/components/BulkActionBar.d.ts +36 -0
- package/resource-workbench/components/BulkActionBar.d.ts.map +1 -0
- package/resource-workbench/components/BulkActionBar.js +35 -0
- package/resource-workbench/components/BulkActionBar.js.map +1 -0
- package/resource-workbench/components/ColumnHeader.d.ts +23 -0
- package/resource-workbench/components/ColumnHeader.d.ts.map +1 -0
- package/resource-workbench/components/ColumnHeader.js +25 -0
- package/resource-workbench/components/ColumnHeader.js.map +1 -0
- package/resource-workbench/components/FilterBar.d.ts +33 -0
- package/resource-workbench/components/FilterBar.d.ts.map +1 -0
- package/resource-workbench/components/FilterBar.js +72 -0
- package/resource-workbench/components/FilterBar.js.map +1 -0
- package/resource-workbench/components/ResourceAvatar.d.ts +29 -0
- package/resource-workbench/components/ResourceAvatar.d.ts.map +1 -0
- package/resource-workbench/components/ResourceAvatar.js +51 -0
- package/resource-workbench/components/ResourceAvatar.js.map +1 -0
- package/resource-workbench/components/ResourceCards.d.ts +39 -0
- package/resource-workbench/components/ResourceCards.d.ts.map +1 -0
- package/resource-workbench/components/ResourceCards.js +41 -0
- package/resource-workbench/components/ResourceCards.js.map +1 -0
- package/resource-workbench/components/ResourceInspector.d.ts +26 -0
- package/resource-workbench/components/ResourceInspector.d.ts.map +1 -0
- package/resource-workbench/components/ResourceInspector.js +22 -0
- package/resource-workbench/components/ResourceInspector.js.map +1 -0
- package/resource-workbench/components/ResourceList.d.ts +39 -0
- package/resource-workbench/components/ResourceList.d.ts.map +1 -0
- package/resource-workbench/components/ResourceList.js +41 -0
- package/resource-workbench/components/ResourceList.js.map +1 -0
- package/resource-workbench/components/ResourceTable.d.ts +47 -0
- package/resource-workbench/components/ResourceTable.d.ts.map +1 -0
- package/resource-workbench/components/ResourceTable.js +78 -0
- package/resource-workbench/components/ResourceTable.js.map +1 -0
- package/resource-workbench/components/ResourceWorkbench.d.ts +131 -0
- package/resource-workbench/components/ResourceWorkbench.d.ts.map +1 -0
- package/resource-workbench/components/ResourceWorkbench.js +170 -0
- package/resource-workbench/components/ResourceWorkbench.js.map +1 -0
- package/resource-workbench/components/SelectionCheckbox.d.ts +24 -0
- package/resource-workbench/components/SelectionCheckbox.d.ts.map +1 -0
- package/resource-workbench/components/SelectionCheckbox.js +16 -0
- package/resource-workbench/components/SelectionCheckbox.js.map +1 -0
- package/resource-workbench/components/StatusBadge.d.ts +31 -0
- package/resource-workbench/components/StatusBadge.d.ts.map +1 -0
- package/resource-workbench/components/StatusBadge.js +75 -0
- package/resource-workbench/components/StatusBadge.js.map +1 -0
- package/resource-workbench/components/ViewSwitcher.d.ts +21 -0
- package/resource-workbench/components/ViewSwitcher.d.ts.map +1 -0
- package/resource-workbench/components/ViewSwitcher.js +37 -0
- package/resource-workbench/components/ViewSwitcher.js.map +1 -0
- package/resource-workbench/hooks/useResourceCollection.d.ts +93 -0
- package/resource-workbench/hooks/useResourceCollection.d.ts.map +1 -0
- package/resource-workbench/hooks/useResourceCollection.js +133 -0
- package/resource-workbench/hooks/useResourceCollection.js.map +1 -0
- package/resource-workbench/hooks/useResourceFilters.d.ts +73 -0
- package/resource-workbench/hooks/useResourceFilters.d.ts.map +1 -0
- package/resource-workbench/hooks/useResourceFilters.js +105 -0
- package/resource-workbench/hooks/useResourceFilters.js.map +1 -0
- package/resource-workbench/hooks/useResourceSelection.d.ts +44 -0
- package/resource-workbench/hooks/useResourceSelection.d.ts.map +1 -0
- package/resource-workbench/hooks/useResourceSelection.js +123 -0
- package/resource-workbench/hooks/useResourceSelection.js.map +1 -0
- package/resource-workbench/hooks/useViewPreference.d.ts +32 -0
- package/resource-workbench/hooks/useViewPreference.d.ts.map +1 -0
- package/resource-workbench/hooks/useViewPreference.js +60 -0
- package/resource-workbench/hooks/useViewPreference.js.map +1 -0
- package/resource-workbench/index.d.ts +34 -0
- package/resource-workbench/index.d.ts.map +1 -0
- package/resource-workbench/index.js +19 -0
- package/resource-workbench/index.js.map +1 -0
- package/resource-workbench/types.d.ts +165 -0
- package/resource-workbench/types.d.ts.map +1 -0
- package/resource-workbench/types.js +2 -0
- package/resource-workbench/types.js.map +1 -0
- package/runner/RunnerDetailView.d.ts +44 -0
- package/runner/RunnerDetailView.d.ts.map +1 -0
- package/runner/RunnerDetailView.js +154 -0
- package/runner/RunnerDetailView.js.map +1 -0
- package/runner/RunnerListPanel.d.ts +26 -1
- package/runner/RunnerListPanel.d.ts.map +1 -1
- package/runner/RunnerListPanel.js +68 -46
- package/runner/RunnerListPanel.js.map +1 -1
- package/runner/index.d.ts +7 -1
- package/runner/index.d.ts.map +1 -1
- package/runner/index.js +3 -0
- package/runner/index.js.map +1 -1
- package/runner/shared.d.ts +31 -0
- package/runner/shared.d.ts.map +1 -0
- package/runner/shared.js +55 -0
- package/runner/shared.js.map +1 -0
- package/runner/useRunner.d.ts +37 -0
- package/runner/useRunner.d.ts.map +1 -0
- package/runner/useRunner.js +24 -0
- package/runner/useRunner.js.map +1 -0
- package/session/__tests__/group-sessions.test.js +3 -3
- package/session/__tests__/group-sessions.test.js.map +1 -1
- package/skill/SkillDetailView.d.ts +70 -7
- package/skill/SkillDetailView.d.ts.map +1 -1
- package/skill/SkillDetailView.js +107 -39
- package/skill/SkillDetailView.js.map +1 -1
- package/skill/SkillDiffDialog.d.ts +42 -0
- package/skill/SkillDiffDialog.d.ts.map +1 -0
- package/skill/SkillDiffDialog.js +72 -0
- package/skill/SkillDiffDialog.js.map +1 -0
- package/skill/SkillFileBrowser.d.ts +31 -0
- package/skill/SkillFileBrowser.d.ts.map +1 -0
- package/skill/SkillFileBrowser.js +105 -0
- package/skill/SkillFileBrowser.js.map +1 -0
- package/skill/SkillUploader.d.ts +39 -0
- package/skill/SkillUploader.d.ts.map +1 -0
- package/skill/SkillUploader.js +141 -0
- package/skill/SkillUploader.js.map +1 -0
- package/skill/index.d.ts +18 -0
- package/skill/index.d.ts.map +1 -1
- package/skill/index.js +9 -0
- package/skill/index.js.map +1 -1
- package/skill/internal/computeArtifactHash.d.ts +9 -0
- package/skill/internal/computeArtifactHash.d.ts.map +1 -0
- package/skill/internal/computeArtifactHash.js +14 -0
- package/skill/internal/computeArtifactHash.js.map +1 -0
- package/skill/internal/fetchAndUnpackArtifact.d.ts +16 -0
- package/skill/internal/fetchAndUnpackArtifact.d.ts.map +1 -0
- package/skill/internal/fetchAndUnpackArtifact.js +34 -0
- package/skill/internal/fetchAndUnpackArtifact.js.map +1 -0
- package/skill/usePushSkill.d.ts +53 -0
- package/skill/usePushSkill.d.ts.map +1 -0
- package/skill/usePushSkill.js +57 -0
- package/skill/usePushSkill.js.map +1 -0
- package/skill/useSkillArtifact.d.ts +37 -0
- package/skill/useSkillArtifact.d.ts.map +1 -0
- package/skill/useSkillArtifact.js +76 -0
- package/skill/useSkillArtifact.js.map +1 -0
- package/skill/useSkillDiff.d.ts +31 -0
- package/skill/useSkillDiff.d.ts.map +1 -0
- package/skill/useSkillDiff.js +97 -0
- package/skill/useSkillDiff.js.map +1 -0
- package/skill/useSkillDuplicateCheck.d.ts +34 -0
- package/skill/useSkillDuplicateCheck.d.ts.map +1 -0
- package/skill/useSkillDuplicateCheck.js +58 -0
- package/skill/useSkillDuplicateCheck.js.map +1 -0
- package/skill/useSkillUpload.d.ts +69 -0
- package/skill/useSkillUpload.d.ts.map +1 -0
- package/skill/useSkillUpload.js +157 -0
- package/skill/useSkillUpload.js.map +1 -0
- package/skill/useSkillVersions.d.ts +46 -0
- package/skill/useSkillVersions.d.ts.map +1 -0
- package/skill/useSkillVersions.js +104 -0
- package/skill/useSkillVersions.js.map +1 -0
- package/src/action-menu/ActionMenu.tsx +151 -0
- package/src/action-menu/index.ts +9 -0
- package/src/action-menu/types.ts +70 -0
- package/src/agent/AgentCreationWizard.tsx +201 -0
- package/src/agent/AgentDetailView.tsx +817 -321
- package/src/agent/index.ts +16 -0
- package/src/agent/internal/agentToInput.ts +95 -0
- package/src/agent/steps/CapabilitiesStep.tsx +363 -0
- package/src/agent/steps/IdentityStep.tsx +259 -0
- package/src/agent/steps/ReviewStep.tsx +211 -0
- package/src/agent/steps/types.ts +53 -0
- package/src/agent/useCreateAgent.ts +76 -0
- package/src/agent/useUpdateAgent.ts +55 -0
- package/src/dependency-graph/DependencyGraph.tsx +153 -0
- package/src/dependency-graph/DependencyTreeNode.tsx +282 -0
- package/src/dependency-graph/index.ts +15 -0
- package/src/dependency-graph/types.ts +131 -0
- package/src/dependency-graph/useDependencyGraph.ts +158 -0
- package/src/empty-state/EmptyState.tsx +90 -0
- package/src/empty-state/index.ts +9 -0
- package/src/empty-state/types.ts +81 -0
- package/src/empty-state/useEmptyState.ts +85 -0
- package/src/execution/MessageThread.tsx +26 -15
- package/src/execution/SetupProgress.tsx +35 -14
- package/src/execution/__tests__/thread-keys.test.ts +101 -0
- package/src/feedback/StigmerToaster.tsx +45 -0
- package/src/feedback/index.ts +3 -0
- package/src/feedback/toast.ts +13 -0
- package/src/feedback/types.ts +7 -0
- package/src/index.ts +270 -8
- package/src/inline-edit/InlineEditImage.tsx +208 -0
- package/src/inline-edit/InlineEditKeyValue.tsx +278 -0
- package/src/inline-edit/InlineEditResourceList.tsx +325 -0
- package/src/inline-edit/InlineEditSelect.tsx +150 -0
- package/src/inline-edit/InlineEditText.tsx +211 -0
- package/src/inline-edit/InlineEditTextarea.tsx +209 -0
- package/src/inline-edit/index.ts +28 -0
- package/src/inline-edit/types.ts +47 -0
- package/src/inline-edit/useInlineFieldSave.ts +62 -0
- package/src/internal/Tabs.tsx +4 -164
- package/src/library/ImportResourceDialog.tsx +227 -0
- package/src/library/index.ts +18 -8
- package/src/library/serialize-resource-yaml.ts +356 -0
- package/src/library/useExportResource.ts +183 -0
- package/src/library/useImportResource.ts +253 -0
- package/src/mcp-server/McpServerCreationWizard.tsx +206 -0
- package/src/mcp-server/McpServerDetailView.tsx +392 -105
- package/src/mcp-server/index.ts +16 -0
- package/src/mcp-server/internal/mcpServerToInput.ts +95 -0
- package/src/mcp-server/steps/EnvironmentAuthStep.tsx +462 -0
- package/src/mcp-server/steps/IdentityTransportStep.tsx +531 -0
- package/src/mcp-server/steps/ReviewStep.tsx +297 -0
- package/src/mcp-server/steps/types.ts +85 -0
- package/src/mcp-server/useCreateMcpServer.ts +76 -0
- package/src/mcp-server/useUpdateMcpServer.ts +55 -0
- package/src/models/registry.ts +10 -2
- package/src/provider.tsx +1 -1
- package/src/resource-creation/CreationPicker.tsx +292 -0
- package/src/resource-creation/StepIndicator.tsx +156 -0
- package/src/resource-creation/TemplateCard.tsx +143 -0
- package/src/resource-creation/TemplateGallery.tsx +222 -0
- package/src/resource-creation/WizardNav.tsx +163 -0
- package/src/resource-creation/WizardShell.tsx +124 -0
- package/src/resource-creation/index.ts +45 -0
- package/src/resource-creation/templates/agent-templates.ts +160 -0
- package/src/resource-creation/templates/index.ts +7 -0
- package/src/resource-creation/templates/mcp-server-templates.ts +106 -0
- package/src/resource-creation/templates/types.ts +64 -0
- package/src/resource-creation/types.ts +105 -0
- package/src/resource-creation/useTemplateFilter.ts +117 -0
- package/src/resource-creation/useWizardState.ts +223 -0
- package/src/resource-detail/ConfirmDialog.tsx +127 -0
- package/src/resource-detail/ResourceActionBar.tsx +157 -0
- package/src/resource-detail/ResourceDetailShell.tsx +184 -0
- package/src/resource-detail/Section.tsx +78 -0
- package/src/resource-detail/index.ts +34 -0
- package/src/resource-detail/types.ts +177 -0
- package/src/resource-detail/useConfirmAction.ts +70 -0
- package/src/resource-detail/useCopyResource.ts +74 -0
- package/src/resource-detail/useDeleteResource.ts +110 -0
- package/src/resource-detail/useDetailTabs.ts +93 -0
- package/src/resource-workbench/components/BulkActionBar.tsx +122 -0
- package/src/resource-workbench/components/ColumnHeader.tsx +105 -0
- package/src/resource-workbench/components/FilterBar.tsx +173 -0
- package/src/resource-workbench/components/ResourceAvatar.tsx +109 -0
- package/src/resource-workbench/components/ResourceCards.tsx +126 -0
- package/src/resource-workbench/components/ResourceInspector.tsx +88 -0
- package/src/resource-workbench/components/ResourceList.tsx +121 -0
- package/src/resource-workbench/components/ResourceTable.tsx +222 -0
- package/src/resource-workbench/components/ResourceWorkbench.tsx +695 -0
- package/src/resource-workbench/components/SelectionCheckbox.tsx +52 -0
- package/src/resource-workbench/components/StatusBadge.tsx +119 -0
- package/src/resource-workbench/components/ViewSwitcher.tsx +135 -0
- package/src/resource-workbench/hooks/useResourceCollection.ts +261 -0
- package/src/resource-workbench/hooks/useResourceFilters.ts +216 -0
- package/src/resource-workbench/hooks/useResourceSelection.ts +178 -0
- package/src/resource-workbench/hooks/useViewPreference.ts +75 -0
- package/src/resource-workbench/index.ts +73 -0
- package/src/resource-workbench/types.ts +220 -0
- package/src/runner/RunnerDetailView.tsx +410 -0
- package/src/runner/RunnerListPanel.tsx +126 -111
- package/src/runner/index.ts +13 -1
- package/src/runner/shared.tsx +124 -0
- package/src/runner/useRunner.ts +59 -0
- package/src/session/__tests__/group-sessions.test.ts +5 -3
- package/src/skill/SkillDetailView.tsx +371 -165
- package/src/skill/SkillDiffDialog.tsx +213 -0
- package/src/skill/SkillFileBrowser.tsx +289 -0
- package/src/skill/SkillUploader.tsx +481 -0
- package/src/skill/index.ts +34 -0
- package/src/skill/internal/computeArtifactHash.ts +13 -0
- package/src/skill/internal/fetchAndUnpackArtifact.ts +48 -0
- package/src/skill/usePushSkill.ts +101 -0
- package/src/skill/useSkillArtifact.ts +107 -0
- package/src/skill/useSkillDiff.ts +128 -0
- package/src/skill/useSkillDuplicateCheck.ts +92 -0
- package/src/skill/useSkillUpload.ts +231 -0
- package/src/skill/useSkillVersions.ts +165 -0
- package/src/styles.css +28 -0
- package/src/tabs/Tabs.tsx +184 -0
- package/src/tabs/index.ts +2 -0
- package/src/version-history/DiffFileList.tsx +111 -0
- package/src/version-history/DiffSummary.tsx +61 -0
- package/src/version-history/DiffViewer.tsx +163 -0
- package/src/version-history/MultiFileDiffView.tsx +114 -0
- package/src/version-history/VersionTimeline.tsx +232 -0
- package/src/version-history/VersionTimelineEntry.tsx +254 -0
- package/src/version-history/computeDiff.ts +61 -0
- package/src/version-history/computeMultiFileDiff.ts +97 -0
- package/src/version-history/index.ts +22 -0
- package/src/version-history/types.ts +129 -0
- package/styles.css +1 -1
- package/tabs/Tabs.d.ts +58 -0
- package/tabs/Tabs.d.ts.map +1 -0
- package/tabs/Tabs.js +80 -0
- package/tabs/Tabs.js.map +1 -0
- package/tabs/index.d.ts +3 -0
- package/tabs/index.d.ts.map +1 -0
- package/tabs/index.js +2 -0
- package/tabs/index.js.map +1 -0
- package/version-history/DiffFileList.d.ts +22 -0
- package/version-history/DiffFileList.d.ts.map +1 -0
- package/version-history/DiffFileList.js +37 -0
- package/version-history/DiffFileList.js.map +1 -0
- package/version-history/DiffSummary.d.ts +21 -0
- package/version-history/DiffSummary.d.ts.map +1 -0
- package/version-history/DiffSummary.js +16 -0
- package/version-history/DiffSummary.js.map +1 -0
- package/version-history/DiffViewer.d.ts +31 -0
- package/version-history/DiffViewer.d.ts.map +1 -0
- package/version-history/DiffViewer.js +60 -0
- package/version-history/DiffViewer.js.map +1 -0
- package/version-history/MultiFileDiffView.d.ts +30 -0
- package/version-history/MultiFileDiffView.d.ts.map +1 -0
- package/version-history/MultiFileDiffView.js +40 -0
- package/version-history/MultiFileDiffView.js.map +1 -0
- package/version-history/VersionTimeline.d.ts +29 -0
- package/version-history/VersionTimeline.d.ts.map +1 -0
- package/version-history/VersionTimeline.js +87 -0
- package/version-history/VersionTimeline.js.map +1 -0
- package/version-history/VersionTimelineEntry.d.ts +22 -0
- package/version-history/VersionTimelineEntry.d.ts.map +1 -0
- package/version-history/VersionTimelineEntry.js +98 -0
- package/version-history/VersionTimelineEntry.js.map +1 -0
- package/version-history/computeDiff.d.ts +16 -0
- package/version-history/computeDiff.d.ts.map +1 -0
- package/version-history/computeDiff.js +54 -0
- package/version-history/computeDiff.js.map +1 -0
- package/version-history/computeMultiFileDiff.d.ts +15 -0
- package/version-history/computeMultiFileDiff.d.ts.map +1 -0
- package/version-history/computeMultiFileDiff.js +83 -0
- package/version-history/computeMultiFileDiff.js.map +1 -0
- package/version-history/index.d.ts +14 -0
- package/version-history/index.d.ts.map +1 -0
- package/version-history/index.js +9 -0
- package/version-history/index.js.map +1 -0
- package/version-history/types.d.ts +106 -0
- package/version-history/types.d.ts.map +1 -0
- package/version-history/types.js +2 -0
- package/version-history/types.js.map +1 -0
- package/library/ResourceListView.d.ts +0 -174
- package/library/ResourceListView.d.ts.map +0 -1
- package/library/ResourceListView.js +0 -318
- package/library/ResourceListView.js.map +0 -1
- package/src/library/ResourceListView.tsx +0 -956
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo, useCallback, useState, useRef, useEffect } from "react";
|
|
3
|
+
import { getCoreRowModel, getSortedRowModel, useReactTable, } from "@tanstack/react-table";
|
|
4
|
+
import { useFetch } from "../../internal/useFetch";
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Hook
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
const DEFAULT_PAGE_SIZE = 20;
|
|
9
|
+
const INITIAL_DATA = {
|
|
10
|
+
entries: [],
|
|
11
|
+
totalCount: 0,
|
|
12
|
+
totalPages: 0,
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Headless hook that manages resource collection state: data fetching,
|
|
16
|
+
* sorting, selection, and pagination.
|
|
17
|
+
*
|
|
18
|
+
* Wraps `useFetch` for data and `@tanstack/react-table` for table state
|
|
19
|
+
* (sorting, selection, column visibility). The hook itself produces no
|
|
20
|
+
* DOM — it returns data, state, and a TanStack Table instance that view
|
|
21
|
+
* components (`ResourceTable`, `ResourceCards`, `ResourceList`) consume.
|
|
22
|
+
*
|
|
23
|
+
* Platform builders who want full rendering control use this hook
|
|
24
|
+
* directly. The `ResourceWorkbench` shell composes it internally.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* const collection = useResourceCollection({
|
|
29
|
+
* listFn: (params) => stigmer.agent.list(params),
|
|
30
|
+
* org: "acme",
|
|
31
|
+
* query: debouncedQuery,
|
|
32
|
+
* page: 1,
|
|
33
|
+
* columns: agentColumns,
|
|
34
|
+
* });
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export function useResourceCollection(options) {
|
|
38
|
+
const { listFn, org, query = "", scope = "org", page = 1, pageSize = DEFAULT_PAGE_SIZE, sort = null, onSortChange, columns = [], enableSelection = false, } = options;
|
|
39
|
+
// --- Data fetching via useFetch -----------------------------------------
|
|
40
|
+
const { data, isLoading, isRefetching, error, refetch } = useFetch(listFn && org
|
|
41
|
+
? async () => {
|
|
42
|
+
const params = {
|
|
43
|
+
org,
|
|
44
|
+
query: query || undefined,
|
|
45
|
+
excludePublic: false,
|
|
46
|
+
crossOrgPublic: scope === "all",
|
|
47
|
+
page: { num: page, size: pageSize },
|
|
48
|
+
};
|
|
49
|
+
const result = await listFn(params);
|
|
50
|
+
return {
|
|
51
|
+
entries: [...result.entries],
|
|
52
|
+
totalCount: result.totalCount,
|
|
53
|
+
totalPages: result.totalPages,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
: null, [listFn, org, query, scope, page, pageSize], INITIAL_DATA);
|
|
57
|
+
const items = data.entries;
|
|
58
|
+
// --- TanStack Table sorting bridge --------------------------------------
|
|
59
|
+
const sortingState = useMemo(() => {
|
|
60
|
+
if (!sort)
|
|
61
|
+
return [];
|
|
62
|
+
return [{ id: sort.id, desc: sort.direction === "desc" }];
|
|
63
|
+
}, [sort]);
|
|
64
|
+
const onSortChangeRef = useRef(onSortChange);
|
|
65
|
+
onSortChangeRef.current = onSortChange;
|
|
66
|
+
const handleSortingChange = useCallback((updater) => {
|
|
67
|
+
const next = typeof updater === "function" ? updater(sortingState) : updater;
|
|
68
|
+
if (next.length === 0) {
|
|
69
|
+
onSortChangeRef.current?.(null);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
const col = next[0];
|
|
73
|
+
onSortChangeRef.current?.({
|
|
74
|
+
id: col.id,
|
|
75
|
+
direction: (col.desc ? "desc" : "asc"),
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
}, [sortingState]);
|
|
79
|
+
// --- Row selection state ------------------------------------------------
|
|
80
|
+
const [rowSelection, setRowSelection] = useState({});
|
|
81
|
+
// Clear selection when page, query, or scope changes to prevent stale refs.
|
|
82
|
+
const clearKey = `${page}-${query}-${scope}`;
|
|
83
|
+
const prevClearKey = useRef(clearKey);
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (prevClearKey.current !== clearKey) {
|
|
86
|
+
prevClearKey.current = clearKey;
|
|
87
|
+
setRowSelection({});
|
|
88
|
+
}
|
|
89
|
+
}, [clearKey]);
|
|
90
|
+
// --- TanStack Table column conversion -----------------------------------
|
|
91
|
+
const tanstackColumns = useMemo(() => {
|
|
92
|
+
return columns.map((col) => ({
|
|
93
|
+
id: col.id,
|
|
94
|
+
header: col.header,
|
|
95
|
+
cell: (info) => col.cell(info.row.original),
|
|
96
|
+
enableSorting: col.sortable ?? false,
|
|
97
|
+
size: col.minWidth,
|
|
98
|
+
minSize: col.minWidth,
|
|
99
|
+
}));
|
|
100
|
+
}, [columns]);
|
|
101
|
+
// --- TanStack Table instance -------------------------------------------
|
|
102
|
+
const table = useReactTable({
|
|
103
|
+
data: items,
|
|
104
|
+
columns: tanstackColumns,
|
|
105
|
+
state: {
|
|
106
|
+
sorting: sortingState,
|
|
107
|
+
rowSelection,
|
|
108
|
+
},
|
|
109
|
+
onSortingChange: handleSortingChange,
|
|
110
|
+
onRowSelectionChange: enableSelection ? setRowSelection : undefined,
|
|
111
|
+
getCoreRowModel: getCoreRowModel(),
|
|
112
|
+
getSortedRowModel: getSortedRowModel(),
|
|
113
|
+
getRowId: (row) => row.id ?? String(items.indexOf(row)),
|
|
114
|
+
manualPagination: true,
|
|
115
|
+
manualSorting: true,
|
|
116
|
+
enableRowSelection: enableSelection,
|
|
117
|
+
});
|
|
118
|
+
const tableOrNull = tanstackColumns.length > 0 ? table : null;
|
|
119
|
+
return {
|
|
120
|
+
items,
|
|
121
|
+
totalCount: data.totalCount,
|
|
122
|
+
totalPages: data.totalPages,
|
|
123
|
+
currentPage: page,
|
|
124
|
+
isLoading,
|
|
125
|
+
isRefetching,
|
|
126
|
+
error,
|
|
127
|
+
refetch,
|
|
128
|
+
table: tableOrNull,
|
|
129
|
+
rowSelection,
|
|
130
|
+
setRowSelection,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=useResourceCollection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceCollection.js","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useResourceCollection.ts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AAY;SACb;QACD,eAAe,EAAE,mBAAmB;QACpC,oBAAoB,EAAE,eAAe,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;QACnE,eAAe,EAAE,eAAe,EAAE;QAClC,iBAAiB,EAAE,iBAAiB,EAAE;QACtC,QAAQ,EAAE,CAAC,GAAG,EAAE,EAAE,CAAE,GAAoB,CAAC,EAAE,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,GAAY,CAAC,CAAC;QAClF,gBAAgB,EAAE,IAAI;QACtB,aAAa,EAAE,IAAI;QACnB,kBAAkB,EAAE,eAAe;KACpC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,eAAe,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAE9D,OAAO;QACL,KAAK;QACL,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,WAAW,EAAE,IAAI;QACjB,SAAS;QACT,YAAY;QACZ,KAAK;QACL,OAAO;QACP,KAAK,EAAE,WAAW;QAClB,YAAY;QACZ,eAAe;KAChB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { FilterValue, FilterDef, SortValue, SortDef } from "../types";
|
|
2
|
+
/** Options for {@link useResourceFilters}. */
|
|
3
|
+
export interface UseResourceFiltersOptions {
|
|
4
|
+
/** Available filter definitions. Determines which properties can be filtered. */
|
|
5
|
+
readonly filterDefs?: readonly FilterDef[];
|
|
6
|
+
/** Available sort definitions. Determines which properties can be sorted. */
|
|
7
|
+
readonly sortDefs?: readonly SortDef[];
|
|
8
|
+
/** Initial active filters (e.g. restored from URL params on mount). */
|
|
9
|
+
readonly initialFilters?: readonly FilterValue[];
|
|
10
|
+
/** Initial active sort (e.g. restored from URL params on mount). */
|
|
11
|
+
readonly initialSort?: SortValue | null;
|
|
12
|
+
/** Initial search query (e.g. restored from URL params on mount). */
|
|
13
|
+
readonly initialQuery?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Called whenever filter, sort, or query state changes. The consumer
|
|
16
|
+
* uses this to sync state to URL search params or any other
|
|
17
|
+
* persistence layer. The hook itself has zero router dependency.
|
|
18
|
+
*/
|
|
19
|
+
readonly onStateChange?: (state: FilterSortState) => void;
|
|
20
|
+
/** Debounce delay in milliseconds for the search query. @default 300 */
|
|
21
|
+
readonly queryDebounceMs?: number;
|
|
22
|
+
}
|
|
23
|
+
/** Serializable snapshot of filter + sort + query state. */
|
|
24
|
+
export interface FilterSortState {
|
|
25
|
+
readonly filters: readonly FilterValue[];
|
|
26
|
+
readonly sort: SortValue | null;
|
|
27
|
+
readonly query: string;
|
|
28
|
+
}
|
|
29
|
+
/** Return value of {@link useResourceFilters}. */
|
|
30
|
+
export interface UseResourceFiltersReturn {
|
|
31
|
+
/** Current active filters. */
|
|
32
|
+
readonly filters: readonly FilterValue[];
|
|
33
|
+
/** Add a filter. If a filter with the same `filterId` + `operator` exists, it is replaced. */
|
|
34
|
+
readonly addFilter: (filter: FilterValue) => void;
|
|
35
|
+
/** Remove a specific filter by its `filterId`. Removes all operators for that filter. */
|
|
36
|
+
readonly removeFilter: (filterId: string) => void;
|
|
37
|
+
/** Remove all active filters. */
|
|
38
|
+
readonly clearFilters: () => void;
|
|
39
|
+
/** Current active sort, or `null` if unsorted. */
|
|
40
|
+
readonly sort: SortValue | null;
|
|
41
|
+
/** Set the active sort. Pass `null` to clear sorting. */
|
|
42
|
+
readonly setSort: (sort: SortValue | null) => void;
|
|
43
|
+
/** The raw search query as typed by the user. */
|
|
44
|
+
readonly query: string;
|
|
45
|
+
/** The debounced search query (safe to pass to data-fetching hooks). */
|
|
46
|
+
readonly debouncedQuery: string;
|
|
47
|
+
/** Update the raw search query. Debouncing is handled internally. */
|
|
48
|
+
readonly setQuery: (query: string) => void;
|
|
49
|
+
/** `true` when any filters are active. */
|
|
50
|
+
readonly hasActiveFilters: boolean;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Headless hook that manages filter, sort, and search query state for
|
|
54
|
+
* a resource collection.
|
|
55
|
+
*
|
|
56
|
+
* State changes are communicated to the consumer via `onStateChange`
|
|
57
|
+
* so they can be synced to URL search params. The hook itself has
|
|
58
|
+
* **zero router dependency** (DD-004 compliance).
|
|
59
|
+
*
|
|
60
|
+
* Platform builders use this alongside {@link useResourceCollection}
|
|
61
|
+
* for full control. The `ResourceWorkbench` shell composes both.
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```tsx
|
|
65
|
+
* const filters = useResourceFilters({
|
|
66
|
+
* filterDefs: agentFilterDefs,
|
|
67
|
+
* sortDefs: agentSortDefs,
|
|
68
|
+
* onStateChange: (state) => syncToUrl(state),
|
|
69
|
+
* });
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
72
|
+
export declare function useResourceFilters(options?: UseResourceFiltersOptions): UseResourceFiltersReturn;
|
|
73
|
+
//# sourceMappingURL=useResourceFilters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceFilters.d.ts","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useResourceFilters.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,SAAS,EACT,OAAO,EACR,MAAM,UAAU,CAAC;AAMlB,8CAA8C;AAC9C,MAAM,WAAW,yBAAyB;IACxC,iFAAiF;IACjF,QAAQ,CAAC,UAAU,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC;IAC3C,6EAA6E;IAC7E,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,OAAO,EAAE,CAAC;IACvC,uEAAuE;IACvE,QAAQ,CAAC,cAAc,CAAC,EAAE,SAAS,WAAW,EAAE,CAAC;IACjD,oEAAoE;IACpE,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACxC,qEAAqE;IACrE,QAAQ,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;AACH,wBAAgB,kBAAkB,CAChC,OAAO,GAAE,yBAA8B,GACtC,wBAAwB,CAoH1B"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useRef, useState } from "react";
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Hook
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
const DEFAULT_DEBOUNCE_MS = 300;
|
|
7
|
+
/**
|
|
8
|
+
* Headless hook that manages filter, sort, and search query state for
|
|
9
|
+
* a resource collection.
|
|
10
|
+
*
|
|
11
|
+
* State changes are communicated to the consumer via `onStateChange`
|
|
12
|
+
* so they can be synced to URL search params. The hook itself has
|
|
13
|
+
* **zero router dependency** (DD-004 compliance).
|
|
14
|
+
*
|
|
15
|
+
* Platform builders use this alongside {@link useResourceCollection}
|
|
16
|
+
* for full control. The `ResourceWorkbench` shell composes both.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```tsx
|
|
20
|
+
* const filters = useResourceFilters({
|
|
21
|
+
* filterDefs: agentFilterDefs,
|
|
22
|
+
* sortDefs: agentSortDefs,
|
|
23
|
+
* onStateChange: (state) => syncToUrl(state),
|
|
24
|
+
* });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function useResourceFilters(options = {}) {
|
|
28
|
+
const { initialFilters = [], initialSort = null, initialQuery = "", onStateChange, queryDebounceMs = DEFAULT_DEBOUNCE_MS, } = options;
|
|
29
|
+
const [filters, setFilters] = useState(initialFilters);
|
|
30
|
+
const [sort, setSortState] = useState(initialSort);
|
|
31
|
+
const [query, setQueryState] = useState(initialQuery);
|
|
32
|
+
const [debouncedQuery, setDebouncedQuery] = useState(initialQuery);
|
|
33
|
+
// Stable ref for the callback to avoid re-triggering effects.
|
|
34
|
+
const onStateChangeRef = useRef(onStateChange);
|
|
35
|
+
onStateChangeRef.current = onStateChange;
|
|
36
|
+
const notify = useCallback((nextFilters, nextSort, nextQuery) => {
|
|
37
|
+
onStateChangeRef.current?.({
|
|
38
|
+
filters: nextFilters,
|
|
39
|
+
sort: nextSort,
|
|
40
|
+
query: nextQuery,
|
|
41
|
+
});
|
|
42
|
+
}, []);
|
|
43
|
+
// --- Query debounce ----------------------------------------------------
|
|
44
|
+
const debounceTimerRef = useRef(undefined);
|
|
45
|
+
const setQuery = useCallback((value) => {
|
|
46
|
+
setQueryState(value);
|
|
47
|
+
clearTimeout(debounceTimerRef.current);
|
|
48
|
+
debounceTimerRef.current = setTimeout(() => {
|
|
49
|
+
setDebouncedQuery(value);
|
|
50
|
+
// Notify uses the latest filter/sort state via closure.
|
|
51
|
+
// Since we can't read state synchronously inside a timeout,
|
|
52
|
+
// we use refs for filters and sort below.
|
|
53
|
+
}, queryDebounceMs);
|
|
54
|
+
}, [queryDebounceMs]);
|
|
55
|
+
// Refs for latest state (used in debounce callback).
|
|
56
|
+
const filtersRef = useRef(filters);
|
|
57
|
+
filtersRef.current = filters;
|
|
58
|
+
const sortRef = useRef(sort);
|
|
59
|
+
sortRef.current = sort;
|
|
60
|
+
// Notify on debounced query change.
|
|
61
|
+
const prevDebouncedQuery = useRef(debouncedQuery);
|
|
62
|
+
if (prevDebouncedQuery.current !== debouncedQuery) {
|
|
63
|
+
prevDebouncedQuery.current = debouncedQuery;
|
|
64
|
+
notify(filtersRef.current, sortRef.current, debouncedQuery);
|
|
65
|
+
}
|
|
66
|
+
// --- Filter actions ----------------------------------------------------
|
|
67
|
+
const addFilter = useCallback((filter) => {
|
|
68
|
+
setFilters((prev) => {
|
|
69
|
+
const next = prev.filter((f) => !(f.filterId === filter.filterId && f.operator === filter.operator));
|
|
70
|
+
const updated = [...next, filter];
|
|
71
|
+
notify(updated, sortRef.current, prevDebouncedQuery.current);
|
|
72
|
+
return updated;
|
|
73
|
+
});
|
|
74
|
+
}, [notify]);
|
|
75
|
+
const removeFilter = useCallback((filterId) => {
|
|
76
|
+
setFilters((prev) => {
|
|
77
|
+
const updated = prev.filter((f) => f.filterId !== filterId);
|
|
78
|
+
notify(updated, sortRef.current, prevDebouncedQuery.current);
|
|
79
|
+
return updated;
|
|
80
|
+
});
|
|
81
|
+
}, [notify]);
|
|
82
|
+
const clearFilters = useCallback(() => {
|
|
83
|
+
setFilters([]);
|
|
84
|
+
notify([], sortRef.current, prevDebouncedQuery.current);
|
|
85
|
+
}, [notify]);
|
|
86
|
+
// --- Sort action -------------------------------------------------------
|
|
87
|
+
const setSort = useCallback((nextSort) => {
|
|
88
|
+
setSortState(nextSort);
|
|
89
|
+
sortRef.current = nextSort;
|
|
90
|
+
notify(filtersRef.current, nextSort, prevDebouncedQuery.current);
|
|
91
|
+
}, [notify]);
|
|
92
|
+
return {
|
|
93
|
+
filters,
|
|
94
|
+
addFilter,
|
|
95
|
+
removeFilter,
|
|
96
|
+
clearFilters,
|
|
97
|
+
sort,
|
|
98
|
+
setSort,
|
|
99
|
+
query,
|
|
100
|
+
debouncedQuery,
|
|
101
|
+
setQuery,
|
|
102
|
+
hasActiveFilters: filters.length > 0,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=useResourceFilters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceFilters.js","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useResourceFilters.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAqEtD,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAE9E,MAAM,mBAAmB,GAAG,GAAG,CAAC;AAEhC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,kBAAkB,CAChC,UAAqC,EAAE;IAEvC,MAAM,EACJ,cAAc,GAAG,EAAE,EACnB,WAAW,GAAG,IAAI,EAClB,YAAY,GAAG,EAAE,EACjB,aAAa,EACb,eAAe,GAAG,mBAAmB,GACtC,GAAG,OAAO,C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,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;YAC7D,OAAO,OAAO,CAAC;QACjB,CAAC,CAAC,CAAC;IACL,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;QACpC,UAAU,CAAC,EAAE,CAAC,CAAC;QACf,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,OAAO,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC1D,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAEb,0EAA0E;IAC1E,MAAM,OAAO,GAAG,WAAW,CACzB,CAAC,QAA0B,EAAE,EAAE;QAC7B,YAAY,CAAC,QAAQ,CAAC,CAAC;QACvB,OAAO,CAAC,OAAO,GAAG,QAAQ,CAAC;QAC3B,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,QAAQ,EAAE,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACnE,CAAC,EACD,CAAC,MAAM,CAAC,CACT,CAAC;IAEF,OAAO;QACL,OAAO;QACP,SAAS;QACT,YAAY;QACZ,YAAY;QACZ,IAAI;QACJ,OAAO;QACP,KAAK;QACL,cAAc;QACd,QAAQ;QACR,gBAAgB,EAAE,OAAO,CAAC,MAAM,GAAG,CAAC;KACrC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/** Return value of {@link useResourceSelection}. */
|
|
2
|
+
export interface UseResourceSelectionReturn<TData> {
|
|
3
|
+
/** Set of currently selected item IDs. */
|
|
4
|
+
readonly selectedIds: ReadonlySet<string>;
|
|
5
|
+
/** The full selected items (resolved from the current items array). */
|
|
6
|
+
readonly selectedItems: readonly TData[];
|
|
7
|
+
/** Number of selected items. */
|
|
8
|
+
readonly selectedCount: number;
|
|
9
|
+
/** `true` when at least one item is selected. */
|
|
10
|
+
readonly hasSelection: boolean;
|
|
11
|
+
/** `true` when all visible items are selected. */
|
|
12
|
+
readonly allSelected: boolean;
|
|
13
|
+
/** `true` when some (but not all) visible items are selected. */
|
|
14
|
+
readonly someSelected: boolean;
|
|
15
|
+
/** Toggle a single item's selection state. */
|
|
16
|
+
readonly toggleItem: (id: string) => void;
|
|
17
|
+
/**
|
|
18
|
+
* Range-select from the last toggled item to the given ID (shift-click).
|
|
19
|
+
* Selects all items between them (inclusive).
|
|
20
|
+
*/
|
|
21
|
+
readonly rangeSelectTo: (id: string) => void;
|
|
22
|
+
/** Select or deselect all visible items. */
|
|
23
|
+
readonly toggleAll: () => void;
|
|
24
|
+
/** Clear all selections. */
|
|
25
|
+
readonly clearSelection: () => void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Headless hook that manages selection state for a resource collection.
|
|
29
|
+
*
|
|
30
|
+
* Supports single toggle, shift-click range selection, select-all, and
|
|
31
|
+
* automatic clearing when the items array identity changes (page or
|
|
32
|
+
* filter change).
|
|
33
|
+
*
|
|
34
|
+
* @param items The current page of items. Used to resolve selected
|
|
35
|
+
* items and to implement range selection.
|
|
36
|
+
* @param getItemId Extracts a stable unique ID from an item.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const selection = useResourceSelection(items, (item) => item.id);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function useResourceSelection<TData>(items: readonly TData[], getItemId: (item: TData) => string): UseResourceSelectionReturn<TData>;
|
|
44
|
+
//# sourceMappingURL=useResourceSelection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceSelection.d.ts","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useResourceSelection.ts"],"names":[],"mappings":"AAIA,oDAAoD;AACpD,MAAM,WAAW,0BAA0B,CAAC,KAAK;IAC/C,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1C,uEAAuE;IACvE,QAAQ,CAAC,aAAa,EAAE,SAAS,KAAK,EAAE,CAAC;IACzC,gCAAgC;IAChC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,iDAAiD;IACjD,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;IAC9B,iEAAiE;IACjE,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC;IAC/B,8CAA8C;IAC9C,QAAQ,CAAC,UAAU,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C;;;OAGG;IACH,QAAQ,CAAC,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAC7C,4CAA4C;IAC5C,QAAQ,CAAC,SAAS,EAAE,MAAM,IAAI,CAAC;IAC/B,4BAA4B;IAC5B,QAAQ,CAAC,cAAc,EAAE,MAAM,IAAI,CAAC;CACrC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EACxC,KAAK,EAAE,SAAS,KAAK,EAAE,EACvB,SAAS,EAAE,CAAC,IAAI,EAAE,KAAK,KAAK,MAAM,GACjC,0BAA0B,CAAC,KAAK,CAAC,CA+HnC"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Headless hook that manages selection state for a resource collection.
|
|
5
|
+
*
|
|
6
|
+
* Supports single toggle, shift-click range selection, select-all, and
|
|
7
|
+
* automatic clearing when the items array identity changes (page or
|
|
8
|
+
* filter change).
|
|
9
|
+
*
|
|
10
|
+
* @param items The current page of items. Used to resolve selected
|
|
11
|
+
* items and to implement range selection.
|
|
12
|
+
* @param getItemId Extracts a stable unique ID from an item.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```tsx
|
|
16
|
+
* const selection = useResourceSelection(items, (item) => item.id);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export function useResourceSelection(items, getItemId) {
|
|
20
|
+
const [selectedIds, setSelectedIds] = useState(new Set());
|
|
21
|
+
// Track the last toggled item for shift-click range selection.
|
|
22
|
+
const lastToggledRef = useRef(null);
|
|
23
|
+
// Clear selection when items change (page navigation, filter change).
|
|
24
|
+
// We use the length + first/last ID as a heuristic to detect a new page
|
|
25
|
+
// without requiring referential stability on the items array.
|
|
26
|
+
const itemsKey = useMemo(() => {
|
|
27
|
+
if (items.length === 0)
|
|
28
|
+
return "empty";
|
|
29
|
+
const first = getItemId(items[0]);
|
|
30
|
+
const last = getItemId(items[items.length - 1]);
|
|
31
|
+
return `${items.length}:${first}:${last}`;
|
|
32
|
+
}, [items, getItemId]);
|
|
33
|
+
const prevItemsKey = useRef(itemsKey);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (prevItemsKey.current !== itemsKey) {
|
|
36
|
+
prevItemsKey.current = itemsKey;
|
|
37
|
+
setSelectedIds(new Set());
|
|
38
|
+
lastToggledRef.current = null;
|
|
39
|
+
}
|
|
40
|
+
}, [itemsKey]);
|
|
41
|
+
const toggleItem = useCallback((id) => {
|
|
42
|
+
setSelectedIds((prev) => {
|
|
43
|
+
const next = new Set(prev);
|
|
44
|
+
if (next.has(id)) {
|
|
45
|
+
next.delete(id);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
next.add(id);
|
|
49
|
+
}
|
|
50
|
+
lastToggledRef.current = id;
|
|
51
|
+
return next;
|
|
52
|
+
});
|
|
53
|
+
}, []);
|
|
54
|
+
const rangeSelectTo = useCallback((id) => {
|
|
55
|
+
const lastId = lastToggledRef.current;
|
|
56
|
+
if (!lastId) {
|
|
57
|
+
// No previous anchor — fall back to single toggle.
|
|
58
|
+
setSelectedIds((prev) => {
|
|
59
|
+
const next = new Set(prev);
|
|
60
|
+
next.add(id);
|
|
61
|
+
return next;
|
|
62
|
+
});
|
|
63
|
+
lastToggledRef.current = id;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const ids = items.map(getItemId);
|
|
67
|
+
const anchorIndex = ids.indexOf(lastId);
|
|
68
|
+
const targetIndex = ids.indexOf(id);
|
|
69
|
+
if (anchorIndex === -1 || targetIndex === -1) {
|
|
70
|
+
// One of the endpoints isn't in the current list — single toggle.
|
|
71
|
+
setSelectedIds((prev) => {
|
|
72
|
+
const next = new Set(prev);
|
|
73
|
+
next.add(id);
|
|
74
|
+
return next;
|
|
75
|
+
});
|
|
76
|
+
lastToggledRef.current = id;
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
const start = Math.min(anchorIndex, targetIndex);
|
|
80
|
+
const end = Math.max(anchorIndex, targetIndex);
|
|
81
|
+
const rangeIds = ids.slice(start, end + 1);
|
|
82
|
+
setSelectedIds((prev) => {
|
|
83
|
+
const next = new Set(prev);
|
|
84
|
+
for (const rangeId of rangeIds) {
|
|
85
|
+
next.add(rangeId);
|
|
86
|
+
}
|
|
87
|
+
return next;
|
|
88
|
+
});
|
|
89
|
+
lastToggledRef.current = id;
|
|
90
|
+
}, [items, getItemId]);
|
|
91
|
+
const toggleAll = useCallback(() => {
|
|
92
|
+
const allIds = items.map(getItemId);
|
|
93
|
+
setSelectedIds((prev) => {
|
|
94
|
+
const allCurrentlySelected = allIds.every((id) => prev.has(id));
|
|
95
|
+
if (allCurrentlySelected) {
|
|
96
|
+
return new Set();
|
|
97
|
+
}
|
|
98
|
+
return new Set(allIds);
|
|
99
|
+
});
|
|
100
|
+
}, [items, getItemId]);
|
|
101
|
+
const clearSelection = useCallback(() => {
|
|
102
|
+
setSelectedIds(new Set());
|
|
103
|
+
lastToggledRef.current = null;
|
|
104
|
+
}, []);
|
|
105
|
+
const selectedItems = useMemo(() => items.filter((item) => selectedIds.has(getItemId(item))), [items, selectedIds, getItemId]);
|
|
106
|
+
const selectedCount = selectedIds.size;
|
|
107
|
+
const hasSelection = selectedCount > 0;
|
|
108
|
+
const allSelected = items.length > 0 && items.every((item) => selectedIds.has(getItemId(item)));
|
|
109
|
+
const someSelected = hasSelection && !allSelected;
|
|
110
|
+
return {
|
|
111
|
+
selectedIds,
|
|
112
|
+
selectedItems,
|
|
113
|
+
selectedCount,
|
|
114
|
+
hasSelection,
|
|
115
|
+
allSelected,
|
|
116
|
+
someSelected,
|
|
117
|
+
toggleItem,
|
|
118
|
+
rangeSelectTo,
|
|
119
|
+
toggleAll,
|
|
120
|
+
clearSelection,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
//# sourceMappingURL=useResourceSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResourceSelection.js","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useResourceSelection.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA6B1E;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAClC,KAAuB,EACvB,SAAkC;IAElC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAC5C,IAAI,GAAG,EAAE,CACV,CAAC;IAEF,+DAA+D;IAC/D,MAAM,cAAc,GAAG,MAAM,CAAgB,IAAI,CAAC,CAAC;IAEnD,sEAAsE;IACtE,wEAAwE;IACxE,8DAA8D;IAC9D,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,OAAO,CAAC;QACvC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAClC,MAAM,IAAI,GAAG,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;QAChD,OAAO,GAAG,KAAK,CAAC,MAAM,IAAI,KAAK,I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G,YAAY,IAAI,CAAC,WAAW,CAAC;IAElD,OAAO;QACL,WAAW;QACX,aAAa;QACb,aAAa;QACb,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,UAAU;QACV,aAAa;QACb,SAAS;QACT,cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ViewMode } from "../types";
|
|
2
|
+
/** Return value of {@link useViewPreference}. */
|
|
3
|
+
export interface UseViewPreferenceReturn {
|
|
4
|
+
/** The currently active view mode. */
|
|
5
|
+
readonly viewMode: ViewMode;
|
|
6
|
+
/** Update the view mode. Persists to localStorage when a storage key is provided. */
|
|
7
|
+
readonly setViewMode: (mode: ViewMode) => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Persists the user's preferred view mode (table / cards / list) in
|
|
11
|
+
* localStorage, scoped by a caller-provided storage key.
|
|
12
|
+
*
|
|
13
|
+
* Falls back to `defaultMode` when no persisted value exists or when
|
|
14
|
+
* the stored value is invalid (forward-compatible with future modes).
|
|
15
|
+
*
|
|
16
|
+
* Pass `undefined` for `storageKey` to use an ephemeral (non-persisted)
|
|
17
|
+
* view mode that resets on unmount.
|
|
18
|
+
*
|
|
19
|
+
* @param storageKey localStorage key (e.g. `"stigmer:workbench:agents:viewMode"`).
|
|
20
|
+
* Pass `undefined` to disable persistence.
|
|
21
|
+
* @param defaultMode The view mode to use when no persisted value exists.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```tsx
|
|
25
|
+
* const { viewMode, setViewMode } = useViewPreference(
|
|
26
|
+
* "stigmer:workbench:agents:viewMode",
|
|
27
|
+
* "table",
|
|
28
|
+
* );
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export declare function useViewPreference(storageKey: string | undefined, defaultMode: ViewMode): UseViewPreferenceReturn;
|
|
32
|
+
//# sourceMappingURL=useViewPreference.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewPreference.d.ts","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useViewPreference.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAEzC,iDAAiD;AACjD,MAAM,WAAW,uBAAuB;IACtC,sCAAsC;IACtC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,qFAAqF;IACrF,QAAQ,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;CAChD;AAYD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,WAAW,EAAE,QAAQ,GACpB,uBAAuB,CA0BzB"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
const VALID_MODES = new Set([
|
|
4
|
+
"table",
|
|
5
|
+
"cards",
|
|
6
|
+
"list",
|
|
7
|
+
]);
|
|
8
|
+
function isValidMode(value) {
|
|
9
|
+
return VALID_MODES.has(value);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Persists the user's preferred view mode (table / cards / list) in
|
|
13
|
+
* localStorage, scoped by a caller-provided storage key.
|
|
14
|
+
*
|
|
15
|
+
* Falls back to `defaultMode` when no persisted value exists or when
|
|
16
|
+
* the stored value is invalid (forward-compatible with future modes).
|
|
17
|
+
*
|
|
18
|
+
* Pass `undefined` for `storageKey` to use an ephemeral (non-persisted)
|
|
19
|
+
* view mode that resets on unmount.
|
|
20
|
+
*
|
|
21
|
+
* @param storageKey localStorage key (e.g. `"stigmer:workbench:agents:viewMode"`).
|
|
22
|
+
* Pass `undefined` to disable persistence.
|
|
23
|
+
* @param defaultMode The view mode to use when no persisted value exists.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* const { viewMode, setViewMode } = useViewPreference(
|
|
28
|
+
* "stigmer:workbench:agents:viewMode",
|
|
29
|
+
* "table",
|
|
30
|
+
* );
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function useViewPreference(storageKey, defaultMode) {
|
|
34
|
+
const [viewMode, setViewModeState] = useState(() => {
|
|
35
|
+
if (!storageKey || typeof window === "undefined")
|
|
36
|
+
return defaultMode;
|
|
37
|
+
try {
|
|
38
|
+
const stored = localStorage.getItem(storageKey);
|
|
39
|
+
if (stored && isValidMode(stored))
|
|
40
|
+
return stored;
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
// localStorage may be unavailable (e.g. sandboxed iframe).
|
|
44
|
+
}
|
|
45
|
+
return defaultMode;
|
|
46
|
+
});
|
|
47
|
+
const setViewMode = useCallback((mode) => {
|
|
48
|
+
setViewModeState(mode);
|
|
49
|
+
if (!storageKey)
|
|
50
|
+
return;
|
|
51
|
+
try {
|
|
52
|
+
localStorage.setItem(storageKey, mode);
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
// Silently ignore write failures.
|
|
56
|
+
}
|
|
57
|
+
}, [storageKey]);
|
|
58
|
+
return { viewMode, setViewMode };
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=useViewPreference.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useViewPreference.js","sourceRoot":"","sources":["../../../src/resource-workbench/hooks/useViewPreference.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAW9C,MAAM,WAAW,GAAwB,IAAI,GAAG,CAAW;IACzD,OAAO;IACP,OAAO;IACP,MAAM;CACP,CAAC,CAAC;AAEH,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,UAA8B,EAC9B,WAAqB;IAErB,MAAM,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAW,GAAG,EAAE;QAC3D,IAAI,CAAC,UAAU,IAAI,OAAO,MAAM,KAAK,WAAW;YAAE,OAAO,WAAW,CAAC;QACrE,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YAChD,IAAI,MAAM,IAAI,WAAW,CAAC,MAAM,CAAC;gBAAE,OAAO,MAAM,CAAC;QACnD,CAAC;QAAC,MAAM,CAAC;YACP,2DAA2D;QAC7D,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,WAAW,CAC7B,CAAC,IAAc,EAAE,EAAE;QACjB,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC,UAAU;YAAE,OAAO;QACxB,IAAI,CAAC;YACH,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,CAAC;QACzC,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;IACH,CAAC,EACD,CAAC,UAAU,CAAC,CACb,CAAC;IAEF,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export type { ViewMode, StatusPhase, WorkbenchColumnDef, FilterOperator, FilterValue, FilterDef, FilterOption, SortDirection, SortValue, SortDef, ResourceAction, BulkAction, WorkbenchState, } from "./types";
|
|
2
|
+
export { useViewPreference } from "./hooks/useViewPreference";
|
|
3
|
+
export type { UseViewPreferenceReturn } from "./hooks/useViewPreference";
|
|
4
|
+
export { useResourceCollection } from "./hooks/useResourceCollection";
|
|
5
|
+
export type { UseResourceCollectionOptions, UseResourceCollectionReturn, } from "./hooks/useResourceCollection";
|
|
6
|
+
export { useResourceSelection } from "./hooks/useResourceSelection";
|
|
7
|
+
export type { UseResourceSelectionReturn } from "./hooks/useResourceSelection";
|
|
8
|
+
export { useResourceFilters } from "./hooks/useResourceFilters";
|
|
9
|
+
export type { UseResourceFiltersOptions, UseResourceFiltersReturn, FilterSortState, } from "./hooks/useResourceFilters";
|
|
10
|
+
export { StatusBadge } from "./components/StatusBadge";
|
|
11
|
+
export type { StatusBadgeProps } from "./components/StatusBadge";
|
|
12
|
+
export { ColumnHeader } from "./components/ColumnHeader";
|
|
13
|
+
export type { ColumnHeaderProps } from "./components/ColumnHeader";
|
|
14
|
+
export { SelectionCheckbox } from "./components/SelectionCheckbox";
|
|
15
|
+
export type { SelectionCheckboxProps } from "./components/SelectionCheckbox";
|
|
16
|
+
export { ResourceTable } from "./components/ResourceTable";
|
|
17
|
+
export type { ResourceTableProps } from "./components/ResourceTable";
|
|
18
|
+
export { ResourceCards } from "./components/ResourceCards";
|
|
19
|
+
export type { ResourceCardsProps } from "./components/ResourceCards";
|
|
20
|
+
export { ResourceList } from "./components/ResourceList";
|
|
21
|
+
export type { ResourceListProps } from "./components/ResourceList";
|
|
22
|
+
export { BulkActionBar } from "./components/BulkActionBar";
|
|
23
|
+
export type { BulkActionBarProps } from "./components/BulkActionBar";
|
|
24
|
+
export { FilterBar } from "./components/FilterBar";
|
|
25
|
+
export type { FilterBarProps } from "./components/FilterBar";
|
|
26
|
+
export { ViewSwitcher } from "./components/ViewSwitcher";
|
|
27
|
+
export type { ViewSwitcherProps } from "./components/ViewSwitcher";
|
|
28
|
+
export { ResourceInspector } from "./components/ResourceInspector";
|
|
29
|
+
export type { ResourceInspectorProps } from "./components/ResourceInspector";
|
|
30
|
+
export { ResourceWorkbench } from "./components/ResourceWorkbench";
|
|
31
|
+
export type { ResourceWorkbenchProps } from "./components/ResourceWorkbench";
|
|
32
|
+
export { ResourceAvatar } from "./components/ResourceAvatar";
|
|
33
|
+
export type { ResourceAvatarProps } from "./components/ResourceAvatar";
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|