@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
|
@@ -0,0 +1,119 @@
|
|
|
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
|
+
|
|
5
|
+
interface PermissionIconArtworkProps extends IconProps {
|
|
6
|
+
strokeWidth: number
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function ReadOnlyArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
|
|
10
|
+
return (
|
|
11
|
+
<svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
|
|
12
|
+
<path d="M5.08545 8.13775L7.18455 10.2368C7.26636 10.3187 7.4003 10.3142 7.47649 10.2271L11.5148 5.61194" stroke="currentColor" />
|
|
13
|
+
<path d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L13.9245 3.84317V7.11961C13.9245 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2.07544 11.6089 2.07544 7.11961V3.84317L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
|
|
14
|
+
</svg>
|
|
15
|
+
)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function WorkspaceWriteArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
|
|
19
|
+
return (
|
|
20
|
+
<svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
|
|
21
|
+
<path d="M6.4209 1.68067C7.43922 1.299 8.56177 1.29898 9.58008 1.68067L14.0996 3.375C14.2946 3.44811 14.4236 3.63455 14.4238 3.84278V6.89063C14.1115 6.71853 13.7761 6.58312 13.4238 6.48926V4.18946L9.22852 2.61621C8.43657 2.31947 7.56341 2.31939 6.77148 2.61621L2.5752 4.18946V7.11914C2.5752 11.1796 5.52369 13.056 8 14.0391C8.27653 13.9293 8.55827 13.8067 8.8418 13.6729C9.07101 13.9468 9.33228 14.1929 9.62012 14.4053C9.12409 14.6579 8.63578 14.8696 8.17871 15.0449C8.0637 15.0889 7.93628 15.0889 7.82129 15.0449C5.22011 14.0472 1.5752 11.9381 1.5752 7.11914V3.84278C1.57541 3.63469 1.70463 3.44821 1.89941 3.375L6.4209 1.68067Z" fill="currentColor" />
|
|
22
|
+
<path d="M5.26392 6.60339H10.7361" stroke="currentColor" />
|
|
23
|
+
<path d="M5.26392 9.86902H8.32833" stroke="currentColor" />
|
|
24
|
+
<path d="M10.0317 13.2229C10.263 13.3929 10.4943 13.563 10.7256 13.733C10.7932 13.6482 10.8608 13.5634 10.9284 13.4786C12.1455 11.9522 13.3626 10.4258 14.5798 8.89935C14.6474 8.81455 14.715 8.72975 14.7826 8.64495C14.4143 8.37419 14.046 8.10344 13.6777 7.83268C13.6169 7.92252 13.5562 8.01236 13.4954 8.10219C12.4016 9.71926 11.3078 11.3363 10.214 12.9534C10.1532 13.0432 10.0924 13.1331 10.0317 13.2229Z" fill="currentColor" />
|
|
25
|
+
<path d="M12.6516 12.6696C12.6516 12.925 12.6516 13.1804 12.6516 13.4359C12.6952 13.4378 12.7387 13.4398 12.7823 13.4417C13.5663 13.4768 14.3504 13.5118 15.1345 13.5469C15.178 13.5488 15.2216 13.5508 15.2651 13.5527C15.2651 13.2194 15.2651 12.8861 15.2651 12.5527C15.2216 12.5547 15.178 12.5566 15.1345 12.5586C14.3504 12.5936 13.5663 12.6287 12.7823 12.6637C12.7387 12.6657 12.6952 12.6676 12.6516 12.6696Z" fill="currentColor" />
|
|
26
|
+
</svg>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function FullAccessArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
|
|
31
|
+
return (
|
|
32
|
+
<svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
|
|
33
|
+
<path d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L13.9245 3.84317V7.11961C13.9245 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2.07544 11.6089 2.07544 7.11961V3.84317L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
|
|
34
|
+
<path d="M8 4.39209V9.89209" stroke="currentColor" />
|
|
35
|
+
<path d="M8 10.8081V11.8081" stroke="currentColor" />
|
|
36
|
+
</svg>
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function AutoReviewArtwork({ size = 16, className, strokeWidth }: PermissionIconArtworkProps): ReactNode {
|
|
41
|
+
return (
|
|
42
|
+
<svg width={size} height={size} className={className} viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" strokeWidth={strokeWidth}>
|
|
43
|
+
<path d="M6.59624 2.14853C7.50155 1.80917 8.49914 1.80919 9.40444 2.14859L13.9245 3.84317V7.11961C13.9245 11.6089 10.5565 13.5975 8.00035 14.5779C5.44423 13.5975 2.07544 11.6089 2.07544 7.11961V3.84317L6.59624 2.14853Z" stroke="currentColor" strokeLinejoin="round" />
|
|
44
|
+
<path d="M5.75 10.15L8 4.95L10.25 10.15M6.43 8.59H9.57" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" />
|
|
45
|
+
</svg>
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Render the read-only permission icon with a one-pixel stroke.
|
|
51
|
+
* @param props - Size and optional class.
|
|
52
|
+
* @returns The regular decorative permission glyph.
|
|
53
|
+
*/
|
|
54
|
+
export function PermissionIconReadOnlyRegular(props: IconProps): ReactNode {
|
|
55
|
+
return <ReadOnlyArtwork {...props} strokeWidth={ICON_REGULAR_STROKE} />
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Render the read-only permission icon with a 1.3px stroke.
|
|
60
|
+
* @param props - Size and optional class.
|
|
61
|
+
* @returns The medium decorative permission glyph.
|
|
62
|
+
*/
|
|
63
|
+
export function PermissionIconReadOnlyMedium(props: IconProps): ReactNode {
|
|
64
|
+
return <ReadOnlyArtwork {...props} strokeWidth={ICON_MEDIUM_STROKE} />
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Render the workspace-write permission icon with a one-pixel stroke.
|
|
69
|
+
* @param props - Size and optional class.
|
|
70
|
+
* @returns The regular decorative permission glyph.
|
|
71
|
+
*/
|
|
72
|
+
export function PermissionIconWorkspaceWriteRegular(props: IconProps): ReactNode {
|
|
73
|
+
return <WorkspaceWriteArtwork {...props} strokeWidth={ICON_REGULAR_STROKE} />
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Render the workspace-write permission icon with a 1.3px stroke.
|
|
78
|
+
* @param props - Size and optional class.
|
|
79
|
+
* @returns The medium decorative permission glyph.
|
|
80
|
+
*/
|
|
81
|
+
export function PermissionIconWorkspaceWriteMedium(props: IconProps): ReactNode {
|
|
82
|
+
return <WorkspaceWriteArtwork {...props} strokeWidth={ICON_MEDIUM_STROKE} />
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Render the full-access permission icon with a one-pixel stroke.
|
|
87
|
+
* @param props - Size and optional class.
|
|
88
|
+
* @returns The regular decorative permission glyph.
|
|
89
|
+
*/
|
|
90
|
+
export function PermissionIconFullAccessRegular(props: IconProps): ReactNode {
|
|
91
|
+
return <FullAccessArtwork {...props} strokeWidth={ICON_REGULAR_STROKE} />
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Render the full-access permission icon with a 1.3px stroke.
|
|
96
|
+
* @param props - Size and optional class.
|
|
97
|
+
* @returns The medium decorative permission glyph.
|
|
98
|
+
*/
|
|
99
|
+
export function PermissionIconFullAccessMedium(props: IconProps): ReactNode {
|
|
100
|
+
return <FullAccessArtwork {...props} strokeWidth={ICON_MEDIUM_STROKE} />
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Render the auto-review permission icon with a one-pixel stroke.
|
|
105
|
+
* @param props - Size and optional class.
|
|
106
|
+
* @returns The regular decorative permission glyph.
|
|
107
|
+
*/
|
|
108
|
+
export function PermissionIconAutoReviewRegular(props: IconProps): ReactNode {
|
|
109
|
+
return <AutoReviewArtwork {...props} strokeWidth={ICON_REGULAR_STROKE} />
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Render the auto-review permission icon with a 1.3px stroke.
|
|
114
|
+
* @param props - Size and optional class.
|
|
115
|
+
* @returns The medium decorative permission glyph.
|
|
116
|
+
*/
|
|
117
|
+
export function PermissionIconAutoReviewMedium(props: IconProps): ReactNode {
|
|
118
|
+
return <AutoReviewArtwork {...props} strokeWidth={ICON_MEDIUM_STROKE} />
|
|
119
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.pill {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: center;
|
|
4
|
+
gap: 4px;
|
|
5
|
+
height: 24px;
|
|
6
|
+
padding: 0 8px;
|
|
7
|
+
border: none;
|
|
8
|
+
border-radius: 999px;
|
|
9
|
+
corner-shape: round;
|
|
10
|
+
font-size: 12px;
|
|
11
|
+
line-height: 18px;
|
|
12
|
+
color: var(--dsw-alias-label-secondary);
|
|
13
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.interactive {
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@media (hover: hover) {
|
|
21
|
+
.interactive:hover {
|
|
22
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.active {
|
|
27
|
+
color: var(--dsw-alias-label-primary);
|
|
28
|
+
background: var(--dsw-alias-button-ghost-active-fill);
|
|
29
|
+
box-shadow: inset 0 0 0 1px var(--dsw-alias-button-ghost-active-border);
|
|
30
|
+
}
|
package/src/Pill.tsx
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Pill: capsule at the 24px text-line size, selectable when given `onClick`
|
|
2
|
+
// (view switcher tabs, filters) and a static span otherwise — TerminalBlock's
|
|
3
|
+
// exit status is the read-only case. The 11px read-only badge is `Tag`; size
|
|
4
|
+
// separates the two as much as interactivity does.
|
|
5
|
+
|
|
6
|
+
import type { ButtonHTMLAttributes, ReactNode } from 'react'
|
|
7
|
+
import clsx from 'clsx'
|
|
8
|
+
import css from './Pill.module.css'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Render a pill chip. Interactive when onClick is supplied (renders a button);
|
|
12
|
+
* otherwise a static span.
|
|
13
|
+
* @param props.active - selected/active visual state.
|
|
14
|
+
* @returns pill element.
|
|
15
|
+
*/
|
|
16
|
+
export function Pill({ active = false, className, children, onClick, ...rest }: {
|
|
17
|
+
active?: boolean
|
|
18
|
+
// `| undefined` so a caller can forward an optional class straight through
|
|
19
|
+
// under exactOptionalPropertyTypes (a CSS-module lookup is string|undefined).
|
|
20
|
+
className?: string | undefined
|
|
21
|
+
children?: ReactNode
|
|
22
|
+
} & ButtonHTMLAttributes<HTMLButtonElement>) {
|
|
23
|
+
if (!onClick) {
|
|
24
|
+
return <span className={clsx(css.pill, active && css.active, className)}>{children}</span>
|
|
25
|
+
}
|
|
26
|
+
return (
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
className={clsx(css.pill, css.interactive, active && css.active, className)}
|
|
30
|
+
onClick={onClick}
|
|
31
|
+
{...rest}
|
|
32
|
+
>
|
|
33
|
+
{children}
|
|
34
|
+
</button>
|
|
35
|
+
)
|
|
36
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
.quote {
|
|
2
|
+
display: inline-flex;
|
|
3
|
+
align-items: baseline;
|
|
4
|
+
gap: 4px;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
max-width: min(80%, 300px);
|
|
7
|
+
margin: 0;
|
|
8
|
+
padding: 0;
|
|
9
|
+
vertical-align: baseline;
|
|
10
|
+
color: var(--dsw-alias-state-business-primary);
|
|
11
|
+
font-size: var(--dsh-content-font-size, 14px);
|
|
12
|
+
line-height: calc(20px + var(--dsh-content-font-delta, 0px));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.popoverText {
|
|
16
|
+
display: block;
|
|
17
|
+
padding: 8px 10px;
|
|
18
|
+
color: var(--dsw-alias-label-primary);
|
|
19
|
+
font-size: 14px;
|
|
20
|
+
line-height: 20px;
|
|
21
|
+
overflow-wrap: anywhere;
|
|
22
|
+
white-space: pre-wrap;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.visuallyHidden {
|
|
26
|
+
position: absolute;
|
|
27
|
+
width: 1px;
|
|
28
|
+
height: 1px;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
clip: rect(0 0 0 0);
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.inlineBody {
|
|
35
|
+
color: var(--dsw-alias-label-secondary);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.summary {
|
|
39
|
+
display: flex;
|
|
40
|
+
flex-direction: column;
|
|
41
|
+
gap: 4px;
|
|
42
|
+
padding: 8px 10px;
|
|
43
|
+
font-size: 14px;
|
|
44
|
+
line-height: 20px;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.summaryTitle {
|
|
48
|
+
color: var(--dsw-alias-state-business-primary);
|
|
49
|
+
overflow-wrap: anywhere;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.summaryDetail {
|
|
53
|
+
color: var(--dsw-alias-label-secondary);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.summaryBody {
|
|
57
|
+
color: var(--dsw-alias-label-primary);
|
|
58
|
+
overflow-wrap: anywhere;
|
|
59
|
+
white-space: pre-wrap;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.source {
|
|
63
|
+
min-width: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
border: none;
|
|
66
|
+
outline: none;
|
|
67
|
+
background: none;
|
|
68
|
+
color: inherit;
|
|
69
|
+
font: inherit;
|
|
70
|
+
line-height: inherit;
|
|
71
|
+
text-align: left;
|
|
72
|
+
overflow: hidden;
|
|
73
|
+
text-overflow: ellipsis;
|
|
74
|
+
white-space: nowrap;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.marker,
|
|
78
|
+
.remove {
|
|
79
|
+
display: grid;
|
|
80
|
+
place-items: center;
|
|
81
|
+
align-self: center;
|
|
82
|
+
flex: none;
|
|
83
|
+
width: 16px;
|
|
84
|
+
height: 16px;
|
|
85
|
+
padding: 0;
|
|
86
|
+
color: inherit;
|
|
87
|
+
user-select: none;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.marker {
|
|
91
|
+
pointer-events: none;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.remove {
|
|
95
|
+
border: none;
|
|
96
|
+
border-radius: 50%;
|
|
97
|
+
corner-shape: round;
|
|
98
|
+
background: transparent;
|
|
99
|
+
cursor: pointer;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.quoteMark,
|
|
103
|
+
.closeMark {
|
|
104
|
+
grid-area: 1 / 1;
|
|
105
|
+
transition: opacity 120ms ease;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.closeMark {
|
|
109
|
+
opacity: 0;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.quote[data-removable]:focus-within .quoteMark {
|
|
113
|
+
opacity: 0;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.quote[data-removable]:focus-within .closeMark {
|
|
117
|
+
opacity: 1;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@media (hover: hover) {
|
|
121
|
+
.quote[data-removable]:hover .quoteMark {
|
|
122
|
+
opacity: 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.quote[data-removable]:hover .closeMark {
|
|
126
|
+
opacity: 1;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@media (hover: none) {
|
|
131
|
+
.quote[data-removable] .quoteMark {
|
|
132
|
+
opacity: 0;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.quote[data-removable] .closeMark {
|
|
136
|
+
opacity: 1;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/** Shared compact presentation for draft and sent text quotes. */
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef, useState } from 'react'
|
|
4
|
+
import type { JSX, MouseEvent as ReactMouseEvent } from 'react'
|
|
5
|
+
import { IconCloseOutlineRegular } from './icons/index.tsx'
|
|
6
|
+
import { HoverCard } from './HoverCard.tsx'
|
|
7
|
+
import css from './QuotePreview.module.css'
|
|
8
|
+
|
|
9
|
+
function QuoteMarkIcon({ className }: { readonly className?: string | undefined }) {
|
|
10
|
+
return (
|
|
11
|
+
<svg width={16} height={16} className={className} viewBox="0 0 16 16" fill="none" aria-hidden>
|
|
12
|
+
<g transform="translate(6.8 2.4)">
|
|
13
|
+
<path d="M2.8125 0.583008L3.2002 1.16602C2.43912 1.6713 1.88491 2.41238 1.60547 3.25684H2.98926V6.70605H0V4.52148C1.96593e-05 2.70313 0.9109 1.00575 2.42578 0L2.8125 0.583008Z" fill="currentColor" />
|
|
14
|
+
<path d="M7.50781 0.583008L7.89551 1.16602C7.13443 1.6713 6.58022 2.41238 6.30078 3.25684H7.68457V6.70605H4.69531V4.52148C4.69533 2.70313 5.60621 1.00575 7.12109 0L7.50781 0.583008Z" fill="currentColor" />
|
|
15
|
+
</g>
|
|
16
|
+
</svg>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Optional whole-quote removal control supplied by an editable owner. */
|
|
21
|
+
export interface QuotePreviewRemoval {
|
|
22
|
+
/** Localized accessible name for the removal button. */
|
|
23
|
+
readonly label: string
|
|
24
|
+
/** Remove the complete owning quote node. */
|
|
25
|
+
readonly onRemove: () => void
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Owner-supplied readable form of a quote whose exact text is long structured content. */
|
|
29
|
+
export interface QuoteSummary {
|
|
30
|
+
/** Short inline label shown before `body` in place of the exact text; assistive technology reads `title` and `detail` instead. */
|
|
31
|
+
readonly label: string
|
|
32
|
+
/** First popover line, such as a file path; also the label's accessible text. */
|
|
33
|
+
readonly title: string
|
|
34
|
+
/** Secondary popover line, such as a line range. */
|
|
35
|
+
readonly detail?: string | undefined
|
|
36
|
+
/** Main text, such as a user's comment, shown inline after `label` and in full in the popover. */
|
|
37
|
+
readonly body: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Presentation inputs for one compact quote excerpt. */
|
|
41
|
+
export interface QuotePreviewProps {
|
|
42
|
+
/** Exact selected text rendered inline and exposed in a popover while clipped, unless `summary` replaces it. */
|
|
43
|
+
readonly text: string
|
|
44
|
+
/** Readable replacement for `text`: its label renders inline and its popover opens on every hover. */
|
|
45
|
+
readonly summary?: QuoteSummary | undefined
|
|
46
|
+
/** Composer-only removal action; omit for inert sent quotes. */
|
|
47
|
+
readonly removal?: QuotePreviewRemoval | undefined
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Render one width-capped quote preview shared by editable drafts and sent messages.
|
|
52
|
+
* Clipped excerpts open a content-sized, scrollable popover that fits within the viewport.
|
|
53
|
+
* @param props - selected text, optional summary, and optional localized removal action.
|
|
54
|
+
* @returns a non-navigating quote preview with a full-text popover only while clipped, or a summary popover.
|
|
55
|
+
*/
|
|
56
|
+
export function QuotePreview({ text, summary, removal }: QuotePreviewProps): JSX.Element {
|
|
57
|
+
const sourceRef = useRef<HTMLSpanElement | null>(null)
|
|
58
|
+
const [truncated, setTruncated] = useState(false)
|
|
59
|
+
useLayoutEffect(() => {
|
|
60
|
+
const source = sourceRef.current
|
|
61
|
+
/* v8 ignore next -- the ref is attached before layout effects run. */
|
|
62
|
+
if (source === null) return
|
|
63
|
+
const measure = () => {
|
|
64
|
+
const clipped = source.scrollWidth > source.clientWidth
|
|
65
|
+
setTruncated(clipped)
|
|
66
|
+
}
|
|
67
|
+
measure()
|
|
68
|
+
if (typeof ResizeObserver === 'undefined') return
|
|
69
|
+
const observer = new ResizeObserver(measure)
|
|
70
|
+
observer.observe(source)
|
|
71
|
+
return () => { observer.disconnect() }
|
|
72
|
+
}, [text])
|
|
73
|
+
const remove = (event: ReactMouseEvent<HTMLButtonElement>): void => {
|
|
74
|
+
event.preventDefault()
|
|
75
|
+
event.stopPropagation()
|
|
76
|
+
removal?.onRemove()
|
|
77
|
+
}
|
|
78
|
+
const preview = (
|
|
79
|
+
<span
|
|
80
|
+
className={css.quote}
|
|
81
|
+
data-quote-preview=""
|
|
82
|
+
data-removable={removal === undefined ? undefined : ''}
|
|
83
|
+
>
|
|
84
|
+
{removal === undefined
|
|
85
|
+
? (
|
|
86
|
+
<span className={css.marker} aria-hidden>
|
|
87
|
+
<QuoteMarkIcon className={css.quoteMark} />
|
|
88
|
+
</span>
|
|
89
|
+
)
|
|
90
|
+
: (
|
|
91
|
+
<button
|
|
92
|
+
type="button"
|
|
93
|
+
className={css.remove}
|
|
94
|
+
aria-label={removal.label}
|
|
95
|
+
onPointerDown={(event) => { event.preventDefault(); event.stopPropagation() }}
|
|
96
|
+
onKeyDown={(event) => { event.stopPropagation() }}
|
|
97
|
+
onClick={remove}
|
|
98
|
+
>
|
|
99
|
+
<QuoteMarkIcon className={css.quoteMark} />
|
|
100
|
+
<IconCloseOutlineRegular size={12} className={css.closeMark} />
|
|
101
|
+
</button>
|
|
102
|
+
)}
|
|
103
|
+
<span ref={sourceRef} className={css.source} data-quote-preview-text="">
|
|
104
|
+
{summary === undefined ? text : (
|
|
105
|
+
<>
|
|
106
|
+
<span aria-hidden="true">{summary.label}</span>
|
|
107
|
+
<span className={css.visuallyHidden}>{summary.detail === undefined ? summary.title : `${summary.title} ${summary.detail}`}</span>
|
|
108
|
+
{' '}<span className={css.inlineBody}>{summary.body}</span>
|
|
109
|
+
</>
|
|
110
|
+
)}
|
|
111
|
+
</span>
|
|
112
|
+
</span>
|
|
113
|
+
)
|
|
114
|
+
return (
|
|
115
|
+
<HoverCard
|
|
116
|
+
inline
|
|
117
|
+
grouped
|
|
118
|
+
fitContent
|
|
119
|
+
openDelayMs={0}
|
|
120
|
+
disabled={summary === undefined && !truncated}
|
|
121
|
+
anchor={preview}
|
|
122
|
+
content={summary === undefined
|
|
123
|
+
? <span className={css.popoverText} data-quote-popover="" aria-hidden="true">{text}</span>
|
|
124
|
+
: (
|
|
125
|
+
<span className={css.summary} data-quote-popover="" aria-hidden="true">
|
|
126
|
+
<span className={css.summaryTitle}>{summary.title}</span>
|
|
127
|
+
{summary.detail !== undefined && <span className={css.summaryDetail}>{summary.detail}</span>}
|
|
128
|
+
<span className={css.summaryBody}>{summary.body}</span>
|
|
129
|
+
</span>
|
|
130
|
+
)}
|
|
131
|
+
/>
|
|
132
|
+
)
|
|
133
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.line {
|
|
2
|
+
display: flex;
|
|
3
|
+
min-height: 1lh;
|
|
4
|
+
white-space: pre;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.gutter {
|
|
8
|
+
flex: none;
|
|
9
|
+
width: var(--dsl-read-gutter);
|
|
10
|
+
margin-right: 12px;
|
|
11
|
+
text-align: right;
|
|
12
|
+
color: var(--dsw-alias-label-tertiary);
|
|
13
|
+
user-select: none;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.content {
|
|
17
|
+
min-width: 0;
|
|
18
|
+
color: var(--dsw-alias-label-primary);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.block[data-code-wrap='true'] .line {
|
|
22
|
+
white-space: pre-wrap;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.block[data-code-wrap='true'] .content {
|
|
26
|
+
overflow-wrap: anywhere;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.expand {
|
|
30
|
+
display: block;
|
|
31
|
+
width: 100%;
|
|
32
|
+
padding: 0 0 0 calc(var(--dsl-read-gutter) + 12px);
|
|
33
|
+
border: none;
|
|
34
|
+
background: transparent;
|
|
35
|
+
color: var(--dsw-alias-label-tertiary);
|
|
36
|
+
cursor: pointer;
|
|
37
|
+
font: inherit;
|
|
38
|
+
text-align: left;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@media (hover: hover) {
|
|
42
|
+
.expand:hover {
|
|
43
|
+
color: var(--dsw-alias-label-secondary);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { useCallback, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties } from 'react'
|
|
2
|
+
import clsx from 'clsx'
|
|
3
|
+
import { FoldToggle } from './FoldToggle.tsx'
|
|
4
|
+
import { writeClipboard } from './clipboard.ts'
|
|
5
|
+
import { CodeToolbar, type CodeToolbarLabels } from './CodeToolbar.tsx'
|
|
6
|
+
import cardCss from './CodeCard.module.css'
|
|
7
|
+
import {
|
|
8
|
+
grammarLoadCount,
|
|
9
|
+
highlightLines,
|
|
10
|
+
subscribeGrammarLoaded,
|
|
11
|
+
type HighlightSpan,
|
|
12
|
+
} from './markdown/highlight.ts'
|
|
13
|
+
import { useViewportHighlighting } from './markdown/useViewportHighlighting.ts'
|
|
14
|
+
import css from './ReadBlock.module.css'
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Content lines shown before the height cap collapses the middle. Matches
|
|
18
|
+
* TerminalBlock's default so a long read and a long command output cut at the
|
|
19
|
+
* same place in the same flow.
|
|
20
|
+
*/
|
|
21
|
+
export const DEFAULT_READ_MAX_LINES = 16
|
|
22
|
+
|
|
23
|
+
/** One line of the read window: its file line number and its text (no trailing newline). */
|
|
24
|
+
export interface ReadBlockLine {
|
|
25
|
+
/** 1-based line number in the file (a window past an offset keeps the file's own numbering). */
|
|
26
|
+
number: number
|
|
27
|
+
/** The line's text, already truncated to the read tool's per-line cap. */
|
|
28
|
+
text: string
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface ReadBlockProps {
|
|
32
|
+
/** Banner label (the file path, or a tool-supplied replacement title); omitted draws no label. */
|
|
33
|
+
label?: string | undefined
|
|
34
|
+
/** The returned window's lines, in file order, each keeping its file line number. */
|
|
35
|
+
lines: readonly ReadBlockLine[]
|
|
36
|
+
/** Localized chrome supplied by the owning render site. */
|
|
37
|
+
labels: ReadBlockLabels
|
|
38
|
+
/** Exact total line count in the file, for the "showing N of M" note when the read is a window. */
|
|
39
|
+
totalLines: number
|
|
40
|
+
/** Grammar hint (a file-extension-derived language id); unknown or absent = plain monospace. */
|
|
41
|
+
lang?: string | undefined
|
|
42
|
+
/** Height cap in content lines before the middle collapses (default {@link DEFAULT_READ_MAX_LINES}). */
|
|
43
|
+
maxLines?: number | undefined
|
|
44
|
+
/** Extra class merged onto the wrapper (callers position; this component draws). */
|
|
45
|
+
className?: string | undefined
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Localized chrome for {@link ReadBlock}. */
|
|
49
|
+
export interface ReadBlockLabels extends CodeToolbarLabels {
|
|
50
|
+
window: (shown: number, total: number) => string
|
|
51
|
+
copy: string
|
|
52
|
+
copied: string
|
|
53
|
+
collapseAria: string
|
|
54
|
+
expandAria: (hidden: number) => string
|
|
55
|
+
collapse: string
|
|
56
|
+
expand: (hidden: number) => string
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function renderSpans(spans: readonly HighlightSpan[]) {
|
|
60
|
+
return spans.map((span, index) => <span key={index} style={span.style}>{span.text}</span>)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Render a read tool result as a line-numbered, optionally syntax-highlighted
|
|
65
|
+
* file view.
|
|
66
|
+
* @param props - see {@link ReadBlockProps}.
|
|
67
|
+
* @returns the read block element.
|
|
68
|
+
*/
|
|
69
|
+
export function ReadBlock({
|
|
70
|
+
label,
|
|
71
|
+
labels,
|
|
72
|
+
lines,
|
|
73
|
+
totalLines,
|
|
74
|
+
lang,
|
|
75
|
+
maxLines = DEFAULT_READ_MAX_LINES,
|
|
76
|
+
className,
|
|
77
|
+
}: ReadBlockProps) {
|
|
78
|
+
const rootRef = useRef<HTMLDivElement>(null)
|
|
79
|
+
const highlighting = useViewportHighlighting(rootRef, lang)
|
|
80
|
+
// Whole-window highlighting preserves multiline grammar context; copy uses
|
|
81
|
+
// the same text without gutter or banner chrome.
|
|
82
|
+
const raw = useMemo(() => lines.map(line => line.text).join('\n'), [lines])
|
|
83
|
+
// Re-render when a lazy grammar finishes loading, so a read card that showed
|
|
84
|
+
// plain text while its language's grammar imported picks up highlighting. The
|
|
85
|
+
// snapshot value is opaque; only its change across renders drives the memo.
|
|
86
|
+
const loaded = useSyncExternalStore(subscribeGrammarLoaded, grammarLoadCount, grammarLoadCount)
|
|
87
|
+
const highlighted = useMemo(
|
|
88
|
+
() => highlighting ? highlightLines(raw, lang) : undefined,
|
|
89
|
+
[highlighting, raw, lang, loaded],
|
|
90
|
+
)
|
|
91
|
+
const [expanded, setExpanded] = useState(false)
|
|
92
|
+
const [copied, setCopied] = useState(false)
|
|
93
|
+
const [wrapped, setWrapped] = useState(false)
|
|
94
|
+
|
|
95
|
+
const onCopy = useCallback(() => {
|
|
96
|
+
if (copied) return
|
|
97
|
+
void writeClipboard(raw).then((ok) => {
|
|
98
|
+
if (!ok) return
|
|
99
|
+
setCopied(true)
|
|
100
|
+
window.setTimeout(() => { setCopied(false) }, 1000)
|
|
101
|
+
})
|
|
102
|
+
}, [copied, raw])
|
|
103
|
+
|
|
104
|
+
const onToggle = useCallback(() => { setExpanded(value => !value) }, [])
|
|
105
|
+
|
|
106
|
+
const hidden = lines.length - maxLines
|
|
107
|
+
const capped = hidden > 0 && !expanded
|
|
108
|
+
const headLines = Math.ceil(maxLines / 2)
|
|
109
|
+
const tailLines = maxLines - headLines
|
|
110
|
+
// A read is a window when its returned lines are fewer than the file's total;
|
|
111
|
+
// the note states that so a reader is not misled that the file ends here.
|
|
112
|
+
const windowed = lines.length < totalLines
|
|
113
|
+
|
|
114
|
+
const rows = (slice: readonly (readonly [ReadBlockLine, readonly HighlightSpan[] | undefined])[]) =>
|
|
115
|
+
slice.map(([line, spans]) => (
|
|
116
|
+
<div key={line.number} className={css.line}>
|
|
117
|
+
<span className={css.gutter} aria-hidden>{line.number}</span>
|
|
118
|
+
<span className={css.content}>{spans === undefined ? line.text : renderSpans(spans)}</span>
|
|
119
|
+
</div>
|
|
120
|
+
))
|
|
121
|
+
|
|
122
|
+
const gutterDigits = lines.reduce((digits, line) => Math.max(digits, String(line.number).length), 3)
|
|
123
|
+
const gutterStyle = { '--dsl-read-gutter': `${gutterDigits}ch` } as CSSProperties
|
|
124
|
+
|
|
125
|
+
const paired = lines.map((line, index): readonly [ReadBlockLine, readonly HighlightSpan[] | undefined] =>
|
|
126
|
+
[line, highlighted?.[index]])
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<div ref={rootRef} className={clsx(cardCss.card, css.block, className)} data-read="" data-code-wrap={wrapped} style={gutterStyle}>
|
|
130
|
+
<CodeToolbar
|
|
131
|
+
lang={lang} title={label} status={windowed ? labels.window(lines.length, totalLines) : undefined}
|
|
132
|
+
labels={labels} copyLabel={labels.copy} copiedLabel={labels.copied} copied={copied} wrapped={wrapped}
|
|
133
|
+
// Empty files must not replace the clipboard with empty text.
|
|
134
|
+
onCopy={lines.length > 0 ? onCopy : undefined} onWrap={() => { setWrapped(value => !value) }}
|
|
135
|
+
/>
|
|
136
|
+
<div className={cardCss.body}>
|
|
137
|
+
{rows(capped ? paired.slice(0, headLines) : paired)}
|
|
138
|
+
{hidden > 0 && (
|
|
139
|
+
<FoldToggle
|
|
140
|
+
className={css.expand}
|
|
141
|
+
expanded={expanded}
|
|
142
|
+
hidden={hidden}
|
|
143
|
+
labels={labels}
|
|
144
|
+
onToggle={onToggle}
|
|
145
|
+
/>
|
|
146
|
+
)}
|
|
147
|
+
{capped && rows(paired.slice(paired.length - tailLines))}
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
150
|
+
)
|
|
151
|
+
}
|