@deepseek-ai/dsh-client-ui-primitives 0.2.2-rc.1 → 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 +9 -6
- 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
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
import { ICON_MEDIUM_STROKE, ICON_REGULAR_STROKE } from './icons/index.tsx'
|
|
3
|
+
import type { IconProps } from './icons/props.ts'
|
|
4
|
+
import {
|
|
5
|
+
BrowseOutlineArtwork, ChatLinesOutlineArtwork, FolderCloseArtwork,
|
|
6
|
+
} from './icons/shared-artwork.tsx'
|
|
7
|
+
|
|
8
|
+
/** Reference domains with distinct composer and transcript glyphs. */
|
|
9
|
+
export type ReferenceIconKind = 'session' | 'file' | 'folder'
|
|
10
|
+
|
|
11
|
+
/** Props shared by inline reference glyphs. */
|
|
12
|
+
export interface ReferenceIconProps extends IconProps {
|
|
13
|
+
kind: ReferenceIconKind
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface WeightedReferenceIconProps extends ReferenceIconProps {
|
|
17
|
+
strokeWidth: number
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Render the icon that identifies one inline reference domain.
|
|
22
|
+
* @param props - Reference kind, optional size, and optional CSS class.
|
|
23
|
+
* @returns The corresponding decorative current-color SVG glyph.
|
|
24
|
+
*/
|
|
25
|
+
function ReferenceIconArtwork({ kind, size = 16, className, strokeWidth }: WeightedReferenceIconProps): ReactNode {
|
|
26
|
+
switch (kind) {
|
|
27
|
+
case 'session': return <ChatLinesOutlineArtwork size={size} className={className} strokeWidth={strokeWidth} />
|
|
28
|
+
case 'file': return <BrowseOutlineArtwork size={size} className={className} strokeWidth={strokeWidth} />
|
|
29
|
+
case 'folder': return <FolderCloseArtwork size={size} className={className} strokeWidth={strokeWidth} />
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Render a regular one-pixel reference icon.
|
|
35
|
+
* @param props - Reference kind, size, and optional class.
|
|
36
|
+
* @returns The regular decorative reference glyph.
|
|
37
|
+
*/
|
|
38
|
+
export function ReferenceIconRegular(props: ReferenceIconProps): ReactNode {
|
|
39
|
+
return <ReferenceIconArtwork {...props} strokeWidth={ICON_REGULAR_STROKE} />
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Render a medium 1.3px reference icon.
|
|
44
|
+
* @param props - Reference kind, size, and optional class.
|
|
45
|
+
* @returns The medium decorative reference glyph.
|
|
46
|
+
*/
|
|
47
|
+
export function ReferenceIconMedium(props: ReferenceIconProps): ReactNode {
|
|
48
|
+
return <ReferenceIconArtwork {...props} strokeWidth={ICON_MEDIUM_STROKE} />
|
|
49
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
.confirmation {
|
|
2
|
+
width: min(440px, 100%);
|
|
3
|
+
max-height: 100%;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.confirmationContent {
|
|
8
|
+
min-height: 0;
|
|
9
|
+
overflow-y: auto;
|
|
10
|
+
overscroll-behavior: contain;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@supports (height: 100dvh) {
|
|
14
|
+
.confirmation {
|
|
15
|
+
max-height: calc(100dvh - 48px);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.description {
|
|
20
|
+
margin: 0;
|
|
21
|
+
color: var(--dsw-alias-label-secondary);
|
|
22
|
+
font-size: 14px;
|
|
23
|
+
line-height: 22px;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.confirmation .acknowledgement {
|
|
27
|
+
align-items: flex-start;
|
|
28
|
+
margin-top: 16px;
|
|
29
|
+
color: var(--dsw-alias-label-secondary);
|
|
30
|
+
font-size: 14px;
|
|
31
|
+
font-weight: 400;
|
|
32
|
+
line-height: 20px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.confirmation .acknowledgement input {
|
|
36
|
+
width: 14px;
|
|
37
|
+
height: 14px;
|
|
38
|
+
margin-top: 3px;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.modalAction {
|
|
42
|
+
min-width: 72px;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.confirmAction {
|
|
46
|
+
min-width: 136px;
|
|
47
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Controlled risk acknowledgement dialog shared by product surfaces that
|
|
3
|
+
* must gate a sensitive action behind an explicit checkbox.
|
|
4
|
+
*/
|
|
5
|
+
import { Button } from './Button.tsx'
|
|
6
|
+
import { Checkbox } from './Checkbox.tsx'
|
|
7
|
+
import { Modal } from './Modal.tsx'
|
|
8
|
+
import css from './RiskConfirmation.module.css'
|
|
9
|
+
|
|
10
|
+
export interface RiskConfirmationProps {
|
|
11
|
+
open: boolean
|
|
12
|
+
title: string
|
|
13
|
+
description: string
|
|
14
|
+
acknowledgeLabel: string
|
|
15
|
+
cancelLabel: string
|
|
16
|
+
closeLabel: string
|
|
17
|
+
confirmLabel: string
|
|
18
|
+
acknowledged: boolean
|
|
19
|
+
disabled?: boolean
|
|
20
|
+
onAcknowledgedChange: (acknowledged: boolean) => void
|
|
21
|
+
onCancel: () => void
|
|
22
|
+
onConfirm: () => void
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Render one in-page confirmation whose primary action is unavailable until
|
|
27
|
+
* the caller-controlled acknowledgement is checked.
|
|
28
|
+
*/
|
|
29
|
+
export function RiskConfirmation({
|
|
30
|
+
open,
|
|
31
|
+
title,
|
|
32
|
+
description,
|
|
33
|
+
acknowledgeLabel,
|
|
34
|
+
cancelLabel,
|
|
35
|
+
closeLabel,
|
|
36
|
+
confirmLabel,
|
|
37
|
+
acknowledged,
|
|
38
|
+
disabled = false,
|
|
39
|
+
onAcknowledgedChange,
|
|
40
|
+
onCancel,
|
|
41
|
+
onConfirm,
|
|
42
|
+
}: RiskConfirmationProps) {
|
|
43
|
+
return (
|
|
44
|
+
<Modal
|
|
45
|
+
open={open}
|
|
46
|
+
onClose={onCancel}
|
|
47
|
+
title={title}
|
|
48
|
+
tone="warning"
|
|
49
|
+
closeLabel={closeLabel}
|
|
50
|
+
className={css.confirmation ?? ''}
|
|
51
|
+
contentClassName={css.confirmationContent ?? ''}
|
|
52
|
+
footer={(
|
|
53
|
+
<>
|
|
54
|
+
<Button variant="outline" className={css.modalAction} onClick={onCancel}>
|
|
55
|
+
{cancelLabel}
|
|
56
|
+
</Button>
|
|
57
|
+
<Button
|
|
58
|
+
variant="primary"
|
|
59
|
+
className={css.confirmAction}
|
|
60
|
+
disabled={disabled || !acknowledged}
|
|
61
|
+
onClick={onConfirm}
|
|
62
|
+
>
|
|
63
|
+
{confirmLabel}
|
|
64
|
+
</Button>
|
|
65
|
+
</>
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
<p className={css.description}>{description}</p>
|
|
69
|
+
<Checkbox
|
|
70
|
+
className={css.acknowledgement}
|
|
71
|
+
checked={acknowledged}
|
|
72
|
+
disabled={disabled}
|
|
73
|
+
modalAutofocus
|
|
74
|
+
label={acknowledgeLabel}
|
|
75
|
+
onChange={onAcknowledgedChange}
|
|
76
|
+
/>
|
|
77
|
+
</Modal>
|
|
78
|
+
)
|
|
79
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
.block {
|
|
2
|
+
--dsl-search-radius: var(--dsw-radius-lg);
|
|
3
|
+
--dsl-search-line-height: 22px;
|
|
4
|
+
|
|
5
|
+
position: relative;
|
|
6
|
+
margin: 16px 0;
|
|
7
|
+
color: var(--dsw-alias-label-primary);
|
|
8
|
+
background: var(--dsw-alias-markdown-code-block);
|
|
9
|
+
border-radius: var(--dsl-search-radius);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.header {
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
gap: 12px;
|
|
16
|
+
padding: 9px 14px;
|
|
17
|
+
background: var(--dsw-alias-markdown-code-block-banner);
|
|
18
|
+
border-top-left-radius: var(--dsl-search-radius);
|
|
19
|
+
border-top-right-radius: var(--dsl-search-radius);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.summary {
|
|
23
|
+
flex: 1;
|
|
24
|
+
min-width: 0;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
text-overflow: ellipsis;
|
|
27
|
+
white-space: nowrap;
|
|
28
|
+
font: var(--dsw-font-xs-13);
|
|
29
|
+
color: var(--dsw-alias-label-secondary);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.copyButton {
|
|
33
|
+
flex: none;
|
|
34
|
+
background-color: transparent;
|
|
35
|
+
border: none;
|
|
36
|
+
padding: 0;
|
|
37
|
+
margin: 0;
|
|
38
|
+
color: var(--dsw-alias-label-secondary);
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
font: var(--dsw-font-xs-13);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.body {
|
|
44
|
+
padding: 8px 14px 12px 0;
|
|
45
|
+
font: var(--dsw-font-markdown-code-block);
|
|
46
|
+
overflow-x: auto;
|
|
47
|
+
overflow-y: hidden;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* No wrapping: a match line or a path keeps its content on one row and scrolls
|
|
51
|
+
sideways instead of folding. */
|
|
52
|
+
.line {
|
|
53
|
+
min-height: var(--dsl-search-line-height);
|
|
54
|
+
padding-left: 14px;
|
|
55
|
+
white-space: pre;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* The 1-based line number ahead of a grep match line, dimmed so the match text
|
|
59
|
+
stays the salient content. */
|
|
60
|
+
.lineNumber {
|
|
61
|
+
color: var(--dsw-alias-label-tertiary);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* A file group's header: a bold path label plus its match count, the whole row
|
|
65
|
+
the collapse control. */
|
|
66
|
+
.fileHeader {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: baseline;
|
|
69
|
+
gap: 8px;
|
|
70
|
+
width: 100%;
|
|
71
|
+
min-height: var(--dsl-search-line-height);
|
|
72
|
+
padding: 0 14px;
|
|
73
|
+
border: none;
|
|
74
|
+
background-color: transparent;
|
|
75
|
+
cursor: pointer;
|
|
76
|
+
font: inherit;
|
|
77
|
+
text-align: left;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.filePath {
|
|
81
|
+
min-width: 0;
|
|
82
|
+
font-weight: 600;
|
|
83
|
+
color: var(--dsw-alias-label-primary);
|
|
84
|
+
white-space: pre;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.fileCount {
|
|
88
|
+
flex: none;
|
|
89
|
+
color: var(--dsw-alias-label-tertiary);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.expand {
|
|
93
|
+
display: block;
|
|
94
|
+
width: 100%;
|
|
95
|
+
padding: 0 14px;
|
|
96
|
+
border: none;
|
|
97
|
+
background-color: transparent;
|
|
98
|
+
color: var(--dsw-alias-label-tertiary);
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
font: inherit;
|
|
101
|
+
text-align: left;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
@media (hover: hover) {
|
|
105
|
+
.expand:hover {
|
|
106
|
+
color: var(--dsw-alias-label-secondary);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.empty {
|
|
111
|
+
padding: 12px 14px;
|
|
112
|
+
font: var(--dsw-font-markdown-code-block);
|
|
113
|
+
color: var(--dsw-alias-label-tertiary);
|
|
114
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { useCallback, useState, type ReactNode } from 'react'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import { headTailCap } from './head-tail-cap.ts'
|
|
4
|
+
import { useClipboardCopy } from './use-clipboard-copy.ts'
|
|
5
|
+
import css from './SearchBlock.module.css'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Result rows shown before the height cap collapses the middle. Matches
|
|
9
|
+
* {@link DEFAULT_TERMINAL_MAX_LINES} so a search card and a terminal card cut a
|
|
10
|
+
* long result at the same place.
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_SEARCH_MAX_LINES = 16
|
|
13
|
+
|
|
14
|
+
/** One matched line inside a {@link SearchFileGroup}: its 1-based line number and text. */
|
|
15
|
+
export interface SearchBlockLineMatch {
|
|
16
|
+
/** 1-based line number of the match within its file. */
|
|
17
|
+
lineNumber: number
|
|
18
|
+
/** The matched line text, as the tool surfaced it. */
|
|
19
|
+
line: string
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** One file's grouped matches, in first-seen file order. */
|
|
23
|
+
export interface SearchFileGroup {
|
|
24
|
+
/** The file the matches belong to (the display path). */
|
|
25
|
+
path: string
|
|
26
|
+
/** The file's matched lines, in output order. */
|
|
27
|
+
matches: SearchBlockLineMatch[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Fields both search shapes carry (the render site positions; this component draws). */
|
|
31
|
+
interface SearchBlockCommon {
|
|
32
|
+
/** Localized chrome supplied by the owning render site. */
|
|
33
|
+
labels: SearchBlockLabels
|
|
34
|
+
/**
|
|
35
|
+
* Whether the tool capped the inline result: the shape carries only the
|
|
36
|
+
* retained results, not every result the search found. The banner summary
|
|
37
|
+
* folds the pre-cap `total` in (`显示 X / 共 N …`) so the card never presents a
|
|
38
|
+
* capped result as complete.
|
|
39
|
+
*/
|
|
40
|
+
truncated: boolean
|
|
41
|
+
/** Total results the search found before capping (equals the retained count when not `truncated`). */
|
|
42
|
+
total: number
|
|
43
|
+
/** Height cap in rows before the middle collapses (default {@link DEFAULT_SEARCH_MAX_LINES}). */
|
|
44
|
+
maxLines?: number | undefined
|
|
45
|
+
/** Extra class merged onto the wrapper. */
|
|
46
|
+
className?: string | undefined
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/** Localized chrome for {@link SearchBlock}. */
|
|
50
|
+
export interface SearchBlockLabels {
|
|
51
|
+
pathsSummary: (shown: number, total: number, truncated: boolean) => string
|
|
52
|
+
matchesSummary: (shown: number, total: number, files: number, truncated: boolean) => string
|
|
53
|
+
copy: string
|
|
54
|
+
copied: string
|
|
55
|
+
noResults: string
|
|
56
|
+
collapseAria: string
|
|
57
|
+
expandAria: (hidden: number) => string
|
|
58
|
+
collapse: string
|
|
59
|
+
expand: (hidden: number) => string
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Props for the grouped-matches (`grep`) shape. */
|
|
63
|
+
export interface SearchMatchesBlockProps extends SearchBlockCommon {
|
|
64
|
+
kind: 'matches'
|
|
65
|
+
/** Matched lines grouped by file, in first-seen file order. */
|
|
66
|
+
files: SearchFileGroup[]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Props for the flat-path (`glob`) shape. */
|
|
70
|
+
export interface SearchPathsBlockProps extends SearchBlockCommon {
|
|
71
|
+
kind: 'paths'
|
|
72
|
+
/** The discovered paths, in the tool's result order (the retained page when `truncated`). */
|
|
73
|
+
paths: string[]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** {@link SearchBlock} props: one card, two `kind`-discriminated shapes. */
|
|
77
|
+
export type SearchBlockProps = SearchMatchesBlockProps | SearchPathsBlockProps
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* One flattened render row. A matches card produces a `file` header row per
|
|
81
|
+
* group followed by a `match` row per retained line while the group is
|
|
82
|
+
* expanded; a paths card produces one `path` row per path. The height cap
|
|
83
|
+
* counts these rows uniformly, so a file header costs one row exactly as a
|
|
84
|
+
* match line or a path does.
|
|
85
|
+
*/
|
|
86
|
+
type SearchRow =
|
|
87
|
+
| { type: 'file'; path: string; count: number; index: number; collapsed: boolean }
|
|
88
|
+
| { type: 'match'; lineNumber: number; line: string; key: string; fileIndex: number }
|
|
89
|
+
| { type: 'path'; path: string }
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* The plain-text form the copy control writes: the whole structured result
|
|
93
|
+
* regardless of the height cap or which groups are collapsed, so the clipboard
|
|
94
|
+
* carries the result rather than what the card happens to be showing.
|
|
95
|
+
* @param props - the card's props.
|
|
96
|
+
* @returns the copyable text, or the empty string for an empty result.
|
|
97
|
+
*/
|
|
98
|
+
function copyText(props: SearchBlockProps): string {
|
|
99
|
+
if (props.kind === 'paths') return props.paths.join('\n')
|
|
100
|
+
return props.files
|
|
101
|
+
.map(file => [file.path, ...file.matches.map(m => `${m.lineNumber}: ${m.line}`)].join('\n'))
|
|
102
|
+
.join('\n\n')
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Number of retained results the card holds: the matched-line count across all
|
|
107
|
+
* files for a matches card, the path count for a paths card. This is the count
|
|
108
|
+
* the banner summary reports against `total` when the result was capped.
|
|
109
|
+
* @param props - the card's props.
|
|
110
|
+
* @returns the retained result count.
|
|
111
|
+
*/
|
|
112
|
+
function shownCount(props: SearchBlockProps): number {
|
|
113
|
+
return props.kind === 'paths'
|
|
114
|
+
? props.paths.length
|
|
115
|
+
: props.files.reduce((sum, file) => sum + file.matches.length, 0)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* The banner summary. When the search was capped it reads `显示 X / 共 N …` so
|
|
120
|
+
* the retained count and the pre-cap total sit in one clause (mirroring the read
|
|
121
|
+
* card's `显示 X / Y 行`); when it was not capped it is a plain count of what the
|
|
122
|
+
* card holds. The unit — `处匹配 · K 个文件` for grep, `个路径` for glob — trails
|
|
123
|
+
* the count either way.
|
|
124
|
+
* @param props - the card's props.
|
|
125
|
+
* @param shown - the retained result count from {@link shownCount}.
|
|
126
|
+
* @param truncated - whether the search was capped.
|
|
127
|
+
* @param total - the pre-cap total the truncation clause reports.
|
|
128
|
+
* @returns the summary text.
|
|
129
|
+
*/
|
|
130
|
+
function summaryText(props: SearchBlockProps, shown: number, truncated: boolean, total: number): string {
|
|
131
|
+
return props.kind === 'paths'
|
|
132
|
+
? props.labels.pathsSummary(shown, total, truncated)
|
|
133
|
+
: props.labels.matchesSummary(shown, total, props.files.length, truncated)
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Flatten a card's shape into its render rows, dropping a collapsed file
|
|
138
|
+
* group's match rows.
|
|
139
|
+
* @param props - the card's props.
|
|
140
|
+
* @param collapsed - the set of collapsed file-group indices (matches only).
|
|
141
|
+
* @returns the flattened rows in output order.
|
|
142
|
+
*/
|
|
143
|
+
function toRows(props: SearchBlockProps, collapsed: ReadonlySet<number>): SearchRow[] {
|
|
144
|
+
if (props.kind === 'paths') return props.paths.map((path): SearchRow => ({ type: 'path', path }))
|
|
145
|
+
const rows: SearchRow[] = []
|
|
146
|
+
props.files.forEach((file, index) => {
|
|
147
|
+
const isCollapsed = collapsed.has(index)
|
|
148
|
+
rows.push({ type: 'file', path: file.path, count: file.matches.length, index, collapsed: isCollapsed })
|
|
149
|
+
if (isCollapsed) return
|
|
150
|
+
for (const match of file.matches) {
|
|
151
|
+
rows.push({ type: 'match', lineNumber: match.lineNumber, line: match.line, key: `${index}:${match.lineNumber}`, fileIndex: index })
|
|
152
|
+
}
|
|
153
|
+
})
|
|
154
|
+
return rows
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* A stable React key for a flattened render row: the group-scoped match key, a
|
|
159
|
+
* file-index-scoped header key, or the path itself. Rows of different types
|
|
160
|
+
* never collide, since each key carries its type prefix or the group index.
|
|
161
|
+
* @param row - the flattened row.
|
|
162
|
+
* @returns the key.
|
|
163
|
+
*/
|
|
164
|
+
function rowKey(row: SearchRow): string {
|
|
165
|
+
switch (row.type) {
|
|
166
|
+
case 'match': return `match:${row.key}`
|
|
167
|
+
case 'file': return `file:${row.index}`
|
|
168
|
+
case 'path': return `path:${row.path}`
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Render a completed search as a grouped-matches or flat-path card.
|
|
174
|
+
* @param props - see {@link SearchBlockProps}.
|
|
175
|
+
* @returns the search block element.
|
|
176
|
+
*/
|
|
177
|
+
export function SearchBlock(props: SearchBlockProps) {
|
|
178
|
+
const { truncated, total, maxLines = DEFAULT_SEARCH_MAX_LINES, className } = props
|
|
179
|
+
const [expanded, setExpanded] = useState(false)
|
|
180
|
+
const [collapsed, setCollapsed] = useState<ReadonlySet<number>>(() => new Set())
|
|
181
|
+
|
|
182
|
+
// `props` is a fresh object each render, so memoizing on it never hits; the
|
|
183
|
+
// flatten is cheap, so it runs inline keyed on the collapse set instead.
|
|
184
|
+
const rows = toRows(props, collapsed)
|
|
185
|
+
const shown = shownCount(props)
|
|
186
|
+
const empty = rows.length === 0
|
|
187
|
+
const { copied, onCopy } = useClipboardCopy(copyText(props))
|
|
188
|
+
|
|
189
|
+
const onToggle = useCallback(() => { setExpanded(value => !value) }, [])
|
|
190
|
+
|
|
191
|
+
const toggleFile = useCallback((index: number) => {
|
|
192
|
+
setCollapsed((prev) => {
|
|
193
|
+
const next = new Set(prev)
|
|
194
|
+
if (next.has(index)) next.delete(index)
|
|
195
|
+
else next.add(index)
|
|
196
|
+
return next
|
|
197
|
+
})
|
|
198
|
+
}, [])
|
|
199
|
+
|
|
200
|
+
const { hidden, capped, headLines, tailLines } = headTailCap(rows.length, maxLines, expanded)
|
|
201
|
+
const head = capped ? rows.slice(0, headLines) : rows
|
|
202
|
+
const naturalTail = capped ? rows.slice(rows.length - tailLines) : []
|
|
203
|
+
// When the tail slice begins inside a file's matches, its own header sits
|
|
204
|
+
// above the cut and is not shown, so those rows could not be attributed to a
|
|
205
|
+
// file. Restore the owning header at the top of the tail — unless the head
|
|
206
|
+
// slice already carries it (a single large file), where it would duplicate.
|
|
207
|
+
const tailLead = naturalTail[0]
|
|
208
|
+
const tailHeader = tailLead?.type === 'match'
|
|
209
|
+
&& !head.some(row => row.type === 'file' && row.index === tailLead.fileIndex)
|
|
210
|
+
? rows.find((row): row is Extract<SearchRow, { type: 'file' }> =>
|
|
211
|
+
row.type === 'file' && row.index === tailLead.fileIndex)
|
|
212
|
+
: undefined
|
|
213
|
+
// The restored header is itself a row. Left extra it would push the card to
|
|
214
|
+
// maxLines + 1 and overstate `hidden` by one, so it consumes a tail slot: drop
|
|
215
|
+
// the tail's first row (the match whose header this is) for it. Visible rows
|
|
216
|
+
// hold at maxLines and `hidden` stays exact; the dropped match joins the
|
|
217
|
+
// hidden middle.
|
|
218
|
+
const tail = tailHeader === undefined ? naturalTail : naturalTail.slice(1)
|
|
219
|
+
|
|
220
|
+
const renderRow = (row: SearchRow): ReactNode => {
|
|
221
|
+
if (row.type === 'path') return <div className={css.line}>{row.path}</div>
|
|
222
|
+
if (row.type === 'match') {
|
|
223
|
+
return (
|
|
224
|
+
<div className={css.line}>
|
|
225
|
+
<span className={css.lineNumber}>{row.lineNumber}: </span>
|
|
226
|
+
{row.line}
|
|
227
|
+
</div>
|
|
228
|
+
)
|
|
229
|
+
}
|
|
230
|
+
return (
|
|
231
|
+
<button
|
|
232
|
+
type="button"
|
|
233
|
+
className={css.fileHeader}
|
|
234
|
+
aria-expanded={!row.collapsed}
|
|
235
|
+
onClick={() => { toggleFile(row.index) }}
|
|
236
|
+
>
|
|
237
|
+
<span className={css.filePath}>{row.path}</span>
|
|
238
|
+
<span className={css.fileCount}>{row.count}</span>
|
|
239
|
+
</button>
|
|
240
|
+
)
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
return (
|
|
244
|
+
<div className={clsx(css.block, className)} data-search={props.kind}>
|
|
245
|
+
<div className={css.header}>
|
|
246
|
+
<span className={css.summary}>{summaryText(props, shown, truncated, total)}</span>
|
|
247
|
+
{!empty && (
|
|
248
|
+
<button type="button" className={css.copyButton} onClick={onCopy}>
|
|
249
|
+
{copied ? props.labels.copied : props.labels.copy}
|
|
250
|
+
</button>
|
|
251
|
+
)}
|
|
252
|
+
</div>
|
|
253
|
+
{empty
|
|
254
|
+
? <div className={css.empty}>{props.labels.noResults}</div>
|
|
255
|
+
: (
|
|
256
|
+
<div className={css.body}>
|
|
257
|
+
{head.map(row => (
|
|
258
|
+
<div key={rowKey(row)}>{renderRow(row)}</div>
|
|
259
|
+
))}
|
|
260
|
+
{hidden > 0 && (
|
|
261
|
+
<button
|
|
262
|
+
type="button"
|
|
263
|
+
className={css.expand}
|
|
264
|
+
aria-expanded={expanded}
|
|
265
|
+
aria-label={expanded ? props.labels.collapseAria : props.labels.expandAria(hidden)}
|
|
266
|
+
onClick={onToggle}
|
|
267
|
+
>
|
|
268
|
+
{expanded ? props.labels.collapse : props.labels.expand(hidden)}
|
|
269
|
+
</button>
|
|
270
|
+
)}
|
|
271
|
+
{tailHeader !== undefined && (
|
|
272
|
+
<div key={`tailHeader:${rowKey(tailHeader)}`}>{renderRow(tailHeader)}</div>
|
|
273
|
+
)}
|
|
274
|
+
{tail.map(row => (
|
|
275
|
+
<div key={rowKey(row)}>{renderRow(row)}</div>
|
|
276
|
+
))}
|
|
277
|
+
</div>
|
|
278
|
+
)}
|
|
279
|
+
</div>
|
|
280
|
+
)
|
|
281
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* The track is the same translucent fill the hover state uses, so it reads as
|
|
2
|
+
* a place rather than a second button; the one raised part is the indicator,
|
|
3
|
+
* a white pill that slides under the selected segment. Its stroke rides inside
|
|
4
|
+
* the soft elevation shadow (border: 0), the way every elevated surface draws
|
|
5
|
+
* its edge, so the elevation gate keeps it off the alias-border set.
|
|
6
|
+
*
|
|
7
|
+
* Segments are equal-width grid tracks sized to the widest label, which is
|
|
8
|
+
* what lets one indicator be placed arithmetically: the tablist carries the
|
|
9
|
+
* segment count and the selected index as custom properties, and the indicator
|
|
10
|
+
* derives its width and offset from them instead of measuring the DOM. */
|
|
11
|
+
.control {
|
|
12
|
+
position: relative;
|
|
13
|
+
display: inline-grid;
|
|
14
|
+
grid-auto-flow: column;
|
|
15
|
+
grid-auto-columns: 1fr;
|
|
16
|
+
gap: 2px;
|
|
17
|
+
padding: 4px;
|
|
18
|
+
border-radius: var(--dsw-radius-md);
|
|
19
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.indicator {
|
|
23
|
+
position: absolute;
|
|
24
|
+
top: 4px;
|
|
25
|
+
left: 4px;
|
|
26
|
+
width: calc((100% - 8px - 2px * (var(--dsh-segment-count) - 1)) / var(--dsh-segment-count));
|
|
27
|
+
height: calc(100% - 8px);
|
|
28
|
+
border: 0;
|
|
29
|
+
border-radius: var(--dsw-radius-sm);
|
|
30
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
31
|
+
box-shadow: var(--dsw-elevation-soft);
|
|
32
|
+
transform: translateX(calc(var(--dsh-segment-index) * (100% + 2px)));
|
|
33
|
+
transition: transform 160ms ease;
|
|
34
|
+
pointer-events: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.tab {
|
|
38
|
+
box-sizing: border-box;
|
|
39
|
+
position: relative;
|
|
40
|
+
z-index: 1;
|
|
41
|
+
height: 28px;
|
|
42
|
+
padding: 0 16px;
|
|
43
|
+
border: 0;
|
|
44
|
+
border-radius: var(--dsw-radius-sm);
|
|
45
|
+
background: transparent;
|
|
46
|
+
color: var(--dsw-alias-label-secondary);
|
|
47
|
+
font: inherit;
|
|
48
|
+
font-size: 13px;
|
|
49
|
+
line-height: 20px;
|
|
50
|
+
font-weight: 500;
|
|
51
|
+
white-space: nowrap;
|
|
52
|
+
cursor: pointer;
|
|
53
|
+
transition: color 120ms ease;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.tab[aria-selected='true'] {
|
|
57
|
+
color: var(--dsw-alias-label-primary);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@media (hover: hover) {
|
|
61
|
+
.tab:hover:not(:disabled) {
|
|
62
|
+
color: var(--dsw-alias-label-primary);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.tab:disabled {
|
|
67
|
+
cursor: default;
|
|
68
|
+
opacity: 0.4;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.tab:focus-visible {
|
|
72
|
+
outline: var(--dsw-focus-ring-width) solid var(--dsw-focus-ring-color, var(--dsw-alias-state-business-primary));
|
|
73
|
+
outline-offset: -2px;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@media (prefers-reduced-motion: reduce) {
|
|
77
|
+
.indicator,
|
|
78
|
+
.tab {
|
|
79
|
+
transition: none;
|
|
80
|
+
}
|
|
81
|
+
}
|