diff --git a/src/App.tsx b/src/App.tsx
index 2d7fd0c..6bc9159 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -1,140 +1,11 @@
-import { useState, useEffect } from "react";
-import { MantineProvider, Tabs, Button } from "@mantine/core";
-import {
- HotkeysProvider,
- useHotkeys,
- useHotkeysContext,
-} from "react-hotkeys-hook";
-import { Command } from "cmdk";
+import { MantineProvider } from "@mantine/core";
+import CmdkTestDemo from "./cmdkTestDemo";
import "@mantine/core/styles.css";
-function TabContent({ title, scopeName }: any) {
- const [text, setText] = useState(`${title} panel `);
- const [used, setUsed] = useState(false);
-
- useHotkeys(
- "ctrl+b",
- () => {
- if (used) return;
- setText((prev) => prev + `${title} `);
- setUsed(true);
- },
- {
- scopes: [scopeName],
- preventDefault: true,
- },
- );
-
- return <>{text}>;
-}
-
-function TabsPage() {
- const { enableScope, disableScope } = useHotkeysContext();
- const [activeTab, setActiveTab] = useState("1");
- const [opened, setOpened] = useState(false);
-
- const actions = [
- { id: "1", label: "First", description: "First panel" },
- { id: "2", label: "Second", description: "Second panel" },
- { id: "3", label: "Third", description: "Third panel" },
- ];
-
- useEffect(() => {
- const currentScope = `tab${activeTab}`;
- enableScope(currentScope);
-
- return () => {
- disableScope(currentScope);
- };
- }, [activeTab, enableScope, disableScope]);
-
- useHotkeys("ctrl+1", () => setActiveTab("1"), { preventDefault: true });
- useHotkeys("ctrl+2", () => setActiveTab("2"), { preventDefault: true });
- useHotkeys("ctrl+3", () => setActiveTab("3"), { preventDefault: true });
-
- useHotkeys(
- "ctrl+k",
- (e) => {
- e.preventDefault();
- setOpened((prev) => !prev);
- },
- { enableOnFormTags: true },
- );
-
- const handleSelectTab = (tabId: string) => {
- setActiveTab(tabId);
- setOpened(false);
- };
-
- return (
- <>
-
-
- setOpened(false)}
- label="Global Command Menu"
- >
-
-
-
- No results found.
-
-
- {actions.map((action) => (
- handleSelectTab(action.id)}
- style={{
- fontWeight: activeTab === action.id ? "bold" : "normal",
- }}
- >
-
-
{action.label}
-
- {action.description}
-
-
-
- ))}
-
-
-
-
- value && setActiveTab(value)}
- >
-
- First
- Second
- Third
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- );
-}
-
export default function App() {
return (
-
-
-
-
-
+
+
+
);
}
diff --git a/src/cmdkTestDemo.tsx b/src/cmdkTestDemo.tsx
new file mode 100644
index 0000000..c3c2e95
--- /dev/null
+++ b/src/cmdkTestDemo.tsx
@@ -0,0 +1,46 @@
+import { Button } from "@mantine/core";
+import { Command } from "cmdk";
+import { useState } from "react";
+
+export default function CmdkTestDemo() {
+ const [opened, setOpened] = useState(false);
+
+ const actions = [
+ { id: "1", label: "First", description: "First panel" },
+ { id: "2", label: "Second", description: "Second panel" },
+ { id: "3", label: "Third", description: "Third panel" },
+ ];
+
+ return (
+ <>
+
+
+ setOpened(false)}
+ label="Global Command Menu"
+ >
+
+
+
+ No results found.
+
+
+ {actions.map((action) => (
+
+
+
{action.label}
+
+ {action.description}
+
+
+
+ ))}
+
+
+
+ >
+ );
+}