@fgv/ts-res-ui-components 5.0.0-21 → 5.0.0-22

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 (37) hide show
  1. package/README.md +230 -35
  2. package/dist/ts-res-ui-components.d.ts +283 -19
  3. package/lib/components/orchestrator/ResourceOrchestrator.js +3 -1
  4. package/lib/components/pickers/ResourcePicker/ResourcePickerTree.js +29 -10
  5. package/lib/components/pickers/ResourcePicker/index.js +4 -2
  6. package/lib/components/views/ResolutionView/index.js +1 -1
  7. package/lib/hooks/useResolutionState.js +836 -235
  8. package/lib/namespaces/ResolutionTools.d.ts +2 -1
  9. package/lib/namespaces/ResolutionTools.js +2 -0
  10. package/lib/test/unit/workflows/resolutionWorkflows.test.d.ts +2 -0
  11. package/lib/test/unit/workflows/resourceCreation.test.d.ts +2 -0
  12. package/lib/test/unit/workflows/resultPatternExtensions.test.d.ts +2 -0
  13. package/lib/test/unit/workflows/validation.test.d.ts +2 -0
  14. package/lib/types/index.d.ts +124 -19
  15. package/lib/types/index.js +2 -1
  16. package/lib/utils/resolutionEditing.js +2 -1
  17. package/lib/utils/resourceSelectors.d.ts +146 -0
  18. package/lib/utils/resourceSelectors.js +233 -0
  19. package/lib-commonjs/components/orchestrator/ResourceOrchestrator.js +3 -1
  20. package/lib-commonjs/components/pickers/ResourcePicker/ResourcePickerTree.js +29 -10
  21. package/lib-commonjs/components/pickers/ResourcePicker/index.js +4 -2
  22. package/lib-commonjs/components/views/ResolutionView/index.js +1 -1
  23. package/lib-commonjs/hooks/useResolutionState.js +835 -234
  24. package/lib-commonjs/namespaces/ResolutionTools.js +10 -1
  25. package/lib-commonjs/types/index.js +10 -0
  26. package/lib-commonjs/utils/resolutionEditing.js +2 -1
  27. package/lib-commonjs/utils/resourceSelectors.js +242 -0
  28. package/package.json +7 -7
  29. package/src/components/orchestrator/ResourceOrchestrator.tsx +3 -1
  30. package/src/components/pickers/ResourcePicker/ResourcePickerTree.tsx +30 -10
  31. package/src/components/pickers/ResourcePicker/index.tsx +7 -2
  32. package/src/components/views/ResolutionView/index.tsx +1 -1
  33. package/src/hooks/useResolutionState.ts +1054 -257
  34. package/src/namespaces/ResolutionTools.ts +13 -1
  35. package/src/types/index.ts +131 -20
  36. package/src/utils/resolutionEditing.ts +2 -2
  37. package/src/utils/resourceSelectors.ts +278 -0
@@ -8,8 +8,9 @@ const outline_1 = require("@heroicons/react/24/outline");
8
8
  * Creates a virtual tree by merging real resource tree with pending resources
9
9
  */
