@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,72 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { jsx } from "react/jsx-runtime";
|
|
4
|
+
import { Toolbar as Toolbar$1 } from "@base-ui/react/toolbar";
|
|
5
|
+
//#region src/ui/toolbar.tsx
|
|
6
|
+
function Toolbar({ orientation = "horizontal", variant = "default", className, ...props }) {
|
|
7
|
+
return /* @__PURE__ */ jsx(Toolbar$1.Root, {
|
|
8
|
+
orientation,
|
|
9
|
+
"data-control-ui": "toolbar",
|
|
10
|
+
"data-control-family": "toolbar",
|
|
11
|
+
"data-slot": "root",
|
|
12
|
+
"data-variant": variant,
|
|
13
|
+
className: cn("group/toolbar inline-flex", orientation === "vertical" ? "flex-col items-stretch" : "items-center", className),
|
|
14
|
+
...props
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function ToolbarButton({ iconOnly = false, className, ...props }) {
|
|
18
|
+
return /* @__PURE__ */ jsx(Toolbar$1.Button, {
|
|
19
|
+
"data-control-ui": "toolbar",
|
|
20
|
+
"data-control-family": "toolbar",
|
|
21
|
+
"data-slot": "button",
|
|
22
|
+
"data-control": "true",
|
|
23
|
+
"data-size": "sm",
|
|
24
|
+
"data-icon-only": iconOnly ? "true" : void 0,
|
|
25
|
+
className: cn("inline-flex shrink-0 items-center justify-center select-none data-[disabled]:pointer-events-none [&_svg]:block [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", className),
|
|
26
|
+
...props
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function ToolbarLink({ variant = "default", className, ...props }) {
|
|
30
|
+
return /* @__PURE__ */ jsx(Toolbar$1.Link, {
|
|
31
|
+
"data-control-ui": "toolbar",
|
|
32
|
+
"data-control-family": "toolbar",
|
|
33
|
+
"data-slot": "link",
|
|
34
|
+
"data-control": "true",
|
|
35
|
+
"data-size": "sm",
|
|
36
|
+
"data-variant": variant,
|
|
37
|
+
className: cn("inline-flex shrink-0 items-center justify-center [&_svg]:block [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0", variant === "track" && "relative z-[2]", className),
|
|
38
|
+
...props
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
function ToolbarGroup({ className, ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsx(Toolbar$1.Group, {
|
|
43
|
+
"data-control-ui": "toolbar",
|
|
44
|
+
"data-control-family": "toolbar",
|
|
45
|
+
"data-slot": "group",
|
|
46
|
+
className: cn("inline-flex items-center", className),
|
|
47
|
+
...props
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function ToolbarSeparator({ orientation = "vertical", className, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsx(Toolbar$1.Separator, {
|
|
52
|
+
orientation,
|
|
53
|
+
"data-control-ui": "toolbar",
|
|
54
|
+
"data-control-family": "toolbar",
|
|
55
|
+
"data-slot": "separator",
|
|
56
|
+
className: cn("shrink-0 self-stretch", className),
|
|
57
|
+
...props
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
function ToolbarInput({ className, ...props }) {
|
|
61
|
+
return /* @__PURE__ */ jsx(Toolbar$1.Input, {
|
|
62
|
+
"data-control-ui": "toolbar",
|
|
63
|
+
"data-control-family": "toolbar",
|
|
64
|
+
"data-slot": "input",
|
|
65
|
+
"data-control": "true",
|
|
66
|
+
"data-size": "sm",
|
|
67
|
+
className: cn("min-w-0", className),
|
|
68
|
+
...props
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { Toolbar, ToolbarButton, ToolbarGroup, ToolbarInput, ToolbarLink, ToolbarSeparator };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { PopupKnobStyle } from "../knob-contracts/popup-knobs.js";
|
|
2
|
+
import { CSSProperties, ComponentProps, Ref } from "react";
|
|
3
|
+
import { Tooltip as Tooltip$1, TooltipPopupProps, TooltipPositionerProps } from "@base-ui/react/tooltip";
|
|
4
|
+
//#region src/ui/tooltip.d.ts
|
|
5
|
+
type TooltipProviderProps = Omit<ComponentProps<typeof Tooltip$1.Provider>, "delay" | "timeout"> & {
|
|
6
|
+
delay?: number;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
delayDuration?: number;
|
|
9
|
+
skipDelayDuration?: number;
|
|
10
|
+
};
|
|
11
|
+
declare function TooltipProvider({ delay, delayDuration, timeout, skipDelayDuration, ...props }: TooltipProviderProps): import("react").JSX.Element;
|
|
12
|
+
declare function Tooltip(props: ComponentProps<typeof Tooltip$1.Root>): import("react").JSX.Element;
|
|
13
|
+
type TooltipTriggerProps = ComponentProps<typeof Tooltip$1.Trigger> & {
|
|
14
|
+
ref?: Ref<HTMLButtonElement>;
|
|
15
|
+
};
|
|
16
|
+
declare function TooltipTrigger({ render, children, ref, ...props }: TooltipTriggerProps): import("react").JSX.Element;
|
|
17
|
+
type TooltipContentPositionerProps = Omit<TooltipPositionerProps, keyof TooltipPopupProps>;
|
|
18
|
+
type TooltipContentProps = Omit<TooltipPopupProps & Omit<TooltipContentPositionerProps, "style">, "style"> & {
|
|
19
|
+
style?: CSSProperties & PopupKnobStyle;
|
|
20
|
+
} & {
|
|
21
|
+
arrow?: boolean;
|
|
22
|
+
hidden?: boolean;
|
|
23
|
+
ref?: Ref<HTMLDivElement>;
|
|
24
|
+
};
|
|
25
|
+
declare function TooltipContent({ className, children, side, sideOffset, align, alignOffset, arrowPadding, anchor, positionMethod, collisionBoundary, collisionPadding, sticky, disableAnchorTracking, collisionAvoidance, arrow, hidden, ref, ...props }: TooltipContentProps): import("react").JSX.Element | null;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { Tooltip, TooltipContent, TooltipContentProps, TooltipProvider, TooltipTrigger };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { skinEffects, skinId } from "../skin.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Tooltip as Tooltip$1 } from "@base-ui/react/tooltip";
|
|
6
|
+
//#region src/ui/tooltip.tsx
|
|
7
|
+
function TooltipProvider({ delay, delayDuration, timeout, skipDelayDuration, ...props }) {
|
|
8
|
+
const resolvedDelay = delay ?? delayDuration;
|
|
9
|
+
const resolvedTimeout = timeout ?? skipDelayDuration;
|
|
10
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Provider, {
|
|
11
|
+
...resolvedDelay !== void 0 ? { delay: resolvedDelay } : {},
|
|
12
|
+
...resolvedTimeout !== void 0 ? { timeout: resolvedTimeout } : {},
|
|
13
|
+
...props
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function Tooltip(props) {
|
|
17
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Root, { ...props });
|
|
18
|
+
}
|
|
19
|
+
function TooltipTrigger({ render, children, ref, ...props }) {
|
|
20
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Trigger, {
|
|
21
|
+
ref,
|
|
22
|
+
render,
|
|
23
|
+
...props,
|
|
24
|
+
children
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function TooltipContent({ className, children, side = "top", sideOffset = 8, align = "center", alignOffset = 0, arrowPadding = 10, anchor, positionMethod, collisionBoundary, collisionPadding, sticky, disableAnchorTracking, collisionAvoidance, arrow = true, hidden = false, ref, ...props }) {
|
|
28
|
+
if (hidden) return null;
|
|
29
|
+
const positionerProps = {
|
|
30
|
+
side,
|
|
31
|
+
sideOffset,
|
|
32
|
+
align,
|
|
33
|
+
alignOffset,
|
|
34
|
+
arrowPadding,
|
|
35
|
+
anchor,
|
|
36
|
+
positionMethod,
|
|
37
|
+
collisionBoundary,
|
|
38
|
+
collisionPadding,
|
|
39
|
+
sticky,
|
|
40
|
+
disableAnchorTracking,
|
|
41
|
+
collisionAvoidance
|
|
42
|
+
};
|
|
43
|
+
return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(Tooltip$1.Positioner, {
|
|
44
|
+
"data-control-ui": "tooltip",
|
|
45
|
+
"data-popup-kind": "tooltip",
|
|
46
|
+
"data-control-family": "popup",
|
|
47
|
+
"data-slot": "positioner",
|
|
48
|
+
"data-skin": skinId(),
|
|
49
|
+
"data-effects": skinEffects(),
|
|
50
|
+
className: "z-[90]",
|
|
51
|
+
...positionerProps,
|
|
52
|
+
children: /* @__PURE__ */ jsxs(Tooltip$1.Popup, {
|
|
53
|
+
ref,
|
|
54
|
+
role: "tooltip",
|
|
55
|
+
"data-control-ui": "tooltip",
|
|
56
|
+
"data-popup-kind": "tooltip",
|
|
57
|
+
"data-control-family": "popup",
|
|
58
|
+
"data-popup-part": "surface",
|
|
59
|
+
"data-slot": "content",
|
|
60
|
+
"data-arrow": arrow ? "true" : void 0,
|
|
61
|
+
className: cn("relative flex w-fit max-w-xs flex-col", className),
|
|
62
|
+
...props,
|
|
63
|
+
children: [children, arrow ? /* @__PURE__ */ jsx(Tooltip$1.Arrow, {
|
|
64
|
+
"data-control-ui": "tooltip",
|
|
65
|
+
"data-control-family": "popup",
|
|
66
|
+
"data-popup-kind": "tooltip",
|
|
67
|
+
"data-slot": "arrow",
|
|
68
|
+
className: cn("flex", "data-[side=top]:-bottom-[8px]", "data-[side=bottom]:-top-[8px]", "data-[side=left]:-right-[10px]", "data-[side=right]:-left-[10px]"),
|
|
69
|
+
children: /* @__PURE__ */ jsx(TooltipArrowSvg, {})
|
|
70
|
+
}) : null]
|
|
71
|
+
})
|
|
72
|
+
}) });
|
|
73
|
+
}
|
|
74
|
+
function TooltipArrowSvg() {
|
|
75
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
76
|
+
"aria-hidden": "true",
|
|
77
|
+
focusable: "false",
|
|
78
|
+
width: "12",
|
|
79
|
+
height: "8",
|
|
80
|
+
viewBox: "0 0 12 8",
|
|
81
|
+
fill: "none",
|
|
82
|
+
overflow: "visible",
|
|
83
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
84
|
+
"data-control-ui": "tooltip",
|
|
85
|
+
"data-popup-kind": "tooltip",
|
|
86
|
+
"data-control-family": "popup",
|
|
87
|
+
"data-slot": "arrow-shape",
|
|
88
|
+
d: "M0 7L4 2Q6 0 8 2L12 7L12 8L0 8Z"
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
//#endregion
|
|
93
|
+
export { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { RenderProp, SelectionIndicator } from "../control-props.js";
|
|
2
|
+
import { TreeKnobStyle } from "../knob-contracts/tree-knobs.js";
|
|
3
|
+
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
4
|
+
//#region src/ui/tree.d.ts
|
|
5
|
+
type TreeSelectionMode = "none" | "single" | "multiple";
|
|
6
|
+
type TreeInteractionReason = "pointer" | "keyboard" | "imperative";
|
|
7
|
+
type TreeSelectionChangeDetails = {
|
|
8
|
+
value: string;
|
|
9
|
+
reason: TreeInteractionReason;
|
|
10
|
+
};
|
|
11
|
+
type TreeExpandedChangeDetails = {
|
|
12
|
+
value: string;
|
|
13
|
+
expanded: boolean;
|
|
14
|
+
reason: TreeInteractionReason;
|
|
15
|
+
};
|
|
16
|
+
type TreeSelectionIndicator = SelectionIndicator;
|
|
17
|
+
type TreeProps = Omit<Omit<ComponentProps<"ul">, "onChange" | "defaultValue">, "style"> & {
|
|
18
|
+
style?: CSSProperties & TreeKnobStyle;
|
|
19
|
+
} & {
|
|
20
|
+
selectionMode?: TreeSelectionMode;
|
|
21
|
+
value?: string[];
|
|
22
|
+
defaultValue?: string[];
|
|
23
|
+
onValueChange?: (value: string[], details: TreeSelectionChangeDetails) => void;
|
|
24
|
+
expandedValue?: string[];
|
|
25
|
+
defaultExpandedValue?: string[];
|
|
26
|
+
onExpandedChange?: (expanded: string[], details: TreeExpandedChangeDetails) => void;
|
|
27
|
+
indicator?: TreeSelectionIndicator;
|
|
28
|
+
};
|
|
29
|
+
type TreeItemProps = Omit<ComponentProps<"li">, "value"> & {
|
|
30
|
+
value: string;
|
|
31
|
+
disabled?: boolean;
|
|
32
|
+
label?: string;
|
|
33
|
+
children?: ReactNode;
|
|
34
|
+
};
|
|
35
|
+
type TreeItemTriggerProps = Omit<ComponentProps<"div">, "style"> & {
|
|
36
|
+
style?: CSSProperties & TreeKnobStyle;
|
|
37
|
+
} & {
|
|
38
|
+
render?: RenderProp<ComponentProps<"div">>;
|
|
39
|
+
};
|
|
40
|
+
type TreeItemIndicatorProps = Omit<ComponentProps<"span">, "style"> & {
|
|
41
|
+
style?: CSSProperties & TreeKnobStyle;
|
|
42
|
+
};
|
|
43
|
+
type TreeItemLabelProps = ComponentProps<"span"> & {
|
|
44
|
+
render?: RenderProp<ComponentProps<"span">>;
|
|
45
|
+
};
|
|
46
|
+
type TreeItemContentProps = ComponentProps<"div"> & {
|
|
47
|
+
style?: CSSProperties & TreeKnobStyle;
|
|
48
|
+
};
|
|
49
|
+
declare function Tree({ selectionMode, indicator, value, defaultValue, onValueChange, expandedValue, defaultExpandedValue, onExpandedChange, className, style, children, onKeyDown, onFocusCapture, ...props }: TreeProps): import("react").JSX.Element;
|
|
50
|
+
declare function TreeItem({ value, disabled, label, className, style, children, ref, ...props }: TreeItemProps): import("react").JSX.Element;
|
|
51
|
+
declare function TreeItemTrigger({ className, children, onClick, render, ...props }: TreeItemTriggerProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
52
|
+
declare function TreeItemIndicator({ className, children, ...props }: TreeItemIndicatorProps): import("react").JSX.Element;
|
|
53
|
+
declare function TreeItemLabel({ className, children, render, ref, ...props }: TreeItemLabelProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
54
|
+
declare function TreeItemContent({ className, children, ...props }: TreeItemContentProps): import("react").JSX.Element;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { Tree, TreeExpandedChangeDetails, TreeInteractionReason, TreeItem, TreeItemContent, TreeItemContentProps, TreeItemIndicator, TreeItemIndicatorProps, TreeItemLabel, TreeItemLabelProps, TreeItemProps, TreeItemTrigger, TreeItemTriggerProps, TreeProps, TreeSelectionChangeDetails, TreeSelectionIndicator, TreeSelectionMode };
|
package/dist/ui/tree.js
ADDED
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { skinIndicator } from "../skin.js";
|
|
4
|
+
import { Children, Suspense, createContext, isValidElement, lazy, useContext, useRef, useState } from "react";
|
|
5
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
6
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { ChevronRightIcon } from "lucide-react";
|
|
8
|
+
import { Collapsible } from "@base-ui/react/collapsible";
|
|
9
|
+
//#region src/ui/tree.tsx
|
|
10
|
+
const TrackHighlight = lazy(() => import("../extensions/track-highlight.js").then((module) => ({ default: module.TrackHighlight })));
|
|
11
|
+
const TYPEAHEAD_TIMEOUT = 500;
|
|
12
|
+
const TreeContext = createContext(null);
|
|
13
|
+
function useTree() {
|
|
14
|
+
const context = useContext(TreeContext);
|
|
15
|
+
if (!context) throw new Error("Tree parts must be used within <Tree>.");
|
|
16
|
+
return context;
|
|
17
|
+
}
|
|
18
|
+
const TreeItemContext = createContext(null);
|
|
19
|
+
function useTreeItem() {
|
|
20
|
+
const context = useContext(TreeItemContext);
|
|
21
|
+
if (!context) throw new Error("TreeItem parts must be used within <TreeItem>.");
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
function setRef(ref, value) {
|
|
25
|
+
if (typeof ref === "function") return ref(value);
|
|
26
|
+
if (ref) ref.current = value;
|
|
27
|
+
}
|
|
28
|
+
function labelOf(item, ctx) {
|
|
29
|
+
return item.label ?? ctx.getLabel(item.value);
|
|
30
|
+
}
|
|
31
|
+
function compareTreeItems(a, b) {
|
|
32
|
+
const position = a.node.compareDocumentPosition(b.node);
|
|
33
|
+
if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1;
|
|
34
|
+
if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1;
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
function visibleItems(items) {
|
|
38
|
+
return [...items.values()].filter((item) => !item.disabled && item.node.checkVisibility()).sort(compareTreeItems);
|
|
39
|
+
}
|
|
40
|
+
function focusItem(item, ctx) {
|
|
41
|
+
if (!item) return;
|
|
42
|
+
ctx.setFocusedValue(item.value);
|
|
43
|
+
item.node.focus();
|
|
44
|
+
}
|
|
45
|
+
function focusParentItem(items, index, level, ctx) {
|
|
46
|
+
for (let itemIndex = index - 1; itemIndex >= 0; itemIndex--) {
|
|
47
|
+
const item = items[itemIndex];
|
|
48
|
+
if (!item || item.level !== level - 1) continue;
|
|
49
|
+
focusItem(item, ctx);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
function handleTypeahead(event, items, index, ctx, typeahead) {
|
|
54
|
+
if (event.key.length !== 1 || event.metaKey || event.ctrlKey || event.altKey) return;
|
|
55
|
+
const now = Date.now();
|
|
56
|
+
typeahead.current.query = now - typeahead.current.at > TYPEAHEAD_TIMEOUT ? event.key : typeahead.current.query + event.key;
|
|
57
|
+
typeahead.current.at = now;
|
|
58
|
+
const query = typeahead.current.query.toLowerCase();
|
|
59
|
+
const match = [...items.slice(index + 1), ...items.slice(0, index + 1)].find((item) => labelOf(item, ctx).toLowerCase().startsWith(query));
|
|
60
|
+
if (match) focusItem(match, ctx);
|
|
61
|
+
}
|
|
62
|
+
function registeredItemFromTarget(target, root, itemsByNode) {
|
|
63
|
+
let node = target;
|
|
64
|
+
while (node && root.contains(node)) {
|
|
65
|
+
const item = itemsByNode.get(node);
|
|
66
|
+
if (item) return item;
|
|
67
|
+
if (node === root) return;
|
|
68
|
+
node = node.parentElement;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function getTreeKeyboardState(event, ctx) {
|
|
72
|
+
if (event.defaultPrevented || !(event.target instanceof HTMLElement)) return null;
|
|
73
|
+
const current = ctx.getItemFromTarget(event.target, event.currentTarget);
|
|
74
|
+
if (!current) return null;
|
|
75
|
+
const items = ctx.getVisibleItems();
|
|
76
|
+
const index = items.indexOf(current);
|
|
77
|
+
if (index === -1) return null;
|
|
78
|
+
return {
|
|
79
|
+
value: current.value,
|
|
80
|
+
items,
|
|
81
|
+
index,
|
|
82
|
+
isBranch: current.expandable,
|
|
83
|
+
isExpanded: ctx.expanded.has(current.value),
|
|
84
|
+
level: current.level
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
function handleTreeKeyDown(event, ctx, typeahead) {
|
|
88
|
+
const state = getTreeKeyboardState(event, ctx);
|
|
89
|
+
if (!state) return;
|
|
90
|
+
const { value, items, index, isBranch, isExpanded, level } = state;
|
|
91
|
+
switch (event.key) {
|
|
92
|
+
case "ArrowDown":
|
|
93
|
+
event.preventDefault();
|
|
94
|
+
focusItem(items[index + 1], ctx);
|
|
95
|
+
break;
|
|
96
|
+
case "ArrowUp":
|
|
97
|
+
event.preventDefault();
|
|
98
|
+
focusItem(items[index - 1], ctx);
|
|
99
|
+
break;
|
|
100
|
+
case "ArrowRight":
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
if (isBranch && !isExpanded) ctx.toggleExpanded(value, true, "keyboard");
|
|
103
|
+
else if (isBranch && isExpanded) focusItem(items[index + 1], ctx);
|
|
104
|
+
break;
|
|
105
|
+
case "ArrowLeft":
|
|
106
|
+
event.preventDefault();
|
|
107
|
+
if (isBranch && isExpanded) ctx.toggleExpanded(value, false, "keyboard");
|
|
108
|
+
else focusParentItem(items, index, level, ctx);
|
|
109
|
+
break;
|
|
110
|
+
case "Home":
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
focusItem(items[0], ctx);
|
|
113
|
+
break;
|
|
114
|
+
case "End":
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
focusItem(items[items.length - 1], ctx);
|
|
117
|
+
break;
|
|
118
|
+
case "Enter":
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
ctx.select(value, "keyboard", false);
|
|
121
|
+
if (isBranch) ctx.toggleExpanded(value, void 0, "keyboard");
|
|
122
|
+
break;
|
|
123
|
+
case " ":
|
|
124
|
+
event.preventDefault();
|
|
125
|
+
ctx.select(value, "keyboard", ctx.selectionMode === "multiple");
|
|
126
|
+
break;
|
|
127
|
+
default: handleTypeahead(event, items, index, ctx, typeahead);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
function Tree({ selectionMode = "single", indicator, value, defaultValue, onValueChange, expandedValue, defaultExpandedValue, onExpandedChange, className, style, children, onKeyDown, onFocusCapture, ...props }) {
|
|
131
|
+
const [selectedState, setSelectedState] = useState(() => new Set(defaultValue));
|
|
132
|
+
const [expandedState, setExpandedState] = useState(() => new Set(defaultExpandedValue));
|
|
133
|
+
const [focusedValue, setFocusedValue] = useState(null);
|
|
134
|
+
const selected = value ? new Set(value) : selectedState;
|
|
135
|
+
const expanded = expandedValue ? new Set(expandedValue) : expandedState;
|
|
136
|
+
const typeahead = useRef({
|
|
137
|
+
query: "",
|
|
138
|
+
at: 0
|
|
139
|
+
});
|
|
140
|
+
const itemsRef = useRef(/* @__PURE__ */ new Map());
|
|
141
|
+
const itemsByNodeRef = useRef(/* @__PURE__ */ new WeakMap());
|
|
142
|
+
const labelsRef = useRef(/* @__PURE__ */ new Map());
|
|
143
|
+
const seededFocusRef = useRef(false);
|
|
144
|
+
const registerItem = (item) => {
|
|
145
|
+
const previous = itemsRef.current.get(item.value);
|
|
146
|
+
if (previous) itemsByNodeRef.current.delete(previous.node);
|
|
147
|
+
itemsRef.current.set(item.value, item);
|
|
148
|
+
itemsByNodeRef.current.set(item.node, item);
|
|
149
|
+
if (!seededFocusRef.current && !item.disabled) {
|
|
150
|
+
seededFocusRef.current = true;
|
|
151
|
+
setFocusedValue(item.value);
|
|
152
|
+
}
|
|
153
|
+
return () => {
|
|
154
|
+
if (itemsRef.current.get(item.value) !== item) return;
|
|
155
|
+
itemsRef.current.delete(item.value);
|
|
156
|
+
itemsByNodeRef.current.delete(item.node);
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const registerLabel = (itemValue, node) => {
|
|
160
|
+
if (!node) return;
|
|
161
|
+
labelsRef.current.set(itemValue, node);
|
|
162
|
+
return () => {
|
|
163
|
+
if (labelsRef.current.get(itemValue) === node) labelsRef.current.delete(itemValue);
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const getVisibleItems = () => visibleItems(itemsRef.current);
|
|
167
|
+
const getItemFromTarget = (target, root) => registeredItemFromTarget(target, root, itemsByNodeRef.current);
|
|
168
|
+
const getLabel = (itemValue) => labelsRef.current.get(itemValue)?.textContent ?? "";
|
|
169
|
+
const getItem = (itemValue) => itemsRef.current.get(itemValue);
|
|
170
|
+
const select = (itemValue, reason, toggle) => {
|
|
171
|
+
if (selectionMode === "none") return;
|
|
172
|
+
let next;
|
|
173
|
+
if (selectionMode === "single" || !toggle) next = /* @__PURE__ */ new Set([itemValue]);
|
|
174
|
+
else {
|
|
175
|
+
next = new Set(selected);
|
|
176
|
+
if (next.has(itemValue)) next.delete(itemValue);
|
|
177
|
+
else next.add(itemValue);
|
|
178
|
+
}
|
|
179
|
+
if (!value) setSelectedState(next);
|
|
180
|
+
onValueChange?.([...next], {
|
|
181
|
+
value: itemValue,
|
|
182
|
+
reason
|
|
183
|
+
});
|
|
184
|
+
};
|
|
185
|
+
const toggleExpanded = (itemValue, force, reason = "pointer") => {
|
|
186
|
+
const willExpand = force ?? !expanded.has(itemValue);
|
|
187
|
+
const next = new Set(expanded);
|
|
188
|
+
if (willExpand) next.add(itemValue);
|
|
189
|
+
else next.delete(itemValue);
|
|
190
|
+
if (!expandedValue) setExpandedState(next);
|
|
191
|
+
onExpandedChange?.([...next], {
|
|
192
|
+
value: itemValue,
|
|
193
|
+
expanded: willExpand,
|
|
194
|
+
reason
|
|
195
|
+
});
|
|
196
|
+
};
|
|
197
|
+
const resolvedIndicator = indicator ?? skinIndicator("tree") ?? "none";
|
|
198
|
+
const contextValue = {
|
|
199
|
+
selectionMode,
|
|
200
|
+
indicator: resolvedIndicator,
|
|
201
|
+
selected,
|
|
202
|
+
expanded,
|
|
203
|
+
focusedValue,
|
|
204
|
+
registerItem,
|
|
205
|
+
registerLabel,
|
|
206
|
+
getVisibleItems,
|
|
207
|
+
getItemFromTarget,
|
|
208
|
+
getLabel,
|
|
209
|
+
getItem,
|
|
210
|
+
select,
|
|
211
|
+
toggleExpanded,
|
|
212
|
+
setFocusedValue
|
|
213
|
+
};
|
|
214
|
+
const rootStyle = style;
|
|
215
|
+
const sliding = resolvedIndicator === "slide";
|
|
216
|
+
const list = /* @__PURE__ */ jsx("ul", {
|
|
217
|
+
"data-control-ui": "tree",
|
|
218
|
+
"data-control-family": "tree",
|
|
219
|
+
"data-indicator": resolvedIndicator,
|
|
220
|
+
"data-slot": "root",
|
|
221
|
+
role: "tree",
|
|
222
|
+
"aria-multiselectable": selectionMode === "multiple" || void 0,
|
|
223
|
+
className: cn("flex flex-col", sliding ? void 0 : className),
|
|
224
|
+
style: sliding ? void 0 : rootStyle,
|
|
225
|
+
onKeyDown: (event) => {
|
|
226
|
+
onKeyDown?.(event);
|
|
227
|
+
handleTreeKeyDown(event, contextValue, typeahead);
|
|
228
|
+
},
|
|
229
|
+
onFocusCapture: (event) => {
|
|
230
|
+
onFocusCapture?.(event);
|
|
231
|
+
if (event.target instanceof HTMLElement) {
|
|
232
|
+
const focused = contextValue.getItemFromTarget(event.target, event.currentTarget);
|
|
233
|
+
if (focused) setFocusedValue(focused.value);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
...props,
|
|
237
|
+
children
|
|
238
|
+
});
|
|
239
|
+
return /* @__PURE__ */ jsx(TreeContext.Provider, {
|
|
240
|
+
value: contextValue,
|
|
241
|
+
children: sliding ? /* @__PURE__ */ jsxs("div", {
|
|
242
|
+
"data-control-ui": "tree",
|
|
243
|
+
"data-control-family": "tree",
|
|
244
|
+
"data-slot": "track",
|
|
245
|
+
"data-indicator": resolvedIndicator,
|
|
246
|
+
className: cn("relative isolate", className),
|
|
247
|
+
style: rootStyle,
|
|
248
|
+
children: [/* @__PURE__ */ jsx(Suspense, {
|
|
249
|
+
fallback: null,
|
|
250
|
+
children: /* @__PURE__ */ jsx(TrackHighlight, {
|
|
251
|
+
itemSelector: "[data-control-ui=tree][data-slot=item-trigger]",
|
|
252
|
+
activeSelector: "[data-control-ui=tree][data-slot=item-trigger][data-selected]"
|
|
253
|
+
})
|
|
254
|
+
}), list]
|
|
255
|
+
}) : list
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
function TreeItem({ value, disabled = false, label, className, style, children, ref, ...props }) {
|
|
259
|
+
const tree = useTree();
|
|
260
|
+
const level = (useContext(TreeItemContext)?.level ?? 0) + 1;
|
|
261
|
+
const expandable = Children.toArray(children).some((child) => isValidElement(child) && child.type === TreeItemContent);
|
|
262
|
+
const expanded = expandable && tree.expanded.has(value);
|
|
263
|
+
const selected = tree.selected.has(value);
|
|
264
|
+
const itemContext = {
|
|
265
|
+
value,
|
|
266
|
+
level,
|
|
267
|
+
disabled,
|
|
268
|
+
expandable
|
|
269
|
+
};
|
|
270
|
+
const itemRef = (node) => {
|
|
271
|
+
const itemNode = node instanceof HTMLLIElement ? node : null;
|
|
272
|
+
const refCleanup = setRef(ref, itemNode);
|
|
273
|
+
if (!itemNode) return;
|
|
274
|
+
const unregister = tree.registerItem({
|
|
275
|
+
value,
|
|
276
|
+
node: itemNode,
|
|
277
|
+
level,
|
|
278
|
+
disabled,
|
|
279
|
+
expandable,
|
|
280
|
+
label
|
|
281
|
+
});
|
|
282
|
+
return () => {
|
|
283
|
+
unregister();
|
|
284
|
+
if (typeof refCleanup === "function") refCleanup();
|
|
285
|
+
else setRef(ref, null);
|
|
286
|
+
};
|
|
287
|
+
};
|
|
288
|
+
const baseClass = cn("list-none", className);
|
|
289
|
+
const itemStyle = {
|
|
290
|
+
"--_tree-level": level,
|
|
291
|
+
...style
|
|
292
|
+
};
|
|
293
|
+
const shared = {
|
|
294
|
+
...props,
|
|
295
|
+
"data-control-ui": "tree",
|
|
296
|
+
"data-control-family": "tree",
|
|
297
|
+
"data-slot": "item",
|
|
298
|
+
"data-value": value,
|
|
299
|
+
"data-label": label,
|
|
300
|
+
"data-selected": selected || void 0,
|
|
301
|
+
"data-disabled": disabled || void 0,
|
|
302
|
+
role: "treeitem",
|
|
303
|
+
"aria-level": level,
|
|
304
|
+
"aria-selected": tree.selectionMode === "none" ? void 0 : selected,
|
|
305
|
+
"aria-disabled": disabled || void 0,
|
|
306
|
+
tabIndex: tree.focusedValue === value ? 0 : -1,
|
|
307
|
+
style: itemStyle
|
|
308
|
+
};
|
|
309
|
+
if (!expandable) return /* @__PURE__ */ jsx(TreeItemContext.Provider, {
|
|
310
|
+
value: itemContext,
|
|
311
|
+
children: /* @__PURE__ */ jsx("li", {
|
|
312
|
+
ref: itemRef,
|
|
313
|
+
...shared,
|
|
314
|
+
className: baseClass,
|
|
315
|
+
children
|
|
316
|
+
})
|
|
317
|
+
});
|
|
318
|
+
return /* @__PURE__ */ jsx(TreeItemContext.Provider, {
|
|
319
|
+
value: itemContext,
|
|
320
|
+
children: /* @__PURE__ */ jsx(Collapsible.Root, {
|
|
321
|
+
ref: itemRef,
|
|
322
|
+
open: expanded,
|
|
323
|
+
onOpenChange: (open) => tree.toggleExpanded(value, open),
|
|
324
|
+
render: (renderProps) => /* @__PURE__ */ jsx("li", {
|
|
325
|
+
...renderProps,
|
|
326
|
+
...shared,
|
|
327
|
+
role: "treeitem",
|
|
328
|
+
"aria-expanded": expanded,
|
|
329
|
+
tabIndex: tree.focusedValue === value ? 0 : -1,
|
|
330
|
+
"data-state": expanded ? "open" : "closed",
|
|
331
|
+
className: cn(renderProps.className, baseClass)
|
|
332
|
+
}),
|
|
333
|
+
children
|
|
334
|
+
})
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
function TreeItemTrigger({ className, children, onClick, render, ...props }) {
|
|
338
|
+
const tree = useTree();
|
|
339
|
+
const item = useTreeItem();
|
|
340
|
+
const expanded = item.expandable && tree.expanded.has(item.value);
|
|
341
|
+
const selected = tree.selected.has(item.value);
|
|
342
|
+
return useRender({
|
|
343
|
+
defaultTagName: "div",
|
|
344
|
+
render,
|
|
345
|
+
props: {
|
|
346
|
+
...props,
|
|
347
|
+
"data-control-ui": "tree",
|
|
348
|
+
"data-control-family": "tree",
|
|
349
|
+
"data-slot": "item-trigger",
|
|
350
|
+
"data-state": expanded ? "open" : "closed",
|
|
351
|
+
"data-selected": selected || void 0,
|
|
352
|
+
"aria-disabled": item.disabled || void 0,
|
|
353
|
+
onClick: (event) => {
|
|
354
|
+
onClick?.(event);
|
|
355
|
+
if (item.disabled) return;
|
|
356
|
+
const toggle = tree.selectionMode === "multiple" && (event.metaKey || event.ctrlKey);
|
|
357
|
+
tree.select(item.value, "pointer", toggle);
|
|
358
|
+
if (item.expandable) tree.toggleExpanded(item.value);
|
|
359
|
+
focusItem(tree.getItem(item.value), tree);
|
|
360
|
+
},
|
|
361
|
+
className: cn("flex cursor-pointer select-none items-center", "pl-[calc(var(--\\_tree-level,1)*1.25rem)]", "aria-disabled:pointer-events-none", className),
|
|
362
|
+
children
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
function TreeItemIndicator({ className, children, ...props }) {
|
|
367
|
+
const tree = useTree();
|
|
368
|
+
const item = useTreeItem();
|
|
369
|
+
if (!item.expandable) return /* @__PURE__ */ jsx("span", {
|
|
370
|
+
"data-control-ui": "tree",
|
|
371
|
+
"data-control-family": "tree",
|
|
372
|
+
"data-slot": "item-indicator",
|
|
373
|
+
"aria-hidden": true,
|
|
374
|
+
className: cn("inline-flex shrink-0", className),
|
|
375
|
+
...props
|
|
376
|
+
});
|
|
377
|
+
const expanded = tree.expanded.has(item.value);
|
|
378
|
+
return /* @__PURE__ */ jsx("span", {
|
|
379
|
+
"data-control-ui": "tree",
|
|
380
|
+
"data-control-family": "tree",
|
|
381
|
+
"data-slot": "item-indicator",
|
|
382
|
+
"data-state": expanded ? "open" : "closed",
|
|
383
|
+
"aria-hidden": true,
|
|
384
|
+
className: cn("inline-flex shrink-0 items-center justify-center", className),
|
|
385
|
+
...props,
|
|
386
|
+
children: children ?? /* @__PURE__ */ jsx(ChevronRightIcon, { className: "size-4" })
|
|
387
|
+
});
|
|
388
|
+
}
|
|
389
|
+
function TreeItemLabel({ className, children, render, ref, ...props }) {
|
|
390
|
+
const tree = useTree();
|
|
391
|
+
const item = useTreeItem();
|
|
392
|
+
const labelRef = (node) => {
|
|
393
|
+
const unregister = tree.registerLabel(item.value, node);
|
|
394
|
+
const cleanup = setRef(ref, node);
|
|
395
|
+
if (!node) return;
|
|
396
|
+
return () => {
|
|
397
|
+
unregister?.();
|
|
398
|
+
if (typeof cleanup === "function") cleanup();
|
|
399
|
+
else setRef(ref, null);
|
|
400
|
+
};
|
|
401
|
+
};
|
|
402
|
+
return useRender({
|
|
403
|
+
defaultTagName: "span",
|
|
404
|
+
render,
|
|
405
|
+
props: {
|
|
406
|
+
...props,
|
|
407
|
+
ref: labelRef,
|
|
408
|
+
"data-control-ui": "tree",
|
|
409
|
+
"data-control-family": "tree",
|
|
410
|
+
"data-slot": "item-label",
|
|
411
|
+
className: cn("min-w-0 flex-1 truncate", className),
|
|
412
|
+
children
|
|
413
|
+
}
|
|
414
|
+
});
|
|
415
|
+
}
|
|
416
|
+
function TreeItemContent({ className, children, ...props }) {
|
|
417
|
+
return /* @__PURE__ */ jsx(Collapsible.Panel, {
|
|
418
|
+
...props,
|
|
419
|
+
render: (renderProps, state) => /* @__PURE__ */ jsx("div", {
|
|
420
|
+
...renderProps,
|
|
421
|
+
"data-control-ui": "tree",
|
|
422
|
+
"data-control-family": "tree",
|
|
423
|
+
"data-slot": "item-content",
|
|
424
|
+
"data-state": state.open ? "open" : "closed",
|
|
425
|
+
className: renderProps.className
|
|
426
|
+
}),
|
|
427
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
428
|
+
role: "group",
|
|
429
|
+
"data-control-ui": "tree",
|
|
430
|
+
"data-control-family": "tree",
|
|
431
|
+
"data-slot": "item-group",
|
|
432
|
+
className: cn("flex flex-col", className),
|
|
433
|
+
children
|
|
434
|
+
})
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
//#endregion
|
|
438
|
+
export { Tree, TreeItem, TreeItemContent, TreeItemIndicator, TreeItemLabel, TreeItemTrigger };
|