@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,103 @@
|
|
|
1
|
+
/** Accessible menu groups with shared sticky-heading presentation and viewport observation. */
|
|
2
|
+
import { useId, type ReactNode } from 'react'
|
|
3
|
+
import css from './MenuGroup.module.css'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Render a named group with an instance-owned heading id and an inaccessible position sentinel.
|
|
7
|
+
* @param props - Caller-localized label and optional menu rows.
|
|
8
|
+
* @returns A section named by its direct heading, followed by the supplied children.
|
|
9
|
+
*/
|
|
10
|
+
export function MenuGroup({ label, children }: { label: string; children?: ReactNode }) {
|
|
11
|
+
const headingId = useId()
|
|
12
|
+
return (
|
|
13
|
+
<section role="group" aria-labelledby={headingId} data-menu-group="" className={css.group}>
|
|
14
|
+
<span aria-hidden="true" data-menu-group-start="" className={css.start} />
|
|
15
|
+
<div id={headingId} data-menu-group-heading="" className={css.heading}>{label}</div>
|
|
16
|
+
{children}
|
|
17
|
+
</section>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Update heading backgrounds asynchronously from native intersection and viewport-size observations.
|
|
23
|
+
* Headings remain transparent until observations identify a section crossing the viewport top.
|
|
24
|
+
* Without IntersectionObserver or ResizeObserver, CSS sticky headings remain transparent.
|
|
25
|
+
* Group membership is captured at setup; dispose before observing changed groups or the same viewport again.
|
|
26
|
+
* @param viewport - Unpadded, borderless scroll container with direct MenuGroup children.
|
|
27
|
+
* @returns Cleanup owning both intersection observers and the viewport resize observer; disconnects
|
|
28
|
+
* them, ignores queued callbacks, and clears managed data-stuck attributes. No valid groups acquires nothing.
|
|
29
|
+
*/
|
|
30
|
+
export function observeStickyMenuGroups(viewport: HTMLElement): () => void {
|
|
31
|
+
const groups = [...viewport.querySelectorAll<HTMLElement>(':scope > [data-menu-group]')].flatMap((section) => {
|
|
32
|
+
const heading = section.querySelector<HTMLElement>(':scope > [data-menu-group-heading]')
|
|
33
|
+
const start = section.querySelector<HTMLElement>(':scope > [data-menu-group-start]')
|
|
34
|
+
return heading === null || start === null ? [] : [{
|
|
35
|
+
section, heading, start, atTop: false, above: false, topTime: -Infinity, aboveTime: -Infinity,
|
|
36
|
+
}]
|
|
37
|
+
})
|
|
38
|
+
if (groups.length === 0 || typeof IntersectionObserver === 'undefined' || typeof ResizeObserver === 'undefined') {
|
|
39
|
+
return () => {}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const sections = new Map<Element, typeof groups[number]>(groups.map(group => [group.section, group]))
|
|
43
|
+
const starts = new Map<Element, typeof groups[number]>(groups.map(group => [group.start, group]))
|
|
44
|
+
let disposed = false
|
|
45
|
+
let stripObserver: IntersectionObserver | undefined
|
|
46
|
+
let viewportHeight: number | undefined
|
|
47
|
+
const render = (group: typeof groups[number]): void => {
|
|
48
|
+
const stuck = group.atTop && group.above
|
|
49
|
+
if (group.heading.hasAttribute('data-stuck') !== stuck) group.heading.toggleAttribute('data-stuck', stuck)
|
|
50
|
+
}
|
|
51
|
+
const startObserver = new IntersectionObserver((entries) => {
|
|
52
|
+
if (disposed) return
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
const group = starts.get(entry.target)
|
|
55
|
+
if (!group || entry.rootBounds === null || entry.time < group.aboveTime) continue
|
|
56
|
+
group.above = entry.boundingClientRect.top < entry.rootBounds.top
|
|
57
|
+
group.aboveTime = entry.time
|
|
58
|
+
render(group)
|
|
59
|
+
}
|
|
60
|
+
}, { root: viewport, threshold: [0, 1] })
|
|
61
|
+
for (const { start } of groups) startObserver.observe(start)
|
|
62
|
+
|
|
63
|
+
const sizeObserver = new ResizeObserver((entries) => {
|
|
64
|
+
if (disposed) return
|
|
65
|
+
for (const entry of entries) {
|
|
66
|
+
if (entry.target !== viewport || entry.contentRect.height === viewportHeight) continue
|
|
67
|
+
viewportHeight = entry.contentRect.height
|
|
68
|
+
stripObserver?.disconnect()
|
|
69
|
+
// A full section crossing this strip is observable even when scrolling skips its start sentinel.
|
|
70
|
+
const observer = new IntersectionObserver((intersections) => {
|
|
71
|
+
if (disposed || stripObserver !== observer) return
|
|
72
|
+
for (const intersection of intersections) {
|
|
73
|
+
const group = sections.get(intersection.target)
|
|
74
|
+
if (!group || intersection.rootBounds === null) continue
|
|
75
|
+
const top = intersection.rootBounds.top
|
|
76
|
+
if (intersection.time >= group.topTime) {
|
|
77
|
+
group.atTop = intersection.isIntersecting && intersection.boundingClientRect.bottom > top
|
|
78
|
+
group.topTime = intersection.time
|
|
79
|
+
}
|
|
80
|
+
// Both observers describe the section's normal-flow start; the newest sample wins.
|
|
81
|
+
if (intersection.time >= group.aboveTime) {
|
|
82
|
+
group.above = intersection.boundingClientRect.top < top
|
|
83
|
+
group.aboveTime = intersection.time
|
|
84
|
+
}
|
|
85
|
+
render(group)
|
|
86
|
+
}
|
|
87
|
+
}, { root: viewport, rootMargin: `0px 0px ${Math.min(1, viewportHeight) - viewportHeight}px 0px`, threshold: 0 })
|
|
88
|
+
stripObserver = observer
|
|
89
|
+
for (const { section } of groups) observer.observe(section)
|
|
90
|
+
}
|
|
91
|
+
})
|
|
92
|
+
sizeObserver.observe(viewport)
|
|
93
|
+
return () => {
|
|
94
|
+
if (disposed) return
|
|
95
|
+
disposed = true
|
|
96
|
+
startObserver.disconnect()
|
|
97
|
+
stripObserver?.disconnect()
|
|
98
|
+
sizeObserver.disconnect()
|
|
99
|
+
for (const { heading } of groups) {
|
|
100
|
+
if (heading.hasAttribute('data-stuck')) heading.removeAttribute('data-stuck')
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
package/src/MenuRow.tsx
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/** Package-internal row presentation shared by component, data, and child menu entries. */
|
|
2
|
+
import { useId } from 'react'
|
|
3
|
+
import type { ButtonHTMLAttributes, HTMLAttributes, ReactNode } from 'react'
|
|
4
|
+
import clsx from 'clsx'
|
|
5
|
+
import type { MenuEntry, MenuItemButtonProps, MenuLabel, MenuSeparator } from './Menu.tsx'
|
|
6
|
+
import { IconCheckOutlineRegular, IconChevronRightOutlineRegular } from './icons/index.tsx'
|
|
7
|
+
import { ShortcutKeys } from './ShortcutKeys.tsx'
|
|
8
|
+
import { Tooltip } from './Tooltip.tsx'
|
|
9
|
+
import css from './Menu.module.css'
|
|
10
|
+
|
|
11
|
+
/** Optional props that also accept `undefined`, so data rows can forward absent `MenuItem` fields. */
|
|
12
|
+
type OptionalProps<T, K extends keyof T> = { [P in K]?: T[P] | undefined }
|
|
13
|
+
|
|
14
|
+
/** Package-internal row props: the `MenuItemButton` row fields plus data- and child-row presentation. */
|
|
15
|
+
type MenuRowProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'children'>
|
|
16
|
+
& Pick<MenuItemButtonProps, 'children'>
|
|
17
|
+
& OptionalProps<MenuItemButtonProps, 'icon' | 'shortcut' | 'current' | 'disabledReason' | 'danger' | 'separatorBefore'>
|
|
18
|
+
& {
|
|
19
|
+
/** Whether this data row is the menu's current selection. */
|
|
20
|
+
selected?: boolean
|
|
21
|
+
/** Selection marker: a trailing check, or the row fill. */
|
|
22
|
+
selection?: 'check' | 'fill'
|
|
23
|
+
/** Keep an empty icon column so grouped rows stay aligned. */
|
|
24
|
+
reserveIcon?: boolean
|
|
25
|
+
/** Hide the icon from assistive technology; component rows keep it exposed. */
|
|
26
|
+
decorativeIcon?: boolean
|
|
27
|
+
/** Pointer handlers on the row wrapper, used by submenu parents. */
|
|
28
|
+
wrapperProps?: HTMLAttributes<HTMLDivElement> | undefined
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Render a focus-stable row with optional selection, shortcut, and disabled explanation.
|
|
32
|
+
* @param props - row content, native button events, and optional pointer wrapper events.
|
|
33
|
+
* @returns one menu item; explained disabled rows remain focusable but never activate.
|
|
34
|
+
*/
|
|
35
|
+
export function MenuRow({ children, icon, shortcut, current, disabled = false, disabledReason, danger,
|
|
36
|
+
separatorBefore, selected, selection = 'check', reserveIcon, decorativeIcon = true, wrapperProps, ...button }: MenuRowProps) {
|
|
37
|
+
const reasonId = useId()
|
|
38
|
+
const explained = disabled && disabledReason !== undefined
|
|
39
|
+
// Tooltip remains mounted when the explanation changes, preserving button focus.
|
|
40
|
+
return <div {...wrapperProps} className={css.itemWrap}>
|
|
41
|
+
{separatorBefore && <div className={css.separator} role="separator" />}
|
|
42
|
+
<Tooltip label={disabledReason ?? ''} disabled={!explained} side="bottom" delayMs={500} maxWidth={300} portal>
|
|
43
|
+
<button {...button} type="button" role="menuitem"
|
|
44
|
+
className={clsx(css.item, selected && (selection === 'fill' ? css.selectedFill : css.selected), danger && css.danger)}
|
|
45
|
+
disabled={disabled && !explained} aria-disabled={explained || undefined}
|
|
46
|
+
aria-describedby={explained ? reasonId : undefined} aria-keyshortcuts={shortcut?.aria}
|
|
47
|
+
aria-current={current === true ? 'page' : undefined} onClick={explained ? undefined : button.onClick}>
|
|
48
|
+
{(icon !== undefined || reserveIcon) && <span aria-hidden={decorativeIcon || undefined} className={css.itemIcon}>{icon}</span>}
|
|
49
|
+
<span className={css.itemLabel}>{children}</span>
|
|
50
|
+
{shortcut !== undefined && <span aria-hidden="true" className={css.shortcut}><ShortcutKeys keys={shortcut.keys} className={css.shortcutKeys} /></span>}
|
|
51
|
+
{selected && selection === 'check' && <IconCheckOutlineRegular className={css.check} />}
|
|
52
|
+
{button['aria-haspopup'] === 'menu' && <IconChevronRightOutlineRegular aria-hidden="true" className={css.check} />}
|
|
53
|
+
</button>
|
|
54
|
+
</Tooltip>
|
|
55
|
+
{explained && <span id={reasonId} hidden>{disabledReason}</span>}
|
|
56
|
+
</div>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Mark icon columns within each separator-delimited data group.
|
|
60
|
+
* @param entries - entries in one menu area.
|
|
61
|
+
* @param contextual - whether to align grouped context-menu icons.
|
|
62
|
+
* @returns entries that reserve a leading icon column.
|
|
63
|
+
*/
|
|
64
|
+
export function menuIconColumns(entries: readonly MenuEntry[], contextual: boolean): ReadonlySet<MenuEntry> {
|
|
65
|
+
const aligned = new Set<MenuEntry>()
|
|
66
|
+
if (!contextual) return aligned
|
|
67
|
+
let group: MenuEntry[] = []
|
|
68
|
+
const finish = (): void => {
|
|
69
|
+
if (group.some(entry => !('type' in entry) && entry.icon !== undefined)) {
|
|
70
|
+
for (const entry of group) aligned.add(entry)
|
|
71
|
+
}
|
|
72
|
+
group = []
|
|
73
|
+
}
|
|
74
|
+
for (const entry of entries) {
|
|
75
|
+
if ('type' in entry && entry.type === 'separator') finish()
|
|
76
|
+
else group.push(entry)
|
|
77
|
+
}
|
|
78
|
+
finish()
|
|
79
|
+
return aligned
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** Render a separator or group heading outside the keyboard walk.
|
|
83
|
+
* @param entry - non-interactive menu entry.
|
|
84
|
+
* @returns the corresponding element.
|
|
85
|
+
*/
|
|
86
|
+
export function renderMenuDecoration(entry: MenuSeparator | MenuLabel): ReactNode {
|
|
87
|
+
return entry.type === 'separator' ? <div key={entry.id} className={css.separator} role="separator" />
|
|
88
|
+
: <div key={entry.id} className={css.label} role="presentation">{entry.text}</div>
|
|
89
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
.surface,
|
|
2
|
+
.backing {
|
|
3
|
+
border-radius: var(--dsw-radius-lg);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.compact {
|
|
7
|
+
border-radius: var(--dsw-radius-md);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
:where(.surface) {
|
|
11
|
+
position: relative;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.surface {
|
|
15
|
+
anchor-name: var(--dsh-menu-anchor);
|
|
16
|
+
isolation: isolate;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/* Filtering only the background keeps nested menus and fixed overlays free of
|
|
20
|
+
* an ancestor backdrop root or a new fixed-position containing block. */
|
|
21
|
+
.material {
|
|
22
|
+
position: absolute;
|
|
23
|
+
inset: 0;
|
|
24
|
+
z-index: -1;
|
|
25
|
+
border-radius: inherit;
|
|
26
|
+
background: var(--dsw-menu-surface-fill);
|
|
27
|
+
backdrop-filter: var(--dsw-menu-backdrop-filter);
|
|
28
|
+
pointer-events: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.backing {
|
|
32
|
+
display: none;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Chromium needs opaque pixels behind the page content to blur it over native
|
|
36
|
+
* vibrancy. Body isolation keeps this backing above the native window and below
|
|
37
|
+
* the page; CSS anchors limit it to this menu without a layout observer. */
|
|
38
|
+
:global(html[data-platform='darwin']) .backing {
|
|
39
|
+
display: block;
|
|
40
|
+
position: fixed;
|
|
41
|
+
position-anchor: var(--dsh-menu-anchor);
|
|
42
|
+
top: anchor(top);
|
|
43
|
+
left: anchor(left);
|
|
44
|
+
width: anchor-size(width, 0px);
|
|
45
|
+
height: anchor-size(height, 0px);
|
|
46
|
+
z-index: -1;
|
|
47
|
+
background: var(--dsw-alias-bg-base);
|
|
48
|
+
pointer-events: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Opacity on the container would prevent its material from blurring the page.
|
|
52
|
+
* Enter animations release their compositing layers so nested menus can blur too. */
|
|
53
|
+
.surface[data-menu-phase='enter'] > *,
|
|
54
|
+
.backing[data-menu-phase='enter'] { animation: dsh-context-menu-in var(--dsh-menu-enter) ease-out; }
|
|
55
|
+
.surface[data-menu-phase='dismiss'] > *,
|
|
56
|
+
.backing[data-menu-phase='dismiss'],
|
|
57
|
+
.surface[data-menu-phase='replace'] > *,
|
|
58
|
+
.backing[data-menu-phase='replace'] { animation: dsh-context-menu-out var(--dsh-menu-dismiss) ease-in both; }
|
|
59
|
+
.surface[data-menu-phase='replace'] > *,
|
|
60
|
+
.backing[data-menu-phase='replace'] { animation-duration: var(--dsh-menu-replace); }
|
|
61
|
+
@keyframes dsh-context-menu-in { from { opacity: 0; } to { opacity: 1; } }
|
|
62
|
+
@keyframes dsh-context-menu-out { from { opacity: 1; } to { opacity: 0; } }
|
|
63
|
+
@media (prefers-reduced-motion: reduce) {
|
|
64
|
+
.surface[data-menu-phase] > *, .backing[data-menu-phase] { animation-duration: 0ms; }
|
|
65
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** Shared menu material and the macOS backing that lets Chromium blur transparent windows. */
|
|
2
|
+
import { forwardRef, useId, useLayoutEffect, useRef, type ComponentPropsWithoutRef, type CSSProperties } from 'react'
|
|
3
|
+
import { createPortal } from 'react-dom'
|
|
4
|
+
import clsx from 'clsx'
|
|
5
|
+
import css from './MenuSurface.module.css'
|
|
6
|
+
|
|
7
|
+
/** Context-menu transition durations in milliseconds, shared with its lifecycle owner. */
|
|
8
|
+
export const MENU_TRANSITION_MS = Object.freeze({ enter: 40, dismiss: 80, replace: 10, prepare: 20 })
|
|
9
|
+
|
|
10
|
+
/** Menu containers preserve native div props and refs. */
|
|
11
|
+
export interface MenuSurfaceProps extends ComponentPropsWithoutRef<'div'> {
|
|
12
|
+
/** Match the shared compact menu's smaller outer radius. */
|
|
13
|
+
compact?: boolean
|
|
14
|
+
/** Fade direct content, material, and native backing without isolating the material's backdrop. */
|
|
15
|
+
phase?: 'enter' | 'dismiss' | 'replace' | undefined
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Paint a menu and, on macOS, an opaque backing behind the page content within its bounds.
|
|
20
|
+
* CSS anchors keep each backing aligned during placement, resizing, and nested-menu movement.
|
|
21
|
+
* @param props - Div content and placement, and compact geometry.
|
|
22
|
+
* @param ref - The visible menu div, excluding the non-interactive backing.
|
|
23
|
+
* @returns Menu content plus a backing portal removed with the menu.
|
|
24
|
+
*/
|
|
25
|
+
export const MenuSurface = forwardRef<HTMLDivElement, MenuSurfaceProps>(function MenuSurface({
|
|
26
|
+
compact = false, phase, className, style, children, ...props
|
|
27
|
+
}, ref) {
|
|
28
|
+
const id = useId()
|
|
29
|
+
const backingRef = useRef<HTMLDivElement>(null)
|
|
30
|
+
useLayoutEffect(() => {
|
|
31
|
+
// Nested React portals can insert the backing before its anchor. CSS anchor
|
|
32
|
+
// positioning requires the anchor to precede the positioned element.
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- The portal ref is attached before layout effects run.
|
|
34
|
+
document.body.appendChild(backingRef.current!)
|
|
35
|
+
}, [])
|
|
36
|
+
const anchorStyle: CSSProperties & Record<`--dsh-menu-${string}`, string> = {
|
|
37
|
+
'--dsh-menu-anchor': `--dsh-menu-${id.replaceAll(':', '')}`,
|
|
38
|
+
'--dsh-menu-enter': `${MENU_TRANSITION_MS.enter}ms`,
|
|
39
|
+
'--dsh-menu-dismiss': `${MENU_TRANSITION_MS.dismiss}ms`,
|
|
40
|
+
'--dsh-menu-replace': `${MENU_TRANSITION_MS.replace}ms`,
|
|
41
|
+
}
|
|
42
|
+
return <>
|
|
43
|
+
<div {...props} ref={ref} data-menu-material="translucent" data-menu-phase={phase}
|
|
44
|
+
className={clsx(css.surface, compact && css.compact, className)} style={{ ...style, ...anchorStyle }}>
|
|
45
|
+
<div aria-hidden="true" className={css.material} />
|
|
46
|
+
{children}
|
|
47
|
+
</div>
|
|
48
|
+
{createPortal(
|
|
49
|
+
<div ref={backingRef} aria-hidden="true" data-menu-backing="" data-menu-phase={phase} className={clsx(css.backing, compact && css.compact)}
|
|
50
|
+
style={{ ...anchorStyle, visibility: style?.visibility }} />,
|
|
51
|
+
document.body,
|
|
52
|
+
)}
|
|
53
|
+
</>
|
|
54
|
+
})
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/* Full-viewport layer (figma Mask + Dialog 451:18655): mask + centered card.
|
|
2
|
+
24px of air on every side; the top/bottom widen to the frame's published
|
|
3
|
+
overlay inset so a tall card stays clear of it.
|
|
4
|
+
Cards size against this padding box: consumers cap growth with
|
|
5
|
+
`max-height: 100%`, never their own viewport calc. */
|
|
6
|
+
.root {
|
|
7
|
+
pointer-events: auto;
|
|
8
|
+
position: fixed;
|
|
9
|
+
inset: 0;
|
|
10
|
+
z-index: 1000;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: center;
|
|
14
|
+
padding: max(24px, var(--dsh-frame-overlay-top, 24px)) 24px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Only paint excludes the native caption; the root still blocks background clicks. */
|
|
18
|
+
.mask {
|
|
19
|
+
position: absolute;
|
|
20
|
+
inset: var(--dsh-frame-chrome-top, 0px) 0 0;
|
|
21
|
+
backdrop-filter: var(--dsw-mask-blur);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.mask::after {
|
|
25
|
+
content: '';
|
|
26
|
+
position: absolute;
|
|
27
|
+
inset: 0;
|
|
28
|
+
background: var(--dsw-alias-bg-mask-1);
|
|
29
|
+
animation: modalEnter var(--ds-transition-duration) var(--ds-ease-in-out);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* Dialogs use the prominent elevation on the secondary layer. */
|
|
33
|
+
.dialog {
|
|
34
|
+
box-sizing: border-box;
|
|
35
|
+
position: relative;
|
|
36
|
+
z-index: 1;
|
|
37
|
+
display: flex;
|
|
38
|
+
flex-direction: column;
|
|
39
|
+
gap: 20px;
|
|
40
|
+
width: min(380px, 100%);
|
|
41
|
+
padding: 0 0 24px;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
border: 0;
|
|
44
|
+
border-radius: var(--dsw-radius-panel);
|
|
45
|
+
background: var(--dsw-alias-bg-layer-2);
|
|
46
|
+
box-shadow: var(--dsw-elevation-prominent);
|
|
47
|
+
animation: modalEnter var(--ds-transition-duration) var(--ds-ease-in-out);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@keyframes modalEnter {
|
|
51
|
+
from { opacity: 0; }
|
|
52
|
+
to { opacity: 1; }
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@media (prefers-reduced-motion: reduce) {
|
|
56
|
+
.mask::after, .dialog { animation: none; }
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.dialog:focus {
|
|
60
|
+
outline: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.content {
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
width: 100%;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/* Header row (figma Title row): pad l24/t22/r14/b12, SPACE_BETWEEN —
|
|
70
|
+
* title left, close button right. */
|
|
71
|
+
.header {
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: center;
|
|
74
|
+
justify-content: space-between;
|
|
75
|
+
gap: 8px;
|
|
76
|
+
padding: 22px 14px 12px 24px;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.title {
|
|
80
|
+
margin: 0;
|
|
81
|
+
font-size: 16px;
|
|
82
|
+
line-height: 24px;
|
|
83
|
+
font-weight: 500; /* figma wt510, rendered 500 */
|
|
84
|
+
color: var(--dsw-alias-label-primary);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.warning .title {
|
|
88
|
+
display: flex;
|
|
89
|
+
align-items: flex-start;
|
|
90
|
+
gap: 8px;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.warningIcon {
|
|
94
|
+
flex: none;
|
|
95
|
+
margin-top: 3px;
|
|
96
|
+
color: var(--dsw-alias-state-warn-primary);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.warning .body {
|
|
100
|
+
margin-top: 0;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.close {
|
|
104
|
+
flex: none;
|
|
105
|
+
display: inline-flex;
|
|
106
|
+
align-items: center;
|
|
107
|
+
justify-content: center;
|
|
108
|
+
width: 28px;
|
|
109
|
+
height: 28px;
|
|
110
|
+
border: none;
|
|
111
|
+
border-radius: var(--dsw-radius-sm);
|
|
112
|
+
background: transparent;
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
color: var(--dsw-alias-label-secondary);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@media (hover: hover) {
|
|
118
|
+
.close:hover {
|
|
119
|
+
background: var(--dsw-alias-interactive-bg-hover);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/* Description and body share the 332px content column (24px side pads). */
|
|
124
|
+
.description {
|
|
125
|
+
margin: 0;
|
|
126
|
+
padding: 0 24px;
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
line-height: 22px;
|
|
129
|
+
font-weight: 400;
|
|
130
|
+
color: var(--dsw-alias-label-primary);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
.body {
|
|
134
|
+
display: flex;
|
|
135
|
+
flex-direction: column;
|
|
136
|
+
min-width: 0;
|
|
137
|
+
margin-top: 20px;
|
|
138
|
+
padding: 0 24px;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.footer {
|
|
142
|
+
display: flex;
|
|
143
|
+
align-items: center;
|
|
144
|
+
justify-content: flex-end;
|
|
145
|
+
gap: 8px;
|
|
146
|
+
padding: 0 24px;
|
|
147
|
+
}
|
package/src/Modal.tsx
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useRef } from 'react'
|
|
2
|
+
import type { KeyboardEventHandler, ReactNode } from 'react'
|
|
3
|
+
import { createPortal } from 'react-dom'
|
|
4
|
+
import clsx from 'clsx'
|
|
5
|
+
import { IconCloseOutlineRegular, IconWarningOutlineRegular } from './icons/index.tsx'
|
|
6
|
+
import { useModalLayer } from './useModalLayer.ts'
|
|
7
|
+
import css from './Modal.module.css'
|
|
8
|
+
|
|
9
|
+
interface ModalBaseProps {
|
|
10
|
+
open: boolean
|
|
11
|
+
onClose: () => void
|
|
12
|
+
title: string
|
|
13
|
+
tone?: 'warning'
|
|
14
|
+
description?: string
|
|
15
|
+
children?: ReactNode
|
|
16
|
+
footer?: ReactNode
|
|
17
|
+
className?: string
|
|
18
|
+
contentClassName?: string
|
|
19
|
+
shortcutModal?: string
|
|
20
|
+
onKeyDownCapture?: KeyboardEventHandler<HTMLDivElement>
|
|
21
|
+
backdropBlur?: boolean
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type ModalProps = ModalBaseProps & (
|
|
25
|
+
| { headless: true; closeLabel?: never }
|
|
26
|
+
| { headless?: false; closeLabel: string }
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Render a centered, body-portaled modal over a blurred page mask.
|
|
31
|
+
* @param props.open - whether the dialog is showing.
|
|
32
|
+
* @param props.onClose - application close command, Escape, or mask click; while a menu is open inside the
|
|
33
|
+
* dialog, Escape belongs to that menu first.
|
|
34
|
+
* @param props.title - dialog heading (aria-label in every mode).
|
|
35
|
+
* @param props.tone - warning adds an amber title icon and compact title-to-body spacing; ignored for headless dialogs.
|
|
36
|
+
* @param props.closeLabel - localized accessible close-button label.
|
|
37
|
+
* @param props.description - optional supporting sentence under the title.
|
|
38
|
+
* @param props.children - dialog body; mark its initial-focus control with
|
|
39
|
+
* data-modal-autofocus instead of React autoFocus to preserve return focus.
|
|
40
|
+
* @param props.footer - action row (Cancel / Create).
|
|
41
|
+
* @param props.contentClassName - optional class for a scrollable content region.
|
|
42
|
+
* @param props.backdropBlur - disable when the caller already blurs the page; defaults to true.
|
|
43
|
+
* @param props.shortcutModal - command scope allowed by shortcut owners; unnamed
|
|
44
|
+
* dialogs block application commands unless their owner allows the "other" scope.
|
|
45
|
+
* @param props.headless - render children directly in the card (no default
|
|
46
|
+
* header/close/body chrome); mask, card, Escape, and aria-label remain.
|
|
47
|
+
* @param props.onKeyDownCapture - handle a nested dialog's keys before the document Escape listeners.
|
|
48
|
+
* @returns null when closed; otherwise the overlay tree.
|
|
49
|
+
*/
|
|
50
|
+
export function Modal({
|
|
51
|
+
open, onClose, title, closeLabel, description, children, footer, className, contentClassName,
|
|
52
|
+
onKeyDownCapture, headless = false, backdropBlur = true, shortcutModal, tone,
|
|
53
|
+
}: ModalProps) {
|
|
54
|
+
const dialog = useRef<HTMLDivElement>(null)
|
|
55
|
+
useModalLayer(dialog, open, onClose)
|
|
56
|
+
|
|
57
|
+
if (!open) return null
|
|
58
|
+
|
|
59
|
+
return createPortal((
|
|
60
|
+
<div className={css.root} role="presentation" onKeyDownCapture={onKeyDownCapture}>
|
|
61
|
+
<div className={css.mask} style={backdropBlur ? undefined : { backdropFilter: 'none' }} aria-hidden="true" onClick={onClose} />
|
|
62
|
+
<div
|
|
63
|
+
ref={dialog}
|
|
64
|
+
tabIndex={-1}
|
|
65
|
+
data-shortcut-modal={shortcutModal}
|
|
66
|
+
className={clsx(css.dialog, !headless && tone === 'warning' && css.warning, className)}
|
|
67
|
+
role="dialog"
|
|
68
|
+
aria-modal="true"
|
|
69
|
+
aria-label={title}
|
|
70
|
+
>
|
|
71
|
+
{headless
|
|
72
|
+
? children
|
|
73
|
+
: (
|
|
74
|
+
<>
|
|
75
|
+
<div className={clsx(css.content, contentClassName)}>
|
|
76
|
+
<div className={css.header}>
|
|
77
|
+
<h2 className={css.title}>
|
|
78
|
+
{tone === 'warning' && <IconWarningOutlineRegular size={18} className={css.warningIcon} aria-hidden="true" />}
|
|
79
|
+
{title}
|
|
80
|
+
</h2>
|
|
81
|
+
<button type="button" className={css.close} aria-label={closeLabel} onClick={onClose}>
|
|
82
|
+
<IconCloseOutlineRegular size={14} />
|
|
83
|
+
</button>
|
|
84
|
+
</div>
|
|
85
|
+
{description !== undefined && description !== '' && (
|
|
86
|
+
<p className={css.description}>{description}</p>
|
|
87
|
+
)}
|
|
88
|
+
{children !== undefined && <div className={css.body}>{children}</div>}
|
|
89
|
+
</div>
|
|
90
|
+
{footer !== undefined && <div className={css.footer}>{footer}</div>}
|
|
91
|
+
</>
|
|
92
|
+
)}
|
|
93
|
+
</div>
|
|
94
|
+
</div>
|
|
95
|
+
), document.body)
|
|
96
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/* Auto margin keeps fitting text at the left. On overflow it becomes zero,
|
|
2
|
+
so flex-end preserves the filename suffix at the right edge. */
|
|
3
|
+
.path {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex: 1 1 auto;
|
|
6
|
+
justify-content: flex-end;
|
|
7
|
+
min-width: 0;
|
|
8
|
+
overflow: hidden;
|
|
9
|
+
font-size: 12px;
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.path[data-path-clipped] {
|
|
14
|
+
mask-image: linear-gradient(to right, transparent, black 28px);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.text {
|
|
18
|
+
flex: none;
|
|
19
|
+
margin-right: auto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.directory {
|
|
23
|
+
color: var(--dsw-alias-label-tertiary);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.name {
|
|
27
|
+
color: var(--dsw-alias-label-primary);
|
|
28
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/** A single-line file path whose trailing characters remain visible in narrow toolbars. */
|
|
2
|
+
import { useLayoutEffect, useRef, type HTMLAttributes } from 'react'
|
|
3
|
+
import clsx from 'clsx'
|
|
4
|
+
import { pathPartsOf } from '@deepseek-ai/dsh-util-workspace-path'
|
|
5
|
+
import css from './PathLabel.module.css'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Render subdued directories and a primary filename, with the complete path on hover.
|
|
9
|
+
* Fitting text is left-aligned; overflow clips and fades at the left edge.
|
|
10
|
+
* The fade updates on path changes and, when ResizeObserver is available, size changes.
|
|
11
|
+
* @param props - File path and attributes for its outer span; callers own toolbar spacing.
|
|
12
|
+
* @returns the path label.
|
|
13
|
+
*/
|
|
14
|
+
export function PathLabel({ path, className, ...attributes }: {
|
|
15
|
+
path: string
|
|
16
|
+
} & Omit<HTMLAttributes<HTMLSpanElement>, 'children' | 'title'>) {
|
|
17
|
+
const boxRef = useRef<HTMLSpanElement>(null)
|
|
18
|
+
const textRef = useRef<HTMLSpanElement>(null)
|
|
19
|
+
const { directory, name } = pathPartsOf(path)
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
// Both spans mount unconditionally before this layout effect runs.
|
|
22
|
+
const outer = boxRef.current as HTMLSpanElement
|
|
23
|
+
const inner = textRef.current as HTMLSpanElement
|
|
24
|
+
const apply = (): void => {
|
|
25
|
+
outer.toggleAttribute('data-path-clipped', inner.offsetWidth > outer.clientWidth)
|
|
26
|
+
}
|
|
27
|
+
apply()
|
|
28
|
+
const observer = typeof ResizeObserver === 'undefined' ? undefined : new ResizeObserver(apply)
|
|
29
|
+
observer?.observe(outer)
|
|
30
|
+
observer?.observe(inner)
|
|
31
|
+
return () => { observer?.disconnect() }
|
|
32
|
+
}, [path])
|
|
33
|
+
return (
|
|
34
|
+
<span {...attributes} ref={boxRef} className={clsx(css.path, className)} title={path} data-path-label>
|
|
35
|
+
<span ref={textRef} className={css.text}>
|
|
36
|
+
{directory !== '' && <span className={css.directory}>{directory}</span>}
|
|
37
|
+
<span className={css.name}>{name}</span>
|
|
38
|
+
</span>
|
|
39
|
+
</span>
|
|
40
|
+
)
|
|
41
|
+
}
|