@peers-app/peers-ui 0.0.14
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/.github/README.md +52 -0
- package/.github/workflows/publish.yml +45 -0
- package/babel.config.js +7 -0
- package/dist/app.d.ts +9 -0
- package/dist/app.js +54 -0
- package/dist/command-palette/command-palette-ui.d.ts +2 -0
- package/dist/command-palette/command-palette-ui.js +192 -0
- package/dist/command-palette/command-palette.d.ts +23 -0
- package/dist/command-palette/command-palette.js +371 -0
- package/dist/components/checkbox.d.ts +7 -0
- package/dist/components/checkbox.js +20 -0
- package/dist/components/group-switcher.d.ts +6 -0
- package/dist/components/group-switcher.js +301 -0
- package/dist/components/input-date.d.ts +7 -0
- package/dist/components/input-date.js +19 -0
- package/dist/components/input-datetime.d.ts +7 -0
- package/dist/components/input-datetime.js +35 -0
- package/dist/components/input-number.d.ts +9 -0
- package/dist/components/input-number.js +87 -0
- package/dist/components/input.d.ts +7 -0
- package/dist/components/input.js +20 -0
- package/dist/components/io-schema-values.d.ts +15 -0
- package/dist/components/io-schema-values.js +105 -0
- package/dist/components/io-schema.d.ts +13 -0
- package/dist/components/io-schema.js +163 -0
- package/dist/components/lazy-list.d.ts +13 -0
- package/dist/components/lazy-list.js +91 -0
- package/dist/components/lazy-sortable-list.d.ts +29 -0
- package/dist/components/lazy-sortable-list.js +12 -0
- package/dist/components/left-bar.d.ts +3 -0
- package/dist/components/left-bar.js +130 -0
- package/dist/components/list-screen.d.ts +16 -0
- package/dist/components/list-screen.js +100 -0
- package/dist/components/loading-indicator.d.ts +2 -0
- package/dist/components/loading-indicator.js +12 -0
- package/dist/components/main-content-container.d.ts +2 -0
- package/dist/components/main-content-container.js +90 -0
- package/dist/components/markdown-editor/autolink-plugin.d.ts +2 -0
- package/dist/components/markdown-editor/autolink-plugin.js +29 -0
- package/dist/components/markdown-editor/editor-inline.d.ts +3 -0
- package/dist/components/markdown-editor/editor-inline.js +13 -0
- package/dist/components/markdown-editor/editor.d.ts +18 -0
- package/dist/components/markdown-editor/editor.js +143 -0
- package/dist/components/markdown-editor/markdown-plugin.d.ts +9 -0
- package/dist/components/markdown-editor/markdown-plugin.js +194 -0
- package/dist/components/markdown-editor/mention-node.d.ts +21 -0
- package/dist/components/markdown-editor/mention-node.js +160 -0
- package/dist/components/markdown-editor/mentions-plugin.d.ts +7 -0
- package/dist/components/markdown-editor/mentions-plugin.js +268 -0
- package/dist/components/markdown-editor/theme.d.ts +46 -0
- package/dist/components/markdown-editor/theme.js +48 -0
- package/dist/components/markdown-editor/toolbar.d.ts +10 -0
- package/dist/components/markdown-editor/toolbar.js +112 -0
- package/dist/components/markdown-with-mentions.d.ts +4 -0
- package/dist/components/markdown-with-mentions.js +140 -0
- package/dist/components/message-logs/message-logs.d.ts +6 -0
- package/dist/components/message-logs/message-logs.js +307 -0
- package/dist/components/messages/avatar.d.ts +10 -0
- package/dist/components/messages/avatar.js +65 -0
- package/dist/components/messages/channel-message-list.d.ts +14 -0
- package/dist/components/messages/channel-message-list.js +158 -0
- package/dist/components/messages/channel-view.d.ts +6 -0
- package/dist/components/messages/channel-view.js +82 -0
- package/dist/components/messages/message-compose.d.ts +11 -0
- package/dist/components/messages/message-compose.js +152 -0
- package/dist/components/messages/message-display.d.ts +10 -0
- package/dist/components/messages/message-display.js +152 -0
- package/dist/components/messages/thread-message-list.d.ts +11 -0
- package/dist/components/messages/thread-message-list.js +122 -0
- package/dist/components/messages/thread-view.d.ts +6 -0
- package/dist/components/messages/thread-view.js +174 -0
- package/dist/components/off-canvas.d.ts +13 -0
- package/dist/components/off-canvas.js +89 -0
- package/dist/components/router.d.ts +6 -0
- package/dist/components/router.js +240 -0
- package/dist/components/save-button.d.ts +13 -0
- package/dist/components/save-button.js +75 -0
- package/dist/components/sortable-list.d.ts +36 -0
- package/dist/components/sortable-list.js +77 -0
- package/dist/components/tabs.d.ts +11 -0
- package/dist/components/tabs.js +69 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.d.ts +6 -0
- package/dist/components/text-list-editor.tsx/text-list-editor.js +13 -0
- package/dist/components/tooltip.d.ts +11 -0
- package/dist/components/tooltip.js +20 -0
- package/dist/components/top-bar.d.ts +2 -0
- package/dist/components/top-bar.js +51 -0
- package/dist/components/typeahead/mentions-plugin.d.ts +7 -0
- package/dist/components/typeahead/mentions-plugin.js +203 -0
- package/dist/components/typeahead/typeahead-editor.d.ts +15 -0
- package/dist/components/typeahead/typeahead-editor.js +134 -0
- package/dist/components/typeahead/typeahead.d.ts +12 -0
- package/dist/components/typeahead/typeahead.js +94 -0
- package/dist/components/typeahead.d.ts +22 -0
- package/dist/components/typeahead.js +270 -0
- package/dist/globals.d.ts +29 -0
- package/dist/globals.js +148 -0
- package/dist/hooks.d.ts +34 -0
- package/dist/hooks.js +137 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +20 -0
- package/dist/layout-vars.d.ts +6 -0
- package/dist/layout-vars.js +10 -0
- package/dist/mention-configs.d.ts +18 -0
- package/dist/mention-configs.js +149 -0
- package/dist/screens/assistants/assistant-config.d.ts +5 -0
- package/dist/screens/assistants/assistant-config.js +52 -0
- package/dist/screens/assistants/assistant-details.d.ts +4 -0
- package/dist/screens/assistants/assistant-details.js +85 -0
- package/dist/screens/assistants/assistant-info.d.ts +6 -0
- package/dist/screens/assistants/assistant-info.js +28 -0
- package/dist/screens/assistants/assistant-list.d.ts +2 -0
- package/dist/screens/assistants/assistant-list.js +114 -0
- package/dist/screens/assistants/assistant-tools.d.ts +5 -0
- package/dist/screens/assistants/assistant-tools.js +38 -0
- package/dist/screens/contacts/contact-details.d.ts +6 -0
- package/dist/screens/contacts/contact-details.js +100 -0
- package/dist/screens/contacts/contact-list.d.ts +2 -0
- package/dist/screens/contacts/contact-list.js +213 -0
- package/dist/screens/contacts/index.d.ts +4 -0
- package/dist/screens/contacts/index.js +21 -0
- package/dist/screens/events/cron.d.ts +3 -0
- package/dist/screens/events/cron.js +77 -0
- package/dist/screens/events/event-details.d.ts +6 -0
- package/dist/screens/events/event-details.js +112 -0
- package/dist/screens/events/event-handlers.d.ts +7 -0
- package/dist/screens/events/event-handlers.js +84 -0
- package/dist/screens/events/event-info.d.ts +5 -0
- package/dist/screens/events/event-info.js +19 -0
- package/dist/screens/events/event-list.d.ts +2 -0
- package/dist/screens/events/event-list.js +107 -0
- package/dist/screens/events/event-schedule.d.ts +5 -0
- package/dist/screens/events/event-schedule.js +124 -0
- package/dist/screens/groups/group-details.d.ts +6 -0
- package/dist/screens/groups/group-details.js +218 -0
- package/dist/screens/groups/group-list.d.ts +2 -0
- package/dist/screens/groups/group-list.js +275 -0
- package/dist/screens/groups/group-members.d.ts +8 -0
- package/dist/screens/groups/group-members.js +315 -0
- package/dist/screens/groups/index.d.ts +6 -0
- package/dist/screens/groups/index.js +23 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-frame-details.bk.js +84 -0
- package/dist/screens/knowledge/knowledge-frame-details.d.ts +8 -0
- package/dist/screens/knowledge/knowledge-frame-details.js +143 -0
- package/dist/screens/knowledge/knowledge-frame-list.d.ts +2 -0
- package/dist/screens/knowledge/knowledge-frame-list.js +45 -0
- package/dist/screens/knowledge/knowledge-value-details.d.ts +6 -0
- package/dist/screens/knowledge/knowledge-value-details.js +150 -0
- package/dist/screens/knowledge/knowledge-value-list-item.d.ts +5 -0
- package/dist/screens/knowledge/knowledge-value-list-item.js +39 -0
- package/dist/screens/knowledge/knowledge-value-list.d.ts +3 -0
- package/dist/screens/knowledge/knowledge-value-list.js +123 -0
- package/dist/screens/packages/package-details.d.ts +6 -0
- package/dist/screens/packages/package-details.js +82 -0
- package/dist/screens/packages/package-info.d.ts +5 -0
- package/dist/screens/packages/package-info.js +42 -0
- package/dist/screens/packages/package-list.d.ts +2 -0
- package/dist/screens/packages/package-list.js +182 -0
- package/dist/screens/packages/package-new-local.d.ts +2 -0
- package/dist/screens/packages/package-new-local.js +82 -0
- package/dist/screens/peer-types/peer-type-details.d.ts +10 -0
- package/dist/screens/peer-types/peer-type-details.js +126 -0
- package/dist/screens/peer-types/peer-type-list.d.ts +2 -0
- package/dist/screens/peer-types/peer-type-list.js +57 -0
- package/dist/screens/predicates/predicate-details.d.ts +6 -0
- package/dist/screens/predicates/predicate-details.js +103 -0
- package/dist/screens/predicates/predicate-list.d.ts +2 -0
- package/dist/screens/predicates/predicate-list.js +46 -0
- package/dist/screens/profile.d.ts +2 -0
- package/dist/screens/profile.js +66 -0
- package/dist/screens/search/global-search.d.ts +2 -0
- package/dist/screens/search/global-search.js +186 -0
- package/dist/screens/settings/color-mode-dropdown.d.ts +6 -0
- package/dist/screens/settings/color-mode-dropdown.js +63 -0
- package/dist/screens/settings/settings-page.d.ts +2 -0
- package/dist/screens/settings/settings-page.js +49 -0
- package/dist/screens/setup-user.d.ts +2 -0
- package/dist/screens/setup-user.js +270 -0
- package/dist/screens/tools/tool-code.d.ts +5 -0
- package/dist/screens/tools/tool-code.js +32 -0
- package/dist/screens/tools/tool-details.d.ts +6 -0
- package/dist/screens/tools/tool-details.js +68 -0
- package/dist/screens/tools/tool-info.d.ts +5 -0
- package/dist/screens/tools/tool-info.js +74 -0
- package/dist/screens/tools/tool-list.d.ts +2 -0
- package/dist/screens/tools/tool-list.js +123 -0
- package/dist/screens/tools/tool-schema.d.ts +5 -0
- package/dist/screens/tools/tool-schema.js +30 -0
- package/dist/screens/tools/tool-test-details.d.ts +4 -0
- package/dist/screens/tools/tool-test-details.js +54 -0
- package/dist/screens/tools/tool-test-list.d.ts +4 -0
- package/dist/screens/tools/tool-test-list.js +82 -0
- package/dist/screens/variables/variable-details.d.ts +6 -0
- package/dist/screens/variables/variable-details.js +140 -0
- package/dist/screens/variables/variable-list.d.ts +2 -0
- package/dist/screens/variables/variable-list.js +58 -0
- package/dist/screens/workflows/workflow-details.d.ts +6 -0
- package/dist/screens/workflows/workflow-details.js +122 -0
- package/dist/screens/workflows/workflow-info.d.ts +5 -0
- package/dist/screens/workflows/workflow-info.js +18 -0
- package/dist/screens/workflows/workflow-instructions.d.ts +5 -0
- package/dist/screens/workflows/workflow-instructions.js +118 -0
- package/dist/screens/workflows/workflow-list.d.ts +2 -0
- package/dist/screens/workflows/workflow-list.js +109 -0
- package/dist/screens/workflows/workflow-subscriptions.d.ts +6 -0
- package/dist/screens/workflows/workflow-subscriptions.js +81 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +31 -0
- package/dist/system-apps/assistants.app.d.ts +2 -0
- package/dist/system-apps/assistants.app.js +8 -0
- package/dist/system-apps/contacts.app.d.ts +2 -0
- package/dist/system-apps/contacts.app.js +9 -0
- package/dist/system-apps/events.app.d.ts +2 -0
- package/dist/system-apps/events.app.js +8 -0
- package/dist/system-apps/groups.app.d.ts +2 -0
- package/dist/system-apps/groups.app.js +9 -0
- package/dist/system-apps/index.d.ts +19 -0
- package/dist/system-apps/index.js +90 -0
- package/dist/system-apps/knowledge-frames.app.d.ts +2 -0
- package/dist/system-apps/knowledge-frames.app.js +9 -0
- package/dist/system-apps/knowledge-values.app.d.ts +2 -0
- package/dist/system-apps/knowledge-values.app.js +9 -0
- package/dist/system-apps/packages.app.d.ts +2 -0
- package/dist/system-apps/packages.app.js +8 -0
- package/dist/system-apps/predicates.app.d.ts +2 -0
- package/dist/system-apps/predicates.app.js +8 -0
- package/dist/system-apps/profile.app.d.ts +2 -0
- package/dist/system-apps/profile.app.js +8 -0
- package/dist/system-apps/search.app.d.ts +2 -0
- package/dist/system-apps/search.app.js +9 -0
- package/dist/system-apps/settings.app.d.ts +2 -0
- package/dist/system-apps/settings.app.js +8 -0
- package/dist/system-apps/threads.app.d.ts +2 -0
- package/dist/system-apps/threads.app.js +8 -0
- package/dist/system-apps/tools.app.d.ts +2 -0
- package/dist/system-apps/tools.app.js +8 -0
- package/dist/system-apps/types.app.d.ts +2 -0
- package/dist/system-apps/types.app.js +8 -0
- package/dist/system-apps/variables.app.d.ts +2 -0
- package/dist/system-apps/variables.app.js +8 -0
- package/dist/system-apps/workflows.app.d.ts +2 -0
- package/dist/system-apps/workflows.app.js +8 -0
- package/dist/tabs-layout/tabs-layout.d.ts +5 -0
- package/dist/tabs-layout/tabs-layout.js +374 -0
- package/dist/tabs-layout/tabs-state.d.ts +26 -0
- package/dist/tabs-layout/tabs-state.js +239 -0
- package/dist/three-bar-layout/left-bar-content.d.ts +7 -0
- package/dist/three-bar-layout/left-bar-content.js +151 -0
- package/dist/three-bar-layout/right-bar-content.d.ts +2 -0
- package/dist/three-bar-layout/right-bar-content.js +64 -0
- package/dist/three-bar-layout/three-bar-layout.d.ts +5 -0
- package/dist/three-bar-layout/three-bar-layout.js +218 -0
- package/dist/ui-defaults/index.d.ts +2 -0
- package/dist/ui-defaults/index.js +4 -0
- package/dist/ui-defaults/list-screen.d.ts +6 -0
- package/dist/ui-defaults/list-screen.js +74 -0
- package/dist/ui-defaults/notes-editor.d.ts +7 -0
- package/dist/ui-defaults/notes-editor.js +41 -0
- package/dist/ui-router/routes-loader.d.ts +25 -0
- package/dist/ui-router/routes-loader.js +97 -0
- package/dist/ui-router/ui-loader.d.ts +18 -0
- package/dist/ui-router/ui-loader.js +481 -0
- package/dist/utils.d.ts +9 -0
- package/dist/utils.js +250 -0
- package/docs/conversation-tab.md +201 -0
- package/docs/getting-started.md +284 -0
- package/docs/knowledge.md +187 -0
- package/docs/tabs-ui.md +696 -0
- package/docs/user-contacts-ui.md +384 -0
- package/jest.config.js +25 -0
- package/package.json +109 -0
- package/src/app.tsx +59 -0
- package/src/command-palette/command-palette-ui.tsx +264 -0
- package/src/command-palette/command-palette.ts +364 -0
- package/src/components/checkbox.tsx +22 -0
- package/src/components/group-switcher.tsx +469 -0
- package/src/components/input-date.tsx +28 -0
- package/src/components/input-datetime.tsx +41 -0
- package/src/components/input-number.tsx +67 -0
- package/src/components/input.tsx +22 -0
- package/src/components/io-schema-values.tsx +122 -0
- package/src/components/io-schema.tsx +234 -0
- package/src/components/lazy-list.tsx +98 -0
- package/src/components/lazy-sortable-list.tsx +51 -0
- package/src/components/left-bar.tsx +264 -0
- package/src/components/list-screen.tsx +105 -0
- package/src/components/loading-indicator.tsx +9 -0
- package/src/components/main-content-container.tsx +76 -0
- package/src/components/markdown-editor/autolink-plugin.tsx +36 -0
- package/src/components/markdown-editor/editor-inline.tsx +10 -0
- package/src/components/markdown-editor/editor.tsx +152 -0
- package/src/components/markdown-editor/markdown-plugin.tsx +224 -0
- package/src/components/markdown-editor/mention-node.ts +199 -0
- package/src/components/markdown-editor/mentions-plugin.tsx +356 -0
- package/src/components/markdown-editor/theme.ts +47 -0
- package/src/components/markdown-editor/toolbar.tsx +263 -0
- package/src/components/markdown-with-mentions.tsx +183 -0
- package/src/components/message-logs/message-logs.tsx +406 -0
- package/src/components/messages/avatar.tsx +95 -0
- package/src/components/messages/channel-message-list.tsx +177 -0
- package/src/components/messages/channel-view.tsx +74 -0
- package/src/components/messages/message-compose.tsx +162 -0
- package/src/components/messages/message-display.tsx +217 -0
- package/src/components/messages/thread-message-list.tsx +126 -0
- package/src/components/messages/thread-view.tsx +214 -0
- package/src/components/off-canvas.tsx +83 -0
- package/src/components/router.tsx +224 -0
- package/src/components/save-button.tsx +109 -0
- package/src/components/sortable-list.tsx +102 -0
- package/src/components/tabs.tsx +70 -0
- package/src/components/text-list-editor.tsx/text-list-editor.tsx +13 -0
- package/src/components/tooltip.tsx +50 -0
- package/src/components/top-bar.tsx +119 -0
- package/src/components/typeahead/mentions-plugin.tsx +265 -0
- package/src/components/typeahead/typeahead-editor.tsx +140 -0
- package/src/components/typeahead/typeahead.tsx +77 -0
- package/src/components/typeahead.tsx +359 -0
- package/src/globals.tsx +162 -0
- package/src/hooks.ts +144 -0
- package/src/index.tsx +8 -0
- package/src/layout-vars.ts +8 -0
- package/src/mention-configs.ts +166 -0
- package/src/screens/assistants/assistant-config.tsx +80 -0
- package/src/screens/assistants/assistant-details.tsx +77 -0
- package/src/screens/assistants/assistant-info.tsx +45 -0
- package/src/screens/assistants/assistant-list.tsx +115 -0
- package/src/screens/assistants/assistant-tools.tsx +61 -0
- package/src/screens/contacts/contact-details.tsx +175 -0
- package/src/screens/contacts/contact-list.tsx +251 -0
- package/src/screens/contacts/index.ts +6 -0
- package/src/screens/events/cron.ts +74 -0
- package/src/screens/events/event-details.tsx +117 -0
- package/src/screens/events/event-handlers.tsx +61 -0
- package/src/screens/events/event-info.tsx +29 -0
- package/src/screens/events/event-list.tsx +104 -0
- package/src/screens/events/event-schedule.tsx +130 -0
- package/src/screens/groups/group-details.tsx +306 -0
- package/src/screens/groups/group-list.tsx +366 -0
- package/src/screens/groups/group-members.tsx +455 -0
- package/src/screens/groups/index.ts +9 -0
- package/src/screens/knowledge/knowledge-frame-details.bk.tsx +160 -0
- package/src/screens/knowledge/knowledge-frame-details.tsx +176 -0
- package/src/screens/knowledge/knowledge-frame-list.tsx +49 -0
- package/src/screens/knowledge/knowledge-value-details.tsx +181 -0
- package/src/screens/knowledge/knowledge-value-list-item.tsx +48 -0
- package/src/screens/knowledge/knowledge-value-list.tsx +131 -0
- package/src/screens/packages/package-details.tsx +117 -0
- package/src/screens/packages/package-info.tsx +83 -0
- package/src/screens/packages/package-list.tsx +191 -0
- package/src/screens/packages/package-new-local.tsx +93 -0
- package/src/screens/peer-types/peer-type-details.tsx +162 -0
- package/src/screens/peer-types/peer-type-list.tsx +74 -0
- package/src/screens/predicates/predicate-details.tsx +125 -0
- package/src/screens/predicates/predicate-list.tsx +50 -0
- package/src/screens/profile.tsx +68 -0
- package/src/screens/search/global-search.tsx +274 -0
- package/src/screens/settings/color-mode-dropdown.tsx +57 -0
- package/src/screens/settings/settings-page.tsx +76 -0
- package/src/screens/setup-user.tsx +367 -0
- package/src/screens/tools/tool-code.tsx +35 -0
- package/src/screens/tools/tool-details.tsx +101 -0
- package/src/screens/tools/tool-info.tsx +60 -0
- package/src/screens/tools/tool-list.tsx +121 -0
- package/src/screens/tools/tool-schema.tsx +42 -0
- package/src/screens/tools/tool-test-details.tsx +100 -0
- package/src/screens/tools/tool-test-list.tsx +74 -0
- package/src/screens/variables/variable-details.tsx +183 -0
- package/src/screens/variables/variable-list.tsx +74 -0
- package/src/screens/workflows/workflow-details.tsx +130 -0
- package/src/screens/workflows/workflow-info.tsx +29 -0
- package/src/screens/workflows/workflow-instructions.tsx +127 -0
- package/src/screens/workflows/workflow-list.tsx +107 -0
- package/src/screens/workflows/workflow-subscriptions.tsx +58 -0
- package/src/setupTests.ts +32 -0
- package/src/system-apps/assistants.app.ts +7 -0
- package/src/system-apps/contacts.app.ts +8 -0
- package/src/system-apps/events.app.ts +7 -0
- package/src/system-apps/groups.app.ts +8 -0
- package/src/system-apps/index.ts +79 -0
- package/src/system-apps/knowledge-frames.app.ts +8 -0
- package/src/system-apps/knowledge-values.app.ts +8 -0
- package/src/system-apps/packages.app.ts +7 -0
- package/src/system-apps/predicates.app.ts +7 -0
- package/src/system-apps/profile.app.ts +7 -0
- package/src/system-apps/search.app.ts +8 -0
- package/src/system-apps/settings.app.ts +7 -0
- package/src/system-apps/threads.app.ts +7 -0
- package/src/system-apps/tools.app.ts +7 -0
- package/src/system-apps/types.app.ts +7 -0
- package/src/system-apps/variables.app.ts +7 -0
- package/src/system-apps/workflows.app.ts +7 -0
- package/src/tabs-layout/tabs-layout.tsx +672 -0
- package/src/tabs-layout/tabs-state.ts +269 -0
- package/src/three-bar-layout/left-bar-content.tsx +202 -0
- package/src/three-bar-layout/right-bar-content.tsx +67 -0
- package/src/three-bar-layout/three-bar-layout.tsx +297 -0
- package/src/ui-defaults/index.ts +3 -0
- package/src/ui-defaults/list-screen.tsx +92 -0
- package/src/ui-defaults/notes-editor.tsx +51 -0
- package/src/ui-router/routes-loader.ts +98 -0
- package/src/ui-router/ui-loader.tsx +497 -0
- package/src/utils.ts +266 -0
- package/tsconfig.json +24 -0
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useObservable } from '../hooks';
|
|
3
|
+
import { colorMode } from '../screens/settings/color-mode-dropdown';
|
|
4
|
+
import {
|
|
5
|
+
closeCommandPalette,
|
|
6
|
+
commandSearchQuery,
|
|
7
|
+
Command,
|
|
8
|
+
executeCommand,
|
|
9
|
+
isCommandPaletteOpen,
|
|
10
|
+
searchCommands
|
|
11
|
+
} from './command-palette';
|
|
12
|
+
|
|
13
|
+
export function CommandPaletteOverlay() {
|
|
14
|
+
const [isOpen] = useObservable(isCommandPaletteOpen);
|
|
15
|
+
const [searchQuery, setSearchQuery] = useObservable(commandSearchQuery);
|
|
16
|
+
const [_colorMode] = useObservable(colorMode);
|
|
17
|
+
const [selectedIndex, setSelectedIndex] = useState(0);
|
|
18
|
+
const inputRef = useRef<HTMLInputElement>(null);
|
|
19
|
+
|
|
20
|
+
const filteredCommands = searchCommands(searchQuery);
|
|
21
|
+
|
|
22
|
+
// Create a flattened list that matches the visual rendering order
|
|
23
|
+
const visualOrderCommands = Object.entries(
|
|
24
|
+
filteredCommands.reduce((acc, cmd) => {
|
|
25
|
+
const category = cmd.category || 'Other';
|
|
26
|
+
if (!acc[category]) acc[category] = [];
|
|
27
|
+
acc[category].push(cmd);
|
|
28
|
+
return acc;
|
|
29
|
+
}, {} as Record<string, Command[]>)
|
|
30
|
+
).flatMap(([, commands]) => commands);
|
|
31
|
+
|
|
32
|
+
// Focus input when opened
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (isOpen && inputRef.current) {
|
|
35
|
+
inputRef.current.focus();
|
|
36
|
+
}
|
|
37
|
+
}, [isOpen]);
|
|
38
|
+
|
|
39
|
+
// Reset selected index when search changes
|
|
40
|
+
useEffect(() => {
|
|
41
|
+
setSelectedIndex(0);
|
|
42
|
+
}, [searchQuery]);
|
|
43
|
+
|
|
44
|
+
// Keyboard navigation
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
if (!isOpen) return;
|
|
47
|
+
|
|
48
|
+
const handleKeyDown = (e: KeyboardEvent) => {
|
|
49
|
+
if (e.key === 'ArrowDown') {
|
|
50
|
+
e.preventDefault();
|
|
51
|
+
setSelectedIndex(prev => Math.min(prev + 1, visualOrderCommands.length - 1));
|
|
52
|
+
} else if (e.key === 'ArrowUp') {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
setSelectedIndex(prev => Math.max(prev - 1, 0));
|
|
55
|
+
} else if (e.key === 'Enter') {
|
|
56
|
+
e.preventDefault();
|
|
57
|
+
if (visualOrderCommands[selectedIndex]) {
|
|
58
|
+
executeCommand(visualOrderCommands[selectedIndex].id);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
64
|
+
return () => document.removeEventListener('keydown', handleKeyDown);
|
|
65
|
+
}, [isOpen, visualOrderCommands, selectedIndex]);
|
|
66
|
+
|
|
67
|
+
if (!isOpen) return null;
|
|
68
|
+
|
|
69
|
+
const isDark = _colorMode === 'dark';
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<div
|
|
73
|
+
className="position-fixed w-100 h-100 d-flex align-items-start justify-content-center"
|
|
74
|
+
style={{
|
|
75
|
+
top: 0,
|
|
76
|
+
left: 0,
|
|
77
|
+
zIndex: 1050,
|
|
78
|
+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
|
|
79
|
+
backdropFilter: 'blur(4px)',
|
|
80
|
+
paddingTop: '10vh'
|
|
81
|
+
}}
|
|
82
|
+
onClick={(e) => {
|
|
83
|
+
if (e.target === e.currentTarget) {
|
|
84
|
+
closeCommandPalette();
|
|
85
|
+
}
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<div
|
|
89
|
+
className={`${isDark ? 'bg-dark text-light' : 'bg-white text-dark'}`}
|
|
90
|
+
style={{
|
|
91
|
+
width: '90%',
|
|
92
|
+
maxWidth: '600px',
|
|
93
|
+
borderRadius: '12px',
|
|
94
|
+
boxShadow: isDark
|
|
95
|
+
? '0 20px 40px rgba(0, 0, 0, 0.5)'
|
|
96
|
+
: '0 20px 40px rgba(0, 0, 0, 0.1)',
|
|
97
|
+
border: isDark ? '1px solid #495057' : '1px solid #dee2e6',
|
|
98
|
+
overflow: 'hidden'
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
{/* Search Input */}
|
|
102
|
+
<div className="p-3 border-bottom" style={{
|
|
103
|
+
borderBottomColor: isDark ? '#495057' : '#dee2e6'
|
|
104
|
+
}}>
|
|
105
|
+
<div className="position-relative">
|
|
106
|
+
<i
|
|
107
|
+
className="bi-search position-absolute"
|
|
108
|
+
style={{
|
|
109
|
+
left: '12px',
|
|
110
|
+
top: '50%',
|
|
111
|
+
transform: 'translateY(-50%)',
|
|
112
|
+
color: '#6c757d',
|
|
113
|
+
zIndex: 1
|
|
114
|
+
}}
|
|
115
|
+
/>
|
|
116
|
+
<input
|
|
117
|
+
ref={inputRef}
|
|
118
|
+
type="text"
|
|
119
|
+
className={`form-control ${isDark ? 'bg-dark text-light border-secondary' : ''}`}
|
|
120
|
+
placeholder="Type a command or search..."
|
|
121
|
+
value={searchQuery}
|
|
122
|
+
onChange={(e) => {
|
|
123
|
+
setSearchQuery(e.target.value);
|
|
124
|
+
commandSearchQuery(e.target.value);
|
|
125
|
+
}}
|
|
126
|
+
style={{
|
|
127
|
+
paddingLeft: '40px',
|
|
128
|
+
fontSize: '16px',
|
|
129
|
+
border: 'none',
|
|
130
|
+
outline: 'none',
|
|
131
|
+
boxShadow: 'none',
|
|
132
|
+
backgroundColor: isDark ? '#343a40' : '#f8f9fa'
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
</div>
|
|
136
|
+
</div>
|
|
137
|
+
|
|
138
|
+
{/* Commands List */}
|
|
139
|
+
<div
|
|
140
|
+
style={{
|
|
141
|
+
maxHeight: '400px',
|
|
142
|
+
overflowY: 'auto'
|
|
143
|
+
}}
|
|
144
|
+
>
|
|
145
|
+
{visualOrderCommands.length === 0 ? (
|
|
146
|
+
<div className="p-4 text-center text-muted">
|
|
147
|
+
<i className="bi-search mb-2 d-block" style={{ fontSize: '24px' }} />
|
|
148
|
+
No commands found
|
|
149
|
+
</div>
|
|
150
|
+
) : (
|
|
151
|
+
<div className="py-2">
|
|
152
|
+
{/* Group commands by category */}
|
|
153
|
+
{Object.entries(
|
|
154
|
+
filteredCommands.reduce((acc, cmd) => {
|
|
155
|
+
const category = cmd.category || 'Other';
|
|
156
|
+
if (!acc[category]) acc[category] = [];
|
|
157
|
+
acc[category].push(cmd);
|
|
158
|
+
return acc;
|
|
159
|
+
}, {} as Record<string, Command[]>)
|
|
160
|
+
).map(([category, commands]) => (
|
|
161
|
+
<div key={category}>
|
|
162
|
+
{/* Category Header */}
|
|
163
|
+
<div
|
|
164
|
+
className="px-3 py-1 small text-muted fw-bold text-uppercase"
|
|
165
|
+
style={{ fontSize: '11px', letterSpacing: '0.5px' }}
|
|
166
|
+
>
|
|
167
|
+
{category}
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
{/* Commands in Category */}
|
|
171
|
+
{commands.map((command) => {
|
|
172
|
+
const globalIndex = visualOrderCommands.indexOf(command);
|
|
173
|
+
const isSelected = globalIndex === selectedIndex;
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<div
|
|
177
|
+
key={command.id}
|
|
178
|
+
className={`px-3 py-2 d-flex align-items-center justify-content-between ${
|
|
179
|
+
isSelected
|
|
180
|
+
? (isDark ? 'bg-primary bg-opacity-25' : 'bg-primary bg-opacity-10')
|
|
181
|
+
: ''
|
|
182
|
+
}`}
|
|
183
|
+
style={{
|
|
184
|
+
cursor: 'pointer',
|
|
185
|
+
transition: 'background-color 0.1s ease'
|
|
186
|
+
}}
|
|
187
|
+
onClick={() => executeCommand(command.id)}
|
|
188
|
+
onMouseEnter={() => setSelectedIndex(globalIndex)}
|
|
189
|
+
>
|
|
190
|
+
<div className="d-flex align-items-center">
|
|
191
|
+
{command.iconClassName && (
|
|
192
|
+
<i
|
|
193
|
+
className={`${command.iconClassName} me-3`}
|
|
194
|
+
style={{
|
|
195
|
+
fontSize: '16px',
|
|
196
|
+
color: isSelected ? (isDark ? '#ffffff' : '#0d6efd') : '#6c757d',
|
|
197
|
+
minWidth: '16px'
|
|
198
|
+
}}
|
|
199
|
+
/>
|
|
200
|
+
)}
|
|
201
|
+
<div>
|
|
202
|
+
<div className="fw-medium">{command.label}</div>
|
|
203
|
+
{command.description && (
|
|
204
|
+
<div
|
|
205
|
+
className="small text-muted"
|
|
206
|
+
style={{ fontSize: '12px' }}
|
|
207
|
+
>
|
|
208
|
+
{command.description}
|
|
209
|
+
</div>
|
|
210
|
+
)}
|
|
211
|
+
</div>
|
|
212
|
+
</div>
|
|
213
|
+
|
|
214
|
+
{command.shortcut && (
|
|
215
|
+
<div
|
|
216
|
+
className={`small px-2 py-1 rounded ${
|
|
217
|
+
isDark ? 'bg-secondary bg-opacity-50' : 'bg-light'
|
|
218
|
+
}`}
|
|
219
|
+
style={{
|
|
220
|
+
fontSize: '11px',
|
|
221
|
+
fontFamily: 'monospace',
|
|
222
|
+
color: isDark ? '#adb5bd' : '#6c757d',
|
|
223
|
+
border: isDark ? '1px solid #495057' : '1px solid #dee2e6'
|
|
224
|
+
}}
|
|
225
|
+
>
|
|
226
|
+
{command.shortcut}
|
|
227
|
+
</div>
|
|
228
|
+
)}
|
|
229
|
+
</div>
|
|
230
|
+
);
|
|
231
|
+
})}
|
|
232
|
+
</div>
|
|
233
|
+
))}
|
|
234
|
+
</div>
|
|
235
|
+
)}
|
|
236
|
+
</div>
|
|
237
|
+
|
|
238
|
+
{/* Footer */}
|
|
239
|
+
<div
|
|
240
|
+
className={`px-3 py-2 small text-muted border-top d-flex align-items-center justify-content-between`}
|
|
241
|
+
style={{
|
|
242
|
+
borderTopColor: isDark ? '#495057' : '#dee2e6',
|
|
243
|
+
fontSize: '11px'
|
|
244
|
+
}}
|
|
245
|
+
>
|
|
246
|
+
<div className="d-flex align-items-center gap-3">
|
|
247
|
+
<span>
|
|
248
|
+
<kbd className="small">↵</kbd> to select
|
|
249
|
+
</span>
|
|
250
|
+
<span>
|
|
251
|
+
<kbd className="small">↑↓</kbd> to navigate
|
|
252
|
+
</span>
|
|
253
|
+
<span>
|
|
254
|
+
<kbd className="small">esc</kbd> to close
|
|
255
|
+
</span>
|
|
256
|
+
</div>
|
|
257
|
+
<div>
|
|
258
|
+
{visualOrderCommands.length} command{visualOrderCommands.length !== 1 ? 's' : ''}
|
|
259
|
+
</div>
|
|
260
|
+
</div>
|
|
261
|
+
</div>
|
|
262
|
+
</div>
|
|
263
|
+
);
|
|
264
|
+
}
|
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { deviceVar } from "@peers-app/peers-sdk";
|
|
2
|
+
import { goToTabPath } from '../tabs-layout/tabs-state';
|
|
3
|
+
|
|
4
|
+
export interface Command {
|
|
5
|
+
id: string;
|
|
6
|
+
label: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
shortcut?: string;
|
|
9
|
+
category?: string;
|
|
10
|
+
iconClassName?: string;
|
|
11
|
+
action: () => void;
|
|
12
|
+
isAvailable?: () => boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// Command palette state (using device scope but with temporary defaults)
|
|
16
|
+
export const isCommandPaletteOpen = deviceVar<boolean>('commandPaletteOpen', {
|
|
17
|
+
defaultValue: false,
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export const commandSearchQuery = deviceVar<string>('commandSearchQuery', {
|
|
21
|
+
defaultValue: '',
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Command registry
|
|
25
|
+
const registeredCommands = new Map<string, Command>();
|
|
26
|
+
|
|
27
|
+
// Detect platform for keyboard shortcuts
|
|
28
|
+
const isMac = typeof navigator !== 'undefined'
|
|
29
|
+
? /Mac|iPod|iPhone|iPad/.test(navigator.userAgent)
|
|
30
|
+
: false;
|
|
31
|
+
const modKey = isMac ? 'Cmd' : 'Ctrl';
|
|
32
|
+
|
|
33
|
+
// Core system commands
|
|
34
|
+
const coreCommands: Command[] = [
|
|
35
|
+
{
|
|
36
|
+
id: 'search',
|
|
37
|
+
label: 'Search Everything',
|
|
38
|
+
description: 'Search across all content',
|
|
39
|
+
shortcut: `${modKey}+K`,
|
|
40
|
+
iconClassName: 'bi-search',
|
|
41
|
+
category: 'Navigation',
|
|
42
|
+
action: () => {
|
|
43
|
+
closeCommandPalette();
|
|
44
|
+
goToTabPath('search');
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
id: 'close-tab',
|
|
49
|
+
label: 'Close Tab',
|
|
50
|
+
description: 'Close the current tab',
|
|
51
|
+
shortcut: `${modKey}+W`,
|
|
52
|
+
iconClassName: 'bi-x',
|
|
53
|
+
category: 'Tabs',
|
|
54
|
+
action: () => {
|
|
55
|
+
closeCommandPalette();
|
|
56
|
+
// Import dynamically to avoid circular dependency
|
|
57
|
+
import('../tabs-layout/tabs-state').then(({ closeCurrentTab }) => {
|
|
58
|
+
closeCurrentTab();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
id: 'next-tab',
|
|
64
|
+
label: 'Next Tab',
|
|
65
|
+
description: 'Switch to next tab',
|
|
66
|
+
shortcut: 'Ctrl+Tab',
|
|
67
|
+
iconClassName: 'bi-arrow-right',
|
|
68
|
+
category: 'Tabs',
|
|
69
|
+
action: () => {
|
|
70
|
+
closeCommandPalette();
|
|
71
|
+
import('../tabs-layout/tabs-state').then(({ switchToNextTab }) => {
|
|
72
|
+
switchToNextTab();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
id: 'previous-tab',
|
|
78
|
+
label: 'Previous Tab',
|
|
79
|
+
description: 'Switch to previous tab',
|
|
80
|
+
shortcut: 'Ctrl+Shift+Tab',
|
|
81
|
+
iconClassName: 'bi-arrow-left',
|
|
82
|
+
category: 'Tabs',
|
|
83
|
+
action: () => {
|
|
84
|
+
closeCommandPalette();
|
|
85
|
+
import('../tabs-layout/tabs-state').then(({ switchToPreviousTab }) => {
|
|
86
|
+
switchToPreviousTab();
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
id: 'go-home',
|
|
92
|
+
label: 'Go to Threads',
|
|
93
|
+
description: 'Navigate to threads/home',
|
|
94
|
+
shortcut: `${modKey}+H`,
|
|
95
|
+
iconClassName: 'bi-cpu',
|
|
96
|
+
category: 'Navigation',
|
|
97
|
+
action: () => {
|
|
98
|
+
closeCommandPalette();
|
|
99
|
+
goToTabPath('threads');
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
id: 'go-settings',
|
|
104
|
+
label: 'Open Settings',
|
|
105
|
+
description: 'Open application settings',
|
|
106
|
+
iconClassName: 'bi-gear-fill',
|
|
107
|
+
category: 'Navigation',
|
|
108
|
+
action: () => {
|
|
109
|
+
closeCommandPalette();
|
|
110
|
+
goToTabPath('settings');
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
id: 'go-assistants',
|
|
115
|
+
label: 'Go to Assistants',
|
|
116
|
+
description: 'View and manage assistants',
|
|
117
|
+
iconClassName: 'bi-person-fill-gear',
|
|
118
|
+
category: 'Navigation',
|
|
119
|
+
action: () => {
|
|
120
|
+
closeCommandPalette();
|
|
121
|
+
goToTabPath('assistants');
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: 'go-workflows',
|
|
126
|
+
label: 'Go to Workflows',
|
|
127
|
+
description: 'View and manage workflows',
|
|
128
|
+
iconClassName: 'bi-database-fill-gear',
|
|
129
|
+
category: 'Navigation',
|
|
130
|
+
action: () => {
|
|
131
|
+
closeCommandPalette();
|
|
132
|
+
goToTabPath('workflows');
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
id: 'go-tools',
|
|
137
|
+
label: 'Go to Tools',
|
|
138
|
+
description: 'View and manage tools',
|
|
139
|
+
iconClassName: 'bi-tools',
|
|
140
|
+
category: 'Navigation',
|
|
141
|
+
action: () => {
|
|
142
|
+
closeCommandPalette();
|
|
143
|
+
goToTabPath('tools');
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
id: 'go-events',
|
|
148
|
+
label: 'Go to Events',
|
|
149
|
+
description: 'View and manage events',
|
|
150
|
+
iconClassName: 'bi-lightning-charge-fill',
|
|
151
|
+
category: 'Navigation',
|
|
152
|
+
action: () => {
|
|
153
|
+
closeCommandPalette();
|
|
154
|
+
goToTabPath('events');
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
id: 'go-predicates',
|
|
159
|
+
label: 'Go to Predicates',
|
|
160
|
+
description: 'View and manage predicates',
|
|
161
|
+
iconClassName: 'bi-node-plus-fill',
|
|
162
|
+
category: 'Navigation',
|
|
163
|
+
action: () => {
|
|
164
|
+
closeCommandPalette();
|
|
165
|
+
goToTabPath('predicates');
|
|
166
|
+
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: 'go-peer-types',
|
|
170
|
+
label: 'Go to Peer Types',
|
|
171
|
+
description: 'View and manage peer types',
|
|
172
|
+
iconClassName: 'bi-code-square',
|
|
173
|
+
category: 'Navigation',
|
|
174
|
+
action: () => {
|
|
175
|
+
closeCommandPalette();
|
|
176
|
+
goToTabPath('peer-types');
|
|
177
|
+
}
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
id: 'go-packages',
|
|
181
|
+
label: 'Go to Packages',
|
|
182
|
+
description: 'View and manage packages',
|
|
183
|
+
iconClassName: 'bi-box-fill',
|
|
184
|
+
category: 'Navigation',
|
|
185
|
+
action: () => {
|
|
186
|
+
closeCommandPalette();
|
|
187
|
+
goToTabPath('packages');
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: 'go-variables',
|
|
192
|
+
label: 'Go to Variables',
|
|
193
|
+
description: 'View and manage variables',
|
|
194
|
+
iconClassName: 'bi-braces',
|
|
195
|
+
category: 'Navigation',
|
|
196
|
+
action: () => {
|
|
197
|
+
closeCommandPalette();
|
|
198
|
+
goToTabPath('variables');
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
id: 'go-knowledge-values',
|
|
203
|
+
label: 'Go to Knowledge Values',
|
|
204
|
+
description: 'View and manage knowledge values',
|
|
205
|
+
iconClassName: 'bi-journal-bookmark-fill',
|
|
206
|
+
category: 'Navigation',
|
|
207
|
+
action: () => {
|
|
208
|
+
closeCommandPalette();
|
|
209
|
+
goToTabPath('knowledge-values');
|
|
210
|
+
}
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
id: 'go-knowledge-frames',
|
|
214
|
+
label: 'Go to Knowledge Frames',
|
|
215
|
+
description: 'View and manage knowledge frames',
|
|
216
|
+
iconClassName: 'bi-window-dock',
|
|
217
|
+
category: 'Navigation',
|
|
218
|
+
action: () => {
|
|
219
|
+
closeCommandPalette();
|
|
220
|
+
goToTabPath('knowledge-frames');
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
];
|
|
224
|
+
|
|
225
|
+
// Register core commands
|
|
226
|
+
coreCommands.forEach(cmd => registeredCommands.set(cmd.id, cmd));
|
|
227
|
+
|
|
228
|
+
// Command registration functions
|
|
229
|
+
export function registerCommand(command: Command): void {
|
|
230
|
+
registeredCommands.set(command.id, command);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function unregisterCommand(commandId: string): void {
|
|
234
|
+
registeredCommands.delete(commandId);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export function getCommand(commandId: string): Command | undefined {
|
|
238
|
+
return registeredCommands.get(commandId);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export function getAllCommands(): Command[] {
|
|
242
|
+
return Array.from(registeredCommands.values()).filter(cmd =>
|
|
243
|
+
!cmd.isAvailable || cmd.isAvailable()
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function searchCommands(query: string): Command[] {
|
|
248
|
+
if (!query.trim()) return getAllCommands();
|
|
249
|
+
|
|
250
|
+
const lowerQuery = query.toLowerCase();
|
|
251
|
+
return getAllCommands().filter(cmd =>
|
|
252
|
+
cmd.label.toLowerCase().includes(lowerQuery) ||
|
|
253
|
+
cmd.description?.toLowerCase().includes(lowerQuery) ||
|
|
254
|
+
cmd.category?.toLowerCase().includes(lowerQuery)
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Command palette controls
|
|
259
|
+
export function openCommandPalette(): void {
|
|
260
|
+
isCommandPaletteOpen(true);
|
|
261
|
+
commandSearchQuery('');
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
export function closeCommandPalette(): void {
|
|
265
|
+
isCommandPaletteOpen(false);
|
|
266
|
+
commandSearchQuery('');
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
export function toggleCommandPalette(): void {
|
|
270
|
+
if (isCommandPaletteOpen()) {
|
|
271
|
+
closeCommandPalette();
|
|
272
|
+
} else {
|
|
273
|
+
openCommandPalette();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function executeCommand(commandId: string): void {
|
|
278
|
+
const command = getCommand(commandId);
|
|
279
|
+
if (command) {
|
|
280
|
+
command.action();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
// Keyboard shortcut handling
|
|
285
|
+
const shortcutToCommandMap = new Map<string, string>();
|
|
286
|
+
|
|
287
|
+
// Build shortcut map from registered commands
|
|
288
|
+
function buildShortcutMap(): void {
|
|
289
|
+
shortcutToCommandMap.clear();
|
|
290
|
+
getAllCommands().forEach(cmd => {
|
|
291
|
+
if (cmd.shortcut) {
|
|
292
|
+
shortcutToCommandMap.set(normalizeShortcut(cmd.shortcut), cmd.id);
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function normalizeShortcut(shortcut: string): string {
|
|
298
|
+
return shortcut.toLowerCase()
|
|
299
|
+
.replace('cmd', 'meta')
|
|
300
|
+
.replace('command', 'meta')
|
|
301
|
+
.replace(/\s+/g, '');
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
function getKeyFromEvent(event: KeyboardEvent): string {
|
|
305
|
+
const parts: string[] = [];
|
|
306
|
+
|
|
307
|
+
if (event.metaKey) parts.push('meta');
|
|
308
|
+
if (event.ctrlKey) parts.push('ctrl');
|
|
309
|
+
if (event.altKey) parts.push('alt');
|
|
310
|
+
if (event.shiftKey) parts.push('shift');
|
|
311
|
+
|
|
312
|
+
parts.push(event.key.toLowerCase());
|
|
313
|
+
|
|
314
|
+
return parts.join('+');
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Global keyboard event handler
|
|
318
|
+
const handleKeyDown = (event: KeyboardEvent) => {
|
|
319
|
+
const key = getKeyFromEvent(event);
|
|
320
|
+
|
|
321
|
+
// Handle Cmd+K (Mac) / Ctrl+K (Windows/Linux) to open command palette
|
|
322
|
+
const paletteShortcut = isMac ? 'meta+k' : 'ctrl+k';
|
|
323
|
+
if (key === paletteShortcut) {
|
|
324
|
+
event.preventDefault();
|
|
325
|
+
toggleCommandPalette();
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Handle Escape to close command palette
|
|
330
|
+
if (key === 'escape' && isCommandPaletteOpen()) {
|
|
331
|
+
event.preventDefault();
|
|
332
|
+
closeCommandPalette();
|
|
333
|
+
return;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
// If command palette is open, don't handle other shortcuts
|
|
337
|
+
if (isCommandPaletteOpen()) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Handle other registered shortcuts
|
|
342
|
+
const commandId = shortcutToCommandMap.get(key);
|
|
343
|
+
if (commandId) {
|
|
344
|
+
event.preventDefault();
|
|
345
|
+
executeCommand(commandId);
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
// Initialize keyboard shortcuts
|
|
350
|
+
export function initializeCommandPalette(): void {
|
|
351
|
+
buildShortcutMap();
|
|
352
|
+
document.addEventListener('keydown', handleKeyDown);
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// Clean up (for testing or hot reloading)
|
|
356
|
+
export function destroyCommandPalette(): void {
|
|
357
|
+
document.removeEventListener('keydown', handleKeyDown);
|
|
358
|
+
shortcutToCommandMap.clear();
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
// Auto-initialize when this module loads
|
|
362
|
+
if (typeof window !== 'undefined') {
|
|
363
|
+
initializeCommandPalette();
|
|
364
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useObservable } from '../hooks';
|
|
3
|
+
|
|
4
|
+
interface IProps extends React.DetailedHTMLProps<React.InputHTMLAttributes<HTMLInputElement>, HTMLInputElement> {
|
|
5
|
+
checked: any,
|
|
6
|
+
type?: React.HTMLInputTypeAttribute
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function Checkbox(props: IProps) {
|
|
10
|
+
const [checked, setChecked] = useObservable(props.checked);
|
|
11
|
+
const type = props.type ?? 'checkbox';
|
|
12
|
+
function onChange(evt: React.ChangeEvent<HTMLInputElement>) {
|
|
13
|
+
let _value: any = evt.target.checked;
|
|
14
|
+
if (type === 'checkbox') {
|
|
15
|
+
_value = !!_value;
|
|
16
|
+
}
|
|
17
|
+
setChecked(_value);
|
|
18
|
+
}
|
|
19
|
+
return (
|
|
20
|
+
<input onChange={onChange} type={type} {...props} checked={checked} />
|
|
21
|
+
)
|
|
22
|
+
}
|