@powerhousedao/network-admin 0.0.21 → 0.0.23

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.
Files changed (35) hide show
  1. package/dist/editors/network-admin/components/DriveExplorer.d.ts.map +1 -1
  2. package/dist/editors/network-admin/components/DriveExplorer.js +79 -16
  3. package/dist/editors/network-admin/components/icons/PaymentIcon.d.ts +3 -0
  4. package/dist/editors/network-admin/components/icons/PaymentIcon.d.ts.map +1 -0
  5. package/dist/editors/network-admin/components/icons/PaymentIcon.js +2 -0
  6. package/dist/editors/network-admin/components/icons/RfpIcon.d.ts +3 -0
  7. package/dist/editors/network-admin/components/icons/RfpIcon.d.ts.map +1 -0
  8. package/dist/editors/network-admin/components/icons/RfpIcon.js +2 -0
  9. package/dist/editors/network-admin/components/icons/SowIcon.d.ts +3 -0
  10. package/dist/editors/network-admin/components/icons/SowIcon.d.ts.map +1 -0
  11. package/dist/editors/network-admin/components/icons/SowIcon.js +2 -0
  12. package/dist/editors/network-admin/components/icons/WorkstreamIcon.d.ts +3 -0
  13. package/dist/editors/network-admin/components/icons/WorkstreamIcon.d.ts.map +1 -0
  14. package/dist/editors/network-admin/components/icons/WorkstreamIcon.js +2 -0
  15. package/dist/editors/network-admin/index.d.ts.map +1 -1
  16. package/dist/editors/network-admin/index.js +1 -0
  17. package/dist/editors/workstream/editor.d.ts.map +1 -1
  18. package/dist/editors/workstream/editor.js +17 -16
  19. package/dist/style.css +34 -25
  20. package/package.json +13 -13
  21. package/dist/editors/network-admin/components/CreateDocument.d.ts +0 -6
  22. package/dist/editors/network-admin/components/CreateDocument.d.ts.map +0 -1
  23. package/dist/editors/network-admin/components/CreateDocument.js +0 -24
  24. package/dist/editors/network-admin/components/FolderTree.d.ts +0 -15
  25. package/dist/editors/network-admin/components/FolderTree.d.ts.map +0 -1
  26. package/dist/editors/network-admin/components/FolderTree.js +0 -44
  27. package/dist/editors/network-admin/components/IsolatedSidebar.d.ts +0 -22
  28. package/dist/editors/network-admin/components/IsolatedSidebar.d.ts.map +0 -1
  29. package/dist/editors/network-admin/components/IsolatedSidebar.js +0 -107
  30. package/dist/editors/network-admin/components/IsolatedSidebarProvider.d.ts +0 -15
  31. package/dist/editors/network-admin/components/IsolatedSidebarProvider.d.ts.map +0 -1
  32. package/dist/editors/network-admin/components/IsolatedSidebarProvider.js +0 -367
  33. package/dist/editors/network-admin/utils.d.ts +0 -60
  34. package/dist/editors/network-admin/utils.d.ts.map +0 -1
  35. package/dist/editors/network-admin/utils.js +0 -67
