@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,57 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/blocks/file-explorer-data.d.ts
|
|
3
|
+
type FileExplorerEntryDetail = {
|
|
4
|
+
label: string;
|
|
5
|
+
value: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
type FileExplorerEntry = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
kind: "file" | "folder";
|
|
11
|
+
group?: string;
|
|
12
|
+
icon?: ReactNode;
|
|
13
|
+
description?: ReactNode;
|
|
14
|
+
details?: readonly FileExplorerEntryDetail[];
|
|
15
|
+
preview?: ReactNode;
|
|
16
|
+
children?: readonly FileExplorerEntry[];
|
|
17
|
+
};
|
|
18
|
+
type FileExplorerLocation = {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
group?: string;
|
|
22
|
+
icon?: ReactNode;
|
|
23
|
+
entries: readonly FileExplorerEntry[];
|
|
24
|
+
};
|
|
25
|
+
type FileExplorerColumn = {
|
|
26
|
+
id: string;
|
|
27
|
+
label: string;
|
|
28
|
+
entries: readonly FileExplorerEntry[];
|
|
29
|
+
selectedId?: string;
|
|
30
|
+
};
|
|
31
|
+
type FileExplorerBreadcrumb = {
|
|
32
|
+
id: string;
|
|
33
|
+
label: string;
|
|
34
|
+
path: readonly string[];
|
|
35
|
+
entry?: FileExplorerEntry;
|
|
36
|
+
};
|
|
37
|
+
type FileExplorerResolution = {
|
|
38
|
+
columns: readonly FileExplorerColumn[];
|
|
39
|
+
breadcrumbs: readonly FileExplorerBreadcrumb[];
|
|
40
|
+
selectedEntry?: FileExplorerEntry;
|
|
41
|
+
validPath: readonly string[];
|
|
42
|
+
};
|
|
43
|
+
type FileExplorerSearchResult = {
|
|
44
|
+
entry: FileExplorerEntry;
|
|
45
|
+
path: readonly string[];
|
|
46
|
+
parents: readonly string[];
|
|
47
|
+
};
|
|
48
|
+
declare function resolveFileExplorer(location: FileExplorerLocation, selectedPath: readonly string[]): FileExplorerResolution;
|
|
49
|
+
declare function groupFileExplorerItems<T extends {
|
|
50
|
+
group?: string;
|
|
51
|
+
}>(items: readonly T[]): {
|
|
52
|
+
label: string;
|
|
53
|
+
items: T[];
|
|
54
|
+
}[];
|
|
55
|
+
declare function searchFileExplorer(location: FileExplorerLocation, query: string): readonly FileExplorerSearchResult[];
|
|
56
|
+
//#endregion
|
|
57
|
+
export { FileExplorerBreadcrumb, FileExplorerColumn, FileExplorerEntry, FileExplorerEntryDetail, FileExplorerLocation, FileExplorerResolution, FileExplorerSearchResult, groupFileExplorerItems, resolveFileExplorer, searchFileExplorer };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/blocks/file-explorer-data.ts
|
|
2
|
+
function resolveFileExplorer(location, selectedPath) {
|
|
3
|
+
const columns = [];
|
|
4
|
+
const breadcrumbs = [{
|
|
5
|
+
id: location.id,
|
|
6
|
+
label: location.label,
|
|
7
|
+
path: []
|
|
8
|
+
}];
|
|
9
|
+
const validPath = [];
|
|
10
|
+
let entries = location.entries;
|
|
11
|
+
let selectedEntry;
|
|
12
|
+
let columnLabel = location.label;
|
|
13
|
+
for (let depth = 0;; depth += 1) {
|
|
14
|
+
const selectedId = selectedPath[depth];
|
|
15
|
+
const selected = selectedId ? entries.find((entry) => entry.id === selectedId) : void 0;
|
|
16
|
+
columns.push({
|
|
17
|
+
id: depth === 0 ? `location:${location.id}` : `folder:${validPath[depth - 1]}`,
|
|
18
|
+
label: columnLabel,
|
|
19
|
+
entries,
|
|
20
|
+
selectedId: selected?.id
|
|
21
|
+
});
|
|
22
|
+
if (!selected) break;
|
|
23
|
+
selectedEntry = selected;
|
|
24
|
+
validPath.push(selected.id);
|
|
25
|
+
breadcrumbs.push({
|
|
26
|
+
id: selected.id,
|
|
27
|
+
label: selected.name,
|
|
28
|
+
path: [...validPath],
|
|
29
|
+
entry: selected
|
|
30
|
+
});
|
|
31
|
+
if (selected.kind !== "folder") break;
|
|
32
|
+
entries = selected.children ?? [];
|
|
33
|
+
columnLabel = selected.name;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
columns,
|
|
37
|
+
breadcrumbs,
|
|
38
|
+
selectedEntry,
|
|
39
|
+
validPath
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function groupFileExplorerItems(items) {
|
|
43
|
+
const groups = /* @__PURE__ */ new Map();
|
|
44
|
+
for (const item of items) {
|
|
45
|
+
const label = item.group ?? "";
|
|
46
|
+
const group = groups.get(label) ?? [];
|
|
47
|
+
group.push(item);
|
|
48
|
+
groups.set(label, group);
|
|
49
|
+
}
|
|
50
|
+
return [...groups].map(([label, groupedItems]) => ({
|
|
51
|
+
label,
|
|
52
|
+
items: groupedItems
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
function searchFileExplorer(location, query) {
|
|
56
|
+
const normalizedQuery = query.trim().toLocaleLowerCase();
|
|
57
|
+
if (!normalizedQuery) return [];
|
|
58
|
+
const results = [];
|
|
59
|
+
function visit(entries, path, parents) {
|
|
60
|
+
for (const entry of entries) {
|
|
61
|
+
const entryPath = [...path, entry.id];
|
|
62
|
+
if (entry.name.toLocaleLowerCase().includes(normalizedQuery)) results.push({
|
|
63
|
+
entry,
|
|
64
|
+
path: entryPath,
|
|
65
|
+
parents
|
|
66
|
+
});
|
|
67
|
+
if (entry.kind === "folder" && entry.children) visit(entry.children, entryPath, [...parents, entry.name]);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
visit(location.entries, [], []);
|
|
71
|
+
return results;
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
74
|
+
export { groupFileExplorerItems, resolveFileExplorer, searchFileExplorer };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { FileExplorerBreadcrumb, FileExplorerColumn, FileExplorerEntry, FileExplorerEntryDetail, FileExplorerLocation, FileExplorerResolution, FileExplorerSearchResult } from "./file-explorer-data.js";
|
|
2
|
+
import { ComponentProps, ReactNode } from "react";
|
|
3
|
+
//#region src/blocks/file-explorer.d.ts
|
|
4
|
+
type FileExplorerBlockProps = Omit<ComponentProps<"div">, "children" | "defaultValue" | "onChange"> & {
|
|
5
|
+
locations: readonly FileExplorerLocation[];
|
|
6
|
+
activeLocationId?: string;
|
|
7
|
+
defaultActiveLocationId?: string;
|
|
8
|
+
selectedPath?: readonly string[];
|
|
9
|
+
defaultSelectedPath?: readonly string[];
|
|
10
|
+
searchValue?: string;
|
|
11
|
+
defaultSearchValue?: string;
|
|
12
|
+
onActiveLocationChange?: (location: FileExplorerLocation) => void;
|
|
13
|
+
onSelectedPathChange?: (path: readonly string[], entry: FileExplorerEntry | undefined) => void;
|
|
14
|
+
onSearchValueChange?: (value: string) => void;
|
|
15
|
+
onOpenEntry?: (entry: FileExplorerEntry, path: readonly string[]) => void;
|
|
16
|
+
sidebarTop?: ReactNode;
|
|
17
|
+
sidebarFooter?: ReactNode;
|
|
18
|
+
headerActions?: ReactNode;
|
|
19
|
+
searchPlaceholder?: string | false;
|
|
20
|
+
layout?: "viewport" | "contained";
|
|
21
|
+
};
|
|
22
|
+
declare function FileExplorerBlock({ locations, activeLocationId, defaultActiveLocationId, selectedPath, defaultSelectedPath, searchValue, defaultSearchValue, onActiveLocationChange, onSelectedPathChange, onSearchValueChange, onOpenEntry, sidebarTop, sidebarFooter, headerActions, searchPlaceholder, layout, className, style, ...props }: FileExplorerBlockProps): import("react").JSX.Element;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { FileExplorerBlock, FileExplorerBlockProps, type FileExplorerBreadcrumb, type FileExplorerColumn, type FileExplorerEntry, type FileExplorerEntryDetail, type FileExplorerLocation, type FileExplorerResolution, type FileExplorerSearchResult };
|
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { Button } from "../ui/button.js";
|
|
4
|
+
import { ScrollArea } from "../ui/scroll-area.js";
|
|
5
|
+
import { InputGroup, InputGroupAddon, InputGroupInput } from "../ui/input-group.js";
|
|
6
|
+
import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader, SidebarInset, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarProvider, SidebarRail, SidebarTrigger, useSidebar } from "../ui/sidebar.js";
|
|
7
|
+
import { groupFileExplorerItems, resolveFileExplorer, searchFileExplorer } from "./file-explorer-data.js";
|
|
8
|
+
import { Empty, EmptyDescription, EmptyHeader, EmptyMedia, EmptyTitle } from "../ui/empty.js";
|
|
9
|
+
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "../ui/resizable.js";
|
|
10
|
+
import { useState } from "react";
|
|
11
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
import { ChevronRightIcon, FileIcon, FolderIcon, SearchIcon, XIcon } from "lucide-react";
|
|
13
|
+
//#region src/blocks/file-explorer.tsx
|
|
14
|
+
function FileExplorerBlock({ locations, activeLocationId, defaultActiveLocationId, selectedPath, defaultSelectedPath = [], searchValue, defaultSearchValue = "", onActiveLocationChange, onSelectedPathChange, onSearchValueChange, onOpenEntry, sidebarTop, sidebarFooter, headerActions, searchPlaceholder = "Search files", layout = "viewport", className, style, ...props }) {
|
|
15
|
+
const [internalLocationId, setInternalLocationId] = useState(defaultActiveLocationId ?? locations[0]?.id);
|
|
16
|
+
const [internalSelectedPath, setInternalSelectedPath] = useState(defaultSelectedPath);
|
|
17
|
+
const [internalSearchValue, setInternalSearchValue] = useState(defaultSearchValue);
|
|
18
|
+
const currentLocationId = activeLocationId ?? internalLocationId;
|
|
19
|
+
const currentPath = selectedPath ?? internalSelectedPath;
|
|
20
|
+
const query = searchValue ?? internalSearchValue;
|
|
21
|
+
const activeLocation = locations.find((location) => location.id === currentLocationId) ?? locations[0];
|
|
22
|
+
const contained = layout === "contained";
|
|
23
|
+
function changePath(path, entry) {
|
|
24
|
+
if (selectedPath === void 0) setInternalSelectedPath(path);
|
|
25
|
+
onSelectedPathChange?.(path, entry);
|
|
26
|
+
}
|
|
27
|
+
function changeQuery(value) {
|
|
28
|
+
if (searchValue === void 0) setInternalSearchValue(value);
|
|
29
|
+
onSearchValueChange?.(value);
|
|
30
|
+
}
|
|
31
|
+
function changeLocation(location) {
|
|
32
|
+
if (activeLocationId === void 0) setInternalLocationId(location.id);
|
|
33
|
+
changePath([], void 0);
|
|
34
|
+
changeQuery("");
|
|
35
|
+
onActiveLocationChange?.(location);
|
|
36
|
+
}
|
|
37
|
+
if (!activeLocation) return /* @__PURE__ */ jsx(FileExplorerUnavailable, {
|
|
38
|
+
className,
|
|
39
|
+
style,
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
const resolution = resolveFileExplorer(activeLocation, currentPath);
|
|
43
|
+
const searchResults = searchFileExplorer(activeLocation, query);
|
|
44
|
+
function selectEntry(entry, columnIndex) {
|
|
45
|
+
changePath([...resolution.validPath.slice(0, columnIndex), entry.id], entry);
|
|
46
|
+
}
|
|
47
|
+
function selectSearchResult(result) {
|
|
48
|
+
changePath(result.path, result.entry);
|
|
49
|
+
changeQuery("");
|
|
50
|
+
}
|
|
51
|
+
function openEntry(entry, path) {
|
|
52
|
+
onOpenEntry?.(entry, path);
|
|
53
|
+
}
|
|
54
|
+
const providerStyle = {
|
|
55
|
+
"--sidebar-width": "14.5rem",
|
|
56
|
+
...style
|
|
57
|
+
};
|
|
58
|
+
return /* @__PURE__ */ jsxs(SidebarProvider, {
|
|
59
|
+
className: cn("overflow-hidden bg-background text-foreground", contained ? "relative h-full min-h-0" : "h-svh min-h-svh", className),
|
|
60
|
+
style: providerStyle,
|
|
61
|
+
...props,
|
|
62
|
+
children: [/* @__PURE__ */ jsx(FileExplorerSidebar, {
|
|
63
|
+
locations,
|
|
64
|
+
activeLocationId: activeLocation.id,
|
|
65
|
+
contained,
|
|
66
|
+
sidebarTop,
|
|
67
|
+
sidebarFooter,
|
|
68
|
+
onLocationSelect: changeLocation
|
|
69
|
+
}), /* @__PURE__ */ jsxs(SidebarInset, {
|
|
70
|
+
className: "h-full min-h-0 min-w-0 overflow-hidden",
|
|
71
|
+
children: [
|
|
72
|
+
/* @__PURE__ */ jsx(FileExplorerHeader, {
|
|
73
|
+
location: activeLocation,
|
|
74
|
+
breadcrumbs: resolution.breadcrumbs,
|
|
75
|
+
query,
|
|
76
|
+
searchPlaceholder,
|
|
77
|
+
canGoBack: resolution.validPath.length > 0,
|
|
78
|
+
headerActions,
|
|
79
|
+
onBack: () => changePath(resolution.validPath.slice(0, -1), resolution.breadcrumbs.at(-2)?.entry),
|
|
80
|
+
onBreadcrumbSelect: (breadcrumb) => changePath(breadcrumb.path, breadcrumb.entry),
|
|
81
|
+
onQueryChange: changeQuery
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ jsx("div", {
|
|
84
|
+
className: "min-h-0 flex-1 overflow-hidden",
|
|
85
|
+
children: query.trim() ? /* @__PURE__ */ jsx(FileExplorerSearchResults, {
|
|
86
|
+
query,
|
|
87
|
+
results: searchResults,
|
|
88
|
+
onSelect: selectSearchResult,
|
|
89
|
+
onOpen: openEntry
|
|
90
|
+
}) : /* @__PURE__ */ jsx(FileExplorerColumns, {
|
|
91
|
+
columns: resolution.columns,
|
|
92
|
+
selectedEntry: resolution.selectedEntry,
|
|
93
|
+
selectedPath: resolution.validPath,
|
|
94
|
+
onSelect: selectEntry,
|
|
95
|
+
onOpen: openEntry
|
|
96
|
+
})
|
|
97
|
+
}),
|
|
98
|
+
/* @__PURE__ */ jsx(FileExplorerStatusBar, {
|
|
99
|
+
breadcrumbs: resolution.breadcrumbs,
|
|
100
|
+
selectedEntry: resolution.selectedEntry,
|
|
101
|
+
onBreadcrumbSelect: (breadcrumb) => changePath(breadcrumb.path, breadcrumb.entry)
|
|
102
|
+
})
|
|
103
|
+
]
|
|
104
|
+
})]
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function FileExplorerUnavailable({ className, ...props }) {
|
|
108
|
+
return /* @__PURE__ */ jsx("div", {
|
|
109
|
+
className: cn("flex min-h-96 items-center justify-center border bg-background", className),
|
|
110
|
+
...props,
|
|
111
|
+
children: /* @__PURE__ */ jsx(Empty, { children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
112
|
+
/* @__PURE__ */ jsx(EmptyMedia, { children: /* @__PURE__ */ jsx(FolderIcon, {}) }),
|
|
113
|
+
/* @__PURE__ */ jsx(EmptyTitle, { children: "No locations" }),
|
|
114
|
+
/* @__PURE__ */ jsx(EmptyDescription, { children: "Add at least one location to populate the file explorer." })
|
|
115
|
+
] }) })
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function FileExplorerSidebar({ locations, activeLocationId, contained, sidebarTop, sidebarFooter, onLocationSelect }) {
|
|
119
|
+
const { setOpenMobile } = useSidebar();
|
|
120
|
+
const groups = groupFileExplorerItems(locations);
|
|
121
|
+
return /* @__PURE__ */ jsxs(Sidebar, {
|
|
122
|
+
collapsible: "offcanvas",
|
|
123
|
+
className: contained ? "absolute! inset-y-0! h-full border-r border-sidebar-border" : void 0,
|
|
124
|
+
children: [
|
|
125
|
+
sidebarTop ? /* @__PURE__ */ jsx(SidebarHeader, {
|
|
126
|
+
className: "min-h-11 justify-center border-b border-sidebar-border px-3",
|
|
127
|
+
children: sidebarTop
|
|
128
|
+
}) : null,
|
|
129
|
+
/* @__PURE__ */ jsx(SidebarContent, { children: groups.map((group) => /* @__PURE__ */ jsxs(SidebarGroup, { children: [group.label ? /* @__PURE__ */ jsx(SidebarGroupLabel, { children: group.label }) : null, /* @__PURE__ */ jsx(SidebarMenu, { children: group.items.map((location) => {
|
|
130
|
+
const isActive = location.id === activeLocationId;
|
|
131
|
+
return /* @__PURE__ */ jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxs(SidebarMenuButton, {
|
|
132
|
+
size: "sm",
|
|
133
|
+
isActive,
|
|
134
|
+
"aria-current": isActive ? "location" : void 0,
|
|
135
|
+
onClick: () => {
|
|
136
|
+
onLocationSelect(location);
|
|
137
|
+
setOpenMobile(false);
|
|
138
|
+
},
|
|
139
|
+
children: [location.icon ?? /* @__PURE__ */ jsx(FolderIcon, {}), /* @__PURE__ */ jsx("span", { children: location.label })]
|
|
140
|
+
}) }, location.id);
|
|
141
|
+
}) })] }, group.label || "locations")) }),
|
|
142
|
+
sidebarFooter ? /* @__PURE__ */ jsx(SidebarFooter, {
|
|
143
|
+
className: "border-t border-sidebar-border",
|
|
144
|
+
children: sidebarFooter
|
|
145
|
+
}) : null,
|
|
146
|
+
/* @__PURE__ */ jsx(SidebarRail, {})
|
|
147
|
+
]
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
function FileExplorerHeader({ location, breadcrumbs, query, searchPlaceholder, canGoBack, headerActions, onBack, onBreadcrumbSelect, onQueryChange }) {
|
|
151
|
+
return /* @__PURE__ */ jsxs("header", {
|
|
152
|
+
className: "shrink-0 border-b border-border/70 bg-card/35",
|
|
153
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
154
|
+
className: "flex h-12 items-center gap-2 px-3",
|
|
155
|
+
children: [
|
|
156
|
+
/* @__PURE__ */ jsx(SidebarTrigger, { size: "xs" }),
|
|
157
|
+
/* @__PURE__ */ jsx(Button, {
|
|
158
|
+
variant: "ghost",
|
|
159
|
+
size: "xs",
|
|
160
|
+
disabled: !canGoBack,
|
|
161
|
+
"aria-label": "Go back",
|
|
162
|
+
onClick: onBack,
|
|
163
|
+
children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "size-4 rotate-180" })
|
|
164
|
+
}),
|
|
165
|
+
/* @__PURE__ */ jsx("h1", {
|
|
166
|
+
className: "min-w-0 flex-1 truncate text-label font-semibold",
|
|
167
|
+
children: location.label
|
|
168
|
+
}),
|
|
169
|
+
headerActions ? /* @__PURE__ */ jsx("div", {
|
|
170
|
+
className: "hidden shrink-0 items-center gap-1 sm:flex",
|
|
171
|
+
children: headerActions
|
|
172
|
+
}) : null,
|
|
173
|
+
searchPlaceholder ? /* @__PURE__ */ jsxs(InputGroup, {
|
|
174
|
+
size: "sm",
|
|
175
|
+
className: "w-36 bg-background/60 md:w-48",
|
|
176
|
+
children: [
|
|
177
|
+
/* @__PURE__ */ jsx(InputGroupAddon, {
|
|
178
|
+
className: "pl-2",
|
|
179
|
+
children: /* @__PURE__ */ jsx(SearchIcon, {
|
|
180
|
+
className: "size-3.5",
|
|
181
|
+
"aria-hidden": "true"
|
|
182
|
+
})
|
|
183
|
+
}),
|
|
184
|
+
/* @__PURE__ */ jsx(InputGroupInput, {
|
|
185
|
+
type: "search",
|
|
186
|
+
"aria-label": searchPlaceholder,
|
|
187
|
+
placeholder: searchPlaceholder,
|
|
188
|
+
value: query,
|
|
189
|
+
onChange: (event) => onQueryChange(event.currentTarget.value)
|
|
190
|
+
}),
|
|
191
|
+
query ? /* @__PURE__ */ jsx(Button, {
|
|
192
|
+
variant: "ghost",
|
|
193
|
+
size: "xs",
|
|
194
|
+
iconOnly: true,
|
|
195
|
+
className: "mr-1",
|
|
196
|
+
"aria-label": "Clear search",
|
|
197
|
+
onClick: () => onQueryChange(""),
|
|
198
|
+
children: /* @__PURE__ */ jsx(XIcon, { className: "size-3.5" })
|
|
199
|
+
}) : null
|
|
200
|
+
]
|
|
201
|
+
}) : null
|
|
202
|
+
]
|
|
203
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
204
|
+
className: "px-3 pb-2",
|
|
205
|
+
children: /* @__PURE__ */ jsx(FileExplorerBreadcrumbs, {
|
|
206
|
+
breadcrumbs,
|
|
207
|
+
onSelect: onBreadcrumbSelect,
|
|
208
|
+
variant: "address"
|
|
209
|
+
})
|
|
210
|
+
})]
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
function FileExplorerColumns({ columns, selectedEntry, selectedPath, onSelect, onOpen }) {
|
|
214
|
+
const paneCount = columns.length + 1;
|
|
215
|
+
const columnSize = `${Math.max(18, Math.floor(68 / paneCount))}%`;
|
|
216
|
+
return /* @__PURE__ */ jsxs(ResizablePanelGroup, {
|
|
217
|
+
orientation: "horizontal",
|
|
218
|
+
className: "rounded-none border-0 bg-card shadow-none",
|
|
219
|
+
children: [columns.map((column, columnIndex) => /* @__PURE__ */ jsx(FileExplorerPanel, {
|
|
220
|
+
defaultSize: columnSize,
|
|
221
|
+
minSize: "16%",
|
|
222
|
+
children: /* @__PURE__ */ jsx(FileExplorerColumnView, {
|
|
223
|
+
column,
|
|
224
|
+
columnIndex,
|
|
225
|
+
onSelect,
|
|
226
|
+
onOpen: (entry) => onOpen(entry, [...selectedPath.slice(0, columnIndex), entry.id])
|
|
227
|
+
})
|
|
228
|
+
}, column.id)), /* @__PURE__ */ jsx(ResizablePanel, {
|
|
229
|
+
defaultSize: "32%",
|
|
230
|
+
minSize: "20%",
|
|
231
|
+
children: /* @__PURE__ */ jsx(FileExplorerPreview, { entry: selectedEntry })
|
|
232
|
+
})]
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
function FileExplorerPanel({ children, ...props }) {
|
|
236
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(ResizablePanel, {
|
|
237
|
+
...props,
|
|
238
|
+
children
|
|
239
|
+
}), /* @__PURE__ */ jsx(ResizableHandle, {})] });
|
|
240
|
+
}
|
|
241
|
+
function FileExplorerColumnView({ column, columnIndex, onSelect, onOpen }) {
|
|
242
|
+
const groups = groupFileExplorerItems(column.entries);
|
|
243
|
+
if (column.entries.length === 0) return /* @__PURE__ */ jsx(Empty, {
|
|
244
|
+
className: "h-full rounded-none",
|
|
245
|
+
children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
246
|
+
/* @__PURE__ */ jsx(EmptyMedia, { children: /* @__PURE__ */ jsx(FolderIcon, {}) }),
|
|
247
|
+
/* @__PURE__ */ jsx(EmptyTitle, { children: "Empty folder" }),
|
|
248
|
+
/* @__PURE__ */ jsxs(EmptyDescription, { children: [column.label, " has no files yet."] })
|
|
249
|
+
] })
|
|
250
|
+
});
|
|
251
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
252
|
+
className: "h-full",
|
|
253
|
+
lockAxis: "x",
|
|
254
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
255
|
+
className: "grid gap-4 p-2",
|
|
256
|
+
children: groups.map((group) => /* @__PURE__ */ jsxs("section", {
|
|
257
|
+
className: "min-w-0",
|
|
258
|
+
children: [group.label ? /* @__PURE__ */ jsx("h2", {
|
|
259
|
+
className: "mb-1 px-2 text-caption font-semibold text-muted-foreground",
|
|
260
|
+
children: group.label
|
|
261
|
+
}) : null, /* @__PURE__ */ jsx("div", {
|
|
262
|
+
className: "grid gap-0.5",
|
|
263
|
+
children: group.items.map((entry) => {
|
|
264
|
+
const isSelected = entry.id === column.selectedId;
|
|
265
|
+
return /* @__PURE__ */ jsxs(Button, {
|
|
266
|
+
variant: "quiet",
|
|
267
|
+
size: "sm",
|
|
268
|
+
active: isSelected,
|
|
269
|
+
"aria-current": isSelected ? "page" : void 0,
|
|
270
|
+
className: "w-full justify-start gap-2 px-2 text-left",
|
|
271
|
+
title: entry.name,
|
|
272
|
+
onClick: () => onSelect(entry, columnIndex),
|
|
273
|
+
onDoubleClick: () => onOpen(entry),
|
|
274
|
+
children: [
|
|
275
|
+
/* @__PURE__ */ jsx("span", {
|
|
276
|
+
className: "flex size-4 shrink-0 items-center justify-center text-[oklch(0.72_0.14_235)] [&>svg]:size-4",
|
|
277
|
+
children: entry.icon ?? (entry.kind === "folder" ? /* @__PURE__ */ jsx(FolderIcon, {}) : /* @__PURE__ */ jsx(FileIcon, { className: "text-muted-foreground" }))
|
|
278
|
+
}),
|
|
279
|
+
/* @__PURE__ */ jsx("span", {
|
|
280
|
+
className: "min-w-0 flex-1 truncate",
|
|
281
|
+
children: entry.name
|
|
282
|
+
}),
|
|
283
|
+
entry.kind === "folder" ? /* @__PURE__ */ jsx(ChevronRightIcon, { className: "size-3.5 shrink-0 text-muted-foreground" }) : null
|
|
284
|
+
]
|
|
285
|
+
}, entry.id);
|
|
286
|
+
})
|
|
287
|
+
})]
|
|
288
|
+
}, group.label || "files"))
|
|
289
|
+
})
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
function FileExplorerPreview({ entry }) {
|
|
293
|
+
if (!entry) return /* @__PURE__ */ jsx(Empty, {
|
|
294
|
+
className: "h-full rounded-none bg-background/45",
|
|
295
|
+
children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
296
|
+
/* @__PURE__ */ jsx(EmptyMedia, { children: /* @__PURE__ */ jsx(FileIcon, {}) }),
|
|
297
|
+
/* @__PURE__ */ jsx(EmptyTitle, { children: "Select an item" }),
|
|
298
|
+
/* @__PURE__ */ jsx(EmptyDescription, { children: "Choose a file or folder to inspect its details." })
|
|
299
|
+
] })
|
|
300
|
+
});
|
|
301
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
302
|
+
className: "h-full bg-background/45",
|
|
303
|
+
lockAxis: "x",
|
|
304
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
305
|
+
className: "mx-auto flex w-full max-w-lg flex-col items-center px-6 py-10 text-center",
|
|
306
|
+
children: [
|
|
307
|
+
/* @__PURE__ */ jsx("div", {
|
|
308
|
+
className: "flex size-16 items-center justify-center rounded-[var(--radius-panel)] bg-foreground/6 text-[oklch(0.72_0.14_235)] shadow-sm ring-1 ring-foreground/8 [&>svg]:size-8",
|
|
309
|
+
children: entry.icon ?? (entry.kind === "folder" ? /* @__PURE__ */ jsx(FolderIcon, {}) : /* @__PURE__ */ jsx(FileIcon, { className: "text-muted-foreground" }))
|
|
310
|
+
}),
|
|
311
|
+
/* @__PURE__ */ jsx("h2", {
|
|
312
|
+
className: "mt-4 max-w-full truncate text-base font-semibold",
|
|
313
|
+
children: entry.name
|
|
314
|
+
}),
|
|
315
|
+
entry.description ? /* @__PURE__ */ jsx("div", {
|
|
316
|
+
className: "mt-1 text-caption leading-5 text-muted-foreground",
|
|
317
|
+
children: entry.description
|
|
318
|
+
}) : null,
|
|
319
|
+
entry.details && entry.details.length > 0 ? /* @__PURE__ */ jsx("dl", {
|
|
320
|
+
className: "mt-6 grid w-full grid-cols-[auto_1fr] gap-x-4 gap-y-2 border-t border-border/70 pt-4 text-left text-caption",
|
|
321
|
+
children: entry.details.map((detail) => /* @__PURE__ */ jsxs("div", {
|
|
322
|
+
className: "contents",
|
|
323
|
+
children: [/* @__PURE__ */ jsx("dt", {
|
|
324
|
+
className: "text-muted-foreground",
|
|
325
|
+
children: detail.label
|
|
326
|
+
}), /* @__PURE__ */ jsx("dd", {
|
|
327
|
+
className: "min-w-0 truncate text-right text-foreground",
|
|
328
|
+
children: detail.value
|
|
329
|
+
})]
|
|
330
|
+
}, detail.label))
|
|
331
|
+
}) : null,
|
|
332
|
+
entry.preview ? /* @__PURE__ */ jsx("div", {
|
|
333
|
+
className: "mt-6 w-full text-left",
|
|
334
|
+
children: entry.preview
|
|
335
|
+
}) : null
|
|
336
|
+
]
|
|
337
|
+
})
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
function FileExplorerSearchResults({ query, results, onSelect, onOpen }) {
|
|
341
|
+
if (results.length === 0) return /* @__PURE__ */ jsx(Empty, {
|
|
342
|
+
className: "h-full rounded-none",
|
|
343
|
+
children: /* @__PURE__ */ jsxs(EmptyHeader, { children: [
|
|
344
|
+
/* @__PURE__ */ jsx(EmptyMedia, { children: /* @__PURE__ */ jsx(SearchIcon, {}) }),
|
|
345
|
+
/* @__PURE__ */ jsxs(EmptyTitle, { children: [
|
|
346
|
+
"No results for “",
|
|
347
|
+
query,
|
|
348
|
+
"”"
|
|
349
|
+
] }),
|
|
350
|
+
/* @__PURE__ */ jsx(EmptyDescription, { children: "Try a shorter file or folder name." })
|
|
351
|
+
] })
|
|
352
|
+
});
|
|
353
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
354
|
+
className: "h-full",
|
|
355
|
+
lockAxis: "x",
|
|
356
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
357
|
+
className: "mx-auto grid w-full max-w-3xl gap-1 p-4",
|
|
358
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
359
|
+
className: "mb-2 flex items-center justify-between px-2 text-caption text-muted-foreground",
|
|
360
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
361
|
+
results.length,
|
|
362
|
+
" ",
|
|
363
|
+
results.length === 1 ? "result" : "results"
|
|
364
|
+
] }), /* @__PURE__ */ jsxs("span", { children: ["Search: ", query] })]
|
|
365
|
+
}), results.map((result) => /* @__PURE__ */ jsxs(Button, {
|
|
366
|
+
variant: "quiet",
|
|
367
|
+
size: "lg",
|
|
368
|
+
className: "h-auto w-full justify-start gap-3 px-3 py-2 text-left",
|
|
369
|
+
onClick: () => onSelect(result),
|
|
370
|
+
onDoubleClick: () => onOpen(result.entry, result.path),
|
|
371
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
372
|
+
className: "flex size-8 shrink-0 items-center justify-center rounded-[var(--radius-control)] bg-foreground/6 text-[oklch(0.72_0.14_235)] [&>svg]:size-4",
|
|
373
|
+
children: result.entry.icon ?? (result.entry.kind === "folder" ? /* @__PURE__ */ jsx(FolderIcon, {}) : /* @__PURE__ */ jsx(FileIcon, { className: "text-muted-foreground" }))
|
|
374
|
+
}), /* @__PURE__ */ jsxs("span", {
|
|
375
|
+
className: "min-w-0 flex-1",
|
|
376
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
377
|
+
className: "block truncate text-label text-foreground",
|
|
378
|
+
children: result.entry.name
|
|
379
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
380
|
+
className: "block truncate text-caption text-muted-foreground",
|
|
381
|
+
children: result.parents.join(" / ") || "Top level"
|
|
382
|
+
})]
|
|
383
|
+
})]
|
|
384
|
+
}, result.path.join("/")))]
|
|
385
|
+
})
|
|
386
|
+
});
|
|
387
|
+
}
|
|
388
|
+
function FileExplorerStatusBar({ breadcrumbs, selectedEntry, onBreadcrumbSelect }) {
|
|
389
|
+
return /* @__PURE__ */ jsxs("footer", {
|
|
390
|
+
className: "flex h-8 shrink-0 items-center gap-3 border-t border-border/70 bg-card/45 px-3",
|
|
391
|
+
children: [/* @__PURE__ */ jsx(FileExplorerBreadcrumbs, {
|
|
392
|
+
breadcrumbs,
|
|
393
|
+
onSelect: onBreadcrumbSelect,
|
|
394
|
+
variant: "status"
|
|
395
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
396
|
+
className: "ml-auto shrink-0 text-micro text-muted-foreground",
|
|
397
|
+
children: selectedEntry?.kind === "folder" ? `${selectedEntry.children?.length ?? 0} items` : selectedEntry?.name ?? "No selection"
|
|
398
|
+
})]
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
function FileExplorerBreadcrumbs({ breadcrumbs, onSelect, variant }) {
|
|
402
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
403
|
+
"aria-label": variant === "address" ? "Current folder" : "Selected path",
|
|
404
|
+
className: cn("min-w-0 flex-1 overflow-hidden", variant === "address" && "rounded-[var(--radius-control)] border bg-background/55 px-2 py-1 shadow-inner"),
|
|
405
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
406
|
+
className: cn("flex min-w-0 flex-nowrap items-center gap-1 overflow-hidden text-caption text-muted-foreground", variant === "status" && "text-micro"),
|
|
407
|
+
children: breadcrumbs.map((breadcrumb, index) => {
|
|
408
|
+
const isCurrent = index === breadcrumbs.length - 1;
|
|
409
|
+
return /* @__PURE__ */ jsxs("li", {
|
|
410
|
+
className: "flex min-w-0 items-center gap-1",
|
|
411
|
+
children: [index > 0 ? /* @__PURE__ */ jsx(ChevronRightIcon, {
|
|
412
|
+
className: "size-3 shrink-0",
|
|
413
|
+
"aria-hidden": "true"
|
|
414
|
+
}) : null, /* @__PURE__ */ jsx("button", {
|
|
415
|
+
type: "button",
|
|
416
|
+
"aria-current": isCurrent ? "page" : void 0,
|
|
417
|
+
className: cn("min-w-0 truncate rounded-[var(--radius-popup-item)] px-1 py-0.5 text-muted-foreground transition hover:bg-foreground/6 hover:text-foreground focus-visible:outline-(--focus-ring) focus-visible:outline-offset-(--focus-ring-offset) focus-visible:outline-(length:--focus-ring-width)", isCurrent && "text-foreground"),
|
|
418
|
+
onClick: () => onSelect(breadcrumb),
|
|
419
|
+
children: breadcrumb.label
|
|
420
|
+
})]
|
|
421
|
+
}, `${breadcrumb.id}:${breadcrumb.path.join("/")}`);
|
|
422
|
+
})
|
|
423
|
+
})
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
//#endregion
|
|
427
|
+
export { FileExplorerBlock };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
//#region src/blocks/settings-data.d.ts
|
|
3
|
+
type SettingsControlProps = {
|
|
4
|
+
id: string;
|
|
5
|
+
"aria-labelledby": string;
|
|
6
|
+
"aria-describedby"?: string;
|
|
7
|
+
};
|
|
8
|
+
type SettingDefinition = {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
keywords?: readonly string[];
|
|
13
|
+
renderControl: (props: SettingsControlProps) => ReactNode;
|
|
14
|
+
};
|
|
15
|
+
type SettingsSectionDefinition = {
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
settings: readonly SettingDefinition[];
|
|
19
|
+
};
|
|
20
|
+
type SettingsPageDefinition = {
|
|
21
|
+
id: string;
|
|
22
|
+
title: string;
|
|
23
|
+
icon?: ReactNode;
|
|
24
|
+
sections: readonly SettingsSectionDefinition[];
|
|
25
|
+
};
|
|
26
|
+
type SettingsSearchResult = {
|
|
27
|
+
page: SettingsPageDefinition;
|
|
28
|
+
section: SettingsSectionDefinition;
|
|
29
|
+
setting: SettingDefinition;
|
|
30
|
+
score: number;
|
|
31
|
+
order: number;
|
|
32
|
+
};
|
|
33
|
+
declare function normalizeSettingsSearchText(value: string): string;
|
|
34
|
+
declare function searchSettings(pages: readonly SettingsPageDefinition[], query: string): SettingsSearchResult[];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { SettingDefinition, SettingsControlProps, SettingsPageDefinition, SettingsSearchResult, SettingsSectionDefinition, normalizeSettingsSearchText, searchSettings };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/blocks/settings-data.ts
|
|
2
|
+
function normalizeSettingsSearchText(value) {
|
|
3
|
+
return value.normalize("NFKD").replace(/\p{Diacritic}/gu, "").toLocaleLowerCase().trim().replace(/\s+/g, " ");
|
|
4
|
+
}
|
|
5
|
+
function titleSearchScore(title, query) {
|
|
6
|
+
if (title === query) return 1e3;
|
|
7
|
+
if (title.startsWith(query)) return 800;
|
|
8
|
+
if (title.includes(query)) return 600;
|
|
9
|
+
return 0;
|
|
10
|
+
}
|
|
11
|
+
function settingSearchScore(fields, query, tokens) {
|
|
12
|
+
const { title, description, keywords, pageTitle, sectionTitle } = fields;
|
|
13
|
+
const searchableText = [
|
|
14
|
+
title,
|
|
15
|
+
description,
|
|
16
|
+
keywords,
|
|
17
|
+
pageTitle,
|
|
18
|
+
sectionTitle
|
|
19
|
+
].join(" ");
|
|
20
|
+
for (const token of tokens) if (!searchableText.includes(token)) return void 0;
|
|
21
|
+
let score = titleSearchScore(title, query);
|
|
22
|
+
if (keywords.includes(query)) score += 300;
|
|
23
|
+
if (sectionTitle.includes(query)) score += 180;
|
|
24
|
+
if (pageTitle.includes(query)) score += 160;
|
|
25
|
+
if (description.includes(query)) score += 100;
|
|
26
|
+
for (const token of tokens) score += (title.indexOf(token) >= 0 ? 20 : 0) + (keywords.indexOf(token) >= 0 ? 10 : 0);
|
|
27
|
+
return score;
|
|
28
|
+
}
|
|
29
|
+
function searchSettings(pages, query) {
|
|
30
|
+
const normalizedQuery = normalizeSettingsSearchText(query);
|
|
31
|
+
if (!normalizedQuery) return [];
|
|
32
|
+
const tokens = new Set(normalizedQuery.split(" "));
|
|
33
|
+
let order = 0;
|
|
34
|
+
const results = [];
|
|
35
|
+
for (const page of pages) {
|
|
36
|
+
const pageTitle = normalizeSettingsSearchText(page.title);
|
|
37
|
+
for (const section of page.sections) {
|
|
38
|
+
const sectionTitle = normalizeSettingsSearchText(section.title);
|
|
39
|
+
for (const setting of section.settings) {
|
|
40
|
+
const title = normalizeSettingsSearchText(setting.title);
|
|
41
|
+
const description = normalizeSettingsSearchText(setting.description ?? "");
|
|
42
|
+
const keywords = normalizeSettingsSearchText(setting.keywords?.join(" ") ?? "");
|
|
43
|
+
const currentOrder = order;
|
|
44
|
+
order += 1;
|
|
45
|
+
const score = settingSearchScore({
|
|
46
|
+
title,
|
|
47
|
+
description,
|
|
48
|
+
keywords,
|
|
49
|
+
pageTitle,
|
|
50
|
+
sectionTitle
|
|
51
|
+
}, normalizedQuery, tokens);
|
|
52
|
+
if (score === void 0) continue;
|
|
53
|
+
results.push({
|
|
54
|
+
page,
|
|
55
|
+
section,
|
|
56
|
+
setting,
|
|
57
|
+
score,
|
|
58
|
+
order: currentOrder
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return results.sort((a, b) => b.score - a.score || a.order - b.order);
|
|
64
|
+
}
|
|
65
|
+
//#endregion
|
|
66
|
+
export { normalizeSettingsSearchText, searchSettings };
|