@xynolog/react-ui 0.0.0-stage → 0.8.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/LICENSE +201 -0
- package/README.md +379 -2
- package/dist/PdfAnnotationCanvas.client-S64VRLUN.css +193 -0
- package/dist/PdfAnnotationCanvas.client-V7R4NXFO.js +799 -0
- package/dist/ar-AIV7P4FL.js +594 -0
- package/dist/bn-J2OR57PB.js +594 -0
- package/dist/chunk-4L3TYOIV.js +172 -0
- package/dist/chunk-BM76QBIO.js +594 -0
- package/dist/chunk-D2O46PZQ.js +240 -0
- package/dist/chunk-O23TLLXW.js +42 -0
- package/dist/chunk-WGTUIB6C.js +304 -0
- package/dist/cs-JNEAMHFB.js +594 -0
- package/dist/da-UY5ZRVTZ.js +594 -0
- package/dist/de-EETVXC42.js +594 -0
- package/dist/el-S5YKDMTL.js +594 -0
- package/dist/en-3YQWF45H.js +61 -0
- package/dist/es-GHA7S27R.js +594 -0
- package/dist/fa-JTR3GF6I.js +594 -0
- package/dist/fi-CQZ7BW57.js +594 -0
- package/dist/fr-OJH2WIY7.js +594 -0
- package/dist/he-2DBXWA2V.js +594 -0
- package/dist/hi-NZP7B55I.js +594 -0
- package/dist/id-4KXFKWOI.js +594 -0
- package/dist/index.css +4134 -0
- package/dist/index.d.ts +4040 -0
- package/dist/index.js +29638 -0
- package/dist/it-XBMYGKKY.js +594 -0
- package/dist/ja-OVHZS3EH.js +594 -0
- package/dist/ko-NW2MVM5L.js +594 -0
- package/dist/ms-RXLPBZLK.js +594 -0
- package/dist/nl-77CTBEDA.js +594 -0
- package/dist/no-RAPO56SE.js +594 -0
- package/dist/pl-XCFXZCTT.js +594 -0
- package/dist/pt-EMBE27IS.js +594 -0
- package/dist/ro-M7QLJBYN.js +594 -0
- package/dist/sv-ST6CITQY.js +594 -0
- package/dist/test-utils.css +112 -0
- package/dist/test-utils.d.ts +126 -0
- package/dist/test-utils.js +13119 -0
- package/dist/th-EEQGL3G7.js +594 -0
- package/dist/tr-5FYHZQKD.js +594 -0
- package/dist/uk-VTWDC467.js +594 -0
- package/dist/vi-ISBKJ66X.js +594 -0
- package/dist/zh-2AW2N66Z.js +594 -0
- package/package.json +129 -4
- package/src/components/Button/Button.tsx +188 -0
- package/src/components/Button/__tests__/Button.test.tsx +449 -0
- package/src/components/CodeMirrorRenderer.tsx +536 -0
- package/src/components/DelegateProgress.tsx +308 -0
- package/src/components/ErrorBoundary.tsx +174 -0
- package/src/components/ItemFoundLog.tsx +42 -0
- package/src/components/LiveRegion.tsx +261 -0
- package/src/components/ProtectedErrorBoundary.css +121 -0
- package/src/components/ProtectedErrorBoundary.tsx +114 -0
- package/src/components/ResizeHandle.tsx +167 -0
- package/src/components/ResourceTagsInline.tsx +120 -0
- package/src/components/SessionExpiryBanner.css +67 -0
- package/src/components/SessionExpiryBanner.tsx +74 -0
- package/src/components/SessionTimer.tsx +17 -0
- package/src/components/StatusDisplay.css +439 -0
- package/src/components/StatusDisplay.tsx +131 -0
- package/src/components/Toast.css +136 -0
- package/src/components/Toast.tsx +217 -0
- package/src/components/Toolbar.tsx +194 -0
- package/src/components/UserMenuSkeleton.tsx +13 -0
- package/src/components/__tests__/DelegateProgress.denominator.test.tsx +102 -0
- package/src/components/__tests__/DelegateProgress.test.tsx +649 -0
- package/src/components/__tests__/ErrorBoundary.test.tsx +565 -0
- package/src/components/__tests__/LiveRegion.a11y.test.tsx +258 -0
- package/src/components/__tests__/LiveRegion.hooks.test.tsx +140 -0
- package/src/components/__tests__/ProtectedErrorBoundary.test.tsx +225 -0
- package/src/components/__tests__/ResizeHandle.test.tsx +159 -0
- package/src/components/__tests__/ResourceTagsInline.test.tsx +325 -0
- package/src/components/__tests__/SessionExpiryBanner.test.tsx +124 -0
- package/src/components/__tests__/SessionTimer.test.tsx +199 -0
- package/src/components/__tests__/StatusDisplay.test.tsx +179 -0
- package/src/components/__tests__/Toast.test.tsx +96 -0
- package/src/components/__tests__/Toolbar.test.tsx +111 -0
- package/src/components/__tests__/UserMenuSkeleton.test.tsx +182 -0
- package/src/components/annotation/AnchoredTextNotice.tsx +36 -0
- package/src/components/annotation/AnnotateToolbar.tsx +531 -0
- package/src/components/annotation/__tests__/AnnotateToolbar.display.test.tsx +127 -0
- package/src/components/annotation/__tests__/AnnotateToolbar.test.tsx +304 -0
- package/src/components/annotation/annotation-entries.css +138 -0
- package/src/components/annotation/annotations.css +93 -0
- package/src/components/annotation/references.css +300 -0
- package/src/components/annotation-popups/JsonLdView.tsx +127 -0
- package/src/components/annotation-popups/SharedPopupElements.tsx +131 -0
- package/src/components/annotation-popups/__tests__/JsonLdView.test.tsx +432 -0
- package/src/components/annotation-popups/__tests__/SharedPopupElements.test.tsx +297 -0
- package/src/components/branding/Branding.css +129 -0
- package/src/components/branding/XynologBranding.tsx +41 -0
- package/src/components/branding/__tests__/XynologBranding.test.tsx +383 -0
- package/src/components/error-states/ResourceErrorState.tsx +30 -0
- package/src/components/error-states/__tests__/ResourceErrorState.test.tsx +102 -0
- package/src/components/error-states/errors.css +34 -0
- package/src/components/image-annotation/AnnotationOverlay.tsx +307 -0
- package/src/components/image-annotation/SvgDrawingCanvas.tsx +514 -0
- package/src/components/image-annotation/__tests__/AnnotationOverlay.click.test.tsx +169 -0
- package/src/components/image-annotation/__tests__/AnnotationOverlay.hover.test.tsx +83 -0
- package/src/components/image-annotation/__tests__/SvgDrawingCanvas.annotate-gate.test.tsx +228 -0
- package/src/components/image-annotation/__tests__/SvgDrawingCanvas.click.test.tsx +204 -0
- package/src/components/layout/Header.css +99 -0
- package/src/components/layout/LeftSidebar.css +115 -0
- package/src/components/layout/LeftSidebar.tsx +150 -0
- package/src/components/layout/PageLayout.tsx +49 -0
- package/src/components/layout/ResizeHandle.css +110 -0
- package/src/components/layout/SkipLinks.css +84 -0
- package/src/components/layout/SkipLinks.tsx +36 -0
- package/src/components/layout/UnifiedHeader.tsx +151 -0
- package/src/components/layout/__tests__/LeftSidebar.test.tsx +426 -0
- package/src/components/layout/__tests__/PageLayout.test.tsx +311 -0
- package/src/components/layout/__tests__/SkipLinks.a11y.test.tsx +218 -0
- package/src/components/layout/__tests__/UnifiedHeader.test.tsx +555 -0
- package/src/components/loading-states/ComposeLoadingState.tsx +19 -0
- package/src/components/loading-states/ResourceLoadingState.tsx +13 -0
- package/src/components/loading-states/__tests__/ComposeLoadingState.test.tsx +37 -0
- package/src/components/loading-states/__tests__/ResourceLoadingState.test.tsx +31 -0
- package/src/components/loading-states/loading.css +42 -0
- package/src/components/modals/ComposeStep.tsx +245 -0
- package/src/components/modals/ConfigureGatherStep.tsx +110 -0
- package/src/components/modals/ConfigureGenerationStep.tsx +458 -0
- package/src/components/modals/ConfigureSearchStep.tsx +124 -0
- package/src/components/modals/ContextSummary.tsx +317 -0
- package/src/components/modals/CorpusPane.tsx +96 -0
- package/src/components/modals/DiscardPrompt.tsx +44 -0
- package/src/components/modals/GatherContextStep.tsx +480 -0
- package/src/components/modals/KbIdentityConflictModal.tsx +122 -0
- package/src/components/modals/KeyboardShortcutsHelpModal.tsx +238 -0
- package/src/components/modals/PermissionDeniedModal.tsx +207 -0
- package/src/components/modals/ReferenceWizardModal.tsx +656 -0
- package/src/components/modals/ResourceGenerateModal.tsx +457 -0
- package/src/components/modals/SearchModal.css +1019 -0
- package/src/components/modals/SearchModal.tsx +334 -0
- package/src/components/modals/SearchResultsStep.tsx +117 -0
- package/src/components/modals/SessionEndedModal.tsx +148 -0
- package/src/components/modals/WizardFooter.tsx +72 -0
- package/src/components/modals/__tests__/ComposeStep.test.tsx +187 -0
- package/src/components/modals/__tests__/ConfigureGatherStep.test.tsx +92 -0
- package/src/components/modals/__tests__/ConfigureGenerationStep.test.tsx +574 -0
- package/src/components/modals/__tests__/ConfigureSearchStep.test.tsx +124 -0
- package/src/components/modals/__tests__/GatherContextStep.resource.test.tsx +702 -0
- package/src/components/modals/__tests__/KbIdentityConflictModal.test.tsx +102 -0
- package/src/components/modals/__tests__/KeyboardShortcutsHelpModal.test.tsx +115 -0
- package/src/components/modals/__tests__/PermissionDeniedModal.test.tsx +218 -0
- package/src/components/modals/__tests__/ReferenceWizardModal.test.tsx +936 -0
- package/src/components/modals/__tests__/ResourceGenerateModal.test.tsx +532 -0
- package/src/components/modals/__tests__/SearchModal.accessibility.test.tsx +95 -0
- package/src/components/modals/__tests__/SearchModal.basic.test.tsx +84 -0
- package/src/components/modals/__tests__/SearchModal.keyboard.test.tsx +162 -0
- package/src/components/modals/__tests__/SearchModal.search-wiring.test.tsx +237 -0
- package/src/components/modals/__tests__/SearchModal.translations.test.tsx +91 -0
- package/src/components/modals/__tests__/SearchResultsStep.test.tsx +95 -0
- package/src/components/modals/__tests__/SessionEndedModal.test.tsx +171 -0
- package/src/components/modals/__tests__/WizardFooter.test.tsx +446 -0
- package/src/components/modals/__tests__/search-modal-harness.ts +82 -0
- package/src/components/modals/modals.css +655 -0
- package/src/components/navigation/CollapsibleResourceNavigation.css +10 -0
- package/src/components/navigation/CollapsibleResourceNavigation.tsx +364 -0
- package/src/components/navigation/NavigationMenu.css +59 -0
- package/src/components/navigation/NavigationMenu.tsx +66 -0
- package/src/components/navigation/NavigationTabs.css +466 -0
- package/src/components/navigation/ObservableLink.tsx +90 -0
- package/src/components/navigation/SimpleNavigation.css +9 -0
- package/src/components/navigation/SimpleNavigation.tsx +169 -0
- package/src/components/navigation/SortableResourceTab.tsx +122 -0
- package/src/components/navigation/__tests__/NavigationMenu.a11y.test.tsx +302 -0
- package/src/components/navigation/__tests__/NavigationMenu.test.tsx +399 -0
- package/src/components/navigation/__tests__/ObservableLink.test.tsx +85 -0
- package/src/components/navigation/__tests__/SimpleNavigation.test.tsx +193 -0
- package/src/components/navigation/__tests__/SortableResourceTab.test.tsx +421 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.client.tsx +10 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.css +288 -0
- package/src/components/pdf-annotation/PdfAnnotationCanvas.tsx +632 -0
- package/src/components/pdf-annotation/PdfPageView.tsx +527 -0
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.annotate-gate.test.tsx +295 -0
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.pixels-before-anchoring.test.tsx +166 -0
- package/src/components/pdf-annotation/__tests__/PdfAnnotationCanvas.test.tsx +1719 -0
- package/src/components/pdf-annotation/__tests__/estimate-slot-height.test.ts +61 -0
- package/src/components/pdf-annotation/__tests__/rects-for-page.test.ts +110 -0
- package/src/components/pdf-annotation/estimate-slot-height.ts +31 -0
- package/src/components/pdf-annotation/rects-for-page.ts +50 -0
- package/src/components/resource/AnnotateView.tsx +373 -0
- package/src/components/resource/AnnotationHistory.tsx +169 -0
- package/src/components/resource/BrowseView.tsx +440 -0
- package/src/components/resource/DownloadFileLink.tsx +53 -0
- package/src/components/resource/HistoryEvent.tsx +186 -0
- package/src/components/resource/ResourceViewer.tsx +617 -0
- package/src/components/resource/__tests__/AnnotateView.code-point-offsets.test.tsx +482 -0
- package/src/components/resource/__tests__/AnnotateView.embeddable.test.tsx +78 -0
- package/src/components/resource/__tests__/AnnotateView.focus.test.tsx +147 -0
- package/src/components/resource/__tests__/AnnotateView.registry.test.tsx +143 -0
- package/src/components/resource/__tests__/AnnotationHistory.test.tsx +257 -0
- package/src/components/resource/__tests__/BrowseView.code-point-offsets.test.tsx +123 -0
- package/src/components/resource/__tests__/BrowseView.embeddable.test.tsx +76 -0
- package/src/components/resource/__tests__/BrowseView.links.test.tsx +84 -0
- package/src/components/resource/__tests__/BrowseView.overlay-async.test.tsx +165 -0
- package/src/components/resource/__tests__/BrowseView.reference-hover.test.tsx +200 -0
- package/src/components/resource/__tests__/BrowseView.registry.test.tsx +57 -0
- package/src/components/resource/__tests__/BrowseView.test.tsx +915 -0
- package/src/components/resource/__tests__/HistoryEvent.test.tsx +571 -0
- package/src/components/resource/__tests__/ResourceViewer.delete-failure.test.tsx +103 -0
- package/src/components/resource/__tests__/ResourceViewer.embeddable.test.tsx +250 -0
- package/src/components/resource/__tests__/ResourceViewer.mode-switch.test.tsx +262 -0
- package/src/components/resource/__tests__/ResourceViewer.multi-mount-invalidation.test.tsx +166 -0
- package/src/components/resource/__tests__/ResourceViewer.registry.test.tsx +112 -0
- package/src/components/resource/__tests__/ResourceViewer.toolbar-opt-out.test.tsx +207 -0
- package/src/components/resource/__tests__/ResourceViewer.toolbar-prefs.test.tsx +274 -0
- package/src/components/resource/__tests__/annotation-interactions.test.tsx +116 -0
- package/src/components/resource/__tests__/browse-renderers.dispatch.test.tsx +183 -0
- package/src/components/resource/__tests__/browse-renderers.test.tsx +47 -0
- package/src/components/resource/__tests__/download-link.test.tsx +171 -0
- package/src/components/resource/__tests__/event-formatting.test.ts +379 -0
- package/src/components/resource/__tests__/inline-embedding.test.tsx +133 -0
- package/src/components/resource/__tests__/media-completeness.test.tsx +144 -0
- package/src/components/resource/annotate-renderers.tsx +186 -0
- package/src/components/resource/browse-renderers.tsx +133 -0
- package/src/components/resource/event-formatting.ts +393 -0
- package/src/components/resource/panels/AssessmentEntry.tsx +127 -0
- package/src/components/resource/panels/AssessmentPanel.tsx +309 -0
- package/src/components/resource/panels/CollaborationPanel.css +184 -0
- package/src/components/resource/panels/CollaborationPanel.tsx +228 -0
- package/src/components/resource/panels/CommentEntry.tsx +242 -0
- package/src/components/resource/panels/CommentsPanel.tsx +320 -0
- package/src/components/resource/panels/DelegateSection.css +330 -0
- package/src/components/resource/panels/DelegateSection.tsx +282 -0
- package/src/components/resource/panels/DelegateShell.tsx +134 -0
- package/src/components/resource/panels/HighlightEntry.tsx +83 -0
- package/src/components/resource/panels/HighlightPanel.tsx +212 -0
- package/src/components/resource/panels/JsonLdPanel.css +37 -0
- package/src/components/resource/panels/JsonLdPanel.tsx +119 -0
- package/src/components/resource/panels/PanelHeader.tsx +22 -0
- package/src/components/resource/panels/ReferenceEntry.tsx +232 -0
- package/src/components/resource/panels/ReferencesPanel.css +108 -0
- package/src/components/resource/panels/ReferencesPanel.tsx +626 -0
- package/src/components/resource/panels/ResourceInfoPanel.css +183 -0
- package/src/components/resource/panels/ResourceInfoPanel.tsx +433 -0
- package/src/components/resource/panels/StatisticsPanel.css +127 -0
- package/src/components/resource/panels/StatisticsPanel.tsx +145 -0
- package/src/components/resource/panels/TagEntry.tsx +87 -0
- package/src/components/resource/panels/TaggingPanel.tsx +554 -0
- package/src/components/resource/panels/UnifiedAnnotationsPanel.css +129 -0
- package/src/components/resource/panels/UnifiedAnnotationsPanel.tsx +384 -0
- package/src/components/resource/panels/__tests__/AssessmentEntry.test.tsx +292 -0
- package/src/components/resource/panels/__tests__/AssessmentPanel.test.tsx +685 -0
- package/src/components/resource/panels/__tests__/CollaborationPanel.test.tsx +685 -0
- package/src/components/resource/panels/__tests__/CommentEntry.test.tsx +750 -0
- package/src/components/resource/panels/__tests__/CommentsPanel.test.tsx +877 -0
- package/src/components/resource/panels/__tests__/DelegateSection.test.tsx +623 -0
- package/src/components/resource/panels/__tests__/DelegateShell.test.tsx +212 -0
- package/src/components/resource/panels/__tests__/HighlightEntry.test.tsx +236 -0
- package/src/components/resource/panels/__tests__/HighlightPanel.annotationProgress.test.tsx +506 -0
- package/src/components/resource/panels/__tests__/HighlightPanel.out-of-order.test.tsx +132 -0
- package/src/components/resource/panels/__tests__/JsonLdPanel.test.tsx +230 -0
- package/src/components/resource/panels/__tests__/PanelHeader.test.tsx +54 -0
- package/src/components/resource/panels/__tests__/ReferenceEntry.test.tsx +578 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.headless.test.tsx +193 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.observable-flow.test.tsx +193 -0
- package/src/components/resource/panels/__tests__/ReferencesPanel.test.tsx +1080 -0
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.test.tsx +812 -0
- package/src/components/resource/panels/__tests__/ResourceInfoPanel.text-layer.test.tsx +106 -0
- package/src/components/resource/panels/__tests__/StatisticsPanel.test.tsx +329 -0
- package/src/components/resource/panels/__tests__/TagEntry.test.tsx +250 -0
- package/src/components/resource/panels/__tests__/TaggingPanel.test.tsx +772 -0
- package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.delegated-job.test.tsx +207 -0
- package/src/components/resource/panels/__tests__/UnifiedAnnotationsPanel.failure.test.tsx +89 -0
- package/src/components/resource/panels/__tests__/agent-label.test.ts +136 -0
- package/src/components/resource/panels/agent-label.ts +35 -0
- package/src/components/settings/SettingsPanel.css +92 -0
- package/src/components/settings/SettingsPanel.tsx +251 -0
- package/src/components/settings/__tests__/SettingsPanel.test.tsx +260 -0
- package/src/components/toolbar/Toolbar.css +245 -0
- package/src/components/viewers/ImageViewer.tsx +18 -0
- package/src/components/viewers/__tests__/ImageViewer.test.tsx +57 -0
- package/src/components/viewers/index.ts +1 -0
- package/src/features/auth/__tests__/AuthErrorDisplay.test.tsx +181 -0
- package/src/features/auth/auth.css +120 -0
- package/src/features/auth/components/AuthErrorDisplay.tsx +89 -0
- package/src/features/moderate-entity-tags/__tests__/EntityTagsPage.test.tsx +387 -0
- package/src/features/moderate-entity-tags/components/EntityTagsPage.tsx +161 -0
- package/src/features/moderate-entity-tags/state/__tests__/entity-tags-state-unit.test.ts +183 -0
- package/src/features/moderate-entity-tags/state/entity-tags-state-unit.ts +73 -0
- package/src/features/moderate-recent/__tests__/RecentDocumentsPage.test.tsx +422 -0
- package/src/features/moderate-recent/components/RecentDocumentsPage.tsx +117 -0
- package/src/features/moderate-tag-schemas/__tests__/TagSchemasPage.test.tsx +481 -0
- package/src/features/moderate-tag-schemas/components/TagSchemasPage.tsx +161 -0
- package/src/features/resource-compose/__tests__/ResourceComposePage.test.tsx +600 -0
- package/src/features/resource-compose/__tests__/UploadProgressBar.test.tsx +256 -0
- package/src/features/resource-compose/components/ResourceComposePage.tsx +809 -0
- package/src/features/resource-compose/components/UploadProgressBar.tsx +125 -0
- package/src/features/resource-compose/state/__tests__/compose-page-state-unit.test.ts +195 -0
- package/src/features/resource-compose/state/compose-page-state-unit.ts +187 -0
- package/src/features/resource-discovery/__tests__/ResourceCard.test.tsx +338 -0
- package/src/features/resource-discovery/__tests__/ResourceDiscoveryPage.test.tsx +449 -0
- package/src/features/resource-discovery/components/ResourceCard.tsx +80 -0
- package/src/features/resource-discovery/components/ResourceDiscoveryPage.tsx +330 -0
- package/src/features/resource-discovery/state/__tests__/discover-state-unit.test.ts +477 -0
- package/src/features/resource-discovery/state/discover-state-unit.ts +162 -0
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.content-loading.test.tsx +260 -0
- package/src/features/resource-viewer/__tests__/ResourceViewerPage.test.tsx +570 -0
- package/src/features/resource-viewer/__tests__/generation-params.test.ts +49 -0
- package/src/features/resource-viewer/components/ResourceViewerPage.tsx +1058 -0
- package/src/features/resource-viewer/generation-params.ts +23 -0
- package/src/features/resource-viewer/hooks/__tests__/useResourceViewedReport.test.tsx +77 -0
- package/src/features/resource-viewer/hooks/useResourceViewedReport.ts +38 -0
- package/src/features/resource-viewer/state/__tests__/resource-loader-state-unit.test.ts +178 -0
- package/src/features/resource-viewer/state/__tests__/resource-viewer-page-state-unit.test.ts +505 -0
- package/src/features/resource-viewer/state/resource-loader-state-unit.ts +93 -0
- package/src/features/resource-viewer/state/resource-viewer-page-state-unit.ts +156 -0
- package/src/styles/base/reset.css +105 -0
- package/src/styles/base/utilities.css +35 -0
- package/src/styles/core/badges.css +17 -0
- package/src/styles/core/buttons.css +772 -0
- package/src/styles/core/checkboxes.css +85 -0
- package/src/styles/core/forms.css +237 -0
- package/src/styles/core/index.css +43 -0
- package/src/styles/core/indicators.css +24 -0
- package/src/styles/core/inputs.css +164 -0
- package/src/styles/core/progress.css +85 -0
- package/src/styles/core/selects.css +119 -0
- package/src/styles/core/sliders.css +180 -0
- package/src/styles/core/tags.css +86 -0
- package/src/styles/core/textareas.css +104 -0
- package/src/styles/core/toggles.css +82 -0
- package/src/styles/features/compose.css +341 -0
- package/src/styles/features/entity-tags.css +140 -0
- package/src/styles/features/recent-docs.css +97 -0
- package/src/styles/features/resource-discovery.css +349 -0
- package/src/styles/features/resource-viewer.css +609 -0
- package/src/styles/features/resource.css +483 -0
- package/src/styles/features/schemas.css +222 -0
- package/src/styles/index.css +84 -0
- package/src/styles/layout/layout.css +28 -0
- package/src/styles/motivations/motivation-assessment.css +179 -0
- package/src/styles/motivations/motivation-comment.css +164 -0
- package/src/styles/motivations/motivation-highlight.css +132 -0
- package/src/styles/motivations/motivation-reference.css +167 -0
- package/src/styles/motivations/motivation-tag.css +182 -0
- package/src/styles/panels/history-panel.css +212 -0
- package/src/styles/panels/user-panel.css +21 -0
- package/src/styles/patterns/cards.css +26 -0
- package/src/styles/patterns/panel-helpers.css +32 -0
- package/src/styles/patterns/panels-base.css +272 -0
- package/src/styles/utilities/contrast.css +280 -0
- package/src/styles/utilities/focus-extended.css +276 -0
- package/src/styles/utilities/focus.css +41 -0
- package/src/styles/utilities/motion-overrides.css +286 -0
- package/src/styles/utilities/motion.css +184 -0
- package/src/styles/utilities/semantic-indicators.css +254 -0
- package/src/styles/variables.css +410 -0
- package/translations/ar.json +534 -0
- package/translations/bn.json +534 -0
- package/translations/cs.json +534 -0
- package/translations/da.json +534 -0
- package/translations/de.json +534 -0
- package/translations/el.json +534 -0
- package/translations/en.json +534 -0
- package/translations/es.json +534 -0
- package/translations/fa.json +534 -0
- package/translations/fi.json +534 -0
- package/translations/fr.json +534 -0
- package/translations/he.json +534 -0
- package/translations/hi.json +534 -0
- package/translations/id.json +534 -0
- package/translations/it.json +534 -0
- package/translations/ja.json +534 -0
- package/translations/ko.json +534 -0
- package/translations/ms.json +534 -0
- package/translations/nl.json +534 -0
- package/translations/no.json +534 -0
- package/translations/pl.json +534 -0
- package/translations/pt.json +534 -0
- package/translations/ro.json +534 -0
- package/translations/sv.json +534 -0
- package/translations/th.json +534 -0
- package/translations/tr.json +534 -0
- package/translations/uk.json +534 -0
- package/translations/vi.json +534 -0
- package/translations/zh.json +534 -0
|
@@ -0,0 +1,477 @@
|
|
|
1
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
+
import { asStates } from '../../../../__tests__/test-client';
|
|
3
|
+
import { sessionOf } from '../../../../__tests__/test-client';
|
|
4
|
+
import { BehaviorSubject, firstValueFrom } from 'rxjs';
|
|
5
|
+
import { filter, map, skip, take, toArray } from 'rxjs/operators';
|
|
6
|
+
import type { XynologClient } from '@xynolog/sdk';
|
|
7
|
+
import type { components } from '@xynolog/core';
|
|
8
|
+
import type { ShellStateUnit } from '../../../../state/shell-state-unit';
|
|
9
|
+
import {
|
|
10
|
+
createDiscoverStateUnit,
|
|
11
|
+
type DiscoverStateUnit,
|
|
12
|
+
} from '../discover-state-unit';
|
|
13
|
+
import {
|
|
14
|
+
assertStateUnitAxioms,
|
|
15
|
+
disposeProbe,
|
|
16
|
+
} from '@xynolog/core/testing/axioms';
|
|
17
|
+
|
|
18
|
+
function mockBrowse(): ShellStateUnit {
|
|
19
|
+
return { dispose: vi.fn() } as unknown as ShellStateUnit;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** What either query was asked: `search` is set when `match.resources()` asked it. */
|
|
23
|
+
interface BrowseFilters {
|
|
24
|
+
limit?: number;
|
|
25
|
+
archived?: boolean;
|
|
26
|
+
search?: string;
|
|
27
|
+
entityType?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function mockClient(
|
|
31
|
+
overrides: {
|
|
32
|
+
resources$?: BehaviorSubject<unknown[] | undefined>;
|
|
33
|
+
entityTypes$?: BehaviorSubject<string[] | undefined>;
|
|
34
|
+
resourcesFn?: (
|
|
35
|
+
filters: BrowseFilters,
|
|
36
|
+
) => BehaviorSubject<unknown[] | undefined>;
|
|
37
|
+
/** What the stubbed search envelope reports as its match kind. */
|
|
38
|
+
matchKind?: components['schemas']['MatchResourcesResponse']['matchKind'];
|
|
39
|
+
} = {},
|
|
40
|
+
): { client: XynologClient; resourceCalls: BrowseFilters[] } {
|
|
41
|
+
const resourceCalls: BrowseFilters[] = [];
|
|
42
|
+
const defaultResources$ =
|
|
43
|
+
overrides.resources$ ??
|
|
44
|
+
new BehaviorSubject<unknown[] | undefined>([{ '@id': 'r1' }]);
|
|
45
|
+
const entityTypes$ =
|
|
46
|
+
overrides.entityTypes$ ??
|
|
47
|
+
new BehaviorSubject<string[] | undefined>(['Person']);
|
|
48
|
+
|
|
49
|
+
const resourcesFn = overrides.resourcesFn ?? (() => defaultResources$);
|
|
50
|
+
|
|
51
|
+
// Arrays get the envelope the query emits; explicit status objects (B15
|
|
52
|
+
// fixtures) and `undefined` pass through.
|
|
53
|
+
const asked = (
|
|
54
|
+
filters: BrowseFilters,
|
|
55
|
+
envelope: (page: unknown[]) => unknown,
|
|
56
|
+
) => {
|
|
57
|
+
resourceCalls.push(filters);
|
|
58
|
+
return asStates(
|
|
59
|
+
resourcesFn(filters)
|
|
60
|
+
.asObservable()
|
|
61
|
+
.pipe(map((v) => (Array.isArray(v) ? envelope(v) : v))),
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const client = {
|
|
66
|
+
browse: {
|
|
67
|
+
resources: (filters: Omit<BrowseFilters, 'search'> = {}) =>
|
|
68
|
+
asked(filters, (page) => ({
|
|
69
|
+
resources: page,
|
|
70
|
+
total: page.length,
|
|
71
|
+
offset: 0,
|
|
72
|
+
limit: 20,
|
|
73
|
+
})),
|
|
74
|
+
entityTypes: () => asStates(entityTypes$.asObservable()),
|
|
75
|
+
},
|
|
76
|
+
match: {
|
|
77
|
+
resources: (
|
|
78
|
+
search: string,
|
|
79
|
+
filters: Omit<BrowseFilters, 'search'> = {},
|
|
80
|
+
) =>
|
|
81
|
+
asked({ search, ...filters }, (page) => ({
|
|
82
|
+
resources: page,
|
|
83
|
+
total: page.length,
|
|
84
|
+
offset: 0,
|
|
85
|
+
limit: 20,
|
|
86
|
+
matchKind: overrides.matchKind ?? 'lexical',
|
|
87
|
+
})),
|
|
88
|
+
},
|
|
89
|
+
} as unknown as XynologClient;
|
|
90
|
+
|
|
91
|
+
return { client, resourceCalls };
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
describe('createDiscoverStateUnit — search match kind', () => {
|
|
95
|
+
// Semantic-fallback axiom S10 is tier-agnostic: the label and the resources
|
|
96
|
+
// it describes must arrive as ONE value. Exposing `matchKind$` as a second
|
|
97
|
+
// observable beside `state$.results` would satisfy the component and still
|
|
98
|
+
// let a render pair this query's label with the previous query's list.
|
|
99
|
+
it('emits matchKind in the SAME value as the results it labels', async () => {
|
|
100
|
+
vi.useFakeTimers();
|
|
101
|
+
try {
|
|
102
|
+
const results$ = new BehaviorSubject<unknown[] | undefined>([
|
|
103
|
+
{ '@id': 'sem-1' },
|
|
104
|
+
]);
|
|
105
|
+
const { client } = mockClient({
|
|
106
|
+
resourcesFn: () => results$,
|
|
107
|
+
matchKind: 'semantic',
|
|
108
|
+
});
|
|
109
|
+
const stateUnit = createDiscoverStateUnit(
|
|
110
|
+
sessionOf(client),
|
|
111
|
+
mockBrowse(),
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
// Subscribe BEFORE setQuery: `queryInput$` is a plain Subject, so a value
|
|
115
|
+
// pushed with nothing listening is gone.
|
|
116
|
+
const collected: Array<{ results: unknown[]; matchKind?: string }> = [];
|
|
117
|
+
const sub = stateUnit.search.state$.subscribe((st) => collected.push(st));
|
|
118
|
+
|
|
119
|
+
stateUnit.search.setQuery('kitten');
|
|
120
|
+
await vi.advanceTimersByTimeAsync(300);
|
|
121
|
+
|
|
122
|
+
const last = collected.at(-1)!;
|
|
123
|
+
expect(last.results).toEqual([{ '@id': 'sem-1' }]);
|
|
124
|
+
expect(last.matchKind).toBe('semantic');
|
|
125
|
+
|
|
126
|
+
sub.unsubscribe();
|
|
127
|
+
stateUnit.dispose();
|
|
128
|
+
} finally {
|
|
129
|
+
vi.useRealTimers();
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
it('carries no matchKind on the empty-query view', async () => {
|
|
134
|
+
// Clearing the box returns to `recent`, which no label describes.
|
|
135
|
+
const { client } = mockClient();
|
|
136
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
137
|
+
|
|
138
|
+
const first = await firstValueFrom(stateUnit.search.state$);
|
|
139
|
+
expect(first.results).toEqual([]);
|
|
140
|
+
expect(first.matchKind).toBeUndefined();
|
|
141
|
+
|
|
142
|
+
stateUnit.dispose();
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
describe('createDiscoverStateUnit', () => {
|
|
147
|
+
it('exposes recent resources from browse namespace', async () => {
|
|
148
|
+
const { client } = mockClient();
|
|
149
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
150
|
+
|
|
151
|
+
const recent = await firstValueFrom(stateUnit.recent.value$);
|
|
152
|
+
expect(recent).toEqual([{ '@id': 'r1' }]);
|
|
153
|
+
|
|
154
|
+
stateUnit.dispose();
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
it('exposes entity types from browse namespace', async () => {
|
|
158
|
+
const { client } = mockClient();
|
|
159
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
160
|
+
|
|
161
|
+
const types = await firstValueFrom(stateUnit.entityTypes.value$);
|
|
162
|
+
expect(types).toEqual(['Person']);
|
|
163
|
+
|
|
164
|
+
stateUnit.dispose();
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('falls back to [] when entityTypes() emits undefined', async () => {
|
|
168
|
+
const entityTypes$ = new BehaviorSubject<string[] | undefined>(undefined);
|
|
169
|
+
const { client } = mockClient({ entityTypes$ });
|
|
170
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
171
|
+
|
|
172
|
+
const types = await firstValueFrom(stateUnit.entityTypes.value$);
|
|
173
|
+
expect(types).toEqual([]);
|
|
174
|
+
|
|
175
|
+
stateUnit.dispose();
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
it('reports loading when resources are undefined', async () => {
|
|
179
|
+
const resources$ = new BehaviorSubject<unknown[] | undefined>(undefined);
|
|
180
|
+
const { client } = mockClient({ resources$ });
|
|
181
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
182
|
+
|
|
183
|
+
const loading = await firstValueFrom(stateUnit.recent.loading$);
|
|
184
|
+
expect(loading).toBe(true);
|
|
185
|
+
|
|
186
|
+
resources$.next([]);
|
|
187
|
+
const loaded = await firstValueFrom(
|
|
188
|
+
stateUnit.recent.loading$.pipe(filter((l) => !l)),
|
|
189
|
+
);
|
|
190
|
+
expect(loaded).toBe(false);
|
|
191
|
+
|
|
192
|
+
stateUnit.dispose();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
it('exposes a search pipeline', () => {
|
|
196
|
+
const { client } = mockClient();
|
|
197
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
198
|
+
|
|
199
|
+
expect(stateUnit.search).toBeDefined();
|
|
200
|
+
expect(typeof stateUnit.search.setQuery).toBe('function');
|
|
201
|
+
expect(stateUnit.search.state$).toBeDefined();
|
|
202
|
+
|
|
203
|
+
stateUnit.dispose();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('initial selectedEntityType$ is empty and recent fetch carries no entityType', async () => {
|
|
207
|
+
const { client, resourceCalls } = mockClient();
|
|
208
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
209
|
+
|
|
210
|
+
await firstValueFrom(stateUnit.recent.value$);
|
|
211
|
+
|
|
212
|
+
expect(resourceCalls).toHaveLength(1);
|
|
213
|
+
expect(resourceCalls[0]).toEqual({ limit: 10, archived: false });
|
|
214
|
+
expect(await firstValueFrom(stateUnit.selectedEntityType$)).toBe('');
|
|
215
|
+
|
|
216
|
+
stateUnit.dispose();
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
it('setSelectedEntityType drives a refetch with the entityType filter', async () => {
|
|
220
|
+
const { client, resourceCalls } = mockClient();
|
|
221
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
222
|
+
|
|
223
|
+
// Prime the first subscription so the switchMap is live.
|
|
224
|
+
const sub = stateUnit.recent.value$.subscribe();
|
|
225
|
+
|
|
226
|
+
stateUnit.setSelectedEntityType('Person');
|
|
227
|
+
|
|
228
|
+
expect(await firstValueFrom(stateUnit.selectedEntityType$)).toBe('Person');
|
|
229
|
+
// Two calls expected: initial '' then 'Person'.
|
|
230
|
+
expect(resourceCalls.length).toBeGreaterThanOrEqual(2);
|
|
231
|
+
expect(resourceCalls.at(-1)).toEqual({
|
|
232
|
+
limit: 10,
|
|
233
|
+
archived: false,
|
|
234
|
+
entityType: 'Person',
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
sub.unsubscribe();
|
|
238
|
+
stateUnit.dispose();
|
|
239
|
+
});
|
|
240
|
+
|
|
241
|
+
it('search with an empty query yields no results without hitting the wire', async () => {
|
|
242
|
+
vi.useFakeTimers();
|
|
243
|
+
try {
|
|
244
|
+
const { client, resourceCalls } = mockClient();
|
|
245
|
+
const stateUnit = createDiscoverStateUnit(
|
|
246
|
+
sessionOf(client),
|
|
247
|
+
mockBrowse(),
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
const collected: Array<{ results: unknown[]; isSearching: boolean }> = [];
|
|
251
|
+
const sub = stateUnit.search.state$.subscribe((s) => collected.push(s));
|
|
252
|
+
|
|
253
|
+
await vi.advanceTimersByTimeAsync(300);
|
|
254
|
+
|
|
255
|
+
expect(collected.at(-1)).toEqual({ results: [], isSearching: false });
|
|
256
|
+
const searchCalls = resourceCalls.filter((c) => c.search !== undefined);
|
|
257
|
+
expect(searchCalls).toHaveLength(0);
|
|
258
|
+
|
|
259
|
+
sub.unsubscribe();
|
|
260
|
+
stateUnit.dispose();
|
|
261
|
+
} finally {
|
|
262
|
+
vi.useRealTimers();
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
it('search with a non-empty query and selected entityType pushes both into the filter', async () => {
|
|
267
|
+
vi.useFakeTimers();
|
|
268
|
+
try {
|
|
269
|
+
const results$ = new BehaviorSubject<unknown[] | undefined>([
|
|
270
|
+
{ '@id': 'hit' },
|
|
271
|
+
]);
|
|
272
|
+
const { client, resourceCalls } = mockClient({
|
|
273
|
+
resourcesFn: (filters) =>
|
|
274
|
+
filters.search
|
|
275
|
+
? results$
|
|
276
|
+
: new BehaviorSubject<unknown[] | undefined>([]),
|
|
277
|
+
});
|
|
278
|
+
const stateUnit = createDiscoverStateUnit(
|
|
279
|
+
sessionOf(client),
|
|
280
|
+
mockBrowse(),
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
const sub = stateUnit.search.state$.subscribe();
|
|
284
|
+
stateUnit.setSelectedEntityType('Person');
|
|
285
|
+
stateUnit.search.setQuery('lincoln');
|
|
286
|
+
|
|
287
|
+
await vi.advanceTimersByTimeAsync(300);
|
|
288
|
+
|
|
289
|
+
const searchCalls = resourceCalls.filter((c) => c.search !== undefined);
|
|
290
|
+
expect(searchCalls.length).toBeGreaterThanOrEqual(1);
|
|
291
|
+
expect(searchCalls.at(-1)).toEqual({
|
|
292
|
+
search: 'lincoln',
|
|
293
|
+
limit: 20,
|
|
294
|
+
entityType: 'Person',
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
sub.unsubscribe();
|
|
298
|
+
stateUnit.dispose();
|
|
299
|
+
} finally {
|
|
300
|
+
vi.useRealTimers();
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('search results flow through state$ once the debounced query fetches', async () => {
|
|
305
|
+
vi.useFakeTimers();
|
|
306
|
+
try {
|
|
307
|
+
const results$ = new BehaviorSubject<unknown[] | undefined>([
|
|
308
|
+
{ '@id': 'hit' },
|
|
309
|
+
]);
|
|
310
|
+
const { client } = mockClient({
|
|
311
|
+
resourcesFn: () => results$,
|
|
312
|
+
});
|
|
313
|
+
const stateUnit = createDiscoverStateUnit(
|
|
314
|
+
sessionOf(client),
|
|
315
|
+
mockBrowse(),
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
const collected: Array<{ results: unknown[]; isSearching: boolean }> = [];
|
|
319
|
+
const sub = stateUnit.search.state$.subscribe((s) => collected.push(s));
|
|
320
|
+
|
|
321
|
+
stateUnit.search.setQuery('lincoln');
|
|
322
|
+
await vi.advanceTimersByTimeAsync(300);
|
|
323
|
+
|
|
324
|
+
expect(collected.at(-1)).toEqual({
|
|
325
|
+
results: [{ '@id': 'hit' }],
|
|
326
|
+
isSearching: false,
|
|
327
|
+
matchKind: 'lexical',
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
sub.unsubscribe();
|
|
331
|
+
stateUnit.dispose();
|
|
332
|
+
} finally {
|
|
333
|
+
vi.useRealTimers();
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('search reports isSearching while the fetch is in flight', async () => {
|
|
338
|
+
vi.useFakeTimers();
|
|
339
|
+
try {
|
|
340
|
+
const inflight$ = new BehaviorSubject<unknown[] | undefined>(undefined);
|
|
341
|
+
const { client } = mockClient({
|
|
342
|
+
resourcesFn: () => inflight$,
|
|
343
|
+
});
|
|
344
|
+
const stateUnit = createDiscoverStateUnit(
|
|
345
|
+
sessionOf(client),
|
|
346
|
+
mockBrowse(),
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
const collected: Array<{ results: unknown[]; isSearching: boolean }> = [];
|
|
350
|
+
const sub = stateUnit.search.state$.subscribe((s) => collected.push(s));
|
|
351
|
+
|
|
352
|
+
stateUnit.search.setQuery('lincoln');
|
|
353
|
+
await vi.advanceTimersByTimeAsync(300);
|
|
354
|
+
|
|
355
|
+
expect(collected.at(-1)).toEqual({ results: [], isSearching: true });
|
|
356
|
+
|
|
357
|
+
sub.unsubscribe();
|
|
358
|
+
stateUnit.dispose();
|
|
359
|
+
} finally {
|
|
360
|
+
vi.useRealTimers();
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
it('search query observable echoes the latest setQuery value', async () => {
|
|
365
|
+
const { client } = mockClient();
|
|
366
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
367
|
+
|
|
368
|
+
const queries = stateUnit.search.query$
|
|
369
|
+
.pipe(skip(1), take(1), toArray())
|
|
370
|
+
.toPromise();
|
|
371
|
+
stateUnit.search.setQuery('alpha');
|
|
372
|
+
|
|
373
|
+
expect(await queries).toEqual(['alpha']);
|
|
374
|
+
|
|
375
|
+
stateUnit.dispose();
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
it('omits entityType from the filter when the empty sentinel is selected', async () => {
|
|
379
|
+
const { client, resourceCalls } = mockClient();
|
|
380
|
+
const stateUnit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
381
|
+
|
|
382
|
+
const sub = stateUnit.recent.value$.subscribe();
|
|
383
|
+
stateUnit.setSelectedEntityType('Person');
|
|
384
|
+
stateUnit.setSelectedEntityType('');
|
|
385
|
+
|
|
386
|
+
const last = resourceCalls.at(-1)!;
|
|
387
|
+
expect(last.entityType).toBeUndefined();
|
|
388
|
+
|
|
389
|
+
sub.unsubscribe();
|
|
390
|
+
stateUnit.dispose();
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
|
|
394
|
+
describe('DiscoverStateUnit — StateUnit axioms', () => {
|
|
395
|
+
it('satisfies the StateUnit axioms (incl. A7-passed: never disposes the injected browse)', () => {
|
|
396
|
+
assertStateUnitAxioms<DiscoverStateUnit>({
|
|
397
|
+
setup: () => {
|
|
398
|
+
const browse = disposeProbe();
|
|
399
|
+
const { client } = mockClient();
|
|
400
|
+
return {
|
|
401
|
+
unit: createDiscoverStateUnit(
|
|
402
|
+
sessionOf(client),
|
|
403
|
+
browse as unknown as ShellStateUnit,
|
|
404
|
+
),
|
|
405
|
+
passedIn: [browse],
|
|
406
|
+
};
|
|
407
|
+
},
|
|
408
|
+
surfaces: (u) => [u.selectedEntityType$],
|
|
409
|
+
invocations: (u) => [() => u.setSelectedEntityType('')],
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
describe('createDiscoverStateUnit — terminal load failure', () => {
|
|
415
|
+
// A terminally failed list (B15) has no value either, so a `loading$` that
|
|
416
|
+
// is only "no value yet" would leave /know/discover spinning for ever.
|
|
417
|
+
|
|
418
|
+
it('recent: stops loading and surfaces the reason instead of spinning for ever', async () => {
|
|
419
|
+
const resources$ = new BehaviorSubject<unknown[] | undefined>(undefined);
|
|
420
|
+
const { client } = mockClient({ resources$ });
|
|
421
|
+
const unit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
422
|
+
|
|
423
|
+
expect(await firstValueFrom(unit.recent.loading$)).toBe(true);
|
|
424
|
+
resources$.next({
|
|
425
|
+
status: 'failed',
|
|
426
|
+
error: new Error('Resource not found'),
|
|
427
|
+
} as never);
|
|
428
|
+
|
|
429
|
+
expect(await firstValueFrom(unit.recent.loading$)).toBe(false);
|
|
430
|
+
expect(
|
|
431
|
+
((await firstValueFrom(unit.recent.error$)) as Error | null)?.message,
|
|
432
|
+
).toBe('Resource not found');
|
|
433
|
+
|
|
434
|
+
unit.dispose();
|
|
435
|
+
});
|
|
436
|
+
|
|
437
|
+
it('entityTypes: same, and keeps an empty list to render', async () => {
|
|
438
|
+
const entityTypes$ = new BehaviorSubject<string[] | undefined>(undefined);
|
|
439
|
+
const { client } = mockClient({ entityTypes$ });
|
|
440
|
+
const unit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
441
|
+
|
|
442
|
+
entityTypes$.next({ status: 'failed', error: new Error('boom') } as never);
|
|
443
|
+
|
|
444
|
+
expect(await firstValueFrom(unit.entityTypes.loading$)).toBe(false);
|
|
445
|
+
expect(await firstValueFrom(unit.entityTypes.error$)).not.toBeNull();
|
|
446
|
+
expect(await firstValueFrom(unit.entityTypes.value$)).toEqual([]);
|
|
447
|
+
|
|
448
|
+
unit.dispose();
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
it('recent.retry() re-issues the query and can recover', async () => {
|
|
452
|
+
// A fresh `observe()` is what clears the B15 marker, so retry must reach
|
|
453
|
+
// `browse.resources()` again rather than re-subscribing to a dead stream.
|
|
454
|
+
const attempts: BehaviorSubject<unknown[] | undefined>[] = [];
|
|
455
|
+
const { client } = mockClient({
|
|
456
|
+
resourcesFn: () => {
|
|
457
|
+
const s = new BehaviorSubject<unknown[] | undefined>(undefined);
|
|
458
|
+
attempts.push(s);
|
|
459
|
+
return s;
|
|
460
|
+
},
|
|
461
|
+
});
|
|
462
|
+
const unit = createDiscoverStateUnit(sessionOf(client), mockBrowse());
|
|
463
|
+
|
|
464
|
+
attempts[0]!.next({ status: 'failed', error: new Error('nope') } as never);
|
|
465
|
+
expect(await firstValueFrom(unit.recent.error$)).not.toBeNull();
|
|
466
|
+
|
|
467
|
+
unit.recent.retry();
|
|
468
|
+
expect(attempts.length).toBeGreaterThan(1);
|
|
469
|
+
expect(await firstValueFrom(unit.recent.error$)).toBeNull();
|
|
470
|
+
|
|
471
|
+
attempts[attempts.length - 1]!.next([{ '@id': 'r1' }]);
|
|
472
|
+
expect(await firstValueFrom(unit.recent.value$)).toHaveLength(1);
|
|
473
|
+
expect(await firstValueFrom(unit.recent.loading$)).toBe(false);
|
|
474
|
+
|
|
475
|
+
unit.dispose();
|
|
476
|
+
});
|
|
477
|
+
});
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BehaviorSubject,
|
|
3
|
+
Subject,
|
|
4
|
+
combineLatest,
|
|
5
|
+
of,
|
|
6
|
+
type Observable,
|
|
7
|
+
} from 'rxjs';
|
|
8
|
+
import { readyValue, type CacheState } from '@xynolog/sdk';
|
|
9
|
+
import {
|
|
10
|
+
debounceTime,
|
|
11
|
+
distinctUntilChanged,
|
|
12
|
+
map,
|
|
13
|
+
startWith,
|
|
14
|
+
switchMap,
|
|
15
|
+
shareReplay,
|
|
16
|
+
} from 'rxjs/operators';
|
|
17
|
+
import type { ResourceDescriptor, components } from '@xynolog/core';
|
|
18
|
+
import type { XynologSession } from '@xynolog/sdk';
|
|
19
|
+
import { SEARCH_DEBOUNCE_MS, type StateUnit } from '@xynolog/core';
|
|
20
|
+
import { createDisposer } from '@xynolog/sdk';
|
|
21
|
+
import type { ShellStateUnit } from '../../../state/shell-state-unit';
|
|
22
|
+
import { trackList, type ListState } from '../../../state/list-state';
|
|
23
|
+
|
|
24
|
+
const RECENT_LIMIT = 10;
|
|
25
|
+
const SEARCH_LIMIT = 20;
|
|
26
|
+
|
|
27
|
+
export interface DiscoverSearchPipeline {
|
|
28
|
+
query$: Observable<string>;
|
|
29
|
+
/**
|
|
30
|
+
* The page AND the label that describes it, as one value. `matchKind` is
|
|
31
|
+
* carried here rather than beside it because the rule that a label and the
|
|
32
|
+
* resources it describes arrive as one value (semantic-fallback axiom S10)
|
|
33
|
+
* is tier-agnostic: two separately-observable pieces of state let a render
|
|
34
|
+
* pair this query's label with the previous query's list. Undefined only
|
|
35
|
+
* before the first answer (and while a query is empty), never as a third
|
|
36
|
+
* kind.
|
|
37
|
+
*/
|
|
38
|
+
state$: Observable<{
|
|
39
|
+
results: ResourceDescriptor[];
|
|
40
|
+
isSearching: boolean;
|
|
41
|
+
matchKind?: components['schemas']['MatchResourcesResponse']['matchKind'];
|
|
42
|
+
}>;
|
|
43
|
+
setQuery(value: string): void;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface DiscoverStateUnit extends StateUnit {
|
|
47
|
+
browse: ShellStateUnit;
|
|
48
|
+
search: DiscoverSearchPipeline;
|
|
49
|
+
recent: ListState<ResourceDescriptor[]>;
|
|
50
|
+
entityTypes: ListState<string[]>;
|
|
51
|
+
selectedEntityType$: Observable<string>;
|
|
52
|
+
setSelectedEntityType(value: string): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createDiscoverStateUnit(
|
|
56
|
+
session: XynologSession,
|
|
57
|
+
browse: ShellStateUnit,
|
|
58
|
+
): DiscoverStateUnit {
|
|
59
|
+
const { client } = session;
|
|
60
|
+
const disposer = createDisposer();
|
|
61
|
+
// `browse` (ShellStateUnit) is a *passed-in* dependency owned by the caller
|
|
62
|
+
// (`useShellStateUnit`), not this unit — do NOT add it to the disposer (it's the
|
|
63
|
+
// shared, app-scoped shell). See https://github.com/xynolog/docs/blob/main/builder/STATE-UNITS.md (composition rule).
|
|
64
|
+
|
|
65
|
+
// Selected entity-type chip on the Discover page. Drives both the
|
|
66
|
+
// `recent` list and the search results — filtering happens on the
|
|
67
|
+
// gateway, not via post-fetch array filtering.
|
|
68
|
+
const selectedEntityType$ = new BehaviorSubject<string>('');
|
|
69
|
+
disposer.add(() => selectedEntityType$.complete());
|
|
70
|
+
|
|
71
|
+
const queryInput$ = new Subject<string>();
|
|
72
|
+
disposer.add(() => queryInput$.complete());
|
|
73
|
+
|
|
74
|
+
// `trackList` holds the single subscription and multicasts through its own
|
|
75
|
+
// subjects, so no `shareReplay` is needed — and one would be actively
|
|
76
|
+
// wrong here: a replayed ERROR cannot be retried away, and retry must
|
|
77
|
+
// reach `browse.resources()` again for B15 to clear the marker.
|
|
78
|
+
// The thunk therefore rebuilds the whole chain per attempt.
|
|
79
|
+
const recent = trackList<ResourceDescriptor[]>(
|
|
80
|
+
() =>
|
|
81
|
+
selectedEntityType$.pipe(
|
|
82
|
+
switchMap((et) =>
|
|
83
|
+
client.browse
|
|
84
|
+
.resources({
|
|
85
|
+
limit: RECENT_LIMIT,
|
|
86
|
+
archived: false,
|
|
87
|
+
...(et ? { entityType: et } : {}),
|
|
88
|
+
})
|
|
89
|
+
.pipe(
|
|
90
|
+
// This list renders only the page; project it out of the list
|
|
91
|
+
// envelope.
|
|
92
|
+
map((st): CacheState<ResourceDescriptor[]> =>
|
|
93
|
+
st.status === 'ready'
|
|
94
|
+
? { status: 'ready', value: st.value.resources }
|
|
95
|
+
: st,
|
|
96
|
+
),
|
|
97
|
+
),
|
|
98
|
+
),
|
|
99
|
+
),
|
|
100
|
+
[],
|
|
101
|
+
);
|
|
102
|
+
disposer.add(recent.dispose);
|
|
103
|
+
|
|
104
|
+
const entityTypes = trackList<string[]>(
|
|
105
|
+
() => client.browse.entityTypes(),
|
|
106
|
+
[],
|
|
107
|
+
);
|
|
108
|
+
disposer.add(entityTypes.dispose);
|
|
109
|
+
|
|
110
|
+
const debouncedQuery$ = queryInput$.pipe(
|
|
111
|
+
startWith(''),
|
|
112
|
+
debounceTime(SEARCH_DEBOUNCE_MS),
|
|
113
|
+
distinctUntilChanged(),
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const state$: DiscoverSearchPipeline['state$'] = combineLatest([
|
|
117
|
+
debouncedQuery$,
|
|
118
|
+
selectedEntityType$,
|
|
119
|
+
]).pipe(
|
|
120
|
+
switchMap(([q, et]) => {
|
|
121
|
+
const trimmed = q.trim();
|
|
122
|
+
if (!trimmed) {
|
|
123
|
+
// No query, no answer to label: `recent` is what renders, and no
|
|
124
|
+
// matchKind describes it.
|
|
125
|
+
return of({ results: [] as ResourceDescriptor[], isSearching: false });
|
|
126
|
+
}
|
|
127
|
+
return client.match
|
|
128
|
+
.resources(trimmed, {
|
|
129
|
+
limit: SEARCH_LIMIT,
|
|
130
|
+
...(et ? { entityType: et } : {}),
|
|
131
|
+
})
|
|
132
|
+
.pipe(
|
|
133
|
+
map((st) => {
|
|
134
|
+
const ready = readyValue(st);
|
|
135
|
+
return {
|
|
136
|
+
results: ready?.resources ?? [],
|
|
137
|
+
isSearching: st.status === 'pending',
|
|
138
|
+
...(ready ? { matchKind: ready.matchKind } : {}),
|
|
139
|
+
};
|
|
140
|
+
}),
|
|
141
|
+
startWith({ results: [] as ResourceDescriptor[], isSearching: true }),
|
|
142
|
+
);
|
|
143
|
+
}),
|
|
144
|
+
shareReplay({ bufferSize: 1, refCount: true }),
|
|
145
|
+
);
|
|
146
|
+
|
|
147
|
+
const search: DiscoverSearchPipeline = {
|
|
148
|
+
query$: queryInput$.pipe(startWith('')),
|
|
149
|
+
state$,
|
|
150
|
+
setQuery: (value) => queryInput$.next(value),
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
return {
|
|
154
|
+
browse,
|
|
155
|
+
search,
|
|
156
|
+
recent: recent.state,
|
|
157
|
+
entityTypes: entityTypes.state,
|
|
158
|
+
selectedEntityType$: selectedEntityType$.asObservable(),
|
|
159
|
+
setSelectedEntityType: (value) => selectedEntityType$.next(value),
|
|
160
|
+
dispose: () => disposer.dispose(),
|
|
161
|
+
};
|
|
162
|
+
}
|