@@ -1,107 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { useState, useRef, useCallback } from "react";
3
- import { Icon } from "@powerhousedao/document-engineering";
4
- import { useIsolatedSidebar } from "./IsolatedSidebarProvider.js";
5
- /**
6
- * Isolated Sidebar component that uses our custom context instead of the global one
7
- * This prevents interference with other sidebars in the application
8
- */
9
- export const IsolatedSidebar = ({ nodes, activeNodeId, onActiveNodeChange, sidebarTitle = "Network Admin", showSearchBar = true, allowPinning = true, resizable = true, initialWidth = 300, maxWidth = 500, enableMacros = 3, handleOnTitleClick, className, style, children, }) => {
10
- const sidebarContext = useIsolatedSidebar();
11
- const [isCollapsed, setIsCollapsed] = useState(false);
12
- const [searchTerm, setSearchTerm] = useState("");
13
- const sidebarRef = useRef(null);
14
- const handleToggleCollapse = useCallback(() => {
15
- setIsCollapsed(!isCollapsed);
16
- }, [isCollapsed]);
17
- const handleNodeClick = useCallback((nodeId) => {
18
- sidebarContext.toggleNode(nodeId);
19
- sidebarContext.syncActiveNodeId(nodeId);
20
- if (onActiveNodeChange) {
21
- onActiveNodeChange(nodeId);
22
- }
23
- }, [sidebarContext, onActiveNodeChange]);
24
- const handleSearchChange = useCallback((e) => {
25
- const term = e.target.value;
26
- setSearchTerm(term);
27
- // Simple search implementation
28
- if (term.trim() === "") {
29
- sidebarContext.setSearchResults([]);
30
- sidebarContext.setIsSearching(false);
31
- sidebarContext.setActiveSearchIndex(0);
32
- }
33
- else {
34
- sidebarContext.setIsSearching(true);
35
- // Filter nodes based on search term
36
- const searchInNodes = (nodes, searchTerm) => {
37
- const results = [];
38
- for (const node of nodes) {
39
- const nodeName = node.name || node.title || "";
40
- if (nodeName &&
41
- nodeName.toLowerCase().includes(searchTerm.toLowerCase())) {
42
- results.push(node);
43
- }
44
- if (node.children && node.children.length > 0) {
45
- results.push(...searchInNodes(node.children, searchTerm));
46
- }
47
- }
48
- return results;
49
- };
50
- const searchResults = searchInNodes(sidebarContext.nodes, term);
51
- sidebarContext.setSearchResults(searchResults);
52
- sidebarContext.setIsSearching(false);
53
- sidebarContext.setActiveSearchIndex(0);
54
- }
55
- }, [sidebarContext]);
56
- const renderNode = (node, depth = 0) => {
57
- const isActive = activeNodeId === node.id || sidebarContext.activeNodeId === node.id;
58
- const isExpanded = sidebarContext.expandedNodes.has(node.id);
59
- const hasChildren = node.children && node.children.length > 0;
60
- // Check if this node is the active search result
61
- const isSearchActive = sidebarContext.searchResults.length > 0 &&
62
- sidebarContext.searchResults[sidebarContext.activeSearchIndex]?.id ===
63
- node.id;
64
- // Check if this node matches the search term
65
- const nodeName = node.name || node.title || "";
66
- const matchesSearch = searchTerm && nodeName.toLowerCase().includes(searchTerm.toLowerCase());
67
- return (_jsxs("div", { className: "select-none", children: [_jsxs("div", { className: `flex items-center py-2 px-3 cursor-pointer rounded-md mx-2 ${isActive
68
- ? "bg-gray-200 text-gray-900 font-semibold"
69
- : isSearchActive
70
- ? "bg-yellow-100 dark:bg-[#604B0033] text-gray-700 hover:bg-yellow-200"
71
- : "text-gray-700 hover:bg-gray-200"}`, style: { paddingLeft: `${depth * 16 + 12}px` }, onClick: () => handleNodeClick(node.id), children: [hasChildren && (_jsx("button", { className: "mr-1 p-1 hover:bg-gray-300 rounded transition-colors", onClick: (e) => {
72
- e.stopPropagation();
73
- sidebarContext.toggleNode(node.id);
74
- }, children: _jsx(Icon, { name: isExpanded ? "ChevronDown" : "CaretRight", size: 16, className: "text-gray-500" }) })), !hasChildren && (_jsx("div", { className: "mr-1 p-1", children: _jsx(Icon, { name: "CaretRight", size: 16, className: "text-gray-500" }) })), _jsx("span", { className: "text-sm truncate font-semimedium", children: matchesSearch && searchTerm ? (_jsx("span", { dangerouslySetInnerHTML: {
75
- __html: nodeName.replace(new RegExp(searchTerm, "gi"), (match) => `<span class="bg-yellow-300 dark:bg-[#604B00]">${match}</span>`),
76
- } })) : (nodeName) })] }), hasChildren && isExpanded && (_jsx("div", { children: node.children.map((child) => renderNode(child, depth + 1)) }))] }, node.id));
77
- };
78
- const filteredNodes = searchTerm
79
- ? sidebarContext.searchResults.length > 0
80
- ? sidebarContext.searchResults
81
- : sidebarContext.nodes.filter((node) => {
82
- const nodeName = node.name || node.title || "";
83
- return (nodeName &&
84
- nodeName.toLowerCase().includes(searchTerm.toLowerCase()));
85
- })
86
- : sidebarContext.nodes;
87
- // Don't render anything when collapsed, just the toggle button
88
- if (isCollapsed) {
89
- return (_jsx("div", { className: "relative", children: resizable && (_jsx("div", { className: "group/sidebar-resizer absolute right-0 top-0 h-full w-[24px] translate-x-1/2 cursor-ew-resize select-none", children: _jsx("div", { className: "relative h-full w-px translate-x-[12px] transition-colors group-hover/sidebar-resizer:bg-gray-500 dark:group-hover/sidebar-resizer:bg-gray-600", children: _jsx("button", { type: "button", className: "absolute right-0 top-14 size-4 translate-x-1/2 rounded-full bg-gray-500 dark:bg-gray-900 opacity-100", onClick: handleToggleCollapse, title: "Expand sidebar", children: _jsx(Icon, { name: "Caret", size: 16, className: "min-w-4 text-gray-50 dark:text-gray-500" }) }) }) })) }));
90
- }
91
- return (_jsxs("div", { ref: sidebarRef, className: `group peer relative flex h-full flex-col bg-gray-50 shadow-lg transition-[width] duration-75 ease-linear dark:bg-slate-600 ${className || ""}`, style: {
92
- width: initialWidth,
93
- minWidth: resizable ? 200 : initialWidth,
94
- maxWidth: resizable ? maxWidth : initialWidth,
95
- ...style,
96
- }, children: [_jsxs("div", { className: "flex items-center justify-between gap-2 border-b border-gray-300 bg-gray-50 p-4 dark:border-gray-800 dark:bg-slate-600", children: [!isCollapsed && (_jsx("div", { className: "flex items-center gap-2 truncate", children: _jsx("h2", { className: "truncate text-sm font-semibold text-gray-700 dark:text-gray-300 cursor-pointer hover:text-gray-600", onClick: handleOnTitleClick, children: sidebarTitle }) })), !isCollapsed && enableMacros > 0 && (_jsx("div", { className: "flex select-none items-center gap-2", children: Array.from({ length: Math.min(enableMacros, 4) }).map((_, index) => {
97
- const isDisabled = index + 1 > sidebarContext.maxDepth;
98
- return (_jsx("div", { role: "button", tabIndex: 2, className: `w-[26px] rounded-lg p-1 text-center text-xs ${!isDisabled
99
- ? "bg-slate-50 text-slate-100 hover:bg-slate-100 hover:text-slate-200 dark:bg-gray-900 dark:text-slate-200 dark:hover:bg-gray-600 dark:hover:text-slate-50"
100
- : "cursor-not-allowed bg-gray-100 text-[#E2E4E7] dark:bg-[#252728] dark:text-slate-500"}`, onClick: () => {
101
- if (!isDisabled) {
102
- // Use the context's openLevel function for proper toggle behavior
103
- sidebarContext.openLevel(index + 1);
104
- }
105
- }, children: index + 1 }, `macro-${index}`));
106
- }) }))] }), !isCollapsed && (_jsx("div", { className: "flex-1 overflow-y-auto bg-gray-50", children: filteredNodes.length === 0 ? (_jsxs("div", { className: "p-4 text-center text-gray-500", children: [_jsx(Icon, { name: "FolderOpen", size: 24, className: "mx-auto mb-2 text-gray-300" }), _jsx("p", { className: "text-sm", children: "This node is empty" })] })) : (_jsx("div", { className: "py-2", children: filteredNodes.map((node) => renderNode(node)) })) })), !isCollapsed && showSearchBar && (_jsx("div", { className: "p-3 border-t border-gray-200 bg-gray-50", children: _jsxs("div", { className: "relative", children: [_jsx(Icon, { name: "Search", size: 16, className: "absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400" }), _jsx("input", { type: "text", placeholder: "Search...", value: searchTerm, onChange: handleSearchChange, className: "w-full pl-9 pr-3 py-2 border border-gray-300 rounded-md text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent bg-white" })] }) })), children, resizable && (_jsx("div", { className: "group/sidebar-resizer absolute right-0 top-0 h-full w-[24px] translate-x-1/2 cursor-ew-resize select-none", children: _jsx("div", { className: "relative h-full w-px translate-x-[12px] transition-colors group-hover/sidebar-resizer:bg-gray-500 dark:group-hover/sidebar-resizer:bg-gray-600", children: _jsx("button", { type: "button", className: "absolute right-0 top-14 size-4 translate-x-1/2 rounded-full bg-gray-500 dark:bg-gray-900 opacity-0 group-hover/sidebar-resizer:opacity-100 transition-opacity", onClick: handleToggleCollapse, title: "Collapse sidebar", children: _jsx(Icon, { name: "Caret", size: 16, className: "min-w-4 text-gray-50 dark:text-gray-500 -rotate-180" }) }) }) }))] }));
107
- };
@@ -1,15 +0,0 @@
1
- import React from 'react';
2
- import type { SidebarNode } from '@powerhousedao/document-engineering';
3
- /**
4
- * Isolated SidebarProvider that doesn't interfere with other sidebars
5
- * Uses a completely separate React context and state management
6
- */
7
- export declare const IsolatedSidebarProvider: React.FC<{
8
- children: React.ReactNode;
9
- nodes?: SidebarNode[];
10
- }>;
11
- /**
12
- * Hook to use the isolated sidebar context
13
- */
14
- export declare const useIsolatedSidebar: () => any;
15
- //# sourceMappingURL=IsolatedSidebarProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IsolatedSidebarProvider.d.ts","sourceRoot":"","sources":["../../../../editors/network-admin/components/IsolatedSidebarProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmG,MAAM,OAAO,CAAC;AACxH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qCAAqC,CAAC;AA4EvE;;;GAGG;AACH,eAAO,MAAM,uBAAuB,EAAE,KAAK,CAAC,EAAE,CAAC;IAC7C,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;CACvB,CAuTA,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,WAM9B,CAAC"}
@@ -1,367 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { createContext, useContext, useReducer, useRef, useState, useCallback, useEffect, useMemo } from 'react';
3
- // Create a completely isolated context for Network Admin sidebar
4
- const NetworkAdminSidebarContext = createContext(null);
5
- // Initial state for the isolated sidebar
6
- const initialSidebarState = {
7
- nodes: [],
8
- expandedNodes: new Set(),
9
- activeNodeId: undefined,
10
- searchTerm: '',
11
- searchResults: [],
12
- isSearching: false,
13
- activeSearchIndex: 0,
14
- pinnedNodePath: [],
15
- isStatusFilterEnabled: false,
16
- };
17
- // Action types for the isolated sidebar
18
- const SidebarActionType = {
19
- SET_NODES: 'SET_NODES',
20
- TOGGLE_NODE: 'TOGGLE_NODE',
21
- SET_ACTIVE_NODE: 'SET_ACTIVE_NODE',
22
- SET_SEARCH_TERM: 'SET_SEARCH_TERM',
23
- SET_SEARCH_RESULTS: 'SET_SEARCH_RESULTS',
24
- SET_IS_SEARCHING: 'SET_IS_SEARCHING',
25
- SET_ACTIVE_SEARCH_INDEX: 'SET_ACTIVE_SEARCH_INDEX',
26
- SET_PINNED_NODE_PATH: 'SET_PINNED_NODE_PATH',
27
- TOGGLE_STATUS_FILTER: 'TOGGLE_STATUS_FILTER',
28
- OPEN_NODE: 'OPEN_NODE',
29
- CLOSE_NODE: 'CLOSE_NODE',
30
- SET_EXPANDED_NODES: 'SET_EXPANDED_NODES',
31
- };
32
- // Reducer for the isolated sidebar
33
- const networkAdminSidebarReducer = (state, action) => {
34
- switch (action.type) {
35
- case SidebarActionType.SET_NODES:
36
- return { ...state, nodes: action.payload };
37
- case SidebarActionType.TOGGLE_NODE:
38
- const newExpandedNodes = new Set(state.expandedNodes);
39
- if (newExpandedNodes.has(action.payload)) {
40
- newExpandedNodes.delete(action.payload);
41
- }
42
- else {
43
- newExpandedNodes.add(action.payload);
44
- }
45
- return { ...state, expandedNodes: newExpandedNodes };
46
- case SidebarActionType.SET_ACTIVE_NODE:
47
- return { ...state, activeNodeId: action.payload };
48
- case SidebarActionType.SET_SEARCH_TERM:
49
- return { ...state, searchTerm: action.payload };
50
- case SidebarActionType.SET_SEARCH_RESULTS:
51
- return { ...state, searchResults: action.payload };
52
- case SidebarActionType.SET_IS_SEARCHING:
53
- return { ...state, isSearching: action.payload };
54
- case SidebarActionType.SET_PINNED_NODE_PATH:
55
- return { ...state, pinnedNodePath: action.payload };
56
- case SidebarActionType.TOGGLE_STATUS_FILTER:
57
- return { ...state, isStatusFilterEnabled: !state.isStatusFilterEnabled };
58
- case SidebarActionType.OPEN_NODE:
59
- const openExpandedNodes = new Set(state.expandedNodes);
60
- openExpandedNodes.add(action.payload);
61
- return { ...state, expandedNodes: openExpandedNodes };
62
- case SidebarActionType.CLOSE_NODE:
63
- const closeExpandedNodes = new Set(state.expandedNodes);
64
- closeExpandedNodes.delete(action.payload);
65
- return { ...state, expandedNodes: closeExpandedNodes };
66
- case SidebarActionType.SET_ACTIVE_SEARCH_INDEX:
67
- return { ...state, activeSearchIndex: action.payload };
68
- case SidebarActionType.SET_EXPANDED_NODES:
69
- return { ...state, expandedNodes: action.payload };
70
- default:
71
- return state;
72
- }
73
- };
74
- /**
75
- * Isolated SidebarProvider that doesn't interfere with other sidebars
76
- * Uses a completely separate React context and state management
77
- */
78
- export const IsolatedSidebarProvider = ({ children, nodes: initialNodes = [] }) => {
79
- const [state, dispatch] = useReducer(networkAdminSidebarReducer, {
80
- ...initialSidebarState,
81
- nodes: initialNodes,
82
- });
83
- const virtualListRef = useRef(null);
84
- const [onActiveNodeChange, setOnActiveNodeChange] = useState(() => () => undefined);
85
- const setNodes = useCallback((newNodes) => {
86
- dispatch({ type: SidebarActionType.SET_NODES, payload: newNodes });
87
- }, []);
88
- const toggleNode = useCallback((nodeId) => {
89
- dispatch({ type: SidebarActionType.TOGGLE_NODE, payload: nodeId });
90
- }, []);
91
- const setActiveNodeId = useCallback((nodeId) => {
92
- dispatch({ type: SidebarActionType.SET_ACTIVE_NODE, payload: nodeId });
93
- }, []);
94
- const setSearchTerm = useCallback((term) => {
95
- dispatch({ type: SidebarActionType.SET_SEARCH_TERM, payload: term });
96
- }, []);
97
- const setSearchResults = useCallback((results) => {
98
- dispatch({ type: SidebarActionType.SET_SEARCH_RESULTS, payload: results });
99
- }, []);
100
- const setIsSearching = useCallback((isSearching) => {
101
- dispatch({ type: SidebarActionType.SET_IS_SEARCHING, payload: isSearching });
102
- }, []);
103
- const setActiveSearchIndex = useCallback((index) => {
104
- dispatch({ type: SidebarActionType.SET_ACTIVE_SEARCH_INDEX, payload: index });
105
- }, []);
106
- const nextSearchResult = useCallback(() => {
107
- if (state.searchResults.length > 0) {
108
- const nextIndex = Math.min(state.searchResults.length - 1, state.activeSearchIndex + 1);
109
- setActiveSearchIndex(nextIndex);
110
- }
111
- }, [state.searchResults.length, state.activeSearchIndex, setActiveSearchIndex]);
112
- const previousSearchResult = useCallback(() => {
113
- if (state.searchResults.length > 0) {
114
- const prevIndex = Math.max(0, state.activeSearchIndex - 1);
115
- setActiveSearchIndex(prevIndex);
116
- }
117
- }, [state.searchResults.length, state.activeSearchIndex, setActiveSearchIndex]);
118
- const setPinnedNodePath = useCallback((path) => {
119
- dispatch({ type: SidebarActionType.SET_PINNED_NODE_PATH, payload: path });
120
- }, []);
121
- const toggleStatusFilter = useCallback(() => {
122
- dispatch({ type: SidebarActionType.TOGGLE_STATUS_FILTER });
123
- }, []);
124
- const openNode = useCallback((nodeId) => {
125
- dispatch({ type: SidebarActionType.OPEN_NODE, payload: nodeId });
126
- }, []);
127
- const closeNode = useCallback((nodeId) => {
128
- dispatch({ type: SidebarActionType.CLOSE_NODE, payload: nodeId });
129
- }, []);
130
- const setExpandedNodes = useCallback((nodes) => {
131
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: nodes });
132
- }, []);
133
- const setActiveNodeChangeCallback = useCallback((callback) => {
134
- setOnActiveNodeChange(() => callback);
135
- }, []);
136
- const syncActiveNodeId = useCallback((nodeId) => {
137
- dispatch({ type: SidebarActionType.SET_ACTIVE_NODE, payload: nodeId });
138
- }, []);
139
- // Update nodes when initialNodes change
140
- useEffect(() => {
141
- if (initialNodes.length > 0) {
142
- setNodes(initialNodes);
143
- }
144
- }, [initialNodes, setNodes]);
145
- // Calculate flattened nodes
146
- const flattenedNodes = useMemo(() => {
147
- const flattened = [];
148
- const dfs = (node, depth) => {
149
- const flatNode = {
150
- ...node,
151
- depth,
152
- isExpanded: state.expandedNodes.has(node.id),
153
- };
154
- flattened.push(flatNode);
155
- if (Array.isArray(node.children) && state.expandedNodes.has(node.id)) {
156
- for (const child of node.children) {
157
- dfs(child, depth + 1);
158
- }
159
- }
160
- };
161
- for (const node of state.nodes) {
162
- dfs(node, 0);
163
- }
164
- return flattened;
165
- }, [state.nodes, state.expandedNodes]);
166
- // Calculate max depth
167
- const maxDepth = useMemo(() => {
168
- const getMaxDepth = (nodes, currentLevel = 0) => {
169
- if (!nodes || nodes.length === 0)
170
- return currentLevel;
171
- let max = currentLevel;
172
- for (const node of nodes) {
173
- if (node.children && node.children.length > 0) {
174
- const childDepth = getMaxDepth(node.children, currentLevel + 1);
175
- max = Math.max(max, childDepth);
176
- }
177
- }
178
- return max;
179
- };
180
- const depth = getMaxDepth(state.nodes, 0);
181
- // Return depth count (number of levels) instead of level number (0-based index)
182
- const depthCount = depth + 1;
183
- return depthCount;
184
- }, [state.nodes]);
185
- // Utility function to check if a level is open
186
- const isOpenLevel = useCallback((items, expandedNodes, level) => {
187
- if (!items.length || level < 1) {
188
- return false;
189
- }
190
- // Check if all levels up to the target level are open
191
- const queue = [...items];
192
- for (let i = 0; i < level; i++) {
193
- const nextLevelQueue = [];
194
- while (queue.length > 0) {
195
- const current = queue.shift();
196
- if (!current)
197
- continue;
198
- // Check if current level is expanded
199
- if (!expandedNodes.has(current.id)) {
200
- return false;
201
- }
202
- // Add children to next level queue
203
- if (current.children?.length) {
204
- nextLevelQueue.push(...current.children);
205
- }
206
- }
207
- // Move to next level
208
- queue.push(...nextLevelQueue);
209
- if (queue.length === 0)
210
- break;
211
- }
212
- return true;
213
- }, []);
214
- // Utility function to get nodes that should be expanded for a specific level
215
- const getOpenLevels = useCallback((items, level) => {
216
- if (level < 1) {
217
- return new Set();
218
- }
219
- const result = new Set();
220
- const traverse = (nodes, currentLevel) => {
221
- for (const node of nodes) {
222
- // Add current node if we're not at the target level yet
223
- if (currentLevel < level) {
224
- result.add(node.id);
225
- }
226
- // Continue traversing children if we haven't reached the target level
227
- if (node.children?.length && currentLevel < level - 1) {
228
- traverse(node.children, currentLevel + 1);
229
- }
230
- }
231
- };
232
- traverse(items, 0); // Start from level 0 (root)
233
- return result;
234
- }, []);
235
- const openLevel = useCallback((targetLevel) => {
236
- // Check if the target level is currently visible by checking if nodes at that level are expanded
237
- const isTargetLevelVisible = (() => {
238
- if (targetLevel === 1) {
239
- // For level 1, check if root nodes are expanded
240
- return state.nodes.every((node) => state.expandedNodes.has(node.id));
241
- }
242
- else if (targetLevel === 2) {
243
- // For level 2, check if folder nodes are expanded
244
- const folderNodes = state.nodes.flatMap((node) => node.children || []);
245
- return folderNodes.length > 0 && folderNodes.every((folder) => state.expandedNodes.has(folder.id));
246
- }
247
- else if (targetLevel === 3) {
248
- // For level 3, check if document nodes are expanded
249
- const documentNodes = state.nodes.flatMap((node) => (node.children || []).flatMap((folder) => folder.children || []));
250
- return documentNodes.length > 0 && documentNodes.every((doc) => state.expandedNodes.has(doc.id));
251
- }
252
- return false;
253
- })();
254
- if (isTargetLevelVisible) {
255
- // If the target level is visible, hide it by closing nodes at that level
256
- if (targetLevel === 1) {
257
- // Close root nodes
258
- const newExpandedNodes = new Set(state.expandedNodes);
259
- state.nodes.forEach((node) => newExpandedNodes.delete(node.id));
260
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: newExpandedNodes });
261
- }
262
- else if (targetLevel === 2) {
263
- // Close folder nodes
264
- const newExpandedNodes = new Set(state.expandedNodes);
265
- state.nodes.forEach((node) => {
266
- if (node.children) {
267
- node.children.forEach((folder) => newExpandedNodes.delete(folder.id));
268
- }
269
- });
270
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: newExpandedNodes });
271
- }
272
- else if (targetLevel === 3) {
273
- // Close document nodes
274
- const newExpandedNodes = new Set(state.expandedNodes);
275
- state.nodes.forEach((node) => {
276
- if (node.children) {
277
- node.children.forEach((folder) => {
278
- if (folder.children) {
279
- folder.children.forEach((doc) => newExpandedNodes.delete(doc.id));
280
- }
281
- });
282
- }
283
- });
284
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: newExpandedNodes });
285
- }
286
- }
287
- else {
288
- // If the target level is not visible, show it by opening nodes at that level
289
- if (targetLevel === 1) {
290
- // Open root nodes
291
- const newExpandedNodes = new Set(state.expandedNodes);
292
- state.nodes.forEach((node) => newExpandedNodes.add(node.id));
293
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: newExpandedNodes });
294
- }
295
- else if (targetLevel === 2) {
296
- // Open folder nodes (and root nodes if not already open)
297
- const newExpandedNodes = new Set(state.expandedNodes);
298
- state.nodes.forEach((node) => {
299
- newExpandedNodes.add(node.id); // Ensure root is open
300
- if (node.children) {
301
- node.children.forEach((folder) => newExpandedNodes.add(folder.id));
302
- }
303
- });
304
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: newExpandedNodes });
305
- }
306
- else if (targetLevel === 3) {
307
- // Open document nodes (and root + folder nodes if not already open)
308
- const newExpandedNodes = new Set(state.expandedNodes);
309
- state.nodes.forEach((node) => {
310
- newExpandedNodes.add(node.id); // Ensure root is open
311
- if (node.children) {
312
- node.children.forEach((folder) => {
313
- newExpandedNodes.add(folder.id); // Ensure folder is open
314
- if (folder.children) {
315
- folder.children.forEach((doc) => newExpandedNodes.add(doc.id));
316
- }
317
- });
318
- }
319
- });
320
- dispatch({ type: SidebarActionType.SET_EXPANDED_NODES, payload: newExpandedNodes });
321
- }
322
- }
323
- }, [state.nodes, state.expandedNodes]);
324
- const contextValue = {
325
- nodes: state.nodes,
326
- flattenedNodes,
327
- expandedNodes: state.expandedNodes,
328
- pinnedNodePath: state.pinnedNodePath,
329
- maxDepth,
330
- searchTerm: state.searchTerm,
331
- searchResults: state.searchResults,
332
- isSearching: state.isSearching,
333
- activeSearchIndex: state.activeSearchIndex,
334
- isStatusFilterEnabled: state.isStatusFilterEnabled,
335
- virtualListRef,
336
- activeNodeId: state.activeNodeId,
337
- toggleNode,
338
- openNode,
339
- closeNode,
340
- togglePin: () => { }, // Simplified for now
341
- openLevel,
342
- changeSearchTerm: setSearchTerm,
343
- nextSearchResult,
344
- previousSearchResult,
345
- setNodes,
346
- syncActiveNodeId,
347
- onActiveNodeChange,
348
- setActiveNodeChangeCallback,
349
- toggleStatusFilter,
350
- setSearchTerm,
351
- setSearchResults,
352
- setIsSearching,
353
- setActiveSearchIndex,
354
- setExpandedNodes,
355
- };
356
- return (_jsx(NetworkAdminSidebarContext.Provider, { value: contextValue, children: children }));
357
- };
358
- /**
359
- * Hook to use the isolated sidebar context
360
- */
361
- export const useIsolatedSidebar = () => {
362
- const context = useContext(NetworkAdminSidebarContext);
363
- if (!context) {
364
- throw new Error('useIsolatedSidebar must be used within IsolatedSidebarProvider');
365
- }
366
- return context;
367
- };
@@ -1,60 +0,0 @@
1
- export declare const getNewDocumentObject: (documentName: string, documentType: string, code?: string) => {
2
- header: {
3
- name: string;
4
- documentType: string;
5
- createdAtUtcIso: string;
6
- slug: string;
7
- branch: string;
8
- id: string;
9
- sig: {
10
- nonce: string;
11
- publicKey: {};
12
- };
13
- revision: {};
14
- lastModifiedAtUtcIso: string;
15
- };
16
- history: {
17
- operations: never[];
18
- clipboard: never[];
19
- };
20
- state: {
21
- auth: {};
22
- document: {
23
- version: string;
24
- };
25
- global: {
26
- title: string;
27
- code: string;
28
- description: string;
29
- createdBy: string;
30
- createdAt: string;
31
- updatedBy: string;
32
- updatedAt: string;
33
- status: string;
34
- };
35
- local: {};
36
- };
37
- initialState: {
38
- auth: {};
39
- document: {
40
- version: string;
41
- };
42
- global: {
43
- title: string;
44
- code: string;
45
- description: string;
46
- createdBy: string;
47
- createdAt: string;
48
- updatedBy: string;
49
- updatedAt: string;
50
- status: string;
51
- };
52
- local: {};
53
- };
54
- operations: {
55
- [x: string]: never[];
56
- };
57
- clipboard: never[];
58
- attachments: {};
59
- };
60
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../editors/network-admin/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,GAAI,cAAc,MAAM,EAAE,cAAc,MAAM,EAAE,OAAO,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkE7F,CAAA"}
@@ -1,67 +0,0 @@
1
- export const getNewDocumentObject = (documentName, documentType, code) => {
2
- console.log("documentName", documentName);
3
- console.log("documentType", documentType);
4
- console.log("code", code);
5
- if (documentType === "powerhouse/rfp") {
6
- documentName = documentName.replace(/^RFP-/, "");
7
- }
8
- return {
9
- header: {
10
- name: documentName,
11
- documentType: documentType,
12
- createdAtUtcIso: new Date().toISOString(),
13
- slug: documentName,
14
- branch: "main",
15
- id: "",
16
- sig: {
17
- nonce: "",
18
- publicKey: {},
19
- },
20
- revision: {},
21
- lastModifiedAtUtcIso: new Date().toISOString(),
22
- },
23
- history: {
24
- operations: [],
25
- clipboard: [],
26
- },
27
- state: {
28
- auth: {},
29
- document: {
30
- version: "1.0.0",
31
- },
32
- global: {
33
- title: documentName,
34
- code: code || "",
35
- description: "",
36
- createdBy: "network-admin",
37
- createdAt: new Date().toISOString(),
38
- updatedBy: "network-admin",
39
- updatedAt: new Date().toISOString(),
40
- status: "draft",
41
- },
42
- local: {},
43
- },
44
- initialState: {
45
- auth: {},
46
- document: {
47
- version: "1.0.0",
48
- },
49
- global: {
50
- title: documentName,
51
- code: code || "",
52
- description: "",
53
- createdBy: "network-admin",
54
- createdAt: new Date().toISOString(),
55
- updatedBy: "network-admin",
56
- updatedAt: new Date().toISOString(),
57
- status: "draft",
58
- },
59
- local: {},
60
- },
61
- operations: {
62
- [documentType]: [],
63
- },
64
- clipboard: [],
65
- attachments: {},
66
- };
67
- };