@ctrl-ui/react 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +70 -0
- package/dist/action-bar.d.ts +44 -0
- package/dist/action-bar.js +89 -0
- package/dist/activity.d.ts +53 -0
- package/dist/activity.js +188 -0
- package/dist/audio-recorder.d.ts +32 -0
- package/dist/audio-recorder.js +235 -0
- package/dist/audio-visualizer.d.ts +12 -0
- package/dist/audio-visualizer.js +58 -0
- package/dist/blocks/chat.d.ts +10 -0
- package/dist/blocks/chat.js +12 -0
- package/dist/blocks/coding-agent.d.ts +61 -0
- package/dist/blocks/coding-agent.js +255 -0
- package/dist/blocks/file-explorer-data.d.ts +57 -0
- package/dist/blocks/file-explorer-data.js +74 -0
- package/dist/blocks/file-explorer.d.ts +24 -0
- package/dist/blocks/file-explorer.js +427 -0
- package/dist/blocks/settings-data.d.ts +36 -0
- package/dist/blocks/settings-data.js +66 -0
- package/dist/blocks/settings.d.ts +19 -0
- package/dist/blocks/settings.js +282 -0
- package/dist/blocks/theme-toggle.d.ts +43 -0
- package/dist/blocks/theme-toggle.js +180 -0
- package/dist/chat-composer-attachment.d.ts +55 -0
- package/dist/chat-composer-attachment.js +267 -0
- package/dist/chat-composer-editor/extensions/mention.d.ts +14 -0
- package/dist/chat-composer-editor/extensions/mention.js +278 -0
- package/dist/chat-composer-editor/ghost.d.ts +5 -0
- package/dist/chat-composer-editor/ghost.js +55 -0
- package/dist/chat-composer-editor/schema.d.ts +6 -0
- package/dist/chat-composer-editor/schema.js +25 -0
- package/dist/chat-composer-editor/serialize.d.ts +6 -0
- package/dist/chat-composer-editor/serialize.js +16 -0
- package/dist/chat-composer-editor/types.d.ts +29 -0
- package/dist/chat-composer-editor/types.js +0 -0
- package/dist/chat-composer-editor.d.ts +9 -0
- package/dist/chat-composer-editor.js +154 -0
- package/dist/chat-composer.d.ts +60 -0
- package/dist/chat-composer.js +134 -0
- package/dist/chat-layout.d.ts +27 -0
- package/dist/chat-layout.js +114 -0
- package/dist/chat-message.d.ts +31 -0
- package/dist/chat-message.js +95 -0
- package/dist/code-block-editor.d.ts +59 -0
- package/dist/code-block-editor.js +250 -0
- package/dist/context-model.d.ts +33 -0
- package/dist/context-model.js +52 -0
- package/dist/context.d.ts +47 -0
- package/dist/context.js +335 -0
- package/dist/control-props.d.ts +28 -0
- package/dist/control-props.js +4 -0
- package/dist/control-variants.d.ts +8 -0
- package/dist/control-variants.js +14 -0
- package/dist/dynamic-notification-glass.d.ts +10 -0
- package/dist/dynamic-notification-glass.js +311 -0
- package/dist/dynamic-notification-liquid.d.ts +24 -0
- package/dist/dynamic-notification-liquid.js +682 -0
- package/dist/dynamic-notification-siri-wave.d.ts +4 -0
- package/dist/dynamic-notification-siri-wave.js +82 -0
- package/dist/dynamic-notification.d.ts +74 -0
- package/dist/dynamic-notification.js +342 -0
- package/dist/environment-variables.d.ts +124 -0
- package/dist/environment-variables.js +492 -0
- package/dist/extensions/create-track-highlight.d.ts +12 -0
- package/dist/extensions/create-track-highlight.js +147 -0
- package/dist/extensions/track-highlight.d.ts +22 -0
- package/dist/extensions/track-highlight.js +52 -0
- package/dist/hooks/use-audio-recorder.d.ts +107 -0
- package/dist/hooks/use-audio-recorder.js +577 -0
- package/dist/hooks/use-chat-composer.d.ts +56 -0
- package/dist/hooks/use-chat-composer.js +63 -0
- package/dist/hooks/use-chat-message.d.ts +28 -0
- package/dist/hooks/use-chat-message.js +24 -0
- package/dist/hooks/use-color-area.d.ts +18 -0
- package/dist/hooks/use-color-area.js +60 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +22 -0
- package/dist/hooks/use-copy-to-clipboard.js +90 -0
- package/dist/hooks/use-dropzone.d.ts +59 -0
- package/dist/hooks/use-dropzone.js +372 -0
- package/dist/hooks/use-dynamic-notification.d.ts +37 -0
- package/dist/hooks/use-dynamic-notification.js +87 -0
- package/dist/hooks/use-environment-variables.d.ts +51 -0
- package/dist/hooks/use-environment-variables.js +188 -0
- package/dist/hooks/use-mobile.d.ts +5 -0
- package/dist/hooks/use-mobile.js +29 -0
- package/dist/hooks/use-textarea-trigger-menu.d.ts +8 -0
- package/dist/hooks/use-textarea-trigger-menu.js +69 -0
- package/dist/hooks/use-trigger-menu.d.ts +49 -0
- package/dist/hooks/use-trigger-menu.js +102 -0
- package/dist/hooks/use-user-ask.d.ts +48 -0
- package/dist/hooks/use-user-ask.js +167 -0
- package/dist/inline-attachment.d.ts +37 -0
- package/dist/inline-attachment.js +192 -0
- package/dist/inline-citation.d.ts +56 -0
- package/dist/inline-citation.js +319 -0
- package/dist/knob-contracts/accordion-knobs.d.ts +5 -0
- package/dist/knob-contracts/accordion-knobs.js +9 -0
- package/dist/knob-contracts/action-bar-knobs.d.ts +5 -0
- package/dist/knob-contracts/action-bar-knobs.js +4 -0
- package/dist/knob-contracts/activity-knobs.d.ts +5 -0
- package/dist/knob-contracts/activity-knobs.js +9 -0
- package/dist/knob-contracts/alert-knobs.d.ts +5 -0
- package/dist/knob-contracts/alert-knobs.js +9 -0
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +5 -0
- package/dist/knob-contracts/audio-recorder-knobs.js +9 -0
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +5 -0
- package/dist/knob-contracts/audio-visualizer-knobs.js +9 -0
- package/dist/knob-contracts/avatar-knobs.d.ts +5 -0
- package/dist/knob-contracts/avatar-knobs.js +9 -0
- package/dist/knob-contracts/badge-knobs.d.ts +5 -0
- package/dist/knob-contracts/badge-knobs.js +9 -0
- package/dist/knob-contracts/button-group-knobs.d.ts +5 -0
- package/dist/knob-contracts/button-group-knobs.js +9 -0
- package/dist/knob-contracts/button-knobs.d.ts +5 -0
- package/dist/knob-contracts/button-knobs.js +25 -0
- package/dist/knob-contracts/calendar-knobs.d.ts +5 -0
- package/dist/knob-contracts/calendar-knobs.js +10 -0
- package/dist/knob-contracts/card-knobs.d.ts +5 -0
- package/dist/knob-contracts/card-knobs.js +11 -0
- package/dist/knob-contracts/chat-composer-attachment-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-composer-attachment-knobs.js +11 -0
- package/dist/knob-contracts/chat-composer-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-composer-knobs.js +18 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-layout-knobs.js +11 -0
- package/dist/knob-contracts/chat-message-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-message-knobs.js +17 -0
- package/dist/knob-contracts/choice-knobs.d.ts +5 -0
- package/dist/knob-contracts/choice-knobs.js +9 -0
- package/dist/knob-contracts/code-block-editor-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-block-editor-knobs.js +11 -0
- package/dist/knob-contracts/code-diff-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-diff-knobs.js +18 -0
- package/dist/knob-contracts/code-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-knobs.js +11 -0
- package/dist/knob-contracts/collapsible-knobs.d.ts +5 -0
- package/dist/knob-contracts/collapsible-knobs.js +4 -0
- package/dist/knob-contracts/color-picker-knobs.d.ts +5 -0
- package/dist/knob-contracts/color-picker-knobs.js +12 -0
- package/dist/knob-contracts/context-knobs.d.ts +5 -0
- package/dist/knob-contracts/context-knobs.js +13 -0
- package/dist/knob-contracts/dockable-panel-knobs.d.ts +5 -0
- package/dist/knob-contracts/dockable-panel-knobs.js +12 -0
- package/dist/knob-contracts/dropzone-knobs.d.ts +5 -0
- package/dist/knob-contracts/dropzone-knobs.js +11 -0
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +5 -0
- package/dist/knob-contracts/dynamic-notification-knobs.js +18 -0
- package/dist/knob-contracts/empty-knobs.d.ts +5 -0
- package/dist/knob-contracts/empty-knobs.js +12 -0
- package/dist/knob-contracts/environment-variables-knobs.d.ts +5 -0
- package/dist/knob-contracts/environment-variables-knobs.js +11 -0
- package/dist/knob-contracts/field-knobs.d.ts +5 -0
- package/dist/knob-contracts/field-knobs.js +16 -0
- package/dist/knob-contracts/gradient-editor-knobs.d.ts +5 -0
- package/dist/knob-contracts/gradient-editor-knobs.js +13 -0
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +5 -0
- package/dist/knob-contracts/infinite-canvas-knobs.js +13 -0
- package/dist/knob-contracts/inline-attachment-knobs.d.ts +5 -0
- package/dist/knob-contracts/inline-attachment-knobs.js +14 -0
- package/dist/knob-contracts/inline-citation-knobs.d.ts +5 -0
- package/dist/knob-contracts/inline-citation-knobs.js +14 -0
- package/dist/knob-contracts/item-knobs.d.ts +5 -0
- package/dist/knob-contracts/item-knobs.js +10 -0
- package/dist/knob-contracts/kbd-knobs.d.ts +5 -0
- package/dist/knob-contracts/kbd-knobs.js +10 -0
- package/dist/knob-contracts/markdown-block-knobs.d.ts +5 -0
- package/dist/knob-contracts/markdown-block-knobs.js +11 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +5 -0
- package/dist/knob-contracts/markdown-knobs.js +14 -0
- package/dist/knob-contracts/morphing-panel-knobs.d.ts +5 -0
- package/dist/knob-contracts/morphing-panel-knobs.js +11 -0
- package/dist/knob-contracts/pagination-knobs.d.ts +5 -0
- package/dist/knob-contracts/pagination-knobs.js +10 -0
- package/dist/knob-contracts/phone-input-knobs.d.ts +5 -0
- package/dist/knob-contracts/phone-input-knobs.js +10 -0
- package/dist/knob-contracts/popup-knobs.d.ts +5 -0
- package/dist/knob-contracts/popup-knobs.js +21 -0
- package/dist/knob-contracts/range-knobs.d.ts +5 -0
- package/dist/knob-contracts/range-knobs.js +13 -0
- package/dist/knob-contracts/resizable-knobs.d.ts +5 -0
- package/dist/knob-contracts/resizable-knobs.js +14 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +5 -0
- package/dist/knob-contracts/rich-tooltip-knobs.js +13 -0
- package/dist/knob-contracts/scroll-area-knobs.d.ts +5 -0
- package/dist/knob-contracts/scroll-area-knobs.js +8 -0
- package/dist/knob-contracts/separator-knobs.d.ts +5 -0
- package/dist/knob-contracts/separator-knobs.js +4 -0
- package/dist/knob-contracts/sidebar-knobs.d.ts +5 -0
- package/dist/knob-contracts/sidebar-knobs.js +26 -0
- package/dist/knob-contracts/skeleton-knobs.d.ts +5 -0
- package/dist/knob-contracts/skeleton-knobs.js +4 -0
- package/dist/knob-contracts/source-badge-knobs.d.ts +5 -0
- package/dist/knob-contracts/source-badge-knobs.js +11 -0
- package/dist/knob-contracts/spinner-knobs.d.ts +5 -0
- package/dist/knob-contracts/spinner-knobs.js +4 -0
- package/dist/knob-contracts/stepper-knobs.d.ts +5 -0
- package/dist/knob-contracts/stepper-knobs.js +11 -0
- package/dist/knob-contracts/switch-knobs.d.ts +5 -0
- package/dist/knob-contracts/switch-knobs.js +12 -0
- package/dist/knob-contracts/table-knobs.d.ts +5 -0
- package/dist/knob-contracts/table-knobs.js +12 -0
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +5 -0
- package/dist/knob-contracts/table-of-contents-knobs.js +8 -0
- package/dist/knob-contracts/tabs-knobs.d.ts +5 -0
- package/dist/knob-contracts/tabs-knobs.js +16 -0
- package/dist/knob-contracts/task-list-knobs.d.ts +5 -0
- package/dist/knob-contracts/task-list-knobs.js +14 -0
- package/dist/knob-contracts/thread-rail-knobs.d.ts +5 -0
- package/dist/knob-contracts/thread-rail-knobs.js +14 -0
- package/dist/knob-contracts/timeline-knobs.d.ts +5 -0
- package/dist/knob-contracts/timeline-knobs.js +12 -0
- package/dist/knob-contracts/toolbar-knobs.d.ts +5 -0
- package/dist/knob-contracts/toolbar-knobs.js +20 -0
- package/dist/knob-contracts/track-highlight-knobs.d.ts +5 -0
- package/dist/knob-contracts/track-highlight-knobs.js +11 -0
- package/dist/knob-contracts/transcript-divider-knobs.d.ts +5 -0
- package/dist/knob-contracts/transcript-divider-knobs.js +10 -0
- package/dist/knob-contracts/tree-knobs.d.ts +5 -0
- package/dist/knob-contracts/tree-knobs.js +13 -0
- package/dist/knob-contracts/user-ask-knobs.d.ts +5 -0
- package/dist/knob-contracts/user-ask-knobs.js +17 -0
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/cn.js +34 -0
- package/dist/lib/code-block-shiki.d.ts +9 -0
- package/dist/lib/code-block-shiki.js +6 -0
- package/dist/lib/code-tokens.d.ts +28 -0
- package/dist/lib/code-tokens.js +160 -0
- package/dist/lib/color.d.ts +72 -0
- package/dist/lib/color.js +490 -0
- package/dist/lib/contrast.d.ts +30 -0
- package/dist/lib/contrast.js +64 -0
- package/dist/lib/diff.d.ts +50 -0
- package/dist/lib/diff.js +315 -0
- package/dist/lib/dropzone-validation.d.ts +66 -0
- package/dist/lib/dropzone-validation.js +228 -0
- package/dist/lib/env-file.d.ts +28 -0
- package/dist/lib/env-file.js +218 -0
- package/dist/lib/format-audio-recorder-duration.d.ts +4 -0
- package/dist/lib/format-audio-recorder-duration.js +7 -0
- package/dist/lib/liquid-glass-optics.d.ts +4 -0
- package/dist/lib/liquid-glass-optics.js +96 -0
- package/dist/lib/phone-input-format.d.ts +6 -0
- package/dist/lib/phone-input-format.js +26 -0
- package/dist/lib/phone-number.d.ts +18 -0
- package/dist/lib/phone-number.js +28 -0
- package/dist/lib/trigger-detect.d.ts +15 -0
- package/dist/lib/trigger-detect.js +77 -0
- package/dist/markdown-block.d.ts +25 -0
- package/dist/markdown-block.js +77 -0
- package/dist/skin.config.d.ts +5 -0
- package/dist/skin.config.js +4 -0
- package/dist/skin.d.ts +69 -0
- package/dist/skin.js +62 -0
- package/dist/source-badge.d.ts +23 -0
- package/dist/source-badge.js +72 -0
- package/dist/styles/chat-composer-editor.css +44 -0
- package/dist/styles/code.css +57 -0
- package/dist/styles/effects.css +126 -0
- package/dist/styles/index.css +81 -0
- package/dist/styles/recipes/accordion.css +87 -0
- package/dist/styles/recipes/action-bar.css +19 -0
- package/dist/styles/recipes/activity.css +129 -0
- package/dist/styles/recipes/alert.css +75 -0
- package/dist/styles/recipes/audio-recorder.css +102 -0
- package/dist/styles/recipes/audio-visualizer.css +90 -0
- package/dist/styles/recipes/avatar.css +52 -0
- package/dist/styles/recipes/badge.css +110 -0
- package/dist/styles/recipes/button-group.css +64 -0
- package/dist/styles/recipes/button.css +305 -0
- package/dist/styles/recipes/calendar.css +152 -0
- package/dist/styles/recipes/card.css +93 -0
- package/dist/styles/recipes/chat-composer-attachment.css +177 -0
- package/dist/styles/recipes/chat-composer.css +195 -0
- package/dist/styles/recipes/chat-layout.css +108 -0
- package/dist/styles/recipes/chat-message.css +160 -0
- package/dist/styles/recipes/choice.css +108 -0
- package/dist/styles/recipes/code-block-editor.css +136 -0
- package/dist/styles/recipes/code-diff.css +256 -0
- package/dist/styles/recipes/code.css +136 -0
- package/dist/styles/recipes/collapsible.css +27 -0
- package/dist/styles/recipes/color-picker-details.css +61 -0
- package/dist/styles/recipes/color-picker-values.css +117 -0
- package/dist/styles/recipes/color-picker.css +158 -0
- package/dist/styles/recipes/context.css +237 -0
- package/dist/styles/recipes/dockable-panel.css +106 -0
- package/dist/styles/recipes/dropzone.css +149 -0
- package/dist/styles/recipes/dynamic-notification-input.css +29 -0
- package/dist/styles/recipes/dynamic-notification-motion.css +298 -0
- package/dist/styles/recipes/dynamic-notification.css +241 -0
- package/dist/styles/recipes/empty.css +96 -0
- package/dist/styles/recipes/environment-variables.css +173 -0
- package/dist/styles/recipes/field-parts.css +148 -0
- package/dist/styles/recipes/field.css +234 -0
- package/dist/styles/recipes/gradient-editor.css +109 -0
- package/dist/styles/recipes/infinite-canvas.css +78 -0
- package/dist/styles/recipes/inline-attachment.css +182 -0
- package/dist/styles/recipes/inline-citation.css +174 -0
- package/dist/styles/recipes/item.css +107 -0
- package/dist/styles/recipes/kbd.css +55 -0
- package/dist/styles/recipes/markdown-block.css +75 -0
- package/dist/styles/recipes/markdown.css +204 -0
- package/dist/styles/recipes/morphing-panel.css +123 -0
- package/dist/styles/recipes/pagination.css +86 -0
- package/dist/styles/recipes/phone-input.css +105 -0
- package/dist/styles/recipes/popup-controls.css +59 -0
- package/dist/styles/recipes/popup-drawer.css +162 -0
- package/dist/styles/recipes/popup-lists.css +198 -0
- package/dist/styles/recipes/popup-motion.css +94 -0
- package/dist/styles/recipes/popup-toast.css +126 -0
- package/dist/styles/recipes/popup.css +396 -0
- package/dist/styles/recipes/range.css +259 -0
- package/dist/styles/recipes/resizable.css +170 -0
- package/dist/styles/recipes/rich-tooltip.css +272 -0
- package/dist/styles/recipes/scroll-area.css +59 -0
- package/dist/styles/recipes/separator.css +12 -0
- package/dist/styles/recipes/sidebar.css +345 -0
- package/dist/styles/recipes/skeleton.css +23 -0
- package/dist/styles/recipes/source-badge.css +77 -0
- package/dist/styles/recipes/spinner.css +33 -0
- package/dist/styles/recipes/stepper.css +178 -0
- package/dist/styles/recipes/switch.css +149 -0
- package/dist/styles/recipes/table-of-contents.css +107 -0
- package/dist/styles/recipes/table.css +124 -0
- package/dist/styles/recipes/tabs.css +235 -0
- package/dist/styles/recipes/task-list.css +146 -0
- package/dist/styles/recipes/thread-rail.css +247 -0
- package/dist/styles/recipes/timeline.css +107 -0
- package/dist/styles/recipes/toolbar.css +260 -0
- package/dist/styles/recipes/track-highlight.css +73 -0
- package/dist/styles/recipes/transcript-divider.css +64 -0
- package/dist/styles/recipes/tree.css +137 -0
- package/dist/styles/recipes/user-ask-details.css +45 -0
- package/dist/styles/recipes/user-ask.css +204 -0
- package/dist/styles/skin-theme.css +137 -0
- package/dist/styles/skin.css +143 -0
- package/dist/styles/theme.css +628 -0
- package/dist/styles/type-scale.css +45 -0
- package/dist/surface-variants.d.ts +6 -0
- package/dist/surface-variants.js +16 -0
- package/dist/task-list.d.ts +34 -0
- package/dist/task-list.js +177 -0
- package/dist/thread-rail.d.ts +52 -0
- package/dist/thread-rail.js +190 -0
- package/dist/transcript-divider.d.ts +15 -0
- package/dist/transcript-divider.js +25 -0
- package/dist/ui/accordion.d.ts +31 -0
- package/dist/ui/accordion.js +60 -0
- package/dist/ui/alert-dialog.d.ts +36 -0
- package/dist/ui/alert-dialog.js +100 -0
- package/dist/ui/alert.d.ts +21 -0
- package/dist/ui/alert.js +36 -0
- package/dist/ui/aspect-ratio.d.ts +8 -0
- package/dist/ui/aspect-ratio.js +17 -0
- package/dist/ui/autocomplete.d.ts +70 -0
- package/dist/ui/autocomplete.js +150 -0
- package/dist/ui/avatar.d.ts +24 -0
- package/dist/ui/avatar.js +44 -0
- package/dist/ui/badge.d.ts +20 -0
- package/dist/ui/badge.js +36 -0
- package/dist/ui/button-group.d.ts +24 -0
- package/dist/ui/button-group.js +45 -0
- package/dist/ui/button.d.ts +36 -0
- package/dist/ui/button.js +104 -0
- package/dist/ui/calendar.d.ts +11 -0
- package/dist/ui/calendar.js +160 -0
- package/dist/ui/card.d.ts +36 -0
- package/dist/ui/card.js +70 -0
- package/dist/ui/checkbox-group.d.ts +11 -0
- package/dist/ui/checkbox-group.js +16 -0
- package/dist/ui/checkbox.d.ts +23 -0
- package/dist/ui/checkbox.js +58 -0
- package/dist/ui/code-diff.d.ts +28 -0
- package/dist/ui/code-diff.js +561 -0
- package/dist/ui/code.d.ts +62 -0
- package/dist/ui/code.js +292 -0
- package/dist/ui/collapsible.d.ts +31 -0
- package/dist/ui/collapsible.js +72 -0
- package/dist/ui/color-picker.d.ts +137 -0
- package/dist/ui/color-picker.js +797 -0
- package/dist/ui/combobox-disabled-selection.d.ts +5 -0
- package/dist/ui/combobox-disabled-selection.js +11 -0
- package/dist/ui/combobox.d.ts +70 -0
- package/dist/ui/combobox.js +194 -0
- package/dist/ui/command.d.ts +44 -0
- package/dist/ui/command.js +166 -0
- package/dist/ui/context-menu.d.ts +86 -0
- package/dist/ui/context-menu.js +202 -0
- package/dist/ui/dialog.d.ts +38 -0
- package/dist/ui/dialog.js +124 -0
- package/dist/ui/dockable-panel-geometry.d.ts +18 -0
- package/dist/ui/dockable-panel-geometry.js +17 -0
- package/dist/ui/dockable-panel.d.ts +58 -0
- package/dist/ui/dockable-panel.js +366 -0
- package/dist/ui/drawer.d.ts +42 -0
- package/dist/ui/drawer.js +182 -0
- package/dist/ui/dropdown-menu.d.ts +46 -0
- package/dist/ui/dropdown-menu.js +89 -0
- package/dist/ui/dropzone.d.ts +66 -0
- package/dist/ui/dropzone.js +311 -0
- package/dist/ui/empty.d.ts +28 -0
- package/dist/ui/empty.js +59 -0
- package/dist/ui/field.d.ts +64 -0
- package/dist/ui/field.js +166 -0
- package/dist/ui/form.d.ts +10 -0
- package/dist/ui/form.js +17 -0
- package/dist/ui/gradient-editor.d.ts +47 -0
- package/dist/ui/gradient-editor.js +301 -0
- package/dist/ui/hover-card.d.ts +25 -0
- package/dist/ui/hover-card.js +46 -0
- package/dist/ui/infinite-canvas.d.ts +40 -0
- package/dist/ui/infinite-canvas.js +278 -0
- package/dist/ui/input-group.d.ts +21 -0
- package/dist/ui/input-group.js +44 -0
- package/dist/ui/input-otp.d.ts +38 -0
- package/dist/ui/input-otp.js +45 -0
- package/dist/ui/input.d.ts +12 -0
- package/dist/ui/input.js +18 -0
- package/dist/ui/item.d.ts +46 -0
- package/dist/ui/item.js +110 -0
- package/dist/ui/kbd.d.ts +12 -0
- package/dist/ui/kbd.js +23 -0
- package/dist/ui/markdown-elements.d.ts +52 -0
- package/dist/ui/markdown-elements.js +211 -0
- package/dist/ui/markdown.d.ts +14 -0
- package/dist/ui/markdown.js +31 -0
- package/dist/ui/menubar.d.ts +74 -0
- package/dist/ui/menubar.js +162 -0
- package/dist/ui/meter.d.ts +34 -0
- package/dist/ui/meter.js +57 -0
- package/dist/ui/morphing-panel.d.ts +24 -0
- package/dist/ui/morphing-panel.js +87 -0
- package/dist/ui/native-select.d.ts +12 -0
- package/dist/ui/native-select.js +41 -0
- package/dist/ui/navigation-menu.d.ts +51 -0
- package/dist/ui/navigation-menu.js +135 -0
- package/dist/ui/number-field.d.ts +72 -0
- package/dist/ui/number-field.js +124 -0
- package/dist/ui/pagination.d.ts +26 -0
- package/dist/ui/pagination.js +77 -0
- package/dist/ui/phone-input.d.ts +30 -0
- package/dist/ui/phone-input.js +263 -0
- package/dist/ui/popover.d.ts +34 -0
- package/dist/ui/popover.js +87 -0
- package/dist/ui/progress.d.ts +34 -0
- package/dist/ui/progress.js +57 -0
- package/dist/ui/radio-group.d.ts +29 -0
- package/dist/ui/radio-group.js +37 -0
- package/dist/ui/resizable.d.ts +56 -0
- package/dist/ui/resizable.js +82 -0
- package/dist/ui/responsive-dialog.d.ts +18 -0
- package/dist/ui/responsive-dialog.js +121 -0
- package/dist/ui/rich-tooltip-tour.d.ts +12 -0
- package/dist/ui/rich-tooltip-tour.js +20 -0
- package/dist/ui/rich-tooltip.d.ts +83 -0
- package/dist/ui/rich-tooltip.js +331 -0
- package/dist/ui/scroll-area.d.ts +25 -0
- package/dist/ui/scroll-area.js +93 -0
- package/dist/ui/select.d.ts +44 -0
- package/dist/ui/select.js +124 -0
- package/dist/ui/separator.d.ts +9 -0
- package/dist/ui/separator.js +16 -0
- package/dist/ui/sheet.d.ts +25 -0
- package/dist/ui/sheet.js +76 -0
- package/dist/ui/sidebar.d.ts +88 -0
- package/dist/ui/sidebar.js +362 -0
- package/dist/ui/skeleton.d.ts +8 -0
- package/dist/ui/skeleton.js +13 -0
- package/dist/ui/slider.d.ts +24 -0
- package/dist/ui/slider.js +114 -0
- package/dist/ui/spinner.d.ts +12 -0
- package/dist/ui/spinner.js +26 -0
- package/dist/ui/stepper.d.ts +58 -0
- package/dist/ui/stepper.js +232 -0
- package/dist/ui/switch.d.ts +26 -0
- package/dist/ui/switch.js +71 -0
- package/dist/ui/table-of-contents.d.ts +22 -0
- package/dist/ui/table-of-contents.js +181 -0
- package/dist/ui/table.d.ts +37 -0
- package/dist/ui/table.js +83 -0
- package/dist/ui/tabs.d.ts +36 -0
- package/dist/ui/tabs.js +127 -0
- package/dist/ui/textarea.d.ts +9 -0
- package/dist/ui/textarea.js +16 -0
- package/dist/ui/timeline.d.ts +40 -0
- package/dist/ui/timeline.js +80 -0
- package/dist/ui/toast.d.ts +28 -0
- package/dist/ui/toast.js +132 -0
- package/dist/ui/toggle.d.ts +20 -0
- package/dist/ui/toggle.js +71 -0
- package/dist/ui/toolbar.d.ts +40 -0
- package/dist/ui/toolbar.js +72 -0
- package/dist/ui/tooltip.d.ts +27 -0
- package/dist/ui/tooltip.js +93 -0
- package/dist/ui/tree.d.ts +56 -0
- package/dist/ui/tree.js +438 -0
- package/dist/ui/trigger-menu.d.ts +46 -0
- package/dist/ui/trigger-menu.js +116 -0
- package/dist/user-ask.d.ts +50 -0
- package/dist/user-ask.js +398 -0
- package/package.json +115 -0
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { ScrollArea } from "./scroll-area.js";
|
|
4
|
+
import { highlightToTokens, mergeCodeTokenLineWithEmphasis } from "../lib/code-tokens.js";
|
|
5
|
+
import { CodeCopy, CodeFloatingCopy, CodeTokenLine } from "./code.js";
|
|
6
|
+
import { buildDiffFromFiles, buildDiffFromPatch, diffRunEnd } from "../lib/diff.js";
|
|
7
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
8
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { useVirtualizer } from "@tanstack/react-virtual";
|
|
10
|
+
//#region src/ui/code-diff.tsx
|
|
11
|
+
const ESTIMATED_ROW_HEIGHT = 20;
|
|
12
|
+
const VIRTUALIZE_THRESHOLD = 150;
|
|
13
|
+
function sideTexts(file) {
|
|
14
|
+
if (!file.isPartial) return {
|
|
15
|
+
old: file.oldLines.join("\n"),
|
|
16
|
+
new: file.newLines.join("\n")
|
|
17
|
+
};
|
|
18
|
+
const oldArr = [];
|
|
19
|
+
const newArr = [];
|
|
20
|
+
for (const hunk of file.hunks) for (const line of hunk.lines) {
|
|
21
|
+
if (line.oldNo !== void 0) oldArr[line.oldNo - 1] = line.text;
|
|
22
|
+
if (line.newNo !== void 0) newArr[line.newNo - 1] = line.text;
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
old: oldArr.join("\n"),
|
|
26
|
+
new: newArr.join("\n")
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function useSideTokens(oldText, newText, lang, enabled) {
|
|
30
|
+
const requestKey = `${lang ?? ""}\n${oldText.length}:${oldText}${newText}`;
|
|
31
|
+
const [state, setState] = useState(null);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (!enabled || !lang) return;
|
|
34
|
+
let cancelled = false;
|
|
35
|
+
Promise.all([highlightToTokens(oldText, lang), highlightToTokens(newText, lang)]).then(([oldTokens, newTokens]) => {
|
|
36
|
+
if (!cancelled) setState({
|
|
37
|
+
key: requestKey,
|
|
38
|
+
tokens: {
|
|
39
|
+
old: oldTokens,
|
|
40
|
+
new: newTokens
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}).catch(() => {
|
|
44
|
+
if (!cancelled) setState({
|
|
45
|
+
key: requestKey,
|
|
46
|
+
tokens: {
|
|
47
|
+
old: null,
|
|
48
|
+
new: null
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
return () => {
|
|
53
|
+
cancelled = true;
|
|
54
|
+
};
|
|
55
|
+
}, [
|
|
56
|
+
oldText,
|
|
57
|
+
newText,
|
|
58
|
+
lang,
|
|
59
|
+
enabled,
|
|
60
|
+
requestKey
|
|
61
|
+
]);
|
|
62
|
+
if (!enabled) return {
|
|
63
|
+
old: null,
|
|
64
|
+
new: null
|
|
65
|
+
};
|
|
66
|
+
return state?.key === requestKey ? state.tokens : {
|
|
67
|
+
old: null,
|
|
68
|
+
new: null
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function lineTokens(line, tokens) {
|
|
72
|
+
if (line.type === "del") return tokens.old?.[(line.oldNo ?? 1) - 1] ?? null;
|
|
73
|
+
if (line.type === "add") return tokens.new?.[(line.newNo ?? 1) - 1] ?? null;
|
|
74
|
+
return tokens.new?.[(line.newNo ?? 1) - 1] ?? tokens.old?.[(line.oldNo ?? 1) - 1] ?? null;
|
|
75
|
+
}
|
|
76
|
+
function splitPairs(lines) {
|
|
77
|
+
const rows = [];
|
|
78
|
+
let index = 0;
|
|
79
|
+
while (index < lines.length) {
|
|
80
|
+
const line = lines[index];
|
|
81
|
+
if (!line) break;
|
|
82
|
+
if (line.type === "context") {
|
|
83
|
+
rows.push({
|
|
84
|
+
left: line,
|
|
85
|
+
right: line
|
|
86
|
+
});
|
|
87
|
+
index += 1;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const delEnd = diffRunEnd(lines, index, "del");
|
|
91
|
+
const addEnd = diffRunEnd(lines, delEnd, "add");
|
|
92
|
+
const dels = lines.slice(index, delEnd);
|
|
93
|
+
const adds = lines.slice(delEnd, addEnd);
|
|
94
|
+
const count = Math.max(dels.length, adds.length);
|
|
95
|
+
for (let pair = 0; pair < count; pair += 1) rows.push({
|
|
96
|
+
left: dels[pair] ?? null,
|
|
97
|
+
right: adds[pair] ?? null
|
|
98
|
+
});
|
|
99
|
+
index = addEnd;
|
|
100
|
+
}
|
|
101
|
+
return rows;
|
|
102
|
+
}
|
|
103
|
+
function expandedContext(file, gapIndex) {
|
|
104
|
+
const hunk = file.hunks[gapIndex];
|
|
105
|
+
if (!hunk) return [];
|
|
106
|
+
const offset = hunk.newStart - hunk.oldStart;
|
|
107
|
+
const lines = [];
|
|
108
|
+
for (let oldNo = hunk.oldStart - hunk.collapsedBefore; oldNo < hunk.oldStart; oldNo += 1) {
|
|
109
|
+
const text = file.oldLines[oldNo - 1] ?? "";
|
|
110
|
+
lines.push({
|
|
111
|
+
type: "context",
|
|
112
|
+
oldNo,
|
|
113
|
+
newNo: oldNo + offset,
|
|
114
|
+
text
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return lines;
|
|
118
|
+
}
|
|
119
|
+
function gapRows(file, hunk, gapIndex, diffStyle, expanded) {
|
|
120
|
+
if (!(gapIndex > 0 || hunk.collapsedBefore > 0)) return [];
|
|
121
|
+
if (expanded.has(gapIndex) && !file.isPartial) return expandedContext(file, gapIndex).map((line) => rowForLine(diffStyle, line, `exp-${gapIndex}-${line.oldNo ?? line.newNo ?? 0}`));
|
|
122
|
+
const label = hunk.header ?? `@@ -${hunk.oldStart},${hunk.oldCount} +${hunk.newStart},${hunk.newCount} @@`;
|
|
123
|
+
return [{
|
|
124
|
+
kind: "separator",
|
|
125
|
+
id: `sep-${gapIndex}`,
|
|
126
|
+
gapIndex,
|
|
127
|
+
label,
|
|
128
|
+
canExpand: !file.isPartial && hunk.collapsedBefore > 0
|
|
129
|
+
}];
|
|
130
|
+
}
|
|
131
|
+
function changedRows(hunk, gapIndex, diffStyle) {
|
|
132
|
+
if (diffStyle === "unified") return hunk.lines.map((line, lineIndex) => rowForLine("unified", line, `u-${gapIndex}-${lineIndex}`));
|
|
133
|
+
return splitPairs(hunk.lines).map((pair, pairIndex) => ({
|
|
134
|
+
kind: "split",
|
|
135
|
+
id: `s-${gapIndex}-${pairIndex}`,
|
|
136
|
+
left: pair.left,
|
|
137
|
+
right: pair.right
|
|
138
|
+
}));
|
|
139
|
+
}
|
|
140
|
+
function buildRows(file, diffStyle, expanded) {
|
|
141
|
+
const rows = [];
|
|
142
|
+
for (const [gapIndex, hunk] of file.hunks.entries()) {
|
|
143
|
+
rows.push(...gapRows(file, hunk, gapIndex, diffStyle, expanded));
|
|
144
|
+
rows.push(...changedRows(hunk, gapIndex, diffStyle));
|
|
145
|
+
}
|
|
146
|
+
return rows;
|
|
147
|
+
}
|
|
148
|
+
function rowForLine(diffStyle, line, id) {
|
|
149
|
+
if (diffStyle === "unified") return {
|
|
150
|
+
kind: "unified",
|
|
151
|
+
id,
|
|
152
|
+
line
|
|
153
|
+
};
|
|
154
|
+
if (line.type === "context") return {
|
|
155
|
+
kind: "split",
|
|
156
|
+
id,
|
|
157
|
+
left: line,
|
|
158
|
+
right: line
|
|
159
|
+
};
|
|
160
|
+
if (line.type === "del") return {
|
|
161
|
+
kind: "split",
|
|
162
|
+
id,
|
|
163
|
+
left: line,
|
|
164
|
+
right: null
|
|
165
|
+
};
|
|
166
|
+
return {
|
|
167
|
+
kind: "split",
|
|
168
|
+
id,
|
|
169
|
+
left: null,
|
|
170
|
+
right: line
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
const markerFor = {
|
|
174
|
+
add: "+",
|
|
175
|
+
del: "-",
|
|
176
|
+
context: ""
|
|
177
|
+
};
|
|
178
|
+
function DiffCode({ line, tokens, overflow }) {
|
|
179
|
+
const wrapClass = overflow === "wrap" ? "whitespace-pre-wrap break-words" : "whitespace-pre";
|
|
180
|
+
if (line.segments && line.segments.length > 0) {
|
|
181
|
+
const runs = mergeCodeTokenLineWithEmphasis(line.text, tokens, line.segments);
|
|
182
|
+
return /* @__PURE__ */ jsx("code", {
|
|
183
|
+
className: cn("min-w-0 flex-1", wrapClass),
|
|
184
|
+
children: runs.map((run) => {
|
|
185
|
+
const style = run.style || void 0;
|
|
186
|
+
if (run.emphasis) return /* @__PURE__ */ jsx("span", {
|
|
187
|
+
"data-control-ui": "code-diff",
|
|
188
|
+
"data-control-family": "code-diff",
|
|
189
|
+
"data-slot": "emphasis",
|
|
190
|
+
"data-line-type": line.type,
|
|
191
|
+
style,
|
|
192
|
+
children: run.content
|
|
193
|
+
}, run.start);
|
|
194
|
+
return /* @__PURE__ */ jsx("span", {
|
|
195
|
+
style,
|
|
196
|
+
children: run.content
|
|
197
|
+
}, run.start);
|
|
198
|
+
})
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
return /* @__PURE__ */ jsx("code", {
|
|
202
|
+
className: cn("min-w-0 flex-1", wrapClass),
|
|
203
|
+
children: /* @__PURE__ */ jsx(CodeTokenLine, {
|
|
204
|
+
tokens,
|
|
205
|
+
plain: line.text
|
|
206
|
+
})
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
function Gutter({ children, type }) {
|
|
210
|
+
return /* @__PURE__ */ jsx("span", {
|
|
211
|
+
"data-control-ui": "code-diff",
|
|
212
|
+
"data-control-family": "code-diff",
|
|
213
|
+
"data-line-type": type,
|
|
214
|
+
"data-slot": "gutter",
|
|
215
|
+
"aria-hidden": "true",
|
|
216
|
+
className: "shrink-0 select-none",
|
|
217
|
+
children
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
function Marker({ type, indicators }) {
|
|
221
|
+
if (indicators !== "classic") return null;
|
|
222
|
+
return /* @__PURE__ */ jsx("span", {
|
|
223
|
+
"data-control-ui": "code-diff",
|
|
224
|
+
"data-control-family": "code-diff",
|
|
225
|
+
"data-slot": "marker",
|
|
226
|
+
"data-line-type": type,
|
|
227
|
+
"aria-hidden": "true",
|
|
228
|
+
className: "shrink-0 select-none",
|
|
229
|
+
children: markerFor[type] || " "
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
function UnifiedRow({ line, tokens, indicators, overflow }) {
|
|
233
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
234
|
+
"data-control-ui": "code-diff",
|
|
235
|
+
"data-control-family": "code-diff",
|
|
236
|
+
"data-slot": "line",
|
|
237
|
+
"data-line-type": line.type,
|
|
238
|
+
"data-indicators": indicators,
|
|
239
|
+
"aria-hidden": "true",
|
|
240
|
+
className: "flex w-full",
|
|
241
|
+
children: [
|
|
242
|
+
/* @__PURE__ */ jsx(Gutter, {
|
|
243
|
+
type: line.type,
|
|
244
|
+
children: line.oldNo ?? ""
|
|
245
|
+
}),
|
|
246
|
+
/* @__PURE__ */ jsx(Gutter, {
|
|
247
|
+
type: line.type,
|
|
248
|
+
children: line.newNo ?? ""
|
|
249
|
+
}),
|
|
250
|
+
/* @__PURE__ */ jsx(Marker, {
|
|
251
|
+
type: line.type,
|
|
252
|
+
indicators
|
|
253
|
+
}),
|
|
254
|
+
/* @__PURE__ */ jsx(DiffCode, {
|
|
255
|
+
line,
|
|
256
|
+
tokens,
|
|
257
|
+
overflow
|
|
258
|
+
})
|
|
259
|
+
]
|
|
260
|
+
});
|
|
261
|
+
}
|
|
262
|
+
function SplitHalf({ line, tokens, indicators, overflow, side }) {
|
|
263
|
+
if (!line) return /* @__PURE__ */ jsx("div", {
|
|
264
|
+
"data-control-ui": "code-diff",
|
|
265
|
+
"data-control-family": "code-diff",
|
|
266
|
+
"data-slot": "empty-half",
|
|
267
|
+
"data-side": side,
|
|
268
|
+
"aria-hidden": "true",
|
|
269
|
+
className: "flex min-w-0 flex-1"
|
|
270
|
+
});
|
|
271
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
272
|
+
"data-control-ui": "code-diff",
|
|
273
|
+
"data-control-family": "code-diff",
|
|
274
|
+
"data-slot": "line",
|
|
275
|
+
"data-line-type": line.type,
|
|
276
|
+
"data-indicators": indicators,
|
|
277
|
+
"data-side": side,
|
|
278
|
+
"aria-hidden": "true",
|
|
279
|
+
className: "flex min-w-0 flex-1",
|
|
280
|
+
children: [
|
|
281
|
+
/* @__PURE__ */ jsx(Gutter, {
|
|
282
|
+
type: line.type,
|
|
283
|
+
children: side === "left" ? line.oldNo ?? "" : line.newNo ?? ""
|
|
284
|
+
}),
|
|
285
|
+
/* @__PURE__ */ jsx(Marker, {
|
|
286
|
+
type: line.type,
|
|
287
|
+
indicators
|
|
288
|
+
}),
|
|
289
|
+
/* @__PURE__ */ jsx(DiffCode, {
|
|
290
|
+
line,
|
|
291
|
+
tokens,
|
|
292
|
+
overflow
|
|
293
|
+
})
|
|
294
|
+
]
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
function fileTitle(file) {
|
|
298
|
+
return file.oldName && file.type === "rename" ? `${file.oldName} → ${file.name}` : file.name;
|
|
299
|
+
}
|
|
300
|
+
function DiffStats({ additions, deletions }) {
|
|
301
|
+
return /* @__PURE__ */ jsxs("span", {
|
|
302
|
+
"data-control-ui": "code-diff",
|
|
303
|
+
"data-control-family": "code-diff",
|
|
304
|
+
"data-slot": "stat",
|
|
305
|
+
className: "flex items-center",
|
|
306
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
307
|
+
"data-control-ui": "code-diff",
|
|
308
|
+
"data-control-family": "code-diff",
|
|
309
|
+
"data-slot": "stat-additions",
|
|
310
|
+
children: ["+", additions]
|
|
311
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
312
|
+
"data-control-ui": "code-diff",
|
|
313
|
+
"data-control-family": "code-diff",
|
|
314
|
+
"data-slot": "stat-deletions",
|
|
315
|
+
children: ["−", deletions]
|
|
316
|
+
})]
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function lineDescription(label, line, number) {
|
|
320
|
+
return `${label} line ${number ?? "?"}: ${line.text}`;
|
|
321
|
+
}
|
|
322
|
+
function unifiedLineDescription(line) {
|
|
323
|
+
if (line.type === "add") return lineDescription("Added", line, line.newNo);
|
|
324
|
+
if (line.type === "del") return lineDescription("Deleted", line, line.oldNo);
|
|
325
|
+
return lineDescription("Unchanged", line, line.newNo ?? line.oldNo);
|
|
326
|
+
}
|
|
327
|
+
function splitRowDescriptions(row) {
|
|
328
|
+
if (row.left?.type === "context") return [lineDescription("Unchanged", row.left, row.left.newNo ?? row.left.oldNo)];
|
|
329
|
+
const descriptions = [];
|
|
330
|
+
if (row.left) descriptions.push(lineDescription(row.right ? "Original" : "Deleted", row.left, row.left.oldNo));
|
|
331
|
+
if (row.right) descriptions.push(lineDescription(row.left ? "Modified" : "Added", row.right, row.right.newNo));
|
|
332
|
+
return descriptions;
|
|
333
|
+
}
|
|
334
|
+
function rowDescriptions(row) {
|
|
335
|
+
if (row.kind === "separator") return [];
|
|
336
|
+
if (row.kind === "unified") return [unifiedLineDescription(row.line)];
|
|
337
|
+
return splitRowDescriptions(row);
|
|
338
|
+
}
|
|
339
|
+
function accessibleDiffText(file, rows) {
|
|
340
|
+
return [fileTitle(file), ...rows.flatMap(rowDescriptions)].join("\n");
|
|
341
|
+
}
|
|
342
|
+
function fileIdentity(file) {
|
|
343
|
+
const hunks = file.hunks.map((hunk) => `${hunk.oldStart}:${hunk.newStart}:${hunk.lines.map((line) => `${line.type}:${line.text}`).join("\n")}`).join("\n");
|
|
344
|
+
return `${file.oldName ?? ""}->${file.name}:${file.type}:${hunks}`;
|
|
345
|
+
}
|
|
346
|
+
function CodeDiffFileSection({ file, lang, diffStyle, diffIndicators, overflow, maxHeight, showFileHeader }) {
|
|
347
|
+
const [expanded, setExpanded] = useState(() => /* @__PURE__ */ new Set());
|
|
348
|
+
const texts = useMemo(() => sideTexts(file), [file]);
|
|
349
|
+
const tokens = useSideTokens(texts.old, texts.new, lang, Boolean(lang));
|
|
350
|
+
const rows = useMemo(() => buildRows(file, diffStyle, expanded), [
|
|
351
|
+
file,
|
|
352
|
+
diffStyle,
|
|
353
|
+
expanded
|
|
354
|
+
]);
|
|
355
|
+
const scrollRef = useRef(null);
|
|
356
|
+
const shouldVirtualize = rows.length > VIRTUALIZE_THRESHOLD;
|
|
357
|
+
const virtualizer = useVirtualizer({
|
|
358
|
+
count: rows.length,
|
|
359
|
+
getScrollElement: () => scrollRef.current,
|
|
360
|
+
estimateSize: () => ESTIMATED_ROW_HEIGHT,
|
|
361
|
+
overscan: 24,
|
|
362
|
+
enabled: shouldVirtualize
|
|
363
|
+
});
|
|
364
|
+
function expandGap(gapIndex) {
|
|
365
|
+
setExpanded((current) => new Set(current).add(gapIndex));
|
|
366
|
+
}
|
|
367
|
+
const gridClassName = overflow === "scroll" ? "w-max min-w-full" : "w-full";
|
|
368
|
+
function renderRow(row) {
|
|
369
|
+
if (row.kind === "separator") return /* @__PURE__ */ jsxs("div", {
|
|
370
|
+
"data-control-ui": "code-diff",
|
|
371
|
+
"data-control-family": "code-diff",
|
|
372
|
+
"data-slot": "expander",
|
|
373
|
+
className: "flex items-center",
|
|
374
|
+
children: [row.canExpand ? /* @__PURE__ */ jsx("button", {
|
|
375
|
+
type: "button",
|
|
376
|
+
"data-control-ui": "code-diff",
|
|
377
|
+
"data-control-family": "code-diff",
|
|
378
|
+
"data-slot": "expand-button",
|
|
379
|
+
"data-control": "true",
|
|
380
|
+
onClick: () => expandGap(row.gapIndex),
|
|
381
|
+
className: "cursor-pointer",
|
|
382
|
+
"aria-label": "Expand hidden lines",
|
|
383
|
+
children: "⋯"
|
|
384
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
385
|
+
"aria-hidden": "true",
|
|
386
|
+
children: "⋯"
|
|
387
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
388
|
+
"data-control-ui": "code-diff",
|
|
389
|
+
"data-control-family": "code-diff",
|
|
390
|
+
"data-slot": "expander-label",
|
|
391
|
+
className: "truncate",
|
|
392
|
+
children: row.label
|
|
393
|
+
})]
|
|
394
|
+
});
|
|
395
|
+
if (row.kind === "unified") return /* @__PURE__ */ jsx(UnifiedRow, {
|
|
396
|
+
line: row.line,
|
|
397
|
+
tokens: lineTokens(row.line, tokens),
|
|
398
|
+
indicators: diffIndicators,
|
|
399
|
+
overflow
|
|
400
|
+
});
|
|
401
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
402
|
+
"data-control-ui": "code-diff",
|
|
403
|
+
"data-control-family": "code-diff",
|
|
404
|
+
"data-slot": "row",
|
|
405
|
+
className: "flex w-full",
|
|
406
|
+
children: [/* @__PURE__ */ jsx(SplitHalf, {
|
|
407
|
+
line: row.left,
|
|
408
|
+
tokens: row.left ? lineTokens(row.left, tokens) : null,
|
|
409
|
+
indicators: diffIndicators,
|
|
410
|
+
overflow,
|
|
411
|
+
side: "left"
|
|
412
|
+
}), /* @__PURE__ */ jsx(SplitHalf, {
|
|
413
|
+
line: row.right,
|
|
414
|
+
tokens: row.right ? lineTokens(row.right, tokens) : null,
|
|
415
|
+
indicators: diffIndicators,
|
|
416
|
+
overflow,
|
|
417
|
+
side: "right"
|
|
418
|
+
})]
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
422
|
+
"data-control-ui": "code-diff",
|
|
423
|
+
"data-control-family": "code-diff",
|
|
424
|
+
"data-slot": "file",
|
|
425
|
+
"data-file-name": file.name,
|
|
426
|
+
children: [
|
|
427
|
+
showFileHeader ? /* @__PURE__ */ jsxs("div", {
|
|
428
|
+
"data-control-ui": "code-diff",
|
|
429
|
+
"data-control-family": "code-diff",
|
|
430
|
+
"data-slot": "file-header",
|
|
431
|
+
className: "flex items-center justify-between",
|
|
432
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
433
|
+
"data-control-ui": "code-diff",
|
|
434
|
+
"data-control-family": "code-diff",
|
|
435
|
+
"data-slot": "file-title",
|
|
436
|
+
className: "min-w-0 truncate",
|
|
437
|
+
children: fileTitle(file)
|
|
438
|
+
}), /* @__PURE__ */ jsx(DiffStats, {
|
|
439
|
+
additions: file.additions,
|
|
440
|
+
deletions: file.deletions
|
|
441
|
+
})]
|
|
442
|
+
}) : null,
|
|
443
|
+
/* @__PURE__ */ jsx("pre", {
|
|
444
|
+
"data-control-ui": "code-diff",
|
|
445
|
+
"data-control-family": "code-diff",
|
|
446
|
+
"data-slot": "accessible-source",
|
|
447
|
+
className: "sr-only",
|
|
448
|
+
children: /* @__PURE__ */ jsx("code", { children: accessibleDiffText(file, rows) })
|
|
449
|
+
}),
|
|
450
|
+
/* @__PURE__ */ jsx(ScrollArea, {
|
|
451
|
+
maxHeight,
|
|
452
|
+
viewportClassName: void 0,
|
|
453
|
+
viewportProps: {
|
|
454
|
+
"data-control-ui": "code-diff",
|
|
455
|
+
"data-control-family": "code-diff",
|
|
456
|
+
"data-slot": "body"
|
|
457
|
+
},
|
|
458
|
+
viewportRef: scrollRef,
|
|
459
|
+
children: shouldVirtualize ? /* @__PURE__ */ jsx("div", {
|
|
460
|
+
className: gridClassName,
|
|
461
|
+
style: {
|
|
462
|
+
position: "relative",
|
|
463
|
+
height: `${virtualizer.getTotalSize()}px`
|
|
464
|
+
},
|
|
465
|
+
children: virtualizer.getVirtualItems().map((item) => {
|
|
466
|
+
const row = rows[item.index];
|
|
467
|
+
if (!row) return null;
|
|
468
|
+
return /* @__PURE__ */ jsx("div", {
|
|
469
|
+
ref: virtualizer.measureElement,
|
|
470
|
+
"data-index": item.index,
|
|
471
|
+
style: {
|
|
472
|
+
position: "absolute",
|
|
473
|
+
top: 0,
|
|
474
|
+
left: 0,
|
|
475
|
+
width: "100%",
|
|
476
|
+
transform: `translateY(${item.start}px)`
|
|
477
|
+
},
|
|
478
|
+
children: renderRow(row)
|
|
479
|
+
}, row.id);
|
|
480
|
+
})
|
|
481
|
+
}) : /* @__PURE__ */ jsx("div", {
|
|
482
|
+
className: gridClassName,
|
|
483
|
+
children: rows.map((row) => /* @__PURE__ */ jsx("div", { children: renderRow(row) }, row.id))
|
|
484
|
+
})
|
|
485
|
+
})
|
|
486
|
+
]
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
function CodeDiff({ patch, oldText, newText, lang, name, diffStyle = "unified", diffIndicators = "bars", lineDiffType = "word", overflow = "scroll", maxLineDiffLength, maxHeight = "32rem", header = true, className, style, ...props }) {
|
|
490
|
+
const options = {
|
|
491
|
+
name,
|
|
492
|
+
lang,
|
|
493
|
+
lineDiffType,
|
|
494
|
+
maxLineDiffLength
|
|
495
|
+
};
|
|
496
|
+
const parsedFiles = patch === void 0 ? [buildDiffFromFiles(oldText ?? "", newText ?? "", options)] : buildDiffFromPatch(patch, options);
|
|
497
|
+
const files = parsedFiles.length > 0 ? parsedFiles : [emptyFile(name)];
|
|
498
|
+
const additions = files.reduce((total, file) => total + file.additions, 0);
|
|
499
|
+
const deletions = files.reduce((total, file) => total + file.deletions, 0);
|
|
500
|
+
const copyValue = patch ?? newText ?? "";
|
|
501
|
+
const firstFile = files[0];
|
|
502
|
+
return /* @__PURE__ */ jsxs("figure", {
|
|
503
|
+
"data-control-ui": "code-diff",
|
|
504
|
+
"data-control-family": "code-diff",
|
|
505
|
+
"data-slot": "root",
|
|
506
|
+
"data-surface": "panel",
|
|
507
|
+
"data-diff-style": diffStyle,
|
|
508
|
+
"data-file-count": files.length,
|
|
509
|
+
"data-header": header ? "true" : void 0,
|
|
510
|
+
className: cn("overflow-hidden", className),
|
|
511
|
+
style,
|
|
512
|
+
...props,
|
|
513
|
+
children: [header ? /* @__PURE__ */ jsxs("figcaption", {
|
|
514
|
+
"data-control-ui": "code-diff",
|
|
515
|
+
"data-control-family": "code-diff",
|
|
516
|
+
"data-slot": "header",
|
|
517
|
+
className: "flex items-center justify-between",
|
|
518
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
519
|
+
"data-control-ui": "code-diff",
|
|
520
|
+
"data-control-family": "code-diff",
|
|
521
|
+
"data-slot": "title",
|
|
522
|
+
className: "min-w-0 truncate",
|
|
523
|
+
children: files.length === 1 && firstFile ? fileTitle(firstFile) : `${files.length} files`
|
|
524
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
525
|
+
"data-control-ui": "code-diff",
|
|
526
|
+
"data-control-family": "code-diff",
|
|
527
|
+
"data-slot": "actions",
|
|
528
|
+
className: "flex shrink-0 items-center",
|
|
529
|
+
children: [/* @__PURE__ */ jsx(DiffStats, {
|
|
530
|
+
additions,
|
|
531
|
+
deletions
|
|
532
|
+
}), /* @__PURE__ */ jsx(CodeDiffCopy, { value: copyValue })]
|
|
533
|
+
})]
|
|
534
|
+
}) : /* @__PURE__ */ jsx(CodeFloatingCopy, { value: copyValue }), files.map((file) => /* @__PURE__ */ jsx(CodeDiffFileSection, {
|
|
535
|
+
file,
|
|
536
|
+
lang,
|
|
537
|
+
diffStyle,
|
|
538
|
+
diffIndicators,
|
|
539
|
+
overflow,
|
|
540
|
+
maxHeight,
|
|
541
|
+
showFileHeader: files.length > 1
|
|
542
|
+
}, fileIdentity(file)))]
|
|
543
|
+
});
|
|
544
|
+
}
|
|
545
|
+
function CodeDiffCopy(props) {
|
|
546
|
+
return /* @__PURE__ */ jsx(CodeCopy, { ...props });
|
|
547
|
+
}
|
|
548
|
+
function emptyFile(name) {
|
|
549
|
+
return {
|
|
550
|
+
name: name ?? "file",
|
|
551
|
+
type: "change",
|
|
552
|
+
hunks: [],
|
|
553
|
+
oldLines: [],
|
|
554
|
+
newLines: [],
|
|
555
|
+
isPartial: true,
|
|
556
|
+
additions: 0,
|
|
557
|
+
deletions: 0
|
|
558
|
+
};
|
|
559
|
+
}
|
|
560
|
+
//#endregion
|
|
561
|
+
export { CodeDiff, CodeDiffCopy };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Button } from "./button.js";
|
|
2
|
+
import { CodeKnobStyle } from "../knob-contracts/code-knobs.js";
|
|
3
|
+
import { CodeTokenLines } from "../lib/code-tokens.js";
|
|
4
|
+
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
5
|
+
//#region src/ui/code.d.ts
|
|
6
|
+
type CodeOverflow = "wrap" | "scroll";
|
|
7
|
+
type CodeHighlight = "auto" | "none";
|
|
8
|
+
type CodeDensity = "default" | "compact";
|
|
9
|
+
type CodeChrome = "standalone" | "embedded";
|
|
10
|
+
type CodeProps = Omit<ComponentProps<"figure">, "style"> & {
|
|
11
|
+
overflow?: CodeOverflow;
|
|
12
|
+
chrome?: CodeChrome;
|
|
13
|
+
density?: CodeDensity;
|
|
14
|
+
style?: CSSProperties & CodeKnobStyle;
|
|
15
|
+
};
|
|
16
|
+
declare function Code({ overflow, chrome, density, className, children, ...props }: CodeProps): import("react").JSX.Element;
|
|
17
|
+
type CodeHeaderProps = Omit<ComponentProps<"figcaption">, "style"> & {
|
|
18
|
+
style?: CSSProperties & CodeKnobStyle;
|
|
19
|
+
};
|
|
20
|
+
declare function CodeHeader({ className, ...props }: CodeHeaderProps): import("react").JSX.Element;
|
|
21
|
+
type CodeTitleProps = Omit<ComponentProps<"span">, "style"> & {
|
|
22
|
+
style?: CSSProperties & CodeKnobStyle;
|
|
23
|
+
};
|
|
24
|
+
declare function CodeTitle({ className, ...props }: CodeTitleProps): import("react").JSX.Element;
|
|
25
|
+
type CodeActionsProps = ComponentProps<"div"> & {
|
|
26
|
+
style?: CSSProperties & CodeKnobStyle;
|
|
27
|
+
};
|
|
28
|
+
declare function CodeActions({ className, ...props }: CodeActionsProps): import("react").JSX.Element;
|
|
29
|
+
type CodeCopyProps = Omit<ComponentProps<typeof Button>, "children" | "onClick"> & {
|
|
30
|
+
value: string;
|
|
31
|
+
children?: ReactNode;
|
|
32
|
+
copiedLabel?: ReactNode;
|
|
33
|
+
copiedAriaLabel?: string;
|
|
34
|
+
};
|
|
35
|
+
declare function CodeCopy({ value, copiedLabel, copiedAriaLabel, children, className, "aria-label": ariaLabel, ...props }: CodeCopyProps): import("react").JSX.Element;
|
|
36
|
+
type CodeFloatingCopyProps = Omit<CodeCopyProps, "children" | "copiedLabel">;
|
|
37
|
+
declare function CodeFloatingCopy({ className, ...props }: CodeFloatingCopyProps): import("react").JSX.Element;
|
|
38
|
+
/** Null until resolved, and whenever highlighting is off or language is unknown — callers fall back to plain text. */
|
|
39
|
+
declare function useCodeTokens({ code, lang, tokens, highlight }: {
|
|
40
|
+
code: string;
|
|
41
|
+
lang?: string;
|
|
42
|
+
tokens?: CodeTokenLines | null;
|
|
43
|
+
highlight: CodeHighlight;
|
|
44
|
+
}): CodeTokenLines | null;
|
|
45
|
+
declare function CodeTokenLine({ tokens, plain }: {
|
|
46
|
+
tokens: CodeTokenLines[number] | null;
|
|
47
|
+
plain: string;
|
|
48
|
+
}): ReactNode;
|
|
49
|
+
type CodeContentProps = Omit<ComponentProps<"div">, "children" | "style"> & {
|
|
50
|
+
code: string;
|
|
51
|
+
lang?: string;
|
|
52
|
+
tokens?: CodeTokenLines | null;
|
|
53
|
+
highlight?: CodeHighlight;
|
|
54
|
+
showLineNumbers?: boolean;
|
|
55
|
+
startLine?: number;
|
|
56
|
+
maxHeight?: string;
|
|
57
|
+
virtualize?: boolean;
|
|
58
|
+
style?: CSSProperties & CodeKnobStyle;
|
|
59
|
+
};
|
|
60
|
+
declare function CodeContent({ code, lang, tokens, highlight, showLineNumbers, startLine, maxHeight, virtualize, className, ref, style, ...props }: CodeContentProps): import("react").JSX.Element;
|
|
61
|
+
//#endregion
|
|
62
|
+
export { Code, CodeActions, CodeActionsProps, CodeChrome, CodeContent, CodeContentProps, CodeCopy, CodeCopyProps, CodeDensity, CodeFloatingCopy, CodeFloatingCopyProps, CodeHeader, CodeHeaderProps, CodeHighlight, CodeOverflow, CodeProps, CodeTitle, CodeTitleProps, CodeTokenLine, useCodeTokens };
|