@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,59 @@
|
|
|
1
|
+
import { ButtonKnobStyle } from "./knob-contracts/button-knobs.js";
|
|
2
|
+
import { Button } from "./ui/button.js";
|
|
3
|
+
import { CodeBlockEditorKnobStyle } from "./knob-contracts/code-block-editor-knobs.js";
|
|
4
|
+
import { CodeKnobStyle } from "./knob-contracts/code-knobs.js";
|
|
5
|
+
import { CodeBlockEditorTokenLines } from "./lib/code-block-shiki.js";
|
|
6
|
+
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
7
|
+
//#region src/code-block-editor.d.ts
|
|
8
|
+
type CodeBlockEditorStyleProps<Props, Style> = Omit<Props, "style"> & {
|
|
9
|
+
style?: CSSProperties & Style;
|
|
10
|
+
};
|
|
11
|
+
type CodeBlockEditorOverflow = "wrap" | "scroll";
|
|
12
|
+
type CodeBlockEditorHighlight = "auto" | "none";
|
|
13
|
+
type CodeBlockEditorChrome = "standalone" | "embedded";
|
|
14
|
+
type CodeBlockEditorDensity = "default" | "compact";
|
|
15
|
+
type CodeBlockEditorVariant = "default" | "command";
|
|
16
|
+
type CodeBlockEditorProps = CodeBlockEditorStyleProps<ComponentProps<"figure">, CodeBlockEditorKnobStyle> & {
|
|
17
|
+
overflow?: CodeBlockEditorOverflow;
|
|
18
|
+
chrome?: CodeBlockEditorChrome;
|
|
19
|
+
density?: CodeBlockEditorDensity;
|
|
20
|
+
variant?: CodeBlockEditorVariant;
|
|
21
|
+
};
|
|
22
|
+
type CodeBlockEditorHeaderProps = CodeBlockEditorStyleProps<ComponentProps<"figcaption">, CodeBlockEditorKnobStyle>;
|
|
23
|
+
type CodeBlockEditorTitleProps = CodeBlockEditorStyleProps<ComponentProps<"span">, CodeBlockEditorKnobStyle>;
|
|
24
|
+
type CodeBlockEditorActionsProps = ComponentProps<"div"> & {
|
|
25
|
+
style?: CSSProperties & CodeBlockEditorKnobStyle;
|
|
26
|
+
};
|
|
27
|
+
type CodeBlockEditorCopyProps = Omit<ComponentProps<typeof Button>, "children" | "onClick"> & {
|
|
28
|
+
value: string;
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
copiedLabel?: ReactNode;
|
|
31
|
+
copiedAriaLabel?: string;
|
|
32
|
+
};
|
|
33
|
+
type CodeBlockEditorContentProps = CodeBlockEditorStyleProps<Omit<ComponentProps<"pre">, "children">, CodeBlockEditorKnobStyle> & {
|
|
34
|
+
code: string;
|
|
35
|
+
lang?: string;
|
|
36
|
+
tokens?: CodeBlockEditorTokenLines | null;
|
|
37
|
+
highlight?: CodeBlockEditorHighlight;
|
|
38
|
+
maxHeight?: string;
|
|
39
|
+
scrollAreaClassName?: string;
|
|
40
|
+
};
|
|
41
|
+
type CodeBlockEditorTextareaProps = CodeBlockEditorStyleProps<Omit<ComponentProps<"textarea">, "defaultValue" | "value">, CodeBlockEditorKnobStyle> & {
|
|
42
|
+
value?: string;
|
|
43
|
+
defaultValue?: string;
|
|
44
|
+
onValueChange?: (value: string) => void;
|
|
45
|
+
fileName?: string;
|
|
46
|
+
};
|
|
47
|
+
declare function CodeBlockEditor({ overflow, chrome, density, variant, className, children, ...props }: CodeBlockEditorProps): import("react").JSX.Element;
|
|
48
|
+
declare function CodeBlockEditorHeader({ className, ...props }: CodeBlockEditorHeaderProps): import("react").JSX.Element;
|
|
49
|
+
declare function CodeBlockEditorTitle({ className, ...props }: CodeBlockEditorTitleProps): import("react").JSX.Element;
|
|
50
|
+
declare function CodeBlockEditorActions({ className, ...props }: CodeBlockEditorActionsProps): import("react").JSX.Element;
|
|
51
|
+
declare function CodeBlockEditorCopy({ value, copiedLabel, copiedAriaLabel, children, className, "aria-label": ariaLabel, ...props }: CodeBlockEditorCopyProps): import("react").JSX.Element;
|
|
52
|
+
type CodeBlockEditorFloatingCopyProps = Omit<CodeBlockEditorCopyProps, "children" | "copiedLabel" | "style"> & {
|
|
53
|
+
style?: CSSProperties & ButtonKnobStyle & CodeKnobStyle;
|
|
54
|
+
};
|
|
55
|
+
declare function CodeBlockEditorFloatingCopy({ className, ...props }: CodeBlockEditorFloatingCopyProps): import("react").JSX.Element;
|
|
56
|
+
declare function CodeBlockEditorContent({ code, lang, tokens, highlight, maxHeight, scrollAreaClassName, className, ...props }: CodeBlockEditorContentProps): import("react").JSX.Element;
|
|
57
|
+
declare function CodeBlockEditorTextarea({ value, defaultValue, onValueChange, onChange, fileName, className, "aria-label": ariaLabel, ...props }: CodeBlockEditorTextareaProps): import("react").JSX.Element;
|
|
58
|
+
//#endregion
|
|
59
|
+
export { CodeBlockEditor, CodeBlockEditorActions, CodeBlockEditorActionsProps, CodeBlockEditorChrome, CodeBlockEditorContent, CodeBlockEditorContentProps, CodeBlockEditorCopy, CodeBlockEditorCopyProps, CodeBlockEditorDensity, CodeBlockEditorFloatingCopy, CodeBlockEditorFloatingCopyProps, CodeBlockEditorHeader, CodeBlockEditorHeaderProps, CodeBlockEditorHighlight, CodeBlockEditorOverflow, CodeBlockEditorProps, CodeBlockEditorTextarea, CodeBlockEditorTextareaProps, CodeBlockEditorTitle, CodeBlockEditorTitleProps, CodeBlockEditorVariant };
|
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCopyToClipboard } from "./hooks/use-copy-to-clipboard.js";
|
|
3
|
+
import { cn } from "./lib/cn.js";
|
|
4
|
+
import { Button } from "./ui/button.js";
|
|
5
|
+
import { ScrollArea } from "./ui/scroll-area.js";
|
|
6
|
+
import { highlightCodeToTokens } from "./lib/code-block-shiki.js";
|
|
7
|
+
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "./ui/tooltip.js";
|
|
8
|
+
import { Children, Fragment, createContext, isValidElement, use, useEffect, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { CheckIcon, CopyIcon } from "lucide-react";
|
|
11
|
+
//#region src/code-block-editor.tsx
|
|
12
|
+
const CodeBlockEditorContext = createContext(null);
|
|
13
|
+
function useCodeBlockEditorContext() {
|
|
14
|
+
const context = use(CodeBlockEditorContext);
|
|
15
|
+
if (!context) throw new Error("CodeBlockEditor compound parts must be rendered inside <CodeBlockEditor>.");
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
function resolveCodeBlockEditorClasses({ overflow, density, variant }) {
|
|
19
|
+
const isCommand = variant === "command";
|
|
20
|
+
const isCompact = density === "compact" || isCommand;
|
|
21
|
+
return {
|
|
22
|
+
codeClassName: cn(overflow === "scroll" ? isCommand ? "w-full max-w-full overflow-x-auto whitespace-pre" : "w-max min-w-full whitespace-pre" : "w-full whitespace-pre-wrap break-words"),
|
|
23
|
+
editorClassName: cn("w-full max-w-full overflow-auto", overflow === "scroll" ? "whitespace-pre" : "whitespace-pre-wrap break-words"),
|
|
24
|
+
scrollable: !isCommand,
|
|
25
|
+
maxHeight: isCompact ? "320px" : "520px"
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function hasCodeBlockEditorHeader(children) {
|
|
29
|
+
return Children.toArray(children).some((child) => isValidElement(child) && child.type === CodeBlockEditorHeader);
|
|
30
|
+
}
|
|
31
|
+
function createKeyedTokenLines(lines) {
|
|
32
|
+
return lines.reduce((state, line) => {
|
|
33
|
+
const tokenState = line.reduce((tokenAccumulator, token) => ({
|
|
34
|
+
offset: tokenAccumulator.offset + token.content.length,
|
|
35
|
+
tokens: [...tokenAccumulator.tokens, {
|
|
36
|
+
key: tokenAccumulator.offset,
|
|
37
|
+
content: token.content,
|
|
38
|
+
style: token.style
|
|
39
|
+
}]
|
|
40
|
+
}), {
|
|
41
|
+
offset: state.offset,
|
|
42
|
+
tokens: []
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
offset: tokenState.offset + 1,
|
|
46
|
+
lines: [...state.lines, {
|
|
47
|
+
key: state.offset,
|
|
48
|
+
tokens: tokenState.tokens
|
|
49
|
+
}]
|
|
50
|
+
};
|
|
51
|
+
}, {
|
|
52
|
+
offset: 0,
|
|
53
|
+
lines: []
|
|
54
|
+
}).lines;
|
|
55
|
+
}
|
|
56
|
+
function useHighlightedTokens({ code, lang, tokens, highlight }) {
|
|
57
|
+
const tokenKey = `${lang ?? ""}\n${code}`;
|
|
58
|
+
const [clientTokens, setClientTokens] = useState(null);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
if (highlight === "none" || tokens !== void 0 || !lang) return;
|
|
61
|
+
let cancelled = false;
|
|
62
|
+
const requestKey = `${lang}\n${code}`;
|
|
63
|
+
highlightCodeToTokens(code, lang).then((result) => {
|
|
64
|
+
if (!cancelled) setClientTokens({
|
|
65
|
+
key: requestKey,
|
|
66
|
+
tokens: result
|
|
67
|
+
});
|
|
68
|
+
}).catch(() => {
|
|
69
|
+
if (!cancelled) setClientTokens({
|
|
70
|
+
key: requestKey,
|
|
71
|
+
tokens: null
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
return () => {
|
|
75
|
+
cancelled = true;
|
|
76
|
+
};
|
|
77
|
+
}, [
|
|
78
|
+
code,
|
|
79
|
+
lang,
|
|
80
|
+
tokens,
|
|
81
|
+
highlight
|
|
82
|
+
]);
|
|
83
|
+
if (highlight === "none") return null;
|
|
84
|
+
return tokens ?? (clientTokens?.key === tokenKey ? clientTokens.tokens : null);
|
|
85
|
+
}
|
|
86
|
+
function CodeBlockEditorCode({ code, lang, tokens, highlight, maxHeight, scrollAreaClassName, scrollable, className, ...props }) {
|
|
87
|
+
const highlightedTokens = useHighlightedTokens({
|
|
88
|
+
code,
|
|
89
|
+
lang,
|
|
90
|
+
tokens,
|
|
91
|
+
highlight
|
|
92
|
+
});
|
|
93
|
+
const codeNode = highlightedTokens === null || highlightedTokens.length === 0 ? /* @__PURE__ */ jsx("code", { children: code }) : /* @__PURE__ */ jsx("code", { children: createKeyedTokenLines(highlightedTokens).map((line, lineIndex, keyedLines) => /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", { children: line.tokens.map((token) => /* @__PURE__ */ jsx("span", {
|
|
94
|
+
style: token.style,
|
|
95
|
+
children: token.content
|
|
96
|
+
}, token.key)) }), lineIndex !== keyedLines.length - 1 ? "\n" : null] }, line.key)) });
|
|
97
|
+
const block = /* @__PURE__ */ jsx("pre", {
|
|
98
|
+
"data-control-ui": "code-block-editor",
|
|
99
|
+
"data-control-family": "code-block-editor",
|
|
100
|
+
"data-slot": "content",
|
|
101
|
+
className,
|
|
102
|
+
...props,
|
|
103
|
+
children: codeNode
|
|
104
|
+
});
|
|
105
|
+
if (!scrollable) return block;
|
|
106
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
107
|
+
className: scrollAreaClassName,
|
|
108
|
+
maxHeight,
|
|
109
|
+
children: block
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
function CodeBlockEditor({ overflow, chrome = "standalone", density = "default", variant = "default", className, children, ...props }) {
|
|
113
|
+
const resolvedOverflow = overflow ?? (variant === "command" ? "wrap" : "scroll");
|
|
114
|
+
const hasHeader = hasCodeBlockEditorHeader(children);
|
|
115
|
+
return /* @__PURE__ */ jsx(CodeBlockEditorContext.Provider, {
|
|
116
|
+
value: {
|
|
117
|
+
overflow: resolvedOverflow,
|
|
118
|
+
chrome,
|
|
119
|
+
density,
|
|
120
|
+
variant,
|
|
121
|
+
hasHeader
|
|
122
|
+
},
|
|
123
|
+
children: /* @__PURE__ */ jsx("figure", {
|
|
124
|
+
"data-control-ui": "code-block-editor",
|
|
125
|
+
"data-control-family": "code-block-editor",
|
|
126
|
+
"data-slot": "root",
|
|
127
|
+
"data-surface": "panel",
|
|
128
|
+
"data-variant": variant,
|
|
129
|
+
"data-chrome": chrome,
|
|
130
|
+
"data-density": density,
|
|
131
|
+
"data-header": hasHeader ? "true" : void 0,
|
|
132
|
+
className: cn("min-w-0 overflow-hidden", !hasHeader && "relative", className),
|
|
133
|
+
...props,
|
|
134
|
+
children
|
|
135
|
+
})
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function CodeBlockEditorHeader({ className, ...props }) {
|
|
139
|
+
return /* @__PURE__ */ jsx("figcaption", {
|
|
140
|
+
"data-control-ui": "code-block-editor",
|
|
141
|
+
"data-control-family": "code-block-editor",
|
|
142
|
+
"data-slot": "header",
|
|
143
|
+
className: cn("flex items-center justify-between", className),
|
|
144
|
+
...props
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function CodeBlockEditorTitle({ className, ...props }) {
|
|
148
|
+
return /* @__PURE__ */ jsx("span", {
|
|
149
|
+
"data-control-ui": "code-block-editor",
|
|
150
|
+
"data-control-family": "code-block-editor",
|
|
151
|
+
"data-slot": "title",
|
|
152
|
+
className: cn("block min-w-0 truncate", className),
|
|
153
|
+
...props
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
function CodeBlockEditorActions({ className, ...props }) {
|
|
157
|
+
return /* @__PURE__ */ jsx("div", {
|
|
158
|
+
"data-control-ui": "code-block-editor",
|
|
159
|
+
"data-control-family": "code-block-editor",
|
|
160
|
+
"data-slot": "actions",
|
|
161
|
+
className: cn("flex shrink-0 items-center", className),
|
|
162
|
+
...props
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function CodeBlockEditorCopy({ value, copiedLabel, copiedAriaLabel = "Copied", children, className, "aria-label": ariaLabel, ...props }) {
|
|
166
|
+
const { isCopied, handleCopy } = useCopyToClipboard({ text: value });
|
|
167
|
+
const isIconOnly = children === void 0;
|
|
168
|
+
const label = ariaLabel ?? (isIconOnly ? "Copy code" : void 0);
|
|
169
|
+
const copied = copiedLabel ?? (isIconOnly ? /* @__PURE__ */ jsx(CheckIcon, {
|
|
170
|
+
"aria-hidden": "true",
|
|
171
|
+
className: "size-3.5"
|
|
172
|
+
}) : "Copied");
|
|
173
|
+
const button = /* @__PURE__ */ jsx(Button, {
|
|
174
|
+
type: "button",
|
|
175
|
+
variant: "quiet",
|
|
176
|
+
size: "xs",
|
|
177
|
+
"aria-live": "polite",
|
|
178
|
+
"aria-label": label && isCopied ? copiedAriaLabel : label,
|
|
179
|
+
"data-code-block-editor-copy": isIconOnly ? "true" : void 0,
|
|
180
|
+
className,
|
|
181
|
+
...props,
|
|
182
|
+
onClick: handleCopy,
|
|
183
|
+
children: isCopied ? copied : children ?? /* @__PURE__ */ jsx(CopyIcon, {
|
|
184
|
+
"aria-hidden": "true",
|
|
185
|
+
className: "size-3.5"
|
|
186
|
+
})
|
|
187
|
+
});
|
|
188
|
+
if (!isIconOnly) return button;
|
|
189
|
+
return /* @__PURE__ */ jsx(TooltipProvider, {
|
|
190
|
+
delay: 0,
|
|
191
|
+
children: /* @__PURE__ */ jsxs(Tooltip, { children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: button }), /* @__PURE__ */ jsx(TooltipContent, {
|
|
192
|
+
side: "left",
|
|
193
|
+
children: label
|
|
194
|
+
})] })
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
function CodeBlockEditorFloatingCopy({ className, ...props }) {
|
|
198
|
+
return /* @__PURE__ */ jsx(CodeBlockEditorCopy, {
|
|
199
|
+
"data-code-block-editor-floating-copy": "true",
|
|
200
|
+
className: cn("absolute top-2 right-2 z-10", className),
|
|
201
|
+
...props
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
function CodeBlockEditorContent({ code, lang, tokens, highlight = "auto", maxHeight, scrollAreaClassName, className, ...props }) {
|
|
205
|
+
const context = useCodeBlockEditorContext();
|
|
206
|
+
const classes = resolveCodeBlockEditorClasses(context);
|
|
207
|
+
const content = /* @__PURE__ */ jsx(CodeBlockEditorCode, {
|
|
208
|
+
code,
|
|
209
|
+
lang,
|
|
210
|
+
tokens,
|
|
211
|
+
highlight,
|
|
212
|
+
maxHeight: maxHeight ?? classes.maxHeight,
|
|
213
|
+
scrollAreaClassName,
|
|
214
|
+
scrollable: classes.scrollable,
|
|
215
|
+
className: cn(classes.codeClassName, className),
|
|
216
|
+
...props
|
|
217
|
+
});
|
|
218
|
+
if (context.hasHeader) return content;
|
|
219
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
220
|
+
"data-control-ui": "code-block-editor",
|
|
221
|
+
"data-control-family": "code-block-editor",
|
|
222
|
+
"data-slot": "floating-frame",
|
|
223
|
+
className: "relative",
|
|
224
|
+
children: [/* @__PURE__ */ jsx(CodeBlockEditorFloatingCopy, { value: code }), content]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
function CodeBlockEditorTextarea({ value, defaultValue = "", onValueChange, onChange, fileName, className, "aria-label": ariaLabel, ...props }) {
|
|
228
|
+
const { editorClassName } = resolveCodeBlockEditorClasses(useCodeBlockEditorContext());
|
|
229
|
+
const [internalValue, setInternalValue] = useState(defaultValue);
|
|
230
|
+
const currentValue = value ?? internalValue;
|
|
231
|
+
function handleChange(event) {
|
|
232
|
+
const nextValue = event.target.value;
|
|
233
|
+
if (value === void 0) setInternalValue(nextValue);
|
|
234
|
+
onValueChange?.(nextValue);
|
|
235
|
+
onChange?.(event);
|
|
236
|
+
}
|
|
237
|
+
return /* @__PURE__ */ jsx("textarea", {
|
|
238
|
+
"data-control-ui": "code-block-editor",
|
|
239
|
+
"data-control-family": "code-block-editor",
|
|
240
|
+
"data-slot": "editor",
|
|
241
|
+
value: currentValue,
|
|
242
|
+
onChange: handleChange,
|
|
243
|
+
"aria-label": ariaLabel ?? (fileName ? `${fileName} code` : "Code editor"),
|
|
244
|
+
spellCheck: false,
|
|
245
|
+
className: cn(editorClassName, "block resize-y", className),
|
|
246
|
+
...props
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
//#endregion
|
|
250
|
+
export { CodeBlockEditor, CodeBlockEditorActions, CodeBlockEditorContent, CodeBlockEditorCopy, CodeBlockEditorFloatingCopy, CodeBlockEditorHeader, CodeBlockEditorTextarea, CodeBlockEditorTitle };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/context-model.d.ts
|
|
3
|
+
type ContextSegmentKind = "system" | "tool" | "message" | "source" | "reasoning" | "cache" | "other";
|
|
4
|
+
type ContextStatus = "normal" | "over-limit" | "unavailable";
|
|
5
|
+
type ContextSegment = {
|
|
6
|
+
id: string;
|
|
7
|
+
label: string;
|
|
8
|
+
tokens: number;
|
|
9
|
+
kind?: ContextSegmentKind;
|
|
10
|
+
description?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
type ContextModelSegment = {
|
|
13
|
+
segment: ContextSegment;
|
|
14
|
+
kind: ContextSegmentKind;
|
|
15
|
+
tokens: number;
|
|
16
|
+
start: number;
|
|
17
|
+
width: number;
|
|
18
|
+
ratio: number | null;
|
|
19
|
+
};
|
|
20
|
+
type ContextModel = {
|
|
21
|
+
segments: readonly ContextModelSegment[];
|
|
22
|
+
usedTokens: number;
|
|
23
|
+
maxTokens: number | null;
|
|
24
|
+
remainingTokens: number | null;
|
|
25
|
+
overageTokens: number;
|
|
26
|
+
ratio: number | null;
|
|
27
|
+
domain: number;
|
|
28
|
+
limitPosition: number | null;
|
|
29
|
+
status: ContextStatus;
|
|
30
|
+
};
|
|
31
|
+
declare function deriveContextModel(segments: readonly ContextSegment[], maxTokens?: number | null): ContextModel;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { ContextModel, ContextModelSegment, ContextSegment, ContextSegmentKind, ContextStatus, deriveContextModel };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/context-model.ts
|
|
2
|
+
function deriveContextModelSegments(segments, domain, validLimit) {
|
|
3
|
+
let consumedTokens = 0;
|
|
4
|
+
return segments.map((segment) => {
|
|
5
|
+
const tokens = Number.isFinite(segment.tokens) && segment.tokens > 0 ? segment.tokens : 0;
|
|
6
|
+
const modelSegment = {
|
|
7
|
+
segment,
|
|
8
|
+
kind: segment.kind ?? "other",
|
|
9
|
+
tokens,
|
|
10
|
+
start: consumedTokens / domain * 100,
|
|
11
|
+
width: tokens / domain * 100,
|
|
12
|
+
ratio: validLimit === null ? null : tokens / validLimit
|
|
13
|
+
};
|
|
14
|
+
consumedTokens += tokens;
|
|
15
|
+
return modelSegment;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function deriveValidatedUsedTokens(segments) {
|
|
19
|
+
const ids = /* @__PURE__ */ new Set();
|
|
20
|
+
let usedTokens = 0;
|
|
21
|
+
for (const segment of segments) {
|
|
22
|
+
if (ids.has(segment.id)) throw new Error(`Context segment ids must be unique: "${segment.id}".`);
|
|
23
|
+
ids.add(segment.id);
|
|
24
|
+
usedTokens += Number.isFinite(segment.tokens) && segment.tokens > 0 ? segment.tokens : 0;
|
|
25
|
+
}
|
|
26
|
+
return usedTokens;
|
|
27
|
+
}
|
|
28
|
+
function deriveContextModel(segments, maxTokens) {
|
|
29
|
+
const usedTokens = deriveValidatedUsedTokens(segments);
|
|
30
|
+
const validLimit = Number.isFinite(maxTokens) && (maxTokens ?? 0) > 0 ? maxTokens ?? null : null;
|
|
31
|
+
const domain = Math.max(validLimit ?? 0, usedTokens, 1);
|
|
32
|
+
const remainingTokens = validLimit === null ? null : Math.max(0, validLimit - usedTokens);
|
|
33
|
+
const overageTokens = validLimit === null ? 0 : Math.max(0, usedTokens - validLimit);
|
|
34
|
+
const ratio = validLimit === null ? null : usedTokens / validLimit;
|
|
35
|
+
const limitPosition = validLimit === null ? null : validLimit / domain * 100;
|
|
36
|
+
let status = "normal";
|
|
37
|
+
if (validLimit === null) status = "unavailable";
|
|
38
|
+
else if (overageTokens > 0) status = "over-limit";
|
|
39
|
+
return {
|
|
40
|
+
segments: deriveContextModelSegments(segments, domain, validLimit),
|
|
41
|
+
usedTokens,
|
|
42
|
+
maxTokens: validLimit,
|
|
43
|
+
remainingTokens,
|
|
44
|
+
overageTokens,
|
|
45
|
+
ratio,
|
|
46
|
+
domain,
|
|
47
|
+
limitPosition,
|
|
48
|
+
status
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { deriveContextModel };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { OpenChangeEventDetails } from "./control-props.js";
|
|
2
|
+
import { ButtonKnobStyle } from "./knob-contracts/button-knobs.js";
|
|
3
|
+
import { Button } from "./ui/button.js";
|
|
4
|
+
import { PopupKnobStyle } from "./knob-contracts/popup-knobs.js";
|
|
5
|
+
import { ContextSegment } from "./context-model.js";
|
|
6
|
+
import { ContextKnobStyle } from "./knob-contracts/context-knobs.js";
|
|
7
|
+
import { PopoverContent, PopoverDescription, PopoverTitle } from "./ui/popover.js";
|
|
8
|
+
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
9
|
+
//#region src/context.d.ts
|
|
10
|
+
type ContextProps = Omit<ComponentProps<"div">, "children"> & {
|
|
11
|
+
segments: readonly ContextSegment[];
|
|
12
|
+
maxTokens?: number | null;
|
|
13
|
+
model?: string;
|
|
14
|
+
locale?: Intl.LocalesArgument;
|
|
15
|
+
open?: boolean;
|
|
16
|
+
defaultOpen?: boolean;
|
|
17
|
+
onOpenChange?: (open: boolean, eventDetails: OpenChangeEventDetails) => void;
|
|
18
|
+
children?: ReactNode;
|
|
19
|
+
} & {
|
|
20
|
+
style?: CSSProperties & ContextKnobStyle;
|
|
21
|
+
};
|
|
22
|
+
type ContextStyleProps<Props, Style> = Omit<Props, "style"> & {
|
|
23
|
+
style?: CSSProperties & Style;
|
|
24
|
+
};
|
|
25
|
+
declare function Context({ segments, maxTokens, model: modelName, locale, open, defaultOpen, onOpenChange, className, children, ...props }: ContextProps): import("react").JSX.Element;
|
|
26
|
+
type ContextTriggerProps = ContextStyleProps<ComponentProps<typeof Button>, ButtonKnobStyle & ContextKnobStyle>;
|
|
27
|
+
declare function ContextTrigger({ "aria-label": ariaLabel, variant, size, className, children, ...props }: ContextTriggerProps): import("react").JSX.Element;
|
|
28
|
+
type ContextContentProps = ContextStyleProps<ComponentProps<typeof PopoverContent>, PopupKnobStyle & ContextKnobStyle>;
|
|
29
|
+
declare function ContextContent({ "aria-label": ariaLabel, side, align, sideOffset, collisionPadding, padding, className, children, ...props }: ContextContentProps): import("react").JSX.Element;
|
|
30
|
+
type ContextHeaderProps = ComponentProps<"div"> & {
|
|
31
|
+
style?: CSSProperties & ContextKnobStyle;
|
|
32
|
+
};
|
|
33
|
+
declare function ContextHeader({ className, children, ...props }: ContextHeaderProps): import("react").JSX.Element;
|
|
34
|
+
type ContextTitleProps = ContextStyleProps<ComponentProps<typeof PopoverTitle>, ContextKnobStyle>;
|
|
35
|
+
declare function ContextTitle({ className, children, ...props }: ContextTitleProps): import("react").JSX.Element;
|
|
36
|
+
type ContextDescriptionProps = ContextStyleProps<ComponentProps<typeof PopoverDescription>, ContextKnobStyle>;
|
|
37
|
+
declare function ContextDescription({ className, children, ...props }: ContextDescriptionProps): import("react").JSX.Element;
|
|
38
|
+
type ContextSummaryProps = ContextStyleProps<ComponentProps<"div">, ContextKnobStyle>;
|
|
39
|
+
declare function ContextSummary({ className, children, ...props }: ContextSummaryProps): import("react").JSX.Element;
|
|
40
|
+
type ContextGraphProps = ContextStyleProps<Omit<ComponentProps<"svg">, "children">, ContextKnobStyle>;
|
|
41
|
+
declare function ContextGraph({ className, ...props }: ContextGraphProps): import("react").JSX.Element;
|
|
42
|
+
type ContextLegendProps = ContextStyleProps<ComponentProps<"ul">, ContextKnobStyle>;
|
|
43
|
+
declare function ContextLegend({ className, children, ...props }: ContextLegendProps): import("react").JSX.Element;
|
|
44
|
+
type ContextCloseProps = ComponentProps<typeof Button>;
|
|
45
|
+
declare function ContextClose({ variant, size, iconOnly, "aria-label": ariaLabel, className, children, ...props }: ContextCloseProps): import("react").JSX.Element;
|
|
46
|
+
//#endregion
|
|
47
|
+
export { Context, ContextClose, ContextCloseProps, ContextContent, ContextContentProps, ContextDescription, ContextDescriptionProps, ContextGraph, ContextGraphProps, ContextHeader, ContextHeaderProps, ContextLegend, ContextLegendProps, ContextProps, ContextSummary, ContextSummaryProps, ContextTitle, ContextTitleProps, ContextTrigger, ContextTriggerProps };
|