@parhelia/core 0.1.12322 → 0.1.12331
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/dist/config/config.js +4 -27
- package/dist/config/config.js.map +1 -1
- package/dist/config/types.d.ts +2 -2
- package/dist/config/types.js.map +1 -1
- package/dist/editor/ai/AgentTerminal.d.ts +4 -2
- package/dist/editor/ai/AgentTerminal.js +33 -3
- package/dist/editor/ai/AgentTerminal.js.map +1 -1
- package/dist/editor/ai/AiResponseMessage.d.ts +2 -1
- package/dist/editor/ai/AiResponseMessage.js +4 -4
- package/dist/editor/ai/AiResponseMessage.js.map +1 -1
- package/dist/editor/commands/templateBuilderCommands.d.ts +8 -0
- package/dist/editor/commands/templateBuilderCommands.js +51 -0
- package/dist/editor/commands/templateBuilderCommands.js.map +1 -0
- package/dist/editor/context-menu/InsertMenu.js +14 -1
- package/dist/editor/context-menu/InsertMenu.js.map +1 -1
- package/dist/editor/services/contentService.d.ts +0 -1
- package/dist/editor/services/contentService.js +0 -9
- package/dist/editor/services/contentService.js.map +1 -1
- package/dist/editor/services/templateBuilderService.d.ts +133 -0
- package/dist/editor/services/templateBuilderService.js +289 -0
- package/dist/editor/services/templateBuilderService.js.map +1 -0
- package/dist/editor/template-wizard/TemplateBuilderDialog.d.ts +11 -0
- package/dist/editor/template-wizard/TemplateBuilderDialog.js +17 -0
- package/dist/editor/template-wizard/TemplateBuilderDialog.js.map +1 -0
- package/dist/editor/template-wizard/TemplateStructureInlineEditor.d.ts +16 -0
- package/dist/editor/template-wizard/TemplateStructureInlineEditor.js +1336 -0
- package/dist/editor/template-wizard/TemplateStructureInlineEditor.js.map +1 -0
- package/dist/editor/ui/Icons.js +1 -1
- package/dist/editor/ui/Icons.js.map +1 -1
- package/dist/editor/views/ItemEditor.js +7 -3
- package/dist/editor/views/ItemEditor.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/revision.d.ts +2 -2
- package/dist/revision.js +2 -2
- package/dist/tour/Tour.d.ts +1 -1
- package/dist/tour/Tour.js +80 -55
- package/dist/tour/Tour.js.map +1 -1
- package/dist/tour/default-tour.js +186 -80
- package/dist/tour/default-tour.js.map +1 -1
- package/package.json +1 -1
- package/dist/editor/ai/HelpTerminal.d.ts +0 -5
- package/dist/editor/ai/HelpTerminal.js +0 -166
- package/dist/editor/ai/HelpTerminal.js.map +0 -1
- package/dist/editor/services-server/graphQL.d.ts +0 -29
- package/dist/editor/services-server/graphQL.js +0 -53
- package/dist/editor/services-server/graphQL.js.map +0 -1
- package/dist/editor/settings/AllAgentsPanel.d.ts +0 -5
- package/dist/editor/settings/AllAgentsPanel.js +0 -139
- package/dist/editor/settings/AllAgentsPanel.js.map +0 -1
- package/dist/editor/settings/LatestFeedback.d.ts +0 -1
- package/dist/editor/settings/LatestFeedback.js +0 -136
- package/dist/editor/settings/LatestFeedback.js.map +0 -1
- package/dist/editor/sidebar/Debug.d.ts +0 -1
- package/dist/editor/sidebar/Debug.js +0 -70
- package/dist/editor/sidebar/Debug.js.map +0 -1
- package/dist/editor/sidebar/GraphQL.d.ts +0 -2
- package/dist/editor/sidebar/GraphQL.js +0 -234
- package/dist/editor/sidebar/GraphQL.js.map +0 -1
- package/dist/editor/sidebar/LeftToolbar.d.ts +0 -1
- package/dist/editor/sidebar/LeftToolbar.js +0 -12
- package/dist/editor/sidebar/LeftToolbar.js.map +0 -1
- package/dist/editor/sidebar/NavigationSidebar.d.ts +0 -4
- package/dist/editor/sidebar/NavigationSidebar.js +0 -254
- package/dist/editor/sidebar/NavigationSidebar.js.map +0 -1
- package/dist/images/bg-shape-black.webp +0 -0
- package/dist/images/parhelia-logo-1.jpg +0 -0
- package/dist/images/phlogo.png +0 -0
- package/dist/images/wizard-bg.png +0 -0
- package/dist/styles.css +0 -8962
- package/dist/task-board/components/ProjectList.d.ts +0 -7
- package/dist/task-board/components/ProjectList.js +0 -74
- package/dist/task-board/components/ProjectList.js.map +0 -1
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { SimpleTabs } from "../ui/SimpleTabs";
|
|
3
|
-
import { CopyButton } from "../../components/ui/copy-button";
|
|
4
|
-
import { useEffect, useState } from "react";
|
|
5
|
-
import { getComponentByIdFromHeadlessLayout } from "../componentTreeHelper";
|
|
6
|
-
import { ObjectInspector, ObjectLabel, ObjectRootLabel } from "react-inspector";
|
|
7
|
-
import { useEditContext } from "../client/editContext";
|
|
8
|
-
import { usePageViewContext } from "../page-viewer/pageViewContext";
|
|
9
|
-
import { getPageJson } from "../services/contentService";
|
|
10
|
-
export function Debug({}) {
|
|
11
|
-
const [activeTab, setActiveTab] = useState(0);
|
|
12
|
-
const [pageLayout, setPageLayout] = useState(null);
|
|
13
|
-
const editContext = useEditContext();
|
|
14
|
-
if (!editContext)
|
|
15
|
-
return;
|
|
16
|
-
const pageViewContext = usePageViewContext({
|
|
17
|
-
pageItemDescriptor: editContext.item?.descriptor,
|
|
18
|
-
itemsRepository: editContext.itemsRepository,
|
|
19
|
-
configuration: editContext.configuration,
|
|
20
|
-
});
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
const loadLayout = async () => {
|
|
23
|
-
if (!editContext.item)
|
|
24
|
-
return;
|
|
25
|
-
const layout = await getPageJson(editContext.item.descriptor);
|
|
26
|
-
setPageLayout(layout);
|
|
27
|
-
};
|
|
28
|
-
loadLayout();
|
|
29
|
-
}, [editContext.item]);
|
|
30
|
-
const page = pageLayout; // editContext.page;
|
|
31
|
-
let component = null;
|
|
32
|
-
if (page) {
|
|
33
|
-
const selectedComponents = editContext.selection
|
|
34
|
-
.map((x) => getComponentByIdFromHeadlessLayout(x, page))
|
|
35
|
-
.filter((x) => x);
|
|
36
|
-
component = selectedComponents.length === 1 ? selectedComponents[0] : null;
|
|
37
|
-
}
|
|
38
|
-
if (!component && !page)
|
|
39
|
-
return;
|
|
40
|
-
const replacer = function (key, value) {
|
|
41
|
-
if (key === "parentComponent" ||
|
|
42
|
-
key === "placeholderReference" ||
|
|
43
|
-
key === "_editor") {
|
|
44
|
-
return undefined;
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
};
|
|
48
|
-
const tabs = [];
|
|
49
|
-
const defaultNodeRenderer = ({ depth, name, data, isNonenumerable }) => {
|
|
50
|
-
if (name == "__editor" ||
|
|
51
|
-
name == "parentComponent" ||
|
|
52
|
-
name == "placeholderReference")
|
|
53
|
-
return null;
|
|
54
|
-
return depth === 0 ? (_jsx(ObjectRootLabel, { name: name, data: data })) : (_jsx(ObjectLabel, { name: name, data: data, isNonenumerable: isNonenumerable }));
|
|
55
|
-
};
|
|
56
|
-
if (component) {
|
|
57
|
-
tabs.push({
|
|
58
|
-
label: "Component",
|
|
59
|
-
id: "component",
|
|
60
|
-
content: (_jsx("div", { className: "relative flex-1", children: _jsx("div", { className: "absolute inset-0 overflow-auto p-2", children: _jsx(ObjectInspector, { data: component, nodeRenderer: defaultNodeRenderer }) }) })),
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
tabs.push({
|
|
64
|
-
label: "Page",
|
|
65
|
-
id: "page",
|
|
66
|
-
content: (_jsx("div", { className: "relative flex-1", children: _jsx("div", { className: "absolute inset-0 overflow-auto p-2", children: _jsx(ObjectInspector, { data: page, nodeRenderer: defaultNodeRenderer }) }) })),
|
|
67
|
-
});
|
|
68
|
-
return (_jsxs("div", { className: "relative flex h-[calc(100%-6px)] flex-col", children: [_jsx(SimpleTabs, { tabs: tabs, activeTab: activeTab, setActiveTab: setActiveTab, className: "border-gray-3 flex border-b px-2 pt-2 text-xs" }), _jsx("div", { className: "absolute top-2 right-1 h-4 w-4", children: _jsx(CopyButton, { textToCopy: JSON.stringify(activeTab === 0 && component ? component : page, replacer, 2), iconOnly: true }) })] }));
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=Debug.js.map
|
|
@@ -1 +0,0 @@
|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|
-
import { Splitter } from "../ui/Splitter";
|
|
4
|
-
import CodeEditor from "@uiw/react-textarea-code-editor";
|
|
5
|
-
import { ActionButton } from "../../components/ActionButton";
|
|
6
|
-
import { useEffect, useState } from "react";
|
|
7
|
-
import { useEditContext } from "../client/editContext";
|
|
8
|
-
import { ObjectInspector } from "react-inspector";
|
|
9
|
-
import { SimpleTabs } from "../ui/SimpleTabs";
|
|
10
|
-
import { createAgentCommand } from "../commands/agentCommands";
|
|
11
|
-
import { RefreshCw } from "lucide-react";
|
|
12
|
-
export function GraphQL() {
|
|
13
|
-
const editContext = useEditContext();
|
|
14
|
-
const [query, setQuery] = useState("");
|
|
15
|
-
const [showSpinner, setShowSpinner] = useState(false);
|
|
16
|
-
const [graphqlResult, setGraphqlResult] = useState({});
|
|
17
|
-
const [schemaResult, setSchemaResult] = useState({});
|
|
18
|
-
const [showSchemaSpinner, setShowSchemaSpinner] = useState(false);
|
|
19
|
-
const [activeTab, setActiveTab] = useState(0);
|
|
20
|
-
const [aiGeneratedQuery, setAiGeneratedQuery] = useState("");
|
|
21
|
-
let item = editContext?.page?.item;
|
|
22
|
-
useEffect(() => {
|
|
23
|
-
setShowSpinner(false);
|
|
24
|
-
}, [editContext?.refreshCompletedFlag]);
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
const graphql_query = item?.fields.find((x) => x.name === "graphql_query")?.rawValue;
|
|
27
|
-
if (graphql_query)
|
|
28
|
-
setQuery(graphql_query || "");
|
|
29
|
-
}, [item]);
|
|
30
|
-
// Auto-fetch schema when Schema tab is activated (now tab index 0)
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (activeTab === 0 && !schemaResult?.data && !showSchemaSpinner) {
|
|
33
|
-
fetchSchema();
|
|
34
|
-
}
|
|
35
|
-
}, [activeTab]);
|
|
36
|
-
// Register a context factory for GraphQL so agents can pull structured context without tool reads
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!editContext || !item)
|
|
39
|
-
return;
|
|
40
|
-
const factoryName = "graphql:context:v1";
|
|
41
|
-
const factory = async () => ({
|
|
42
|
-
schema: schemaResult?.data || "",
|
|
43
|
-
currentQuery: query,
|
|
44
|
-
itemContext: {
|
|
45
|
-
id: item.id,
|
|
46
|
-
language: item.language,
|
|
47
|
-
version: item.version,
|
|
48
|
-
},
|
|
49
|
-
});
|
|
50
|
-
editContext.registerContextFactory?.(factoryName, factory);
|
|
51
|
-
return () => editContext.unregisterContextFactory?.(factoryName);
|
|
52
|
-
}, [
|
|
53
|
-
editContext,
|
|
54
|
-
item?.id,
|
|
55
|
-
item?.language,
|
|
56
|
-
item?.version,
|
|
57
|
-
query,
|
|
58
|
-
schemaResult?.data,
|
|
59
|
-
]);
|
|
60
|
-
// if (item) {
|
|
61
|
-
// const selectedComponents = editContext!.selection
|
|
62
|
-
// .map((x) => getComponentById(x, editContext!.page!))
|
|
63
|
-
// .filter((x) => x) as Component[];
|
|
64
|
-
// if (selectedComponents.length === 1) item = selectedComponents[0];
|
|
65
|
-
// }
|
|
66
|
-
// type JsonType = { [key: string]: any };
|
|
67
|
-
// function findFields(json: JsonType): { [key: string]: Array<JsonValueType> } {
|
|
68
|
-
// let result: { [key: string]: Array<JsonValueType> } = {};
|
|
69
|
-
// for (let key in json) {
|
|
70
|
-
// if (typeof json[key] === "object" && json[key] !== null) {
|
|
71
|
-
// let subResult = findFields(json[key]);
|
|
72
|
-
// for (let subKey in subResult) {
|
|
73
|
-
// if (result[subKey]) {
|
|
74
|
-
// result[subKey] = result[subKey].concat(subResult[subKey]);
|
|
75
|
-
// } else {
|
|
76
|
-
// result[subKey] = subResult[subKey];
|
|
77
|
-
// }
|
|
78
|
-
// }
|
|
79
|
-
// }
|
|
80
|
-
// if (key === "jsonValue" && json[key]) {
|
|
81
|
-
// let groupKey = `${json[key].itemId}_${json[key].language}_${json[key].version}`;
|
|
82
|
-
// if (result[groupKey]) {
|
|
83
|
-
// result[groupKey].push(json[key]);
|
|
84
|
-
// } else {
|
|
85
|
-
// result[groupKey] = [json[key]];
|
|
86
|
-
// }
|
|
87
|
-
// }
|
|
88
|
-
// }
|
|
89
|
-
// return result;
|
|
90
|
-
// }
|
|
91
|
-
//type JsonValueType = { itemId: string; language: string; version: string };
|
|
92
|
-
//const fieldsjsonValues = findFields(graphql);
|
|
93
|
-
// function renderItem(fields: Field[]) {
|
|
94
|
-
// const first = fields[0];
|
|
95
|
-
// const item = first.descriptor.item;
|
|
96
|
-
// if (!item) return null;
|
|
97
|
-
// return (
|
|
98
|
-
// <div key={first.id + item.id + item.language + item.version}>
|
|
99
|
-
// Item: {item.id} {first.id} {item.language} {item.version}
|
|
100
|
-
// <FieldList
|
|
101
|
-
// fields={fields}
|
|
102
|
-
// validators={
|
|
103
|
-
// editContext?.pageValidationResult?.find(
|
|
104
|
-
// (x) =>
|
|
105
|
-
// x.item.id === item.id &&
|
|
106
|
-
// x.item.language === item.language &&
|
|
107
|
-
// x.item.version === item.version
|
|
108
|
-
// )?.results || []
|
|
109
|
-
// }
|
|
110
|
-
// />
|
|
111
|
-
// </div>
|
|
112
|
-
// );
|
|
113
|
-
// }
|
|
114
|
-
if (!item)
|
|
115
|
-
return null;
|
|
116
|
-
async function refresh() {
|
|
117
|
-
if (!item || !query.trim())
|
|
118
|
-
return;
|
|
119
|
-
setShowSpinner(true);
|
|
120
|
-
try {
|
|
121
|
-
const response = await fetch("/alpaca/headless/graphql", {
|
|
122
|
-
method: "POST",
|
|
123
|
-
headers: {
|
|
124
|
-
"Content-Type": "application/json",
|
|
125
|
-
},
|
|
126
|
-
body: JSON.stringify({
|
|
127
|
-
Query: query,
|
|
128
|
-
ItemId: item.id,
|
|
129
|
-
Language: item.language,
|
|
130
|
-
Version: item.version,
|
|
131
|
-
}),
|
|
132
|
-
});
|
|
133
|
-
if (!response.ok) {
|
|
134
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
135
|
-
}
|
|
136
|
-
const result = await response.json();
|
|
137
|
-
if (result.errors) {
|
|
138
|
-
setGraphqlResult({ status: 400, errors: result.errors });
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
setGraphqlResult({ data: result.data, status: response.status });
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
catch (error) {
|
|
145
|
-
console.error("GraphQL query error:", error);
|
|
146
|
-
setGraphqlResult({ error: String(error) });
|
|
147
|
-
}
|
|
148
|
-
finally {
|
|
149
|
-
setShowSpinner(false);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async function fetchSchema() {
|
|
153
|
-
if (!item)
|
|
154
|
-
return;
|
|
155
|
-
setShowSchemaSpinner(true);
|
|
156
|
-
try {
|
|
157
|
-
const response = await fetch("/alpaca/headless/graphql/schema", {
|
|
158
|
-
method: "POST",
|
|
159
|
-
headers: {
|
|
160
|
-
"Content-Type": "application/json",
|
|
161
|
-
},
|
|
162
|
-
body: JSON.stringify({
|
|
163
|
-
ItemId: item.id,
|
|
164
|
-
Language: item.language,
|
|
165
|
-
Version: item.version,
|
|
166
|
-
Schema: "Default", // You may want to make this configurable
|
|
167
|
-
}),
|
|
168
|
-
});
|
|
169
|
-
if (!response.ok) {
|
|
170
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
171
|
-
}
|
|
172
|
-
const result = await response.text(); // Schema returns plain text, not JSON
|
|
173
|
-
setSchemaResult({ data: result, status: response.status });
|
|
174
|
-
}
|
|
175
|
-
catch (error) {
|
|
176
|
-
console.error("Schema fetch error:", error);
|
|
177
|
-
setSchemaResult({ error: String(error) });
|
|
178
|
-
}
|
|
179
|
-
finally {
|
|
180
|
-
setShowSchemaSpinner(false);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
// Function to apply AI-generated query to the editor
|
|
184
|
-
const applyQueryToEditor = (newQuery) => {
|
|
185
|
-
setQuery(newQuery);
|
|
186
|
-
setAiGeneratedQuery(newQuery);
|
|
187
|
-
};
|
|
188
|
-
// Extract GraphQL queries from AI response
|
|
189
|
-
const extractGraphQLFromResponse = (responseText) => {
|
|
190
|
-
const graphqlBlockRegex = /```graphql\s*([\s\S]*?)\s*```/i;
|
|
191
|
-
const match = responseText.match(graphqlBlockRegex);
|
|
192
|
-
return match ? match[1]?.trim() || null : null;
|
|
193
|
-
};
|
|
194
|
-
// removed old AiTerminal context
|
|
195
|
-
// Register a context factory for GraphQL so agents can pull structured context without tool reads
|
|
196
|
-
// (moved useEffect for context factory above to ensure hooks order remains stable)
|
|
197
|
-
return (_jsx(Splitter, { direction: "vertical", className: "h-full", panels: [
|
|
198
|
-
{
|
|
199
|
-
name: "query",
|
|
200
|
-
defaultSize: 850,
|
|
201
|
-
className: "flex flex-col min-h-[500px]",
|
|
202
|
-
content: (_jsxs("div", { className: "flex flex-1 flex-col overflow-hidden", children: [aiGeneratedQuery && aiGeneratedQuery !== query && (_jsxs("div", { className: "flex items-center gap-2 border-b border-yellow-200 bg-yellow-50 p-2 text-xs", children: [_jsx("span", { className: "text-yellow-800", children: "AI generated a new query" }), _jsx(ActionButton, { onClick: () => applyQueryToEditor(aiGeneratedQuery), className: "p-1 text-xs", variant: "outline", children: "Apply" }), _jsx(ActionButton, { onClick: () => setAiGeneratedQuery(""), className: "p-1", variant: "ghost", children: "\u00D7" })] })), _jsxs("div", { className: "flex h-full flex-col", children: [_jsxs("div", { className: "flex flex-1 flex-col border-b border-gray-300", children: [_jsx("div", { className: "border-b border-gray-300 bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700", children: "GraphQL Query" }), _jsx("div", { className: "relative flex-1", children: _jsx("div", { className: "absolute inset-0 overflow-auto", children: _jsx(CodeEditor, { value: query, language: "graphql", placeholder: "Enter your GraphQL query here...", onChange: (evn) => setQuery(evn.target.value), padding: 15, style: {
|
|
203
|
-
fontSize: 12,
|
|
204
|
-
backgroundColor: "#f8f9fa",
|
|
205
|
-
fontFamily: "ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace",
|
|
206
|
-
} }) }) })] }), _jsx("div", { className: "flex items-center justify-center border-b border-gray-300 bg-gray-50 py-3", children: _jsxs(ActionButton, { onClick: refresh, disabled: showSpinner, className: "px-4 py-2", variant: "outline", children: [_jsx(RefreshCw, { strokeWidth: 1.5, className: "mr-2 h-4 w-4" }), "Run"] }) }), _jsxs("div", { className: "flex flex-1 flex-col", children: [_jsx("div", { className: "border-b border-gray-300 bg-gray-100 px-3 py-2 text-sm font-medium text-gray-700", children: "JSON Result" }), _jsx("div", { className: "flex-1 overflow-auto p-2", children: _jsx("div", { className: "min-w-0 overflow-x-auto", children: _jsx(ObjectInspector, { data: graphqlResult, expandLevel: 3 }) }) })] })] })] })),
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
name: "schema",
|
|
210
|
-
defaultSize: 150,
|
|
211
|
-
className: "flex flex-col text-xs min-h-[150px]",
|
|
212
|
-
content: (_jsxs("div", { className: "flex flex-1 flex-col text-xs", children: [_jsx(SimpleTabs, { className: "border-gray-3 border-b px-2 pt-2", tabs: [
|
|
213
|
-
{
|
|
214
|
-
id: "schema",
|
|
215
|
-
label: "Schema",
|
|
216
|
-
content: (_jsxs("div", { className: "relative h-full overflow-hidden", children: [_jsx("div", { className: "flex items-center gap-2 border-b p-2", children: _jsx(ActionButton, { onClick: fetchSchema, disabled: showSchemaSpinner, variant: "outline", className: "text-sm", children: "\uD83D\uDCE5 Fetch Schema" }) }), _jsx("div", { className: "flex-1 overflow-auto p-2", children: _jsx("div", { className: "min-w-0 overflow-x-auto", children: _jsx(ObjectInspector, { data: schemaResult, expandLevel: 3 }) }) })] })),
|
|
217
|
-
},
|
|
218
|
-
], activeTab: activeTab, setActiveTab: setActiveTab }), _jsx("div", { className: "border-t border-gray-200 p-2", children: _jsx(ActionButton, { variant: "outline", className: "text-xs", onClick: () => {
|
|
219
|
-
editContext?.executeCommand?.({
|
|
220
|
-
command: createAgentCommand,
|
|
221
|
-
data: {
|
|
222
|
-
profileName: "GraphQL Assistant",
|
|
223
|
-
contextFactory: "graphql:context:v1",
|
|
224
|
-
initialPrompt: "Help with the current GraphQL query and schema.",
|
|
225
|
-
additionalData: {
|
|
226
|
-
source: "GraphQLPanel",
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
});
|
|
230
|
-
}, children: "Start GraphQL Agent" }) })] })),
|
|
231
|
-
},
|
|
232
|
-
] }));
|
|
233
|
-
}
|
|
234
|
-
//# sourceMappingURL=GraphQL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GraphQL.js","sourceRoot":"","sources":["../../../src/editor/sidebar/GraphQL.tsx"],"names":[],"mappings":";AAAA,OAAO,0CAA0C,CAAC;AAElD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,UAAU,MAAM,iCAAiC,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE5C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,MAAM,UAAU,OAAO;IACrB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAAM,EAAE,CAAC,CAAC;IAC5D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAM,EAAE,CAAC,CAAC;IAC1D,MAA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cAAK,SAAS,EAAC,0BAA0B,YACvC,cAAK,SAAS,EAAC,yBAAyB,YACtC,KAAC,eAAe,IACd,IAAI,EAAE,YAAY,EAClB,WAAW,EAAE,CAAC,GACd,GACE,GACF,IACF,CACP;iCACF;6BACF,EACD,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,GAC1B,EACF,cAAK,SAAS,EAAC,8BAA8B,YAC3C,KAAC,YAAY,IACX,OAAO,EAAC,SAAS,EACjB,SAAS,EAAC,SAAS,EACnB,OAAO,EAAE,GAAG,EAAE;oCACZ,WAAW,EAAE,cAAc,EAAE,CAAC;wCAC5B,OAAO,EAAE,kBAAkB;wCAC3B,IAAI,EAAE;4CACJ,WAAW,EAAE,mBAAmB;4CAChC,cAAc,EAAE,oBAAoB;4CACpC,aAAa,EACX,iDAAiD;4CACnD,cAAc,EAAE;gDACd,MAAM,EAAE,cAAc;6CACvB;yCACF;qCACF,CAAC,CAAC;gCACL,CAAC,oCAGY,GACX,IACF,CACP;aACF;SACF,GACD,CACH,CAAC;AACJ,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function LeftToolbar(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "../../lib/utils";
|
|
3
|
-
import { useEditContext } from "../client/editContext";
|
|
4
|
-
import { NavigationSidebar } from "./NavigationSidebar";
|
|
5
|
-
export function LeftToolbar() {
|
|
6
|
-
const editContext = useEditContext();
|
|
7
|
-
const showLabels = editContext?.userInfo.preferences?.showLabels ?? editContext?.userInfo.preferences?.showViewNames ?? false;
|
|
8
|
-
return (_jsx("div", { className: cn("border-gray-200 bg-gray-50/50 flex items-center gap-1.5 border-r p-1.5", editContext?.isMobile
|
|
9
|
-
? "scrollbar-hide flex-row overflow-x-auto"
|
|
10
|
-
: `flex-col ${showLabels ? "w-16" : "w-9"}`), children: _jsx(NavigationSidebar, {}) }));
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=LeftToolbar.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"LeftToolbar.js","sourceRoot":"","sources":["../../../src/editor/sidebar/LeftToolbar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,UAAU,WAAW;IACzB,MAAM,WAAW,GAAG,cAAc,EAAE,CAAC;IACrC,MAAM,UAAU,GACd,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,UAAU,IAAI,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,aAAa,IAAI,KAAK,CAAC;IAC7G,OAAO,CACL,cACE,SAAS,EAAE,EAAE,CACX,wEAAwE,EACxE,WAAW,EAAE,QAAQ;YACnB,CAAC,CAAC,yCAAyC;YAC3C,CAAC,CAAC,YAAY,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,CAC9C,YAED,KAAC,iBAAiB,KAAG,GACjB,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,254 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import React, { useState, useMemo, useCallback, useRef, useEffect, } from "react";
|
|
3
|
-
import { cn } from "../../lib/utils";
|
|
4
|
-
import { useEditContext } from "../client/editContext";
|
|
5
|
-
import { VerticalDotsIcon, ViewToggleIcon } from "../ui/Icons";
|
|
6
|
-
import { Popover, PopoverContent, PopoverTrigger, } from "../../components/ui/popover";
|
|
7
|
-
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "../../components/ui/tooltip";
|
|
8
|
-
import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "../../components/ui/context-menu";
|
|
9
|
-
import { DrawingPinFilledIcon, DrawingPinIcon } from "@radix-ui/react-icons";
|
|
10
|
-
import { Pin, PinOff, X } from "lucide-react";
|
|
11
|
-
function NavigationSidebarComponent() {
|
|
12
|
-
const editContext = useEditContext();
|
|
13
|
-
// Extract sidebar values
|
|
14
|
-
const contextValues = useMemo(() => ({
|
|
15
|
-
// Workspace state (for checking if we're in Editor workspace)
|
|
16
|
-
workspaceId: editContext?.workspaceId ?? "home",
|
|
17
|
-
// Sidebar state (for Editor workspace)
|
|
18
|
-
sidebars: editContext?.availableSidebars ?? [],
|
|
19
|
-
openSidebars: editContext?.openSidebars ?? [],
|
|
20
|
-
pinnedSidebars: editContext?.pinnedSidebars ?? [],
|
|
21
|
-
lockedSidebars: editContext?.lockedSidebars ?? [],
|
|
22
|
-
sidebarStacks: editContext?.sidebarStacks ?? [],
|
|
23
|
-
toggleSidebar: editContext?.toggleSidebar,
|
|
24
|
-
openSidebar: editContext?.openSidebar,
|
|
25
|
-
toggleSidebarPin: editContext?.toggleSidebarPin,
|
|
26
|
-
toggleSidebarLock: editContext?.toggleSidebarLock,
|
|
27
|
-
stackSidebar: editContext?.stackSidebar,
|
|
28
|
-
unstackSidebar: editContext?.unstackSidebar,
|
|
29
|
-
// Display preferences
|
|
30
|
-
showLabels: editContext?.userInfo.preferences?.showLabels ??
|
|
31
|
-
editContext?.userInfo.preferences?.showViewNames ??
|
|
32
|
-
false,
|
|
33
|
-
isMobile: editContext?.isMobile ?? false,
|
|
34
|
-
setUserPreferences: editContext?.setUserPreferences,
|
|
35
|
-
// Workspace state
|
|
36
|
-
visibleWorkspaces: editContext?.visibleWorkspaces ?? [],
|
|
37
|
-
switchWorkspace: editContext?.switchWorkspace,
|
|
38
|
-
}), [
|
|
39
|
-
editContext?.workspaceId,
|
|
40
|
-
editContext?.availableSidebars,
|
|
41
|
-
editContext?.openSidebars,
|
|
42
|
-
editContext?.pinnedSidebars,
|
|
43
|
-
editContext?.lockedSidebars,
|
|
44
|
-
editContext?.toggleSidebar,
|
|
45
|
-
editContext?.openSidebar,
|
|
46
|
-
editContext?.toggleSidebarPin,
|
|
47
|
-
editContext?.toggleSidebarLock,
|
|
48
|
-
editContext?.sidebarStacks,
|
|
49
|
-
editContext?.stackSidebar,
|
|
50
|
-
editContext?.unstackSidebar,
|
|
51
|
-
editContext?.userInfo.preferences?.showLabels,
|
|
52
|
-
editContext?.userInfo.preferences?.showViewNames,
|
|
53
|
-
editContext?.isMobile,
|
|
54
|
-
editContext?.setUserPreferences,
|
|
55
|
-
editContext?.visibleWorkspaces,
|
|
56
|
-
editContext?.switchWorkspace,
|
|
57
|
-
]);
|
|
58
|
-
const [isSidebarPopoverOpen, setIsSidebarPopoverOpen] = useState(false);
|
|
59
|
-
const [disableTooltip, setDisableTooltip] = useState(false);
|
|
60
|
-
const tooltipReenableTimer = useRef(null);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
return () => {
|
|
63
|
-
if (tooltipReenableTimer.current) {
|
|
64
|
-
window.clearTimeout(tooltipReenableTimer.current);
|
|
65
|
-
tooltipReenableTimer.current = null;
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
}, []);
|
|
69
|
-
// Check if we're in the Editor workspace (which supports sidebars)
|
|
70
|
-
const isEditorWorkspace = contextValues.workspaceId === "editor";
|
|
71
|
-
// Get visible sidebars for the current position
|
|
72
|
-
const leftSidebars = useMemo(() => {
|
|
73
|
-
return contextValues.sidebars
|
|
74
|
-
.filter((s) => s.position === "left" && !s.hidden)
|
|
75
|
-
.sort((a, b) => (a.sortOrder ?? 100) - (b.sortOrder ?? 100));
|
|
76
|
-
}, [contextValues.sidebars]);
|
|
77
|
-
const toggleShowLabels = useCallback(() => {
|
|
78
|
-
const newShowLabels = !contextValues.showLabels;
|
|
79
|
-
contextValues.setUserPreferences?.({ showLabels: newShowLabels });
|
|
80
|
-
}, [contextValues.showLabels, contextValues.setUserPreferences]);
|
|
81
|
-
const mobileWorkspaces = useMemo(() => {
|
|
82
|
-
const base = (contextValues.visibleWorkspaces ?? [])
|
|
83
|
-
.filter((w) => !w.hidden)
|
|
84
|
-
.filter((w) => w.id !== "home")
|
|
85
|
-
.slice()
|
|
86
|
-
.sort((a, b) => (a.sortOrder ?? 100) - (b.sortOrder ?? 100));
|
|
87
|
-
const settingsIndex = base.findIndex((w) => w.id === "settings");
|
|
88
|
-
if (settingsIndex >= 0) {
|
|
89
|
-
const [settings] = base.splice(settingsIndex, 1);
|
|
90
|
-
if (settings)
|
|
91
|
-
base.push(settings);
|
|
92
|
-
}
|
|
93
|
-
return base;
|
|
94
|
-
}, [contextValues.visibleWorkspaces]);
|
|
95
|
-
const handleWorkspaceClick = useCallback((targetWorkspaceId) => {
|
|
96
|
-
if (targetWorkspaceId !== contextValues.workspaceId) {
|
|
97
|
-
contextValues.switchWorkspace?.(targetWorkspaceId);
|
|
98
|
-
}
|
|
99
|
-
}, [contextValues.workspaceId, contextValues.switchWorkspace]);
|
|
100
|
-
const renderIcon = useCallback((icon, additionalClassName) => {
|
|
101
|
-
if (icon && React.isValidElement(icon)) {
|
|
102
|
-
return React.cloneElement(icon, {
|
|
103
|
-
className: cn("w-4 h-4", additionalClassName),
|
|
104
|
-
strokeWidth: 1.5,
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return null;
|
|
108
|
-
}, []);
|
|
109
|
-
const handleSidebarClick = useCallback((sidebarId) => {
|
|
110
|
-
contextValues.toggleSidebar?.(sidebarId);
|
|
111
|
-
}, [contextValues.toggleSidebar]);
|
|
112
|
-
const handleSidebarClickAndClosePopover = useCallback((sidebarId) => {
|
|
113
|
-
contextValues.openSidebar?.(sidebarId);
|
|
114
|
-
if (tooltipReenableTimer.current) {
|
|
115
|
-
window.clearTimeout(tooltipReenableTimer.current);
|
|
116
|
-
}
|
|
117
|
-
setDisableTooltip(true);
|
|
118
|
-
tooltipReenableTimer.current = window.setTimeout(() => {
|
|
119
|
-
setDisableTooltip(false);
|
|
120
|
-
tooltipReenableTimer.current = null;
|
|
121
|
-
}, 800);
|
|
122
|
-
setIsSidebarPopoverOpen(false);
|
|
123
|
-
}, [contextValues.openSidebar]);
|
|
124
|
-
const handlePinClick = useCallback((e, sidebarId) => {
|
|
125
|
-
e.stopPropagation();
|
|
126
|
-
contextValues.toggleSidebarPin?.(sidebarId);
|
|
127
|
-
}, [contextValues.toggleSidebarPin]);
|
|
128
|
-
// Drag state for reordering pinned sidebar icons
|
|
129
|
-
const [dragOverId, setDragOverId] = useState(null);
|
|
130
|
-
const handleIconDragStart = useCallback((e, sidebarId) => {
|
|
131
|
-
e.dataTransfer.setData("text/alpaca-sidebar-icon", sidebarId);
|
|
132
|
-
e.dataTransfer.effectAllowed = "move";
|
|
133
|
-
}, []);
|
|
134
|
-
const handleIconDragOver = useCallback((e, sidebarId) => {
|
|
135
|
-
e.preventDefault();
|
|
136
|
-
e.dataTransfer.dropEffect = "move";
|
|
137
|
-
setDragOverId(sidebarId);
|
|
138
|
-
}, []);
|
|
139
|
-
const handleIconDragLeave = useCallback(() => {
|
|
140
|
-
setDragOverId(null);
|
|
141
|
-
}, []);
|
|
142
|
-
const handleIconDrop = useCallback((e, targetSidebarId) => {
|
|
143
|
-
e.preventDefault();
|
|
144
|
-
setDragOverId(null);
|
|
145
|
-
const sourceSidebarId = e.dataTransfer.getData("text/alpaca-sidebar-icon");
|
|
146
|
-
if (!sourceSidebarId || sourceSidebarId === targetSidebarId) {
|
|
147
|
-
return;
|
|
148
|
-
}
|
|
149
|
-
// Reorder pinned sidebars
|
|
150
|
-
const currentPinned = [...contextValues.pinnedSidebars];
|
|
151
|
-
const sourceIndex = currentPinned.indexOf(sourceSidebarId);
|
|
152
|
-
const targetIndex = currentPinned.indexOf(targetSidebarId);
|
|
153
|
-
if (sourceIndex === -1 || targetIndex === -1) {
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
// Remove source and insert at target position
|
|
157
|
-
currentPinned.splice(sourceIndex, 1);
|
|
158
|
-
const newTargetIndex = currentPinned.indexOf(targetSidebarId);
|
|
159
|
-
const insertIndex = sourceIndex < targetIndex ? newTargetIndex + 1 : newTargetIndex;
|
|
160
|
-
currentPinned.splice(insertIndex, 0, sourceSidebarId);
|
|
161
|
-
editContext?.reorderPinnedSidebars?.(currentPinned);
|
|
162
|
-
}, [contextValues.pinnedSidebars, editContext]);
|
|
163
|
-
// Get the currently visible sidebars in the selector (pinned + open)
|
|
164
|
-
// Order: pinned sidebars first (in their saved order), then open-but-not-pinned
|
|
165
|
-
const visibleSidebarItems = useMemo(() => {
|
|
166
|
-
const pinnedSet = new Set(contextValues.pinnedSidebars);
|
|
167
|
-
const openSet = new Set(contextValues.openSidebars);
|
|
168
|
-
const sidebarMap = new Map(leftSidebars.map((s) => [s.id, s]));
|
|
169
|
-
// Start with pinned sidebars in their saved order
|
|
170
|
-
const result = [];
|
|
171
|
-
for (const id of contextValues.pinnedSidebars) {
|
|
172
|
-
const sidebar = sidebarMap.get(id);
|
|
173
|
-
if (sidebar) {
|
|
174
|
-
result.push(sidebar);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
// Add open-but-not-pinned sidebars (in their sortOrder)
|
|
178
|
-
for (const sidebar of leftSidebars) {
|
|
179
|
-
if (openSet.has(sidebar.id) && !pinnedSet.has(sidebar.id)) {
|
|
180
|
-
result.push(sidebar);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
return result;
|
|
184
|
-
}, [leftSidebars, contextValues.pinnedSidebars, contextValues.openSidebars]);
|
|
185
|
-
return (_jsxs(TooltipProvider, { delayDuration: 500, skipDelayDuration: 0, children: [isEditorWorkspace &&
|
|
186
|
-
visibleSidebarItems.map((sidebar) => {
|
|
187
|
-
const isOpen = contextValues.openSidebars.includes(sidebar.id);
|
|
188
|
-
const isPinned = contextValues.pinnedSidebars.includes(sidebar.id);
|
|
189
|
-
const currentStack = contextValues.sidebarStacks?.find((s) => s.includes(sidebar.id)) ??
|
|
190
|
-
null;
|
|
191
|
-
const isStacked = !!(currentStack && currentStack.length > 1);
|
|
192
|
-
// Check if any sidebar in the stack is locked (stack-level lock)
|
|
193
|
-
const isLocked = currentStack
|
|
194
|
-
? currentStack.some((id) => contextValues.lockedSidebars?.includes(id))
|
|
195
|
-
: (contextValues.lockedSidebars?.includes(sidebar.id) ?? false);
|
|
196
|
-
const stackCandidates = leftSidebars.filter((s) => s.id !== sidebar.id && contextValues.openSidebars.includes(s.id));
|
|
197
|
-
return (_jsxs(ContextMenu, { children: [_jsx(ContextMenuTrigger, { asChild: true, children: _jsxs(Tooltip, { delayDuration: 500, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsxs("div", { className: cn(
|
|
198
|
-
// Sidebar icons: smaller, subtler appearance
|
|
199
|
-
isOpen
|
|
200
|
-
? "border-gray-300 bg-gray-100 text-gray-900"
|
|
201
|
-
: "border-transparent text-gray-500 hover:bg-gray-50 hover:text-gray-700", "relative flex cursor-pointer flex-col items-center justify-center rounded border select-none", contextValues.showLabels ? "p-1" : "p-1", contextValues.isMobile ? "shrink-0" : "",
|
|
202
|
-
// Drag-over visual feedback
|
|
203
|
-
dragOverId === sidebar.id && "ring-2 ring-blue-400"), "data-sidebar-id": sidebar.id, "data-testid": `sidebar-icon-${sidebar.id}`, onClick: () => {
|
|
204
|
-
handleSidebarClick(sidebar.id);
|
|
205
|
-
},
|
|
206
|
-
// Drag-and-drop for reordering pinned icons
|
|
207
|
-
draggable: isPinned, onDragStart: (e) => isPinned && handleIconDragStart(e, sidebar.id), onDragOver: (e) => isPinned && handleIconDragOver(e, sidebar.id), onDragLeave: handleIconDragLeave, onDrop: (e) => isPinned && handleIconDrop(e, sidebar.id), children: [_jsxs("div", { className: cn("relative", contextValues.showLabels ? "p-0.5" : ""), children: [renderIcon(sidebar.icon), isStacked && (_jsx("div", { className: "bg-theme-secondary absolute right-0 bottom-0 size-1.5 rounded-full" }))] }), contextValues.showLabels && (_jsx("span", { className: "mt-0.5 max-w-[50px] text-center text-[10px] leading-tight wrap-break-word", children: sidebar.title }))] }) }), _jsx(TooltipContent, { side: "right", children: sidebar.title })] }) }), _jsxs(ContextMenuContent, { children: [isOpen && (_jsx(ContextMenuItem, { onSelect: () => {
|
|
208
|
-
contextValues.toggleSidebarLock?.(sidebar.id);
|
|
209
|
-
}, children: isLocked ? (_jsxs(_Fragment, { children: [_jsx(PinOff, { className: "size-4", strokeWidth: 1 }), isStacked ? "Unpin stack" : "Unpin"] })) : (_jsxs(_Fragment, { children: [_jsx(Pin, { className: "size-4", strokeWidth: 1 }), isStacked ? "Pin stack open" : "Pin open"] })) })), isOpen && stackCandidates.length > 0 && (_jsxs(ContextMenuSub, { children: [_jsx(ContextMenuSubTrigger, { children: "Stack with..." }), _jsx(ContextMenuSubContent, { children: stackCandidates.map((target) => (_jsx(ContextMenuItem, { onSelect: () => {
|
|
210
|
-
contextValues.stackSidebar?.(sidebar.id, target.id, "after");
|
|
211
|
-
}, children: target.title }, `stack-with-${sidebar.id}-${target.id}`))) })] })), isOpen && isStacked && (_jsx(ContextMenuItem, { onSelect: () => {
|
|
212
|
-
contextValues.unstackSidebar?.(sidebar.id);
|
|
213
|
-
}, children: "Unstack" })), _jsx(ContextMenuItem, { onSelect: () => {
|
|
214
|
-
contextValues.toggleSidebarPin?.(sidebar.id);
|
|
215
|
-
}, children: isPinned ? (_jsxs(_Fragment, { children: [_jsx(PinOff, { className: "size-4", strokeWidth: 1 }), "Unpin from toolbar"] })) : (_jsxs(_Fragment, { children: [_jsx(Pin, { className: "size-4", strokeWidth: 1 }), "Pin to toolbar"] })) }), isOpen && (_jsxs(ContextMenuItem, { onSelect: () => {
|
|
216
|
-
contextValues.toggleSidebar?.(sidebar.id, {
|
|
217
|
-
forceClose: true,
|
|
218
|
-
});
|
|
219
|
-
}, children: [_jsx(X, { className: "size-4", strokeWidth: 1 }), "Close"] }))] })] }, `sidebar-${sidebar.id}`));
|
|
220
|
-
}), isEditorWorkspace && leftSidebars.length > 0 && (_jsxs(Popover, { open: isSidebarPopoverOpen, onOpenChange: (open) => {
|
|
221
|
-
setIsSidebarPopoverOpen(open);
|
|
222
|
-
}, children: [_jsxs(Tooltip, { delayDuration: disableTooltip ? 100000 : 500, open: isSidebarPopoverOpen || disableTooltip ? false : undefined, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { "data-testid": "more-sidebars-button", className: cn("flex items-center justify-center rounded border border-transparent p-1", "text-gray-400 hover:border-gray-200 hover:bg-gray-50 hover:text-gray-600", contextValues.isMobile ? "shrink-0" : ""), children: _jsx(VerticalDotsIcon, { className: "h-4 w-4" }) }) }) }), _jsx(TooltipContent, { side: "right", children: "More panels" })] }), _jsx(PopoverContent, { className: "w-56 p-2", side: contextValues.isMobile ? "bottom" : "right", align: "start", onInteractOutside: (e) => {
|
|
223
|
-
const target = e.target;
|
|
224
|
-
if (target && target.closest('[data-slot="tooltip-content"]')) {
|
|
225
|
-
e.preventDefault();
|
|
226
|
-
}
|
|
227
|
-
}, onPointerDownOutside: (e) => {
|
|
228
|
-
const target = e.target;
|
|
229
|
-
if (target && target.closest('[data-slot="tooltip-content"]')) {
|
|
230
|
-
e.preventDefault();
|
|
231
|
-
}
|
|
232
|
-
}, onFocusOutside: (e) => {
|
|
233
|
-
const target = e.target;
|
|
234
|
-
if (target && target.closest('[data-slot="tooltip-content"]')) {
|
|
235
|
-
e.preventDefault();
|
|
236
|
-
}
|
|
237
|
-
}, children: _jsxs("div", { className: "space-y-1", children: [_jsx("div", { className: "px-2 py-1 text-[9px] font-medium tracking-wider text-gray-600 uppercase", children: "Sidebars" }), leftSidebars.map((sidebar) => {
|
|
238
|
-
const isOpen = contextValues.openSidebars.includes(sidebar.id);
|
|
239
|
-
const isPinned = contextValues.pinnedSidebars.includes(sidebar.id);
|
|
240
|
-
return (_jsxs("div", { className: cn("group flex cursor-pointer items-center justify-between rounded p-2 hover:bg-gray-100", isOpen && "bg-gray-50"), onClick: () => handleSidebarClickAndClosePopover(sidebar.id), "data-testid": `sidebar-${sidebar.id}`, children: [_jsxs("div", { className: "flex flex-1 items-center gap-1.5", children: [renderIcon(sidebar.icon, "w-4 h-4"), _jsx("span", { className: "text-xs", children: sidebar.title })] }), _jsxs(Tooltip, { delayDuration: 500, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { type: "button", className: "flex h-6 w-6 shrink-0 items-center justify-center rounded hover:bg-gray-200", onClick: (e) => {
|
|
241
|
-
e.stopPropagation();
|
|
242
|
-
e.preventDefault();
|
|
243
|
-
handlePinClick(e, sidebar.id);
|
|
244
|
-
}, onMouseDown: (e) => {
|
|
245
|
-
e.stopPropagation();
|
|
246
|
-
}, children: isPinned ? (_jsx(DrawingPinFilledIcon, { className: "text-theme-secondary h-4 w-4" })) : (_jsx(DrawingPinIcon, { className: "h-4 w-4 text-gray-400" })) }) }), _jsx(TooltipContent, { side: "right", children: isPinned ? "Unpin from toolbar" : "Pin to toolbar" })] })] }, `menu-sidebar-${sidebar.id}`));
|
|
247
|
-
})] }) })] })), _jsx("div", { className: "flex-1" }), contextValues.isMobile && mobileWorkspaces.length > 0 && (_jsxs(_Fragment, { children: [_jsx("div", { className: "mx-1 h-px w-full bg-gray-200" }), mobileWorkspaces.map((workspace) => {
|
|
248
|
-
const active = workspace.id === contextValues.workspaceId;
|
|
249
|
-
return (_jsx("button", { type: "button", "aria-label": workspace.title, "aria-current": active ? "page" : undefined, "data-testid": `workspace-mobile-${workspace.id}`, className: cn("flex items-center justify-center rounded border border-transparent p-1", "text-gray-500 hover:border-gray-200 hover:bg-gray-50 hover:text-gray-800", active && "border-gray-300 bg-gray-100 text-gray-900"), onClick: () => handleWorkspaceClick(workspace.id), children: renderIcon(workspace.icon) }, `workspace-${workspace.id}`));
|
|
250
|
-
})] })), _jsxs(Tooltip, { delayDuration: 500, children: [_jsx(TooltipTrigger, { asChild: true, children: _jsx("button", { className: cn("flex items-center justify-center rounded border border-transparent p-0.5", "text-gray-400 hover:border-gray-200 hover:bg-gray-50 hover:text-gray-600", contextValues.isMobile ? "shrink-0" : ""), onClick: toggleShowLabels, children: _jsx(ViewToggleIcon, { className: "h-4 w-4" }) }) }), _jsx(TooltipContent, { side: "right", children: contextValues.showLabels ? "Hide labels" : "Show labels" })] })] }));
|
|
251
|
-
}
|
|
252
|
-
// Export memoized component to prevent unnecessary re-renders
|
|
253
|
-
export const NavigationSidebar = React.memo(NavigationSidebarComponent);
|
|
254
|
-
//# sourceMappingURL=NavigationSidebar.js.map
|