@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,532 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The resource-generate flow modal.
|
|
3
|
+
*
|
|
4
|
+
* One composite stack, no step machine: the gather controls sit at the TOP,
|
|
5
|
+
* the gathered evidence appears below them once gather fires, and the
|
|
6
|
+
* generation params render beneath the evidence once context arrives —
|
|
7
|
+
* [gather zone] → [evidence] → [act zone], the same grammar the resolve
|
|
8
|
+
* wizard expresses. Gather state arrives as PROPS (the page reads
|
|
9
|
+
* `gather.resourceContext$` and friends off the state unit) and the gather
|
|
10
|
+
* itself is an `onGather` callback — the modal mocks no hook and reaches for
|
|
11
|
+
* no provider. Entity-type options are owner-supplied, so a failed
|
|
12
|
+
* load cannot surface as an empty vocabulary.
|
|
13
|
+
*/
|
|
14
|
+
import { describe, it, expect, vi, beforeEach, type Mock } from 'vitest';
|
|
15
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
16
|
+
import '@testing-library/jest-dom';
|
|
17
|
+
import type { GatheredContext } from '@xynolog/core';
|
|
18
|
+
import type { ResourceGatherOptions } from '@xynolog/sdk';
|
|
19
|
+
import type { GenerationConfig } from '../ConfigureGenerationStep';
|
|
20
|
+
import { ResourceGenerateModal } from '../ResourceGenerateModal';
|
|
21
|
+
|
|
22
|
+
const RESOURCE_CONTEXT = {
|
|
23
|
+
focus: {
|
|
24
|
+
kind: 'resource',
|
|
25
|
+
resource: { '@id': 'res-1', name: 'My Resource' },
|
|
26
|
+
summary: 'A short summary',
|
|
27
|
+
},
|
|
28
|
+
graph: {
|
|
29
|
+
nodes: [{ id: 'res-1', type: 'resource', label: 'My Resource' }],
|
|
30
|
+
edges: [],
|
|
31
|
+
},
|
|
32
|
+
metadata: {},
|
|
33
|
+
} as unknown as GatheredContext;
|
|
34
|
+
|
|
35
|
+
const T = {
|
|
36
|
+
title: 'Generate from this Resource',
|
|
37
|
+
gatherIntro: 'Choose what to include.',
|
|
38
|
+
includeContent: 'Include content',
|
|
39
|
+
includeSummary: 'Include summary',
|
|
40
|
+
gatherDepth: 'Depth',
|
|
41
|
+
gatherMaxResources: 'Max resources',
|
|
42
|
+
gatherButton: 'Gather',
|
|
43
|
+
recallLabel: 'Included in recall — deselect to exclude',
|
|
44
|
+
loadingContext: 'Gathering…',
|
|
45
|
+
failedContext: 'Failed',
|
|
46
|
+
sourceContextLabel: 'Resource',
|
|
47
|
+
connectionsLabel: 'Connections',
|
|
48
|
+
citedByLabel: 'Cited by',
|
|
49
|
+
graphPaneTitle: 'In the graph',
|
|
50
|
+
graphEmpty: 'No links yet.',
|
|
51
|
+
resourceLinkLabel: 'Resource link',
|
|
52
|
+
corpusPaneTitle: 'In the corpus',
|
|
53
|
+
corpusEmpty: 'Nothing similar in the corpus.',
|
|
54
|
+
excludedReceipt: '{{types}} excluded from this recall',
|
|
55
|
+
machineRead: 'OCR',
|
|
56
|
+
score: 'Score',
|
|
57
|
+
resourceTitle: 'New resource title',
|
|
58
|
+
resourceTitlePlaceholder: 'Title…',
|
|
59
|
+
saveLocation: 'Save location',
|
|
60
|
+
additionalInstructions: 'Additional Instructions',
|
|
61
|
+
additionalInstructionsPlaceholder: 'Optional…',
|
|
62
|
+
language: 'Language',
|
|
63
|
+
languageHelp: 'Language help',
|
|
64
|
+
creativity: 'Creativity',
|
|
65
|
+
creativityFocused: 'Focused',
|
|
66
|
+
creativityCreative: 'Creative',
|
|
67
|
+
maxLength: 'Max Length',
|
|
68
|
+
maxLengthHelp: 'Max help',
|
|
69
|
+
maxLengthCeiling: 'Limited to {{maxOutputTokens}} tokens by {{model}}.',
|
|
70
|
+
outputFormat: 'Format',
|
|
71
|
+
formatExtensionMismatch:
|
|
72
|
+
'Save location must end in {{extension}} to match the selected format.',
|
|
73
|
+
generate: 'Generate',
|
|
74
|
+
discardDraftPrompt: 'Discard this draft?',
|
|
75
|
+
discardDraft: 'Discard',
|
|
76
|
+
keepEditing: 'Keep editing',
|
|
77
|
+
editGather: 'Change gather settings',
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
let onClose: Mock<() => void>;
|
|
81
|
+
let onGenerateSubmit: Mock<
|
|
82
|
+
(resourceId: string, config: GenerationConfig) => void
|
|
83
|
+
>;
|
|
84
|
+
let onGather: Mock<(options: ResourceGatherOptions) => void>;
|
|
85
|
+
|
|
86
|
+
function renderModal(
|
|
87
|
+
props: Partial<React.ComponentProps<typeof ResourceGenerateModal>> = {},
|
|
88
|
+
) {
|
|
89
|
+
return render(
|
|
90
|
+
<ResourceGenerateModal
|
|
91
|
+
isOpen
|
|
92
|
+
onClose={onClose}
|
|
93
|
+
resourceId="res-1"
|
|
94
|
+
defaultTitle="Default Title"
|
|
95
|
+
locale="en"
|
|
96
|
+
entityTypeOptions={['Person', 'Topic']}
|
|
97
|
+
onGenerateSubmit={onGenerateSubmit}
|
|
98
|
+
gatherContext={null}
|
|
99
|
+
gatherLoading={false}
|
|
100
|
+
gatherError={null}
|
|
101
|
+
onGather={onGather}
|
|
102
|
+
translations={T}
|
|
103
|
+
{...props}
|
|
104
|
+
/>,
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
describe('ResourceGenerateModal', () => {
|
|
109
|
+
beforeEach(() => {
|
|
110
|
+
vi.clearAllMocks();
|
|
111
|
+
onClose = vi.fn<() => void>();
|
|
112
|
+
onGenerateSubmit =
|
|
113
|
+
vi.fn<(resourceId: string, config: GenerationConfig) => void>();
|
|
114
|
+
onGather = vi.fn<(options: ResourceGatherOptions) => void>();
|
|
115
|
+
// jsdom doesn't implement scrollIntoView; GatherContextStep may call it.
|
|
116
|
+
Element.prototype.scrollIntoView = vi.fn();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it('renders nothing when closed', () => {
|
|
120
|
+
renderModal({ isOpen: false });
|
|
121
|
+
expect(screen.queryByText(T.title)).not.toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it('opens with the gather controls at the top and nothing below them yet', () => {
|
|
125
|
+
// Stale slots must not leak a previous run's evidence into a fresh open:
|
|
126
|
+
// even with a context PROP already present, nothing renders below the
|
|
127
|
+
// controls until THIS run's gather fires.
|
|
128
|
+
const { baseElement } = renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
129
|
+
expect(screen.getByText(T.title)).toBeInTheDocument(); // the one modal title
|
|
130
|
+
expect(screen.getByText(T.gatherIntro)).toBeInTheDocument();
|
|
131
|
+
expect(screen.getByLabelText(T.includeContent)).toBeInTheDocument();
|
|
132
|
+
expect(screen.getByRole('button', { name: 'Person' })).toBeInTheDocument();
|
|
133
|
+
expect(screen.getByRole('button', { name: 'Topic' })).toBeInTheDocument();
|
|
134
|
+
expect(
|
|
135
|
+
baseElement.querySelector('.xynolog-wizard__step-scroll'),
|
|
136
|
+
).not.toBeNull();
|
|
137
|
+
expect(screen.queryByText(T.graphPaneTitle)).not.toBeInTheDocument();
|
|
138
|
+
expect(screen.queryByLabelText(T.resourceTitle)).not.toBeInTheDocument();
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('Gather emits onGather; the spent controls collapse to a receipt of what fired', () => {
|
|
142
|
+
// The modal does not know how to gather — it says WHAT to gather and the
|
|
143
|
+
// page wires the state unit. No resourceId in the payload: the
|
|
144
|
+
// owner already holds it.
|
|
145
|
+
const { baseElement } = renderModal({ gatherLoading: true });
|
|
146
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
147
|
+
expect(onGather).toHaveBeenCalledWith({
|
|
148
|
+
includeContent: true,
|
|
149
|
+
includeSummary: true,
|
|
150
|
+
depth: 2,
|
|
151
|
+
maxResources: 10,
|
|
152
|
+
});
|
|
153
|
+
expect(
|
|
154
|
+
baseElement.querySelector('.xynolog-gather__loading'),
|
|
155
|
+
).not.toBeNull();
|
|
156
|
+
// The form's job is done: it folds into a one-line receipt of what THIS
|
|
157
|
+
// gather asked for, and the evidence leads the pane. The form stays
|
|
158
|
+
// mounted (hidden) so its values survive for the expand path.
|
|
159
|
+
const receipt = screen.getByTitle(T.editGather);
|
|
160
|
+
expect(receipt.textContent).toContain(`${T.gatherDepth} 2`);
|
|
161
|
+
expect(receipt.textContent).toContain(`${T.gatherMaxResources} 10`);
|
|
162
|
+
expect(receipt.textContent).toContain(T.includeContent);
|
|
163
|
+
expect(screen.getByText(T.gatherIntro)).not.toBeVisible();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('the receipt names the exclusions of THIS recall', () => {
|
|
167
|
+
renderModal();
|
|
168
|
+
fireEvent.click(screen.getByRole('button', { name: 'Person' }));
|
|
169
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
170
|
+
expect(screen.getByTitle(T.editGather).textContent).toContain(
|
|
171
|
+
'Person excluded from this recall',
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
it('the receipt expands back to the form — values preserved — and re-gather collapses again', () => {
|
|
176
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
177
|
+
fireEvent.change(screen.getByLabelText(T.gatherDepth), {
|
|
178
|
+
target: { value: '3' },
|
|
179
|
+
});
|
|
180
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
181
|
+
expect(screen.getByTitle(T.editGather).textContent).toContain(
|
|
182
|
+
`${T.gatherDepth} 3`,
|
|
183
|
+
);
|
|
184
|
+
|
|
185
|
+
fireEvent.click(screen.getByTitle(T.editGather));
|
|
186
|
+
const depthInput = screen.getByLabelText(T.gatherDepth);
|
|
187
|
+
expect(depthInput).toBeVisible();
|
|
188
|
+
expect(depthInput).toHaveValue(3); // not re-initialized — the form never unmounted
|
|
189
|
+
expect(screen.queryByTitle(T.editGather)).not.toBeInTheDocument();
|
|
190
|
+
|
|
191
|
+
fireEvent.change(depthInput, { target: { value: '1' } });
|
|
192
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
193
|
+
expect(onGather).toHaveBeenCalledTimes(2);
|
|
194
|
+
expect(onGather).toHaveBeenLastCalledWith(
|
|
195
|
+
expect.objectContaining({ depth: 1 }),
|
|
196
|
+
);
|
|
197
|
+
expect(screen.getByTitle(T.editGather).textContent).toContain(
|
|
198
|
+
`${T.gatherDepth} 1`,
|
|
199
|
+
);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it('threads crossed-off entity types into the gather options as the exclude list', () => {
|
|
203
|
+
renderModal();
|
|
204
|
+
fireEvent.click(screen.getByRole('button', { name: 'Person' })); // cross off the recall
|
|
205
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
206
|
+
expect(onGather).toHaveBeenCalledWith({
|
|
207
|
+
includeContent: true,
|
|
208
|
+
includeSummary: true,
|
|
209
|
+
depth: 2,
|
|
210
|
+
maxResources: 10,
|
|
211
|
+
excludeEntityTypes: ['Person'],
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('every entity type starts INCLUDED — deselecting is what excludes (recall chips)', () => {
|
|
216
|
+
// The SDK's wire is an exclude list, but the natural posture is
|
|
217
|
+
// "everything is in the recall until you say otherwise": chips render
|
|
218
|
+
// included by default and a click crosses one off.
|
|
219
|
+
renderModal();
|
|
220
|
+
expect(screen.getByText(T.recallLabel)).toBeInTheDocument();
|
|
221
|
+
const person = screen.getByRole('button', { name: 'Person' });
|
|
222
|
+
const topic = screen.getByRole('button', { name: 'Topic' });
|
|
223
|
+
expect(person).toHaveAttribute('aria-pressed', 'true');
|
|
224
|
+
expect(person).toHaveAttribute('data-included', 'true');
|
|
225
|
+
expect(person.className).toContain('xynolog-form__recall-chip');
|
|
226
|
+
|
|
227
|
+
fireEvent.click(person);
|
|
228
|
+
expect(person).toHaveAttribute('aria-pressed', 'false');
|
|
229
|
+
expect(person).toHaveAttribute('data-included', 'false');
|
|
230
|
+
expect(topic).toHaveAttribute('aria-pressed', 'true'); // the rest stay in
|
|
231
|
+
|
|
232
|
+
fireEvent.click(person); // back in — the toggle round-trips
|
|
233
|
+
expect(person).toHaveAttribute('aria-pressed', 'true');
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('params render beneath the evidence once context arrives; Generate emits and closes', () => {
|
|
237
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT }); // gather resolves immediately
|
|
238
|
+
|
|
239
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
240
|
+
|
|
241
|
+
fireEvent.change(screen.getByLabelText(T.resourceTitle), {
|
|
242
|
+
target: { value: 'Generated Doc' },
|
|
243
|
+
});
|
|
244
|
+
fireEvent.change(screen.getByLabelText(T.saveLocation), {
|
|
245
|
+
target: { value: 'generated/out.md' },
|
|
246
|
+
});
|
|
247
|
+
fireEvent.click(screen.getByRole('button', { name: /Generate/ }));
|
|
248
|
+
|
|
249
|
+
expect(onGenerateSubmit).toHaveBeenCalledTimes(1);
|
|
250
|
+
expect(onGenerateSubmit).toHaveBeenCalledWith(
|
|
251
|
+
'res-1',
|
|
252
|
+
expect.objectContaining({
|
|
253
|
+
title: 'Generated Doc',
|
|
254
|
+
// The submitted payload names this what it IS — a full storage
|
|
255
|
+
// URI, built here by prefixing `file://`.
|
|
256
|
+
storageUri: 'file://generated/out.md',
|
|
257
|
+
// The default is sent, not inherited from the worker.
|
|
258
|
+
outputMediaType: 'text/markdown',
|
|
259
|
+
context: RESOURCE_CONTEXT,
|
|
260
|
+
}),
|
|
261
|
+
);
|
|
262
|
+
expect(onClose).toHaveBeenCalled();
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('a chosen output format survives the host to onGenerateSubmit', () => {
|
|
266
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
267
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
268
|
+
|
|
269
|
+
fireEvent.change(screen.getByLabelText(T.resourceTitle), {
|
|
270
|
+
target: { value: 'Generated Doc' },
|
|
271
|
+
});
|
|
272
|
+
fireEvent.change(screen.getByLabelText(T.saveLocation), {
|
|
273
|
+
target: { value: 'generated/out.pdf' },
|
|
274
|
+
});
|
|
275
|
+
fireEvent.change(screen.getByLabelText(T.outputFormat), {
|
|
276
|
+
target: { value: 'application/pdf' },
|
|
277
|
+
});
|
|
278
|
+
fireEvent.click(screen.getByRole('button', { name: /Generate/ }));
|
|
279
|
+
|
|
280
|
+
expect(onGenerateSubmit).toHaveBeenCalledWith(
|
|
281
|
+
'res-1',
|
|
282
|
+
expect.objectContaining({
|
|
283
|
+
outputMediaType: 'application/pdf',
|
|
284
|
+
storageUri: 'file://generated/out.pdf',
|
|
285
|
+
}),
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it('a failed gather shows its failure in place', () => {
|
|
290
|
+
// The props are the state unit's slots verbatim; the modal renders them
|
|
291
|
+
// without owning them.
|
|
292
|
+
renderModal({ gatherLoading: true });
|
|
293
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
294
|
+
|
|
295
|
+
render(
|
|
296
|
+
<ResourceGenerateModal
|
|
297
|
+
isOpen
|
|
298
|
+
onClose={onClose}
|
|
299
|
+
resourceId="res-1"
|
|
300
|
+
defaultTitle="Default Title"
|
|
301
|
+
locale="en"
|
|
302
|
+
entityTypeOptions={['Person', 'Topic']}
|
|
303
|
+
onGenerateSubmit={onGenerateSubmit}
|
|
304
|
+
gatherContext={null}
|
|
305
|
+
gatherLoading={false}
|
|
306
|
+
gatherError={new Error('boom')}
|
|
307
|
+
onGather={onGather}
|
|
308
|
+
translations={T}
|
|
309
|
+
/>,
|
|
310
|
+
);
|
|
311
|
+
fireEvent.click(screen.getAllByRole('button', { name: /Gather/ }).at(-1)!);
|
|
312
|
+
expect(screen.getByText(T.failedContext)).toBeInTheDocument();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
it('re-Gather refreshes the evidence in place — the stack stays', () => {
|
|
316
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
317
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
318
|
+
fireEvent.click(screen.getByTitle(T.editGather)); // expand the receipt
|
|
319
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ })); // tweak-and-regather
|
|
320
|
+
expect(onGather).toHaveBeenCalledTimes(2);
|
|
321
|
+
expect(screen.getByText(T.graphPaneTitle)).toBeInTheDocument();
|
|
322
|
+
expect(screen.getByLabelText(T.resourceTitle)).toBeInTheDocument();
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
it('no Back anywhere — a single stack has nothing to go back to', () => {
|
|
326
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
327
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
328
|
+
expect(screen.queryAllByRole('button', { name: /Back/ })).toHaveLength(0);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
it('the header close button calls onClose', () => {
|
|
332
|
+
renderModal();
|
|
333
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
334
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it('calls the onClose of the latest render', () => {
|
|
338
|
+
// The modal reads the host's callbacks through refs. A host that passes a
|
|
339
|
+
// new function on each render must be called with the one it passed last.
|
|
340
|
+
const { rerender } = renderModal();
|
|
341
|
+
const latest = vi.fn<() => void>();
|
|
342
|
+
rerender(
|
|
343
|
+
<ResourceGenerateModal
|
|
344
|
+
isOpen
|
|
345
|
+
onClose={latest}
|
|
346
|
+
resourceId="res-1"
|
|
347
|
+
defaultTitle="Default Title"
|
|
348
|
+
locale="en"
|
|
349
|
+
entityTypeOptions={['Person', 'Topic']}
|
|
350
|
+
onGenerateSubmit={onGenerateSubmit}
|
|
351
|
+
gatherContext={null}
|
|
352
|
+
gatherLoading={false}
|
|
353
|
+
gatherError={null}
|
|
354
|
+
onGather={onGather}
|
|
355
|
+
translations={T}
|
|
356
|
+
/>,
|
|
357
|
+
);
|
|
358
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
359
|
+
expect(latest).toHaveBeenCalledTimes(1);
|
|
360
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
it('opening seeds the proposed title from defaultTitle, even one that arrived after mount', () => {
|
|
364
|
+
// The page passes the source resource's name, which loads asynchronously —
|
|
365
|
+
// a draft seeded only in the useState initializer holds whatever was there
|
|
366
|
+
// at FIRST render, which for the real page is ''. Opening is the moment
|
|
367
|
+
// that matters: the draft re-seeds then.
|
|
368
|
+
const { rerender } = render(
|
|
369
|
+
<ResourceGenerateModal
|
|
370
|
+
isOpen={false}
|
|
371
|
+
onClose={onClose}
|
|
372
|
+
resourceId="res-1"
|
|
373
|
+
defaultTitle=""
|
|
374
|
+
locale="en"
|
|
375
|
+
entityTypeOptions={[]}
|
|
376
|
+
onGenerateSubmit={onGenerateSubmit}
|
|
377
|
+
gatherContext={RESOURCE_CONTEXT}
|
|
378
|
+
gatherLoading={false}
|
|
379
|
+
gatherError={null}
|
|
380
|
+
onGather={onGather}
|
|
381
|
+
translations={T}
|
|
382
|
+
/>,
|
|
383
|
+
);
|
|
384
|
+
rerender(
|
|
385
|
+
<ResourceGenerateModal
|
|
386
|
+
isOpen
|
|
387
|
+
onClose={onClose}
|
|
388
|
+
resourceId="res-1"
|
|
389
|
+
defaultTitle="PB"
|
|
390
|
+
locale="en"
|
|
391
|
+
entityTypeOptions={[]}
|
|
392
|
+
onGenerateSubmit={onGenerateSubmit}
|
|
393
|
+
gatherContext={RESOURCE_CONTEXT}
|
|
394
|
+
gatherLoading={false}
|
|
395
|
+
gatherError={null}
|
|
396
|
+
onGather={onGather}
|
|
397
|
+
translations={T}
|
|
398
|
+
/>,
|
|
399
|
+
);
|
|
400
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
401
|
+
expect(screen.getByLabelText(T.resourceTitle)).toHaveValue('PB');
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
it('evidence stays in view above the params — ONE scroll pane, nothing scrolls alone', () => {
|
|
405
|
+
const { baseElement } = renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
406
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
407
|
+
|
|
408
|
+
const scroll = baseElement.querySelector('.xynolog-wizard__step-scroll');
|
|
409
|
+
expect(scroll).not.toBeNull();
|
|
410
|
+
expect(scroll!.querySelector('.xynolog-gather__outer')).not.toBeNull(); // the evidence
|
|
411
|
+
expect(screen.getByText(T.graphPaneTitle)).toBeInTheDocument(); // graph pane up
|
|
412
|
+
expect(screen.getByLabelText(T.resourceTitle)).toBeInTheDocument(); // the form, below
|
|
413
|
+
for (const form of Array.from(
|
|
414
|
+
scroll!.querySelectorAll('form.xynolog-form'),
|
|
415
|
+
)) {
|
|
416
|
+
expect(form.className).not.toContain('xynolog-form--scrollable');
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it('the panel carries the widened class', () => {
|
|
421
|
+
const { baseElement } = renderModal();
|
|
422
|
+
const panel = baseElement.querySelector(
|
|
423
|
+
'.xynolog-search-modal__panel--gather',
|
|
424
|
+
);
|
|
425
|
+
expect(panel).not.toBeNull();
|
|
426
|
+
expect(panel!.className).toContain('xynolog-search-modal__panel--wide');
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
it('every footer is the wizard footer — no dismissal, no flex', () => {
|
|
430
|
+
// The modal renders via a HeadlessUI portal, so query the whole document.
|
|
431
|
+
const { baseElement } = renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
432
|
+
const footerPins = () => {
|
|
433
|
+
expect(
|
|
434
|
+
baseElement.querySelector('.xynolog-modal__actions--wizard'),
|
|
435
|
+
).not.toBeNull();
|
|
436
|
+
expect(
|
|
437
|
+
baseElement.querySelectorAll('.xynolog-button--flex'),
|
|
438
|
+
).toHaveLength(0);
|
|
439
|
+
const footerButtons = Array.from(
|
|
440
|
+
baseElement.querySelectorAll('.xynolog-modal__actions button'),
|
|
441
|
+
).map((b) => b.textContent ?? '');
|
|
442
|
+
expect(footerButtons.filter((l) => /cancel|✕/i.test(l))).toEqual([]);
|
|
443
|
+
};
|
|
444
|
+
|
|
445
|
+
footerPins(); // controls alone
|
|
446
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
447
|
+
footerPins(); // the full stack: Gather footer + Generate footer
|
|
448
|
+
});
|
|
449
|
+
});
|
|
450
|
+
|
|
451
|
+
// Dismissal guards typed work, and typed text only (title beyond the seeded
|
|
452
|
+
// default, save location, instructions); checkbox, depth, and exclusion state
|
|
453
|
+
// is cheap to redo and never nags.
|
|
454
|
+
describe('ResourceGenerateModal — dismissal guards typed work', () => {
|
|
455
|
+
beforeEach(() => {
|
|
456
|
+
onClose = vi.fn();
|
|
457
|
+
onGenerateSubmit = vi.fn();
|
|
458
|
+
onGather = vi.fn();
|
|
459
|
+
});
|
|
460
|
+
|
|
461
|
+
it('a typed save location guards dismissal; Keep editing stays, Discard closes', () => {
|
|
462
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
463
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ })); // reveal the stack
|
|
464
|
+
fireEvent.change(screen.getByLabelText(T.saveLocation), {
|
|
465
|
+
target: { value: 'generated/out.md' },
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
469
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
470
|
+
expect(screen.getByText(T.discardDraftPrompt)).toBeInTheDocument();
|
|
471
|
+
|
|
472
|
+
fireEvent.click(screen.getByRole('button', { name: T.keepEditing }));
|
|
473
|
+
expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
|
|
474
|
+
expect(screen.getByLabelText(T.saveLocation)).toHaveValue(
|
|
475
|
+
'generated/out.md',
|
|
476
|
+
);
|
|
477
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
478
|
+
|
|
479
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
480
|
+
fireEvent.click(screen.getByRole('button', { name: T.discardDraft }));
|
|
481
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
it('a clean draft dismisses without any prompt', () => {
|
|
485
|
+
renderModal({ gatherContext: RESOURCE_CONTEXT });
|
|
486
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
487
|
+
|
|
488
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
489
|
+
expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
|
|
490
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
491
|
+
});
|
|
492
|
+
|
|
493
|
+
it('a defaultTitle arriving mid-flow does not fake a dirty draft', () => {
|
|
494
|
+
// The source resource's name loads asynchronously: the baseline moves
|
|
495
|
+
// while the modal is open, the user has typed nothing. Dirtiness compares
|
|
496
|
+
// against what was SEEDED, not the live prop.
|
|
497
|
+
const { rerender } = renderModal({
|
|
498
|
+
defaultTitle: '',
|
|
499
|
+
gatherContext: RESOURCE_CONTEXT,
|
|
500
|
+
});
|
|
501
|
+
fireEvent.click(screen.getByRole('button', { name: /Gather/ }));
|
|
502
|
+
rerender(
|
|
503
|
+
<ResourceGenerateModal
|
|
504
|
+
isOpen
|
|
505
|
+
onClose={onClose}
|
|
506
|
+
resourceId="res-1"
|
|
507
|
+
defaultTitle="Loaded Name"
|
|
508
|
+
locale="en"
|
|
509
|
+
entityTypeOptions={['Person', 'Topic']}
|
|
510
|
+
onGenerateSubmit={onGenerateSubmit}
|
|
511
|
+
gatherContext={RESOURCE_CONTEXT}
|
|
512
|
+
gatherLoading={false}
|
|
513
|
+
gatherError={null}
|
|
514
|
+
onGather={onGather}
|
|
515
|
+
translations={T}
|
|
516
|
+
/>,
|
|
517
|
+
);
|
|
518
|
+
|
|
519
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
520
|
+
expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
|
|
521
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
522
|
+
});
|
|
523
|
+
|
|
524
|
+
it('non-text state alone never nags — exclusions and depth are cheap to redo', () => {
|
|
525
|
+
renderModal();
|
|
526
|
+
fireEvent.click(screen.getByRole('button', { name: 'Person' })); // cross off the recall
|
|
527
|
+
|
|
528
|
+
fireEvent.click(screen.getByLabelText('Close'));
|
|
529
|
+
expect(screen.queryByText(T.discardDraftPrompt)).not.toBeInTheDocument();
|
|
530
|
+
expect(onClose).toHaveBeenCalledTimes(1);
|
|
531
|
+
});
|
|
532
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SearchModal for a person using assistive technology: a modal dialog with a
|
|
3
|
+
* name, a named search box with focus in it when it opens, and nothing
|
|
4
|
+
* axe-core finds wrong, empty or with results. The real HeadlessUI Dialog is
|
|
5
|
+
* rendered: the dialog's role, its modality and its focus are its behaviour,
|
|
6
|
+
* not the modal's own.
|
|
7
|
+
*/
|
|
8
|
+
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
|
9
|
+
import '@testing-library/jest-dom';
|
|
10
|
+
import { screen, fireEvent, waitFor } from '@testing-library/react';
|
|
11
|
+
import { axe, toHaveNoViolations } from 'jest-axe';
|
|
12
|
+
import { renderWithProviders } from '../../../test-utils';
|
|
13
|
+
import { SearchModal } from '../SearchModal';
|
|
14
|
+
import {
|
|
15
|
+
buildResource,
|
|
16
|
+
matchResourcesMock,
|
|
17
|
+
resetSearch,
|
|
18
|
+
searchTranslations,
|
|
19
|
+
setBrowseResults,
|
|
20
|
+
} from './search-modal-harness';
|
|
21
|
+
|
|
22
|
+
vi.mock('../../../session/XynologProvider', async (importOriginal) => {
|
|
23
|
+
const actual =
|
|
24
|
+
await importOriginal<typeof import('../../../session/XynologProvider')>();
|
|
25
|
+
const { searchBrowser } = await import('./search-modal-harness');
|
|
26
|
+
return { ...actual, useXynolog: () => searchBrowser };
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
expect.extend(toHaveNoViolations);
|
|
30
|
+
|
|
31
|
+
function open() {
|
|
32
|
+
renderWithProviders(
|
|
33
|
+
<SearchModal
|
|
34
|
+
isOpen
|
|
35
|
+
onClose={vi.fn()}
|
|
36
|
+
onNavigate={vi.fn()}
|
|
37
|
+
translations={searchTranslations}
|
|
38
|
+
/>,
|
|
39
|
+
);
|
|
40
|
+
return screen.getByRole('textbox', { name: searchTranslations.title });
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Search, and answer with one result per name. */
|
|
44
|
+
async function search(input: HTMLElement, ...names: string[]) {
|
|
45
|
+
fireEvent.change(input, { target: { value: 'doc' } });
|
|
46
|
+
await waitFor(() => expect(matchResourcesMock).toHaveBeenCalled(), {
|
|
47
|
+
timeout: 1500,
|
|
48
|
+
});
|
|
49
|
+
setBrowseResults(
|
|
50
|
+
names.map((name, index) => buildResource(`res-${index + 1}`, name)),
|
|
51
|
+
);
|
|
52
|
+
await waitFor(
|
|
53
|
+
() => expect(screen.getByText(names.at(-1)!)).toBeInTheDocument(),
|
|
54
|
+
{ timeout: 1500 },
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
describe('SearchModal — Accessibility', () => {
|
|
59
|
+
beforeEach(() => {
|
|
60
|
+
resetSearch();
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('is a modal dialog, named by its title', () => {
|
|
64
|
+
open();
|
|
65
|
+
|
|
66
|
+
const dialog = screen.getByRole('dialog', {
|
|
67
|
+
name: searchTranslations.title,
|
|
68
|
+
});
|
|
69
|
+
expect(dialog).toHaveAttribute('aria-modal', 'true');
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('names its search box', () => {
|
|
73
|
+
expect(open()).toBeInTheDocument();
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('puts focus in the search box when it opens', async () => {
|
|
77
|
+
const input = open();
|
|
78
|
+
|
|
79
|
+
await waitFor(() => expect(input).toHaveFocus());
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
it('has no axe violations when it opens', async () => {
|
|
83
|
+
open();
|
|
84
|
+
|
|
85
|
+
// The dialog is portalled to the body, outside the render's container.
|
|
86
|
+
expect(await axe(document.body)).toHaveNoViolations();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('has no axe violations with results shown', async () => {
|
|
90
|
+
const input = open();
|
|
91
|
+
await search(input, 'First', 'Second');
|
|
92
|
+
|
|
93
|
+
expect(await axe(document.body)).toHaveNoViolations();
|
|
94
|
+
});
|
|
95
|
+
});
|