10
10
  function createVirtualTree(realTree, pendingResources = []) {
11
- if (!realTree)
11
+ if (!realTree) {
12
12
  return null;
13
+ }
13
14
  // Helper to convert real node to virtual node
14
15
  const convertRealNode = (realNode) => {
15
16
  const virtualNode = {
@@ -87,25 +88,41 @@ const ResourcePickerTree = ({ resources, pendingResources, selectedResourceId, o
87
88
  const [expandedNodes, setExpandedNodes] = (0, react_1.useState)(new Set());
88
89
  // Build the virtual tree structure from resources and pending resources
89
90
  const virtualTree = (0, react_1.useMemo)(() => {
90
- if (!resources)
91
+ if (!resources) {
91
92
  return null;
93
+ }
92
94
  // Get the tree from the resource manager
93
95
  const resourceManager = resources.system.resourceManager;
94
96
  const treeResult = resourceManager.getBuiltResourceTree();
95
97
  if (treeResult.isFailure()) {
96
- console.error('Failed to build resource tree:', treeResult.message);
98
+ console.error('ResourcePickerTree: Failed to build resource tree:', treeResult.message);
97
99
  return null;
98
100
  }
99
101
  // Create virtual tree that includes pending resources
100
- return createVirtualTree(treeResult.value, pendingResources);
102
+ try {
103
+ const virtualTree = createVirtualTree(treeResult.value, pendingResources);
104
+ return virtualTree;
105
+ }
106
+ catch (error) {
107
+ console.error('ResourcePickerTree: Error in createVirtualTree:', error);
108
+ return null;
109
+ }
101
110
  }, [resources, pendingResources]);
102
111
  // Find the effective root node(s) to display
103
112
  const effectiveRootNodes = (0, react_1.useMemo)(() => {
104
- if (!virtualTree)
113
+ try {
114
+ if (!virtualTree) {
115
+ return [];
116
+ }
117
+ // If no rootPath, show all top-level nodes
118
+ if (!rootPath) {
119
+ const nodes = Array.from(virtualTree.children.values());
120
+ return nodes;
121
+ }
122
+ }
123
+ catch (error) {
124
+ console.error('ResourcePickerTree: Error in effectiveRootNodes calculation:', error);
105
125
  return [];
106
- // If no rootPath, show all top-level nodes
107
- if (!rootPath) {
108
- return Array.from(virtualTree.children.values());
109
126
  }
110
127
  // Find the target node in the virtual tree
111
128
  const findVirtualNodeById = (node, targetId) => {
@@ -280,7 +297,7 @@ const ResourcePickerTree = ({ resources, pendingResources, selectedResourceId, o
280
297
  return (react_1.default.createElement("div", { className: `${className} p-4 text-center text-gray-500` },
281
298
  react_1.default.createElement("p", null, emptyMessage)));
282
299
  }
283
- return (react_1.default.createElement("div", { className: `${className} overflow-y-auto` }, effectiveRootNodes
300
+ return (react_1.default.createElement("div", { className: `${className} overflow-y-auto !relative !z-auto !min-h-[200px]` }, effectiveRootNodes
284
301
  .sort((a, b) => {
285
302
  // Sort folders first, then by name
286
303
  if (a.isLeaf !== b.isLeaf) {
@@ -288,7 +305,9 @@ const ResourcePickerTree = ({ resources, pendingResources, selectedResourceId, o
288
305
  }
289
306
  return a.name.localeCompare(b.name);
290
307
  })
291
- .map((child) => renderTreeNode(child))));
308
+ .map((child) => {
309
+ return renderTreeNode(child);
310
+ })));
292
311
  };
293
312
  exports.ResourcePickerTree = ResourcePickerTree;
294
313
  /**
@@ -109,7 +109,9 @@ const ResourcePicker = ({ resources, selectedResourceId, onResourceSelect, resou
109
109
  react_1.default.createElement("p", null, emptyMessage || 'No resources loaded')));
110
110
  }
111
111
  const containerHeight = typeof height === 'number' ? `${height}px` : height;
112
- return (react_1.default.createElement("div", { className: `flex flex-col ${className}`, style: { height: containerHeight } },
112
+ return (react_1.default.createElement("div", { className: `flex flex-col !relative !z-auto !min-h-[400px] ${className}`, style: {
113
+ height: containerHeight
114
+ } },
113
115
  (enableSearch || showViewToggle) && (react_1.default.createElement("div", { className: "flex flex-col gap-3 mb-4" },
114
116
  enableSearch && (react_1.default.createElement("div", { className: "relative" },
115
117
  react_1.default.createElement(outline_1.MagnifyingGlassIcon, { className: "absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-gray-400" }),
@@ -131,7 +133,7 @@ const ResourcePicker = ({ resources, selectedResourceId, onResourceSelect, resou
131
133
  : 'text-gray-600 hover:text-gray-900'}`, title: "Tree View" },
132
134
  react_1.default.createElement(outline_1.FolderIcon, { className: "h-4 w-4" }),
133
135
  react_1.default.createElement("span", { className: "ml-1" }, "Tree"))))))),
134
- react_1.default.createElement("div", { className: "flex-1 overflow-y-auto border border-gray-200 rounded-lg bg-gray-50" }, viewMode === 'tree' ? (react_1.default.createElement(ResourcePickerTree_1.ResourcePickerTree, { resources: resources, pendingResources: pendingResources, selectedResourceId: selectedResourceId, onResourceSelect: handleResourceSelect, resourceAnnotations: resourceAnnotations, searchTerm: searchTerm, rootPath: rootPath, hideRootNode: hideRootNode, emptyMessage: emptyMessage })) : (react_1.default.createElement(ResourcePickerList_1.ResourcePickerList, { resourceIds: resources.summary.resourceIds || [], pendingResources: pendingResources, selectedResourceId: selectedResourceId, onResourceSelect: handleResourceSelect, resourceAnnotations: resourceAnnotations, searchTerm: searchTerm, rootPath: rootPath, hideRootNode: hideRootNode, emptyMessage: emptyMessage })))));
136
+ react_1.default.createElement("div", { className: "flex-1 overflow-y-auto border border-gray-200 rounded-lg bg-gray-50 !relative !z-auto !min-h-[300px]" }, viewMode === 'tree' ? (react_1.default.createElement(ResourcePickerTree_1.ResourcePickerTree, { resources: resources, pendingResources: pendingResources, selectedResourceId: selectedResourceId, onResourceSelect: handleResourceSelect, resourceAnnotations: resourceAnnotations, searchTerm: searchTerm, rootPath: rootPath, hideRootNode: hideRootNode, emptyMessage: emptyMessage })) : (react_1.default.createElement(ResourcePickerList_1.ResourcePickerList, { resourceIds: resources.summary.resourceIds || [], pendingResources: pendingResources, selectedResourceId: selectedResourceId, onResourceSelect: handleResourceSelect, resourceAnnotations: resourceAnnotations, searchTerm: searchTerm, rootPath: rootPath, hideRootNode: hideRootNode, emptyMessage: emptyMessage })))));
135
137
  };
136
138
  exports.ResourcePicker = ResourcePicker;
137
139
  exports.default = exports.ResourcePicker;
@@ -308,7 +308,7 @@ const ResolutionView = ({ resources, filterState, filterResult, resolutionState,
308
308
  }, [resolutionActions]);
309
309
  // Handle new resource creation
310
310
  const handleStartNewResource = (0, react_1.useCallback)(() => {
311
- resolutionActions?.startNewResource(defaultResourceType);
311
+ resolutionActions?.startNewResource({ defaultTypeName: defaultResourceType });
312
312
  setShowNewResourceModal(true);
313
313
  }, [resolutionActions]);
314
314
  const handleCloseNewResourceModal = (0, react_1.useCallback)(() => {