@deepseek-ai/dsh-client-ui-primitives 0.2.2-alpha.3 → 0.2.2-rc.2
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/README.i18n.yaml +16 -16
- package/README.md +21 -14
- package/README.zh.md +21 -14
- package/lib/HoverCard.module.css +8 -3
- package/lib/JsonTree.module.css +7 -17
- package/lib/Menu.module.css +157 -37
- package/lib/Modal.module.css +16 -0
- package/lib/QuotePreview.module.css +37 -0
- package/lib/RiskConfirmation.module.css +11 -37
- package/lib/Toast.module.css +2 -3
- package/lib/Tooltip.module.css +2 -1
- package/lib/index.js +1447 -776
- package/lib/index.js.map +1 -0
- package/lib/markdown/CodeBlock.module.css +64 -0
- package/lib/markdown/MarkdownText.module.css +20 -1
- package/lib/types/AnimatedRows.d.ts +3 -0
- package/lib/types/AnimatedRows.d.ts.map +1 -0
- package/lib/types/AnimatedRows.js.map +1 -0
- package/lib/types/BrandWordmark.d.ts.map +1 -0
- package/lib/types/BrandWordmark.js.map +1 -0
- package/lib/types/Button.d.ts.map +1 -0
- package/lib/types/Button.js.map +1 -0
- package/lib/types/Checkbox.d.ts +3 -1
- package/lib/types/Checkbox.d.ts.map +1 -0
- package/lib/types/Checkbox.js.map +1 -0
- package/lib/types/CodeFileIcon.d.ts.map +1 -0
- package/lib/types/CodeFileIcon.js.map +1 -0
- package/lib/types/CodeToolbar.d.ts.map +1 -0
- package/lib/types/CodeToolbar.js.map +1 -0
- package/lib/types/CommandText.d.ts.map +1 -0
- package/lib/types/CommandText.js.map +1 -0
- package/lib/types/ConfigField.d.ts.map +1 -0
- package/lib/types/ConfigField.js.map +1 -0
- package/lib/types/ConnectionIndicator.d.ts.map +1 -0
- package/lib/types/ConnectionIndicator.js.map +1 -0
- package/lib/types/DetailDocument.d.ts.map +1 -0
- package/lib/types/DetailDocument.js.map +1 -0
- package/lib/types/DiffBlock.d.ts.map +1 -0
- package/lib/types/DiffBlock.js.map +1 -0
- package/lib/types/DisclosureRow.d.ts.map +1 -0
- package/lib/types/DisclosureRow.js.map +1 -0
- package/lib/types/DraggableImage.d.ts.map +1 -0
- package/lib/types/DraggableImage.js.map +1 -0
- package/lib/types/FileTypeIcon.d.ts.map +1 -0
- package/lib/types/FileTypeIcon.js.map +1 -0
- package/lib/types/FishLogo.d.ts.map +1 -0
- package/lib/types/FishLogo.js.map +1 -0
- package/lib/types/FoldToggle.d.ts.map +1 -0
- package/lib/types/FoldToggle.js.map +1 -0
- package/lib/types/HoverCard.d.ts.map +1 -0
- package/lib/types/HoverCard.js.map +1 -0
- package/lib/types/HoverCardGroup.d.ts.map +1 -0
- package/lib/types/HoverCardGroup.js.map +1 -0
- package/lib/types/ImageLightbox.d.ts.map +1 -0
- package/lib/types/ImageLightbox.js.map +1 -0
- package/lib/types/ImagePreview.d.ts.map +1 -0
- package/lib/types/ImagePreview.js.map +1 -0
- package/lib/types/InlineEditor.d.ts.map +1 -0
- package/lib/types/InlineEditor.js.map +1 -0
- package/lib/types/Input.d.ts.map +1 -0
- package/lib/types/Input.js.map +1 -0
- package/lib/types/JsonTree.d.ts.map +1 -0
- package/lib/types/JsonTree.js.map +1 -0
- package/lib/types/LinkIcon.d.ts.map +1 -0
- package/lib/types/LinkIcon.js.map +1 -0
- package/lib/types/Menu.d.ts +26 -14
- package/lib/types/Menu.d.ts.map +1 -0
- package/lib/types/Menu.js.map +1 -0
- package/lib/types/MenuGroup.d.ts.map +1 -0
- package/lib/types/MenuGroup.js.map +1 -0
- package/lib/types/MenuRow.d.ts +37 -0
- package/lib/types/MenuRow.d.ts.map +1 -0
- package/lib/types/MenuRow.js.map +1 -0
- package/lib/types/MenuSurface.d.ts.map +1 -0
- package/lib/types/MenuSurface.js.map +1 -0
- package/lib/types/Modal.d.ts +3 -1
- package/lib/types/Modal.d.ts.map +1 -0
- package/lib/types/Modal.js.map +1 -0
- package/lib/types/PathLabel.d.ts.map +1 -0
- package/lib/types/PathLabel.js.map +1 -0
- package/lib/types/PermissionIcon.d.ts.map +1 -0
- package/lib/types/PermissionIcon.js.map +1 -0
- package/lib/types/Pill.d.ts.map +1 -0
- package/lib/types/Pill.js.map +1 -0
- package/lib/types/QuotePreview.d.ts +17 -4
- package/lib/types/QuotePreview.d.ts.map +1 -0
- package/lib/types/QuotePreview.js.map +1 -0
- package/lib/types/ReadBlock.d.ts.map +1 -0
- package/lib/types/ReadBlock.js.map +1 -0
- package/lib/types/ReferenceIcon.d.ts.map +1 -0
- package/lib/types/ReferenceIcon.js.map +1 -0
- package/lib/types/RiskConfirmation.d.ts.map +1 -0
- package/lib/types/RiskConfirmation.js.map +1 -0
- package/lib/types/SearchBlock.d.ts.map +1 -0
- package/lib/types/SearchBlock.js.map +1 -0
- package/lib/types/SegmentedControl.d.ts.map +1 -0
- package/lib/types/SegmentedControl.js.map +1 -0
- package/lib/types/SegmentedTabs.d.ts.map +1 -0
- package/lib/types/SegmentedTabs.js.map +1 -0
- package/lib/types/ShortcutKeys.d.ts.map +1 -0
- package/lib/types/ShortcutKeys.js.map +1 -0
- package/lib/types/SiteGlyph.d.ts.map +1 -0
- package/lib/types/SiteGlyph.js.map +1 -0
- package/lib/types/StateDot.d.ts.map +1 -0
- package/lib/types/StateDot.js.map +1 -0
- package/lib/types/SubmenuPanel.d.ts +19 -0
- package/lib/types/SubmenuPanel.d.ts.map +1 -0
- package/lib/types/SubmenuPanel.js.map +1 -0
- package/lib/types/Switch.d.ts.map +1 -0
- package/lib/types/Switch.js.map +1 -0
- package/lib/types/Tag.d.ts.map +1 -0
- package/lib/types/Tag.js.map +1 -0
- package/lib/types/TerminalBlock.d.ts.map +1 -0
- package/lib/types/TerminalBlock.js.map +1 -0
- package/lib/types/TextShimmer.d.ts.map +1 -0
- package/lib/types/TextShimmer.js.map +1 -0
- package/lib/types/Toast.d.ts.map +1 -0
- package/lib/types/Toast.js.map +1 -0
- package/lib/types/Tooltip.d.ts.map +1 -0
- package/lib/types/Tooltip.js.map +1 -0
- package/lib/types/UserMessageBubble.d.ts.map +1 -0
- package/lib/types/UserMessageBubble.js.map +1 -0
- package/lib/types/WebBlock.d.ts.map +1 -0
- package/lib/types/WebBlock.js.map +1 -0
- package/lib/types/ZoomControls.d.ts.map +1 -0
- package/lib/types/ZoomControls.js.map +1 -0
- package/lib/types/ansi.d.ts.map +1 -0
- package/lib/types/ansi.js.map +1 -0
- package/lib/types/clipboard.d.ts.map +1 -0
- package/lib/types/clipboard.js.map +1 -0
- package/lib/types/code-file-icon-artwork.d.ts.map +1 -0
- package/lib/types/code-file-icon-artwork.js.map +1 -0
- package/lib/types/code-file-types.d.ts.map +1 -0
- package/lib/types/code-file-types.js.map +1 -0
- package/lib/types/code-highlighting.d.ts.map +1 -0
- package/lib/types/code-highlighting.js.map +1 -0
- package/lib/types/darwin-desktop.d.ts.map +1 -0
- package/lib/types/darwin-desktop.js.map +1 -0
- package/lib/types/document-zoom.d.ts.map +1 -0
- package/lib/types/document-zoom.js.map +1 -0
- package/lib/types/file-drag-actions.d.ts.map +1 -0
- package/lib/types/file-drag-actions.js.map +1 -0
- package/lib/types/file-size.d.ts.map +1 -0
- package/lib/types/file-size.js.map +1 -0
- package/lib/types/focus.d.ts.map +1 -0
- package/lib/types/focus.js.map +1 -0
- package/lib/types/guide-artwork.d.ts.map +1 -0
- package/lib/types/guide-artwork.js.map +1 -0
- package/lib/types/head-tail-cap.d.ts.map +1 -0
- package/lib/types/head-tail-cap.js.map +1 -0
- package/lib/types/icons/artwork.d.ts +12 -0
- package/lib/types/icons/artwork.d.ts.map +1 -0
- package/lib/types/icons/artwork.js.map +1 -0
- package/lib/types/icons/index.d.ts +12 -0
- package/lib/types/icons/index.d.ts.map +1 -0
- package/lib/types/icons/index.js.map +1 -0
- package/lib/types/icons/props.d.ts.map +1 -0
- package/lib/types/icons/props.js.map +1 -0
- package/lib/types/icons/shared-artwork.d.ts.map +1 -0
- package/lib/types/icons/shared-artwork.js.map +1 -0
- package/lib/types/image-drag.d.ts.map +1 -0
- package/lib/types/image-drag.js.map +1 -0
- package/lib/types/index.d.ts +5 -4
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/input-modality.d.ts.map +1 -0
- package/lib/types/input-modality.js.map +1 -0
- package/lib/types/keyboard-composition.d.ts.map +1 -0
- package/lib/types/keyboard-composition.js.map +1 -0
- package/lib/types/markdown/CodeBlock.d.ts +8 -1
- package/lib/types/markdown/CodeBlock.d.ts.map +1 -0
- package/lib/types/markdown/CodeBlock.js.map +1 -0
- package/lib/types/markdown/FenceBlocks.d.ts +31 -0
- package/lib/types/markdown/FenceBlocks.d.ts.map +1 -0
- package/lib/types/markdown/FenceBlocks.js.map +1 -0
- package/lib/types/markdown/JsonBlock.d.ts.map +1 -0
- package/lib/types/markdown/JsonBlock.js.map +1 -0
- package/lib/types/markdown/MarkdownDelegate.d.ts +23 -1
- package/lib/types/markdown/MarkdownDelegate.d.ts.map +1 -0
- package/lib/types/markdown/MarkdownDelegate.js.map +1 -0
- package/lib/types/markdown/MarkdownText.d.ts +2 -0
- package/lib/types/markdown/MarkdownText.d.ts.map +1 -0
- package/lib/types/markdown/MarkdownText.js.map +1 -0
- package/lib/types/markdown/cjkFriendlyStrong.d.ts.map +1 -0
- package/lib/types/markdown/cjkFriendlyStrong.js.map +1 -0
- package/lib/types/markdown/copy-tex.d.ts +14 -0
- package/lib/types/markdown/copy-tex.d.ts.map +1 -0
- package/lib/types/markdown/copy-tex.js.map +1 -0
- package/lib/types/markdown/diff-fence.d.ts +58 -0
- package/lib/types/markdown/diff-fence.d.ts.map +1 -0
- package/lib/types/markdown/diff-fence.js.map +1 -0
- package/lib/types/markdown/file-link.d.ts.map +1 -0
- package/lib/types/markdown/file-link.js.map +1 -0
- package/lib/types/markdown/highlight.d.ts +18 -0
- package/lib/types/markdown/highlight.d.ts.map +1 -0
- package/lib/types/markdown/highlight.js.map +1 -0
- package/lib/types/markdown/incremental.d.ts.map +1 -0
- package/lib/types/markdown/incremental.js.map +1 -0
- package/lib/types/markdown/katex.d.ts.map +1 -0
- package/lib/types/markdown/katex.js.map +1 -0
- package/lib/types/markdown/local-image-syntax.d.ts.map +1 -0
- package/lib/types/markdown/local-image-syntax.js.map +1 -0
- package/lib/types/markdown/mathCompatibility.d.ts.map +1 -0
- package/lib/types/markdown/mathCompatibility.js.map +1 -0
- package/lib/types/markdown/parse.d.ts.map +1 -0
- package/lib/types/markdown/parse.js.map +1 -0
- package/lib/types/markdown/plain-text.d.ts.map +1 -0
- package/lib/types/markdown/plain-text.js.map +1 -0
- package/lib/types/markdown/quote-text.d.ts.map +1 -0
- package/lib/types/markdown/quote-text.js.map +1 -0
- package/lib/types/markdown/render.d.ts.map +1 -0
- package/lib/types/markdown/render.js.map +1 -0
- package/lib/types/markdown/useViewportHighlighting.d.ts.map +1 -0
- package/lib/types/markdown/useViewportHighlighting.js.map +1 -0
- package/lib/types/markdown/windows-path-destinations.d.ts.map +1 -0
- package/lib/types/markdown/windows-path-destinations.js.map +1 -0
- package/lib/types/menu-submenu-position.d.ts +15 -0
- package/lib/types/menu-submenu-position.d.ts.map +1 -0
- package/lib/types/menu-submenu-position.js.map +1 -0
- package/lib/types/overlay-top-margin.d.ts.map +1 -0
- package/lib/types/overlay-top-margin.js.map +1 -0
- package/lib/types/plugin-artwork.d.ts.map +1 -0
- package/lib/types/plugin-artwork.js.map +1 -0
- package/lib/types/pointer-grace.d.ts.map +1 -0
- package/lib/types/pointer-grace.js.map +1 -0
- package/lib/types/rank-by-name.d.ts.map +1 -0
- package/lib/types/rank-by-name.js.map +1 -0
- package/lib/types/relative-time.d.ts.map +1 -0
- package/lib/types/relative-time.js.map +1 -0
- package/lib/types/settings-form/SettingsForm.d.ts.map +1 -0
- package/lib/types/settings-form/SettingsForm.js.map +1 -0
- package/lib/types/settings-form/fields.d.ts.map +1 -0
- package/lib/types/settings-form/fields.js.map +1 -0
- package/lib/types/settings-form/form-model.d.ts.map +1 -0
- package/lib/types/settings-form/form-model.js.map +1 -0
- package/lib/types/tooltip-placement.d.ts.map +1 -0
- package/lib/types/tooltip-placement.js.map +1 -0
- package/lib/types/use-clipboard-copy.d.ts.map +1 -0
- package/lib/types/use-clipboard-copy.js.map +1 -0
- package/lib/types/useAnchoredMaxHeight.d.ts.map +1 -0
- package/lib/types/useAnchoredMaxHeight.js.map +1 -0
- package/lib/types/useDismissOnOutsidePointer.d.ts.map +1 -0
- package/lib/types/useDismissOnOutsidePointer.js.map +1 -0
- package/lib/types/useMenuSubmenu.d.ts +43 -0
- package/lib/types/useMenuSubmenu.d.ts.map +1 -0
- package/lib/types/useMenuSubmenu.js.map +1 -0
- package/lib/types/useModalLayer.d.ts.map +1 -0
- package/lib/types/useModalLayer.js.map +1 -0
- package/lib/types/useRowDragPreview.d.ts.map +1 -0
- package/lib/types/useRowDragPreview.js.map +1 -0
- package/lib/types/user-text.d.ts.map +1 -0
- package/lib/types/user-text.js.map +1 -0
- package/package.json +11 -8
- package/src/AnimatedRows.module.css +7 -0
- package/src/AnimatedRows.tsx +195 -0
- package/src/BrandWordmark.tsx +59 -0
- package/src/Button.module.css +84 -0
- package/src/Button.tsx +36 -0
- package/src/Checkbox.module.css +28 -0
- package/src/Checkbox.tsx +34 -0
- package/src/CodeCard.module.css +85 -0
- package/src/CodeFileIcon.tsx +28 -0
- package/src/CodeToolbar.tsx +62 -0
- package/src/CommandText.module.css +12 -0
- package/src/CommandText.tsx +46 -0
- package/src/ConfigField.module.css +12 -0
- package/src/ConfigField.tsx +53 -0
- package/src/ConnectionIndicator.module.css +120 -0
- package/src/ConnectionIndicator.tsx +103 -0
- package/src/DetailDocument.module.css +67 -0
- package/src/DetailDocument.tsx +120 -0
- package/src/DiffBlock.module.css +82 -0
- package/src/DiffBlock.tsx +221 -0
- package/src/DisclosureRow.module.css +115 -0
- package/src/DisclosureRow.tsx +124 -0
- package/src/DraggableImage.tsx +26 -0
- package/src/FileTypeIcon.module.css +50 -0
- package/src/FileTypeIcon.tsx +285 -0
- package/src/FishLogo.tsx +28 -0
- package/src/FoldToggle.tsx +33 -0
- package/src/HoverCard.module.css +108 -0
- package/src/HoverCard.tsx +356 -0
- package/src/HoverCardGroup.tsx +77 -0
- package/src/ImageLightbox.module.css +54 -0
- package/src/ImageLightbox.tsx +72 -0
- package/src/ImagePreview.module.css +24 -0
- package/src/ImagePreview.tsx +36 -0
- package/src/InlineEditor.module.css +23 -0
- package/src/InlineEditor.tsx +69 -0
- package/src/Input.module.css +38 -0
- package/src/Input.tsx +24 -0
- package/src/JsonTree.module.css +371 -0
- package/src/JsonTree.tsx +850 -0
- package/src/LinkIcon.tsx +118 -0
- package/src/Menu.module.css +443 -0
- package/src/Menu.tsx +553 -0
- package/src/MenuGroup.module.css +37 -0
- package/src/MenuGroup.tsx +103 -0
- package/src/MenuRow.tsx +89 -0
- package/src/MenuSurface.module.css +65 -0
- package/src/MenuSurface.tsx +54 -0
- package/src/Modal.module.css +147 -0
- package/src/Modal.tsx +96 -0
- package/src/PathLabel.module.css +28 -0
- package/src/PathLabel.tsx +41 -0
- package/src/PermissionIcon.tsx +119 -0
- package/src/Pill.module.css +30 -0
- package/src/Pill.tsx +36 -0
- package/src/QuotePreview.module.css +138 -0
- package/src/QuotePreview.tsx +133 -0
- package/src/ReadBlock.module.css +45 -0
- package/src/ReadBlock.tsx +151 -0
- package/src/ReferenceIcon.tsx +49 -0
- package/src/RiskConfirmation.module.css +47 -0
- package/src/RiskConfirmation.tsx +79 -0
- package/src/RowDragPreview.module.css +12 -0
- package/src/SearchBlock.module.css +114 -0
- package/src/SearchBlock.tsx +281 -0
- package/src/SegmentedControl.module.css +81 -0
- package/src/SegmentedControl.tsx +140 -0
- package/src/SegmentedTabs.module.css +77 -0
- package/src/SegmentedTabs.tsx +84 -0
- package/src/ShortcutKeys.module.css +33 -0
- package/src/ShortcutKeys.tsx +12 -0
- package/src/SiteGlyph.tsx +149 -0
- package/src/StateDot.module.css +100 -0
- package/src/StateDot.tsx +77 -0
- package/src/SubmenuPanel.tsx +51 -0
- package/src/Switch.module.css +49 -0
- package/src/Switch.tsx +42 -0
- package/src/Tag.module.css +57 -0
- package/src/Tag.tsx +42 -0
- package/src/TerminalBlock.module.css +207 -0
- package/src/TerminalBlock.tsx +294 -0
- package/src/TextShimmer.module.css +88 -0
- package/src/TextShimmer.tsx +58 -0
- package/src/Toast.module.css +102 -0
- package/src/Toast.tsx +101 -0
- package/src/Tooltip.module.css +68 -0
- package/src/Tooltip.tsx +273 -0
- package/src/UserMessageBubble.module.css +11 -0
- package/src/UserMessageBubble.tsx +16 -0
- package/src/WebBlock.module.css +153 -0
- package/src/WebBlock.tsx +196 -0
- package/src/ZoomControls.module.css +54 -0
- package/src/ZoomControls.tsx +92 -0
- package/src/ansi.ts +447 -0
- package/src/clipboard.ts +47 -0
- package/src/code-file-icon-artwork.manifest.json +71 -0
- package/src/code-file-icon-artwork.ts +60 -0
- package/src/code-file-types.ts +340 -0
- package/src/code-highlighting.ts +25 -0
- package/src/css-modules.d.ts +6 -0
- package/src/darwin-desktop.ts +11 -0
- package/src/document-zoom.ts +12 -0
- package/src/file-drag-actions.ts +29 -0
- package/src/file-size.ts +16 -0
- package/src/focus.ts +44 -0
- package/src/guide-artwork.tsx +32 -0
- package/src/head-tail-cap.ts +27 -0
- package/src/icons/artwork.ts +156 -0
- package/src/icons/index.tsx +634 -0
- package/src/icons/props.ts +8 -0
- package/src/icons/shared-artwork.tsx +71 -0
- package/src/image-drag.ts +84 -0
- package/src/index.ts +142 -0
- package/src/input-modality.ts +59 -0
- package/src/keyboard-composition.ts +36 -0
- package/src/markdown/CodeBlock.module.css +209 -0
- package/src/markdown/CodeBlock.tsx +268 -0
- package/src/markdown/FenceBlocks.tsx +51 -0
- package/src/markdown/JsonBlock.module.css +34 -0
- package/src/markdown/JsonBlock.tsx +36 -0
- package/src/markdown/MarkdownDelegate.tsx +102 -0
- package/src/markdown/MarkdownText.module.css +511 -0
- package/src/markdown/MarkdownText.tsx +218 -0
- package/src/markdown/cjkFriendlyStrong.ts +83 -0
- package/src/markdown/copy-tex.ts +53 -0
- package/src/markdown/diff-fence.ts +212 -0
- package/src/markdown/file-link.ts +45 -0
- package/src/markdown/highlight.ts +689 -0
- package/src/markdown/incremental.ts +360 -0
- package/src/markdown/katex.tsx +90 -0
- package/src/markdown/local-image-syntax.ts +29 -0
- package/src/markdown/mathCompatibility.ts +349 -0
- package/src/markdown/parse.ts +49 -0
- package/src/markdown/plain-text.ts +121 -0
- package/src/markdown/quote-text.ts +10 -0
- package/src/markdown/render.tsx +834 -0
- package/src/markdown/useViewportHighlighting.ts +72 -0
- package/src/markdown/windows-path-destinations.ts +34 -0
- package/src/menu-submenu-position.ts +20 -0
- package/src/overlay-top-margin.ts +18 -0
- package/src/plugin-artwork.tsx +110 -0
- package/src/pointer-grace.ts +47 -0
- package/src/rank-by-name.ts +93 -0
- package/src/relative-time.ts +36 -0
- package/src/settings-form/SettingsForm.module.css +53 -0
- package/src/settings-form/SettingsForm.tsx +74 -0
- package/src/settings-form/fields.module.css +153 -0
- package/src/settings-form/fields.tsx +151 -0
- package/src/settings-form/form-model.ts +393 -0
- package/src/tooltip-placement.ts +60 -0
- package/src/use-clipboard-copy.ts +44 -0
- package/src/useAnchoredMaxHeight.ts +45 -0
- package/src/useDismissOnOutsidePointer.ts +34 -0
- package/src/useMenuSubmenu.ts +182 -0
- package/src/useModalLayer.ts +108 -0
- package/src/useRowDragPreview.ts +76 -0
- package/src/user-text.module.css +46 -0
- package/src/user-text.tsx +67 -0
- package/lib/types/useAnchoredPosition.d.ts +0 -36
package/src/WebBlock.tsx
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import clsx from 'clsx'
|
|
2
|
+
import { MarkdownText, type MarkdownLabels } from './markdown/MarkdownText.tsx'
|
|
3
|
+
import { LinkIconMedium } from './LinkIcon.tsx'
|
|
4
|
+
import css from './WebBlock.module.css'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One citeable source drawn in a search card: the projection of the contract's
|
|
8
|
+
* `WebSource`, with the optional fields kept optional so a provider that
|
|
9
|
+
* returned only a URL still renders (its hostname becomes the label).
|
|
10
|
+
*/
|
|
11
|
+
export interface WebSourceView {
|
|
12
|
+
/** The source URL; becomes a safe external link when it is http(s). */
|
|
13
|
+
url: string
|
|
14
|
+
/** The source title; when absent the URL's hostname labels the link. */
|
|
15
|
+
title?: string | undefined
|
|
16
|
+
/** A short excerpt or summary shown under the link. */
|
|
17
|
+
snippet?: string | undefined
|
|
18
|
+
/** Publication/crawl timestamp, a provider-supplied string shown under the link. */
|
|
19
|
+
publishedAt?: string | undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** A `web_search` card: an optional answer over a capped citation list. */
|
|
23
|
+
export interface WebSearchBlockProps {
|
|
24
|
+
kind: 'search'
|
|
25
|
+
/** Localized chrome supplied by the owning render site. */
|
|
26
|
+
labels: WebBlockLabels
|
|
27
|
+
/** The provider-generated answer, rendered as markdown above the sources. */
|
|
28
|
+
answer?: string | undefined
|
|
29
|
+
/** The cited sources, in provider order. */
|
|
30
|
+
sources: WebSourceView[]
|
|
31
|
+
/** True when the tool cut the source list to its result cap. */
|
|
32
|
+
truncated: boolean
|
|
33
|
+
/** Extra class merged onto the wrapper (callers position; this component draws). */
|
|
34
|
+
className?: string | undefined
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A `web_fetch` card: the retrieval summary for one fetched URL. */
|
|
38
|
+
export interface WebFetchBlockProps {
|
|
39
|
+
kind: 'fetch'
|
|
40
|
+
/** Localized chrome supplied by the owning render site. */
|
|
41
|
+
labels: WebBlockLabels
|
|
42
|
+
/** The final URL after allowed redirects; becomes a safe external link when http(s). */
|
|
43
|
+
url: string
|
|
44
|
+
/** HTTP status code of the fetched response. */
|
|
45
|
+
statusCode: number
|
|
46
|
+
/** True when the provider or the output cap cut the fetched content. */
|
|
47
|
+
truncated: boolean
|
|
48
|
+
/** Extra class merged onto the wrapper (callers position; this component draws). */
|
|
49
|
+
className?: string | undefined
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A completed web retrieval card, discriminated by `kind`. */
|
|
53
|
+
export type WebBlockProps = WebSearchBlockProps | WebFetchBlockProps
|
|
54
|
+
|
|
55
|
+
/** Localized chrome for {@link WebBlock}. */
|
|
56
|
+
export interface WebBlockLabels {
|
|
57
|
+
noResults: string
|
|
58
|
+
sourcesTruncated: string
|
|
59
|
+
http: string
|
|
60
|
+
contentTruncated: string
|
|
61
|
+
markdown: MarkdownLabels
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* The URL to link to, or undefined when the URL must render as plain text. Only
|
|
66
|
+
* http(s) becomes a navigable external anchor, so a `javascript:`/`data:`/`file:`
|
|
67
|
+
* URL or an unparseable string never reaches the DOM as an href. This is the
|
|
68
|
+
* http(s) subset of the allowlist MarkdownText applies to untrusted links —
|
|
69
|
+
* MarkdownText also permits `mailto:`, deliberately excluded here since a
|
|
70
|
+
* retrieval URL is never a mail address.
|
|
71
|
+
* @param url - the source or fetch URL, from tool result content.
|
|
72
|
+
* @returns the href to use, or undefined for plain text.
|
|
73
|
+
*/
|
|
74
|
+
function safeHref(url: string): string | undefined {
|
|
75
|
+
try {
|
|
76
|
+
const { protocol } = new URL(url)
|
|
77
|
+
return protocol === 'http:' || protocol === 'https:' ? url : undefined
|
|
78
|
+
} catch {
|
|
79
|
+
return undefined
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* The link's visible label: the title when the provider gave one, otherwise the
|
|
85
|
+
* URL's hostname, falling back to the raw URL when it does not parse OR parses
|
|
86
|
+
* to an empty hostname (a `file:`/`data:`/`javascript:` URL), so a label is
|
|
87
|
+
* never blank.
|
|
88
|
+
* @param url - the source URL.
|
|
89
|
+
* @param title - the provider title, if any.
|
|
90
|
+
* @returns the label text.
|
|
91
|
+
*/
|
|
92
|
+
function linkLabel(url: string, title: string | undefined): string {
|
|
93
|
+
if (title !== undefined && title !== '') return title
|
|
94
|
+
try {
|
|
95
|
+
const { hostname } = new URL(url)
|
|
96
|
+
return hostname === '' ? url : hostname
|
|
97
|
+
} catch {
|
|
98
|
+
return url
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* A single URL rendered as a safe external anchor, or as plain text when the
|
|
104
|
+
* URL is not an http(s) link.
|
|
105
|
+
* @param props.url - the URL to render.
|
|
106
|
+
* @param props.label - the visible label.
|
|
107
|
+
* @param props.className - class for the anchor or the plain span.
|
|
108
|
+
* @returns the anchor or span element.
|
|
109
|
+
*/
|
|
110
|
+
function SafeLink({ url, label, className }: { url: string; label: string; className?: string | undefined }) {
|
|
111
|
+
const href = safeHref(url)
|
|
112
|
+
if (href === undefined) return <span className={className}>{label}</span>
|
|
113
|
+
return (
|
|
114
|
+
<a className={className} href={href} target="_blank" rel="noopener noreferrer">
|
|
115
|
+
<LinkIconMedium kind="url" href={href} className={css.linkIcon} />
|
|
116
|
+
{label}
|
|
117
|
+
</a>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* One source row in a search card: the safe link plus its snippet and date. The
|
|
123
|
+
* `<li value>` pins the source's 1-based citation index explicitly rather than
|
|
124
|
+
* relying on the `<ol>`'s implicit numbering, so a row reads by its real index
|
|
125
|
+
* even inside the scroll container.
|
|
126
|
+
* @param props.source - the source to render.
|
|
127
|
+
* @param props.ordinal - the source's 1-based position in the full list.
|
|
128
|
+
* @returns the source list item.
|
|
129
|
+
*/
|
|
130
|
+
function SourceItem({ source, ordinal }: { source: WebSourceView; ordinal: number }) {
|
|
131
|
+
return (
|
|
132
|
+
<li className={css.source} value={ordinal}>
|
|
133
|
+
<SafeLink url={source.url} label={linkLabel(source.url, source.title)} className={css.sourceLink} />
|
|
134
|
+
{source.snippet !== undefined && source.snippet !== '' && (
|
|
135
|
+
<div className={css.snippet}>{source.snippet}</div>
|
|
136
|
+
)}
|
|
137
|
+
{source.publishedAt !== undefined && source.publishedAt !== '' && (
|
|
138
|
+
<div className={css.published}>{source.publishedAt}</div>
|
|
139
|
+
)}
|
|
140
|
+
</li>
|
|
141
|
+
)
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The search card body: the answer over the full source list, which scrolls in
|
|
146
|
+
* place once it exceeds the `.sources` container height.
|
|
147
|
+
* @param props - see {@link WebSearchBlockProps}.
|
|
148
|
+
* @returns the search card element.
|
|
149
|
+
*/
|
|
150
|
+
function WebSearchBlock({ answer, sources, truncated, labels, className }: WebSearchBlockProps) {
|
|
151
|
+
// A provider may legitimately return no answer and no sources; the chat WebRow
|
|
152
|
+
// does not show the raw result content, so without this the user would see an
|
|
153
|
+
// empty card. Mirror the backend's `No results found.` render text.
|
|
154
|
+
const empty = (answer === undefined || answer === '') && sources.length === 0
|
|
155
|
+
return (
|
|
156
|
+
<div className={clsx(css.block, className)} data-web="search">
|
|
157
|
+
{answer !== undefined && answer !== '' && (
|
|
158
|
+
<div className={css.answer}><MarkdownText text={answer} labels={labels.markdown} /></div>
|
|
159
|
+
)}
|
|
160
|
+
{empty ? (
|
|
161
|
+
<div className={css.empty}>{labels.noResults}</div>
|
|
162
|
+
) : (
|
|
163
|
+
<ol className={css.sources}>
|
|
164
|
+
{sources.map((source, index) => <SourceItem key={index} source={source} ordinal={index + 1} />)}
|
|
165
|
+
</ol>
|
|
166
|
+
)}
|
|
167
|
+
{truncated && <div className={css.truncated}>{labels.sourcesTruncated}</div>}
|
|
168
|
+
</div>
|
|
169
|
+
)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* The fetch card body: the linked URL and its HTTP status.
|
|
174
|
+
* @param props - see {@link WebFetchBlockProps}.
|
|
175
|
+
* @returns the fetch card element.
|
|
176
|
+
*/
|
|
177
|
+
function WebFetchBlock({ url, statusCode, truncated, labels, className }: WebFetchBlockProps) {
|
|
178
|
+
return (
|
|
179
|
+
<div className={clsx(css.block, css.fetch, className)} data-web="fetch">
|
|
180
|
+
<SafeLink url={url} label={url} className={css.fetchUrl} />
|
|
181
|
+
<div className={css.fetchMeta}>
|
|
182
|
+
<span className={css.status}>{labels.http} {statusCode}</span>
|
|
183
|
+
{truncated && <span className={css.truncated}>{labels.contentTruncated}</span>}
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Render a completed web retrieval as a structured card.
|
|
191
|
+
* @param props - see {@link WebBlockProps}; `kind` selects the search or fetch body.
|
|
192
|
+
* @returns the web card element.
|
|
193
|
+
*/
|
|
194
|
+
export function WebBlock(props: WebBlockProps) {
|
|
195
|
+
return props.kind === 'search' ? <WebSearchBlock {...props} /> : <WebFetchBlock {...props} />
|
|
196
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* Zero specificity lets an owner className move the toolbar regardless of stylesheet order. */
|
|
2
|
+
:where(.panel) {
|
|
3
|
+
bottom: 14px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.panel {
|
|
7
|
+
position: absolute;
|
|
8
|
+
z-index: 2;
|
|
9
|
+
inset-inline-start: 50%;
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
gap: 2px;
|
|
13
|
+
box-sizing: border-box;
|
|
14
|
+
padding: 4px 6px;
|
|
15
|
+
/* TODO: replace this border and the literal shadow with `border: 0` and `--dsw-elevation-panel`
|
|
16
|
+
* (docs/web-styling.md#component-rules), with visual review of the document preview. */
|
|
17
|
+
border: 0.5px solid var(--dsw-alias-border-l3);
|
|
18
|
+
border-radius: var(--dsw-radius-lg);
|
|
19
|
+
color: var(--dsw-alias-label-primary);
|
|
20
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
21
|
+
box-shadow: 0 8px 24px light-dark(#0000001a, #00000060), 0 2px 5px light-dark(#00000009, #00000035);
|
|
22
|
+
font-size: 12px;
|
|
23
|
+
line-height: 18px;
|
|
24
|
+
opacity: 0;
|
|
25
|
+
pointer-events: none;
|
|
26
|
+
transform: translate(-50%, 16px) scale(0.98);
|
|
27
|
+
transition: opacity 160ms ease-in, transform 160ms cubic-bezier(0.4, 0, 1, 1);
|
|
28
|
+
will-change: opacity, transform;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.visible {
|
|
32
|
+
opacity: 1;
|
|
33
|
+
pointer-events: auto;
|
|
34
|
+
transform: translate(-50%, 0) scale(1);
|
|
35
|
+
transition: opacity 140ms ease-out, transform 180ms cubic-bezier(0.22, 1, 0.36, 1);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.controlAnchor { display: flex; }
|
|
39
|
+
.zoomButton { width: 28px; padding: 0; flex: none; }
|
|
40
|
+
.percent { display: inline-flex; align-items: center; justify-content: center; gap: 2px; min-width: 58px; padding-inline: 6px; font-variant-numeric: tabular-nums; }
|
|
41
|
+
.zoomMenu { min-width: 112px; }
|
|
42
|
+
|
|
43
|
+
@media (hover: none), (pointer: coarse) {
|
|
44
|
+
.panel {
|
|
45
|
+
opacity: 1;
|
|
46
|
+
pointer-events: auto;
|
|
47
|
+
transform: translate(-50%, 0) scale(1);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@media (prefers-reduced-motion: reduce) {
|
|
52
|
+
.panel,
|
|
53
|
+
.visible { transition-duration: 0.01ms; }
|
|
54
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/** Floating controls shared by every zoomable document renderer. */
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import { forwardRef, useEffect, useImperativeHandle, useState, type ReactNode } from 'react'
|
|
4
|
+
import { Button } from './Button.tsx'
|
|
5
|
+
import { IconChevronDownOutlineRegular, IconPlusOutlineRegular } from './icons/index.tsx'
|
|
6
|
+
import { Menu, type MenuEntry } from './Menu.tsx'
|
|
7
|
+
import { Tooltip } from './Tooltip.tsx'
|
|
8
|
+
import { DOCUMENT_ZOOM, type DocumentZoomLabels } from './document-zoom.ts'
|
|
9
|
+
import css from './ZoomControls.module.css'
|
|
10
|
+
|
|
11
|
+
function steppedZoom(zoom: number, direction: -1 | 1): number {
|
|
12
|
+
const step = direction === -1 ? Math.ceil(zoom / DOCUMENT_ZOOM.step) - 1 : Math.floor(zoom / DOCUMENT_ZOOM.step) + 1
|
|
13
|
+
return Math.min(DOCUMENT_ZOOM.maximum, Math.max(DOCUMENT_ZOOM.minimum, step * DOCUMENT_ZOOM.step))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** Live percentage display updated independently from the document tree. */
|
|
17
|
+
export interface ZoomControlsHandle {
|
|
18
|
+
/** @param zoom - current gesture scale multiplier. */
|
|
19
|
+
showZoom: (zoom: number) => void
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Present optional fitting, fixed presets, and incremental controls.
|
|
24
|
+
* @param props - committed `zoom`, optional `fit` row (omitted: no fitting row), localized labels, `visible`, optional
|
|
25
|
+
* owner `className`, and zoom and activity callbacks.
|
|
26
|
+
* @param ref - `showZoom` displays a transient scale until `zoom` changes.
|
|
27
|
+
* @returns a localized zoom toolbar.
|
|
28
|
+
*/
|
|
29
|
+
export const ZoomControls = forwardRef<ZoomControlsHandle, {
|
|
30
|
+
readonly zoom: number
|
|
31
|
+
readonly fit?: { readonly label: string; readonly selected: boolean; readonly onSelect: () => void } | undefined
|
|
32
|
+
readonly className?: string | undefined
|
|
33
|
+
readonly labels: DocumentZoomLabels
|
|
34
|
+
readonly visible: boolean
|
|
35
|
+
readonly onZoom: (zoom: number) => void
|
|
36
|
+
readonly onActiveChange: (active: boolean) => void
|
|
37
|
+
}>(function ZoomControls({
|
|
38
|
+
zoom, fit, className, labels, visible, onZoom, onActiveChange,
|
|
39
|
+
}, ref): ReactNode {
|
|
40
|
+
const [committed, setCommitted] = useState(zoom)
|
|
41
|
+
const [transient, setTransient] = useState<number>()
|
|
42
|
+
const [open, setOpen] = useState(false)
|
|
43
|
+
const [hovered, setHovered] = useState(false)
|
|
44
|
+
const [focused, setFocused] = useState(false)
|
|
45
|
+
if (committed !== zoom) {
|
|
46
|
+
setCommitted(zoom)
|
|
47
|
+
setTransient(undefined)
|
|
48
|
+
}
|
|
49
|
+
const displayZoom = transient ?? zoom
|
|
50
|
+
useImperativeHandle(ref, () => ({ showZoom: setTransient }), [])
|
|
51
|
+
useEffect(() => { onActiveChange(open || hovered || focused) }, [focused, hovered, onActiveChange, open])
|
|
52
|
+
const items: readonly MenuEntry[] = [
|
|
53
|
+
...(fit === undefined ? [] : [{ id: 'fit', label: fit.label }, { type: 'separator' as const, id: 'fit-scale' }]),
|
|
54
|
+
...DOCUMENT_ZOOM.presets.map(value => ({ id: String(value), label: labels.value(value * 100) })),
|
|
55
|
+
]
|
|
56
|
+
const selectedId = fit?.selected === true ? 'fit'
|
|
57
|
+
: DOCUMENT_ZOOM.presets.some(value => value === displayZoom) ? String(displayZoom) : undefined
|
|
58
|
+
return <div className={clsx(css.panel, visible && css.visible, className)} role="toolbar" aria-label={labels.controls}
|
|
59
|
+
data-document-zoom-controls data-document-zoom-visible={visible || undefined}
|
|
60
|
+
onPointerEnter={(event) => { if (event.pointerType !== 'touch') setHovered(true) }} onPointerLeave={() => { setHovered(false) }}
|
|
61
|
+
onFocusCapture={() => { setFocused(true) }} onBlurCapture={(event) => {
|
|
62
|
+
if (!event.currentTarget.contains(event.relatedTarget)) setFocused(false)
|
|
63
|
+
}}>
|
|
64
|
+
<Tooltip label={labels.out} side="top">
|
|
65
|
+
<span className={css.controlAnchor}><Button size="sm" className={css.zoomButton} aria-label={labels.out}
|
|
66
|
+
disabled={displayZoom <= DOCUMENT_ZOOM.minimum} onMouseDown={(event) => { event.preventDefault() }}
|
|
67
|
+
onClick={() => { onZoom(steppedZoom(displayZoom, -1)) }}>
|
|
68
|
+
<svg width="14" height="14" viewBox="0 0 16 16" aria-hidden="true">
|
|
69
|
+
<path d="M2 8h12" fill="none" stroke="currentColor" strokeWidth="1.5" />
|
|
70
|
+
</svg>
|
|
71
|
+
</Button></span>
|
|
72
|
+
</Tooltip>
|
|
73
|
+
<Menu open={open} side="top" align="start" portal compact listClassName={css.zoomMenu}
|
|
74
|
+
anchor={<Button size="sm" className={css.percent} aria-label={labels.menu} aria-expanded={open}
|
|
75
|
+
onMouseDown={(event) => { event.preventDefault() }} onClick={() => { setOpen(value => !value) }}>
|
|
76
|
+
<span>{labels.value(Math.round(displayZoom * 100))}</span>
|
|
77
|
+
<IconChevronDownOutlineRegular size={12} />
|
|
78
|
+
</Button>}
|
|
79
|
+
items={items} selectedId={selectedId} onClose={() => { setOpen(false) }} onSelect={(selected) => {
|
|
80
|
+
setOpen(false)
|
|
81
|
+
if (selected === 'fit') fit?.onSelect()
|
|
82
|
+
else onZoom(Number(selected))
|
|
83
|
+
}} />
|
|
84
|
+
<Tooltip label={labels.into} side="top">
|
|
85
|
+
<span className={css.controlAnchor}><Button size="sm" className={css.zoomButton} aria-label={labels.into}
|
|
86
|
+
disabled={displayZoom >= DOCUMENT_ZOOM.maximum} onMouseDown={(event) => { event.preventDefault() }}
|
|
87
|
+
onClick={() => { onZoom(steppedZoom(displayZoom, 1)) }}>
|
|
88
|
+
<IconPlusOutlineRegular size={14} />
|
|
89
|
+
</Button></span>
|
|
90
|
+
</Tooltip>
|
|
91
|
+
</div>
|
|
92
|
+
})
|