@fgv/ts-res-ui-components 5.0.0-10
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/.rush/temp/03c8b056281d9db0a97d8a6e25eea798a160d393.tar.log +271 -0
- package/.rush/temp/chunked-rush-logs/ts-res-ui-components.build.chunks.jsonl +9 -0
- package/.rush/temp/operation/build/all.log +9 -0
- package/.rush/temp/operation/build/log-chunks.jsonl +9 -0
- package/.rush/temp/operation/build/state.json +3 -0
- package/.rush/temp/shrinkwrap-deps.json +1111 -0
- package/README.md +18 -0
- package/REFACTORING_PLAN.md +171 -0
- package/config/jest.config.json +16 -0
- package/config/jest.setup.js +64 -0
- package/config/rig.json +16 -0
- package/lib/components/common/QualifierContextControl.d.ts +14 -0
- package/lib/components/common/QualifierContextControl.d.ts.map +1 -0
- package/lib/components/common/QualifierContextControl.js +78 -0
- package/lib/components/common/QualifierContextControl.js.map +1 -0
- package/lib/components/common/ResourceListView.d.ts +11 -0
- package/lib/components/common/ResourceListView.d.ts.map +1 -0
- package/lib/components/common/ResourceListView.js +20 -0
- package/lib/components/common/ResourceListView.js.map +1 -0
- package/lib/components/common/ResourceTreeView.d.ts +12 -0
- package/lib/components/common/ResourceTreeView.d.ts.map +1 -0
- package/lib/components/common/ResourceTreeView.js +162 -0
- package/lib/components/common/ResourceTreeView.js.map +1 -0
- package/lib/components/forms/HierarchyEditor.d.ts +10 -0
- package/lib/components/forms/HierarchyEditor.d.ts.map +1 -0
- package/lib/components/forms/HierarchyEditor.js +106 -0
- package/lib/components/forms/HierarchyEditor.js.map +1 -0
- package/lib/components/forms/QualifierEditForm.d.ts +11 -0
- package/lib/components/forms/QualifierEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierEditForm.js +181 -0
- package/lib/components/forms/QualifierEditForm.js.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts +10 -0
- package/lib/components/forms/QualifierTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/QualifierTypeEditForm.js +172 -0
- package/lib/components/forms/QualifierTypeEditForm.js.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts +10 -0
- package/lib/components/forms/ResourceTypeEditForm.d.ts.map +1 -0
- package/lib/components/forms/ResourceTypeEditForm.js +188 -0
- package/lib/components/forms/ResourceTypeEditForm.js.map +1 -0
- package/lib/components/forms/index.d.ts +9 -0
- package/lib/components/forms/index.d.ts.map +1 -0
- package/lib/components/forms/index.js +5 -0
- package/lib/components/forms/index.js.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts +14 -0
- package/lib/components/orchestrator/ResourceOrchestrator.d.ts.map +1 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js +278 -0
- package/lib/components/orchestrator/ResourceOrchestrator.js.map +1 -0
- package/lib/components/views/CompiledView/index.d.ts +5 -0
- package/lib/components/views/CompiledView/index.d.ts.map +1 -0
- package/lib/components/views/CompiledView/index.js +595 -0
- package/lib/components/views/CompiledView/index.js.map +1 -0
- package/lib/components/views/ConfigurationView/index.d.ts +5 -0
- package/lib/components/views/ConfigurationView/index.d.ts.map +1 -0
- package/lib/components/views/ConfigurationView/index.js +363 -0
- package/lib/components/views/ConfigurationView/index.js.map +1 -0
- package/lib/components/views/FilterView/index.d.ts +5 -0
- package/lib/components/views/FilterView/index.d.ts.map +1 -0
- package/lib/components/views/FilterView/index.js +463 -0
- package/lib/components/views/FilterView/index.js.map +1 -0
- package/lib/components/views/ImportView/index.d.ts +5 -0
- package/lib/components/views/ImportView/index.d.ts.map +1 -0
- package/lib/components/views/ImportView/index.js +514 -0
- package/lib/components/views/ImportView/index.js.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts +21 -0
- package/lib/components/views/ResolutionView/EditableJsonView.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js +109 -0
- package/lib/components/views/ResolutionView/EditableJsonView.js.map +1 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts +19 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js +82 -0
- package/lib/components/views/ResolutionView/ResolutionEditControls.js.map +1 -0
- package/lib/components/views/ResolutionView/index.d.ts +5 -0
- package/lib/components/views/ResolutionView/index.d.ts.map +1 -0
- package/lib/components/views/ResolutionView/index.js +255 -0
- package/lib/components/views/ResolutionView/index.js.map +1 -0
- package/lib/components/views/SourceView/index.d.ts +5 -0
- package/lib/components/views/SourceView/index.d.ts.map +1 -0
- package/lib/components/views/SourceView/index.js +316 -0
- package/lib/components/views/SourceView/index.js.map +1 -0
- package/lib/components/views/ZipLoaderView/index.d.ts +5 -0
- package/lib/components/views/ZipLoaderView/index.d.ts.map +1 -0
- package/lib/components/views/ZipLoaderView/index.js +313 -0
- package/lib/components/views/ZipLoaderView/index.js.map +1 -0
- package/lib/hooks/useConfigurationState.d.ts +46 -0
- package/lib/hooks/useConfigurationState.d.ts.map +1 -0
- package/lib/hooks/useConfigurationState.js +239 -0
- package/lib/hooks/useConfigurationState.js.map +1 -0
- package/lib/hooks/useFilterState.d.ts +7 -0
- package/lib/hooks/useFilterState.d.ts.map +1 -0
- package/lib/hooks/useFilterState.js +80 -0
- package/lib/hooks/useFilterState.js.map +1 -0
- package/lib/hooks/useResolutionState.d.ts +8 -0
- package/lib/hooks/useResolutionState.d.ts.map +1 -0
- package/lib/hooks/useResolutionState.js +253 -0
- package/lib/hooks/useResolutionState.js.map +1 -0
- package/lib/hooks/useResourceData.d.ts +19 -0
- package/lib/hooks/useResourceData.d.ts.map +1 -0
- package/lib/hooks/useResourceData.js +368 -0
- package/lib/hooks/useResourceData.js.map +1 -0
- package/lib/hooks/useViewState.d.ts +10 -0
- package/lib/hooks/useViewState.d.ts.map +1 -0
- package/lib/hooks/useViewState.js +29 -0
- package/lib/hooks/useViewState.js.map +1 -0
- package/lib/index.d.ts +27 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +34 -0
- package/lib/index.js.map +1 -0
- package/lib/test/helpers/testDataLoader.d.ts +37 -0
- package/lib/test/helpers/testDataLoader.d.ts.map +1 -0
- package/lib/test/helpers/testDataLoader.js +171 -0
- package/lib/test/helpers/testDataLoader.js.map +1 -0
- package/lib/test/unit/utils/configurationUtils.test.d.ts +2 -0
- package/lib/test/unit/utils/configurationUtils.test.d.ts.map +1 -0
- package/lib/test/unit/utils/configurationUtils.test.js +497 -0
- package/lib/test/unit/utils/configurationUtils.test.js.map +1 -0
- package/lib/test/unit/utils/fileProcessing.test.d.ts +2 -0
- package/lib/test/unit/utils/fileProcessing.test.d.ts.map +1 -0
- package/lib/test/unit/utils/fileProcessing.test.js +321 -0
- package/lib/test/unit/utils/fileProcessing.test.js.map +1 -0
- package/lib/test/unit/utils/filterResources.test.d.ts +2 -0
- package/lib/test/unit/utils/filterResources.test.d.ts.map +1 -0
- package/lib/test/unit/utils/filterResources.test.js +403 -0
- package/lib/test/unit/utils/filterResources.test.js.map +1 -0
- package/lib/test/unit/utils/resolutionEditing.test.d.ts +2 -0
- package/lib/test/unit/utils/resolutionEditing.test.d.ts.map +1 -0
- package/lib/test/unit/utils/resolutionEditing.test.js +439 -0
- package/lib/test/unit/utils/resolutionEditing.test.js.map +1 -0
- package/lib/test/unit/utils/resolutionUtils.test.d.ts +2 -0
- package/lib/test/unit/utils/resolutionUtils.test.d.ts.map +1 -0
- package/lib/test/unit/utils/resolutionUtils.test.js +397 -0
- package/lib/test/unit/utils/resolutionUtils.test.js.map +1 -0
- package/lib/test/unit/utils/tsResIntegration.test.d.ts +2 -0
- package/lib/test/unit/utils/tsResIntegration.test.d.ts.map +1 -0
- package/lib/test/unit/utils/tsResIntegration.test.js +376 -0
- package/lib/test/unit/utils/tsResIntegration.test.js.map +1 -0
- package/lib/types/index.d.ts +251 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -0
- package/lib/utils/configurationUtils.d.ts +74 -0
- package/lib/utils/configurationUtils.d.ts.map +1 -0
- package/lib/utils/configurationUtils.js +359 -0
- package/lib/utils/configurationUtils.js.map +1 -0
- package/lib/utils/fileProcessing.d.ts +18 -0
- package/lib/utils/fileProcessing.d.ts.map +1 -0
- package/lib/utils/fileProcessing.js +142 -0
- package/lib/utils/fileProcessing.js.map +1 -0
- package/lib/utils/filterResources.d.ts +38 -0
- package/lib/utils/filterResources.d.ts.map +1 -0
- package/lib/utils/filterResources.js +153 -0
- package/lib/utils/filterResources.js.map +1 -0
- package/lib/utils/resolutionEditing.d.ts +58 -0
- package/lib/utils/resolutionEditing.d.ts.map +1 -0
- package/lib/utils/resolutionEditing.js +246 -0
- package/lib/utils/resolutionEditing.js.map +1 -0
- package/lib/utils/resolutionUtils.d.ts +28 -0
- package/lib/utils/resolutionUtils.d.ts.map +1 -0
- package/lib/utils/resolutionUtils.js +216 -0
- package/lib/utils/resolutionUtils.js.map +1 -0
- package/lib/utils/tsResIntegration.d.ts +71 -0
- package/lib/utils/tsResIntegration.d.ts.map +1 -0
- package/lib/utils/tsResIntegration.js +294 -0
- package/lib/utils/tsResIntegration.js.map +1 -0
- package/lib/utils/zipLoader/browserZipLoader.d.ts +48 -0
- package/lib/utils/zipLoader/browserZipLoader.d.ts.map +1 -0
- package/lib/utils/zipLoader/browserZipLoader.js +247 -0
- package/lib/utils/zipLoader/browserZipLoader.js.map +1 -0
- package/lib/utils/zipLoader/index.d.ts +8 -0
- package/lib/utils/zipLoader/index.d.ts.map +1 -0
- package/lib/utils/zipLoader/index.js +13 -0
- package/lib/utils/zipLoader/index.js.map +1 -0
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts +55 -0
- package/lib/utils/zipLoader/nodeZipBuilder.d.ts.map +1 -0
- package/lib/utils/zipLoader/nodeZipBuilder.js +98 -0
- package/lib/utils/zipLoader/nodeZipBuilder.js.map +1 -0
- package/lib/utils/zipLoader/types.d.ts +139 -0
- package/lib/utils/zipLoader/types.d.ts.map +1 -0
- package/lib/utils/zipLoader/types.js +2 -0
- package/lib/utils/zipLoader/types.js.map +1 -0
- package/lib/utils/zipLoader/zipUtils.d.ts +53 -0
- package/lib/utils/zipLoader/zipUtils.d.ts.map +1 -0
- package/lib/utils/zipLoader/zipUtils.js +229 -0
- package/lib/utils/zipLoader/zipUtils.js.map +1 -0
- package/package.json +69 -0
- package/rush-logs/ts-res-ui-components.build.cache.log +3 -0
- package/rush-logs/ts-res-ui-components.build.log +9 -0
- package/src/components/common/QualifierContextControl.tsx +151 -0
- package/src/components/common/ResourceListView.tsx +63 -0
- package/src/components/common/ResourceTreeView.tsx +271 -0
- package/src/components/forms/HierarchyEditor.tsx +204 -0
- package/src/components/forms/QualifierEditForm.tsx +355 -0
- package/src/components/forms/QualifierTypeEditForm.tsx +347 -0
- package/src/components/forms/ResourceTypeEditForm.tsx +331 -0
- package/src/components/forms/index.ts +11 -0
- package/src/components/orchestrator/ResourceOrchestrator.tsx +372 -0
- package/src/components/views/CompiledView/index.tsx +922 -0
- package/src/components/views/ConfigurationView/index.tsx +800 -0
- package/src/components/views/FilterView/index.tsx +825 -0
- package/src/components/views/ImportView/index.tsx +717 -0
- package/src/components/views/ResolutionView/EditableJsonView.tsx +214 -0
- package/src/components/views/ResolutionView/ResolutionEditControls.tsx +170 -0
- package/src/components/views/ResolutionView/index.tsx +591 -0
- package/src/components/views/SourceView/index.tsx +536 -0
- package/src/components/views/ZipLoaderView/index.tsx +485 -0
- package/src/hooks/useConfigurationState.ts +374 -0
- package/src/hooks/useFilterState.ts +97 -0
- package/src/hooks/useResolutionState.ts +355 -0
- package/src/hooks/useResourceData.ts +467 -0
- package/src/hooks/useViewState.ts +44 -0
- package/src/index.ts +45 -0
- package/src/test/helpers/testDataLoader.ts +195 -0
- package/src/test/unit/utils/configurationUtils.test.ts +630 -0
- package/src/test/unit/utils/fileProcessing.test.ts +391 -0
- package/src/test/unit/utils/filterResources.test.ts +574 -0
- package/src/test/unit/utils/resolutionEditing.test.ts +556 -0
- package/src/test/unit/utils/resolutionUtils.test.ts +521 -0
- package/src/test/unit/utils/tsResIntegration.test.ts +433 -0
- package/src/types/index.ts +322 -0
- package/src/utils/configurationUtils.ts +424 -0
- package/src/utils/fileProcessing.ts +160 -0
- package/src/utils/filterResources.ts +206 -0
- package/src/utils/resolutionEditing.ts +319 -0
- package/src/utils/resolutionUtils.ts +289 -0
- package/src/utils/tsResIntegration.ts +440 -0
- package/src/utils/zipLoader/browserZipLoader.ts +319 -0
- package/src/utils/zipLoader/index.ts +26 -0
- package/src/utils/zipLoader/nodeZipBuilder.ts +153 -0
- package/src/utils/zipLoader/types.ts +175 -0
- package/src/utils/zipLoader/zipUtils.ts +266 -0
- package/temp/build/typescript/ts_gZid87Hu.json +1 -0
- package/tsconfig.json +15 -0
|
@@ -0,0 +1,595 @@
|
|
|
1
|
+
import React, { useState, useMemo, useCallback, useEffect } from 'react';
|
|
2
|
+
import { CubeIcon, FolderIcon, FolderOpenIcon, DocumentTextIcon, ChevronRightIcon, ChevronDownIcon, DocumentArrowDownIcon, CodeBracketIcon, ChevronUpIcon, ArchiveBoxIcon } from '@heroicons/react/24/outline';
|
|
3
|
+
import { Config, Bundle } from '@fgv/ts-res';
|
|
4
|
+
export const CompiledView = ({ resources, filterState, filterResult, useNormalization: useNormalizationProp = false, onExport, onMessage, className = '' }) => {
|
|
5
|
+
const [selectedNodeId, setSelectedNodeId] = useState(null);
|
|
6
|
+
const [expandedNodes, setExpandedNodes] = useState(new Set(['root', 'resources']));
|
|
7
|
+
const [showJsonView, setShowJsonView] = useState(false);
|
|
8
|
+
const [useNormalization, setUseNormalization] = useState(useNormalizationProp);
|
|
9
|
+
// Update normalization default when bundle state changes
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
if (resources?.isLoadedFromBundle && !useNormalization) {
|
|
12
|
+
setUseNormalization(true);
|
|
13
|
+
}
|
|
14
|
+
}, [resources?.isLoadedFromBundle, useNormalization]);
|
|
15
|
+
// Use filtered resources when filtering is active and successful
|
|
16
|
+
const isFilteringActive = filterState?.enabled && filterResult?.success === true;
|
|
17
|
+
const activeProcessedResources = isFilteringActive ? filterResult?.processedResources : resources;
|
|
18
|
+
// Get the active compiled collection
|
|
19
|
+
const activeCompiledCollection = useMemo(() => {
|
|
20
|
+
return isFilteringActive
|
|
21
|
+
? filterResult?.processedResources?.compiledCollection
|
|
22
|
+
: resources?.compiledCollection;
|
|
23
|
+
}, [
|
|
24
|
+
isFilteringActive,
|
|
25
|
+
filterResult?.processedResources?.compiledCollection,
|
|
26
|
+
resources?.compiledCollection
|
|
27
|
+
]);
|
|
28
|
+
// Build tree structure using the compiled collection
|
|
29
|
+
const treeData = useMemo(() => {
|
|
30
|
+
if (!activeCompiledCollection) {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
const tree = {
|
|
34
|
+
id: 'root',
|
|
35
|
+
name: 'Compiled Resources',
|
|
36
|
+
type: 'folder',
|
|
37
|
+
children: []
|
|
38
|
+
};
|
|
39
|
+
try {
|
|
40
|
+
// Resources section using the compiled collection
|
|
41
|
+
const resourcesCount = activeCompiledCollection.resources?.length || 0;
|
|
42
|
+
const resourcesSection = {
|
|
43
|
+
id: 'resources',
|
|
44
|
+
name: `Resources (${resourcesCount})`,
|
|
45
|
+
type: 'section',
|
|
46
|
+
children: []
|
|
47
|
+
};
|
|
48
|
+
// Get all resource IDs from the compiled collection
|
|
49
|
+
if (activeCompiledCollection.resources && activeCompiledCollection.resources.length > 0) {
|
|
50
|
+
resourcesSection.children = activeCompiledCollection.resources.map((resource) => ({
|
|
51
|
+
id: `resource-${resource.id}`,
|
|
52
|
+
name: String(resource.id || 'unnamed'),
|
|
53
|
+
type: 'resource',
|
|
54
|
+
data: { type: 'compiled-resource', resource }
|
|
55
|
+
}));
|
|
56
|
+
}
|
|
57
|
+
tree.children.push(resourcesSection);
|
|
58
|
+
// Collectors section - showing from compiled collection
|
|
59
|
+
tree.children.push({
|
|
60
|
+
id: 'qualifiers',
|
|
61
|
+
name: `Qualifiers (${activeCompiledCollection.qualifiers?.length || 0})`,
|
|
62
|
+
type: 'section',
|
|
63
|
+
data: { type: 'qualifiers', items: activeCompiledCollection.qualifiers }
|
|
64
|
+
});
|
|
65
|
+
tree.children.push({
|
|
66
|
+
id: 'qualifier-types',
|
|
67
|
+
name: `Qualifier Types (${activeCompiledCollection.qualifierTypes?.length || 0})`,
|
|
68
|
+
type: 'section',
|
|
69
|
+
data: { type: 'qualifier-types', items: activeCompiledCollection.qualifierTypes }
|
|
70
|
+
});
|
|
71
|
+
tree.children.push({
|
|
72
|
+
id: 'resource-types',
|
|
73
|
+
name: `Resource Types (${activeCompiledCollection.resourceTypes?.length || 0})`,
|
|
74
|
+
type: 'section',
|
|
75
|
+
data: { type: 'resource-types', items: activeCompiledCollection.resourceTypes }
|
|
76
|
+
});
|
|
77
|
+
tree.children.push({
|
|
78
|
+
id: 'conditions',
|
|
79
|
+
name: `Conditions (${activeCompiledCollection.conditions?.length || 0})`,
|
|
80
|
+
type: 'section',
|
|
81
|
+
data: { type: 'conditions', items: activeCompiledCollection.conditions }
|
|
82
|
+
});
|
|
83
|
+
tree.children.push({
|
|
84
|
+
id: 'condition-sets',
|
|
85
|
+
name: `Condition Sets (${activeCompiledCollection.conditionSets?.length || 0})`,
|
|
86
|
+
type: 'section',
|
|
87
|
+
data: { type: 'condition-sets', items: activeCompiledCollection.conditionSets }
|
|
88
|
+
});
|
|
89
|
+
tree.children.push({
|
|
90
|
+
id: 'decisions',
|
|
91
|
+
name: `Decisions (${activeCompiledCollection.decisions?.length || 0})`,
|
|
92
|
+
type: 'section',
|
|
93
|
+
data: { type: 'decisions', items: activeCompiledCollection.decisions }
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
catch (error) {
|
|
97
|
+
onMessage?.('error', `Error building tree: ${error instanceof Error ? error.message : String(error)}`);
|
|
98
|
+
}
|
|
99
|
+
return tree;
|
|
100
|
+
}, [activeCompiledCollection, onMessage]);
|
|
101
|
+
const handleExportCompiledData = useCallback(async () => {
|
|
102
|
+
if (!activeProcessedResources?.compiledCollection) {
|
|
103
|
+
onMessage?.('error', 'No compiled data available to export');
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
let compiledCollection = activeProcessedResources.compiledCollection;
|
|
107
|
+
if (useNormalization && resources?.activeConfiguration) {
|
|
108
|
+
const systemConfigResult = Config.SystemConfiguration.create(resources.activeConfiguration);
|
|
109
|
+
if (systemConfigResult.isSuccess()) {
|
|
110
|
+
// Check if we have a ResourceManagerBuilder (which supports normalization)
|
|
111
|
+
if ('getCompiledResourceCollection' in activeProcessedResources.system.resourceManager) {
|
|
112
|
+
const resourceManagerResult = Bundle.BundleNormalizer.normalize(activeProcessedResources.system.resourceManager, systemConfigResult.value);
|
|
113
|
+
if (resourceManagerResult.isSuccess()) {
|
|
114
|
+
const normalizedCompiledResult = resourceManagerResult.value.getCompiledResourceCollection({
|
|
115
|
+
includeMetadata: true
|
|
116
|
+
});
|
|
117
|
+
if (normalizedCompiledResult.isSuccess()) {
|
|
118
|
+
compiledCollection = normalizedCompiledResult.value;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
console.warn('Failed to get normalized compiled collection:', normalizedCompiledResult.message);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
console.warn('Failed to normalize bundle:', resourceManagerResult.message);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
// For IResourceManager from bundles, the compiled collection is already normalized
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
console.warn('Failed to create system configuration for normalization:', systemConfigResult.message);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const compiledData = {
|
|
135
|
+
...compiledCollection,
|
|
136
|
+
metadata: {
|
|
137
|
+
exportedAt: new Date().toISOString(),
|
|
138
|
+
type: isFilteringActive ? 'ts-res-filtered-compiled-collection' : 'ts-res-compiled-collection',
|
|
139
|
+
normalized: useNormalization,
|
|
140
|
+
...(resources?.isLoadedFromBundle && { loadedFromBundle: true }),
|
|
141
|
+
...(isFilteringActive && { filterContext: filterState?.appliedValues })
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
onExport?.(compiledData, 'json');
|
|
145
|
+
}, [
|
|
146
|
+
activeProcessedResources,
|
|
147
|
+
onMessage,
|
|
148
|
+
isFilteringActive,
|
|
149
|
+
filterState?.appliedValues,
|
|
150
|
+
useNormalization,
|
|
151
|
+
resources,
|
|
152
|
+
onExport
|
|
153
|
+
]);
|
|
154
|
+
const handleExportBundle = useCallback(async () => {
|
|
155
|
+
if (!activeProcessedResources?.system?.resourceManager || !resources?.activeConfiguration) {
|
|
156
|
+
onMessage?.('error', 'No resource manager or configuration available to create bundle');
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const systemConfigResult = Config.SystemConfiguration.create(resources.activeConfiguration);
|
|
160
|
+
if (systemConfigResult.isFailure()) {
|
|
161
|
+
onMessage?.('error', `Failed to create system configuration: ${systemConfigResult.message}`);
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
const systemConfig = systemConfigResult.value;
|
|
165
|
+
const bundleParams = {
|
|
166
|
+
version: '1.0.0',
|
|
167
|
+
description: isFilteringActive
|
|
168
|
+
? 'Bundle exported from ts-res-ui-components (filtered)'
|
|
169
|
+
: 'Bundle exported from ts-res-ui-components',
|
|
170
|
+
normalize: true
|
|
171
|
+
};
|
|
172
|
+
// Check if we have a ResourceManagerBuilder (which supports bundle creation)
|
|
173
|
+
if (!('getCompiledResourceCollection' in activeProcessedResources.system.resourceManager)) {
|
|
174
|
+
onMessage?.('error', 'Bundle export is not supported for resources loaded from bundles');
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
const bundleResult = Bundle.BundleBuilder.create(activeProcessedResources.system.resourceManager, systemConfig, bundleParams);
|
|
178
|
+
if (bundleResult.isFailure()) {
|
|
179
|
+
onMessage?.('error', `Failed to create bundle: ${bundleResult.message}`);
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
const bundle = bundleResult.value;
|
|
183
|
+
const exportBundle = {
|
|
184
|
+
...bundle,
|
|
185
|
+
exportMetadata: {
|
|
186
|
+
exportedAt: new Date().toISOString(),
|
|
187
|
+
exportedFrom: 'ts-res-ui-components',
|
|
188
|
+
type: isFilteringActive ? 'ts-res-bundle-filtered' : 'ts-res-bundle',
|
|
189
|
+
...(isFilteringActive && { filterContext: filterState?.appliedValues })
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
onExport?.(exportBundle, 'bundle');
|
|
193
|
+
}, [
|
|
194
|
+
activeProcessedResources?.system?.resourceManager,
|
|
195
|
+
resources?.activeConfiguration,
|
|
196
|
+
onMessage,
|
|
197
|
+
isFilteringActive,
|
|
198
|
+
filterState?.appliedValues,
|
|
199
|
+
onExport
|
|
200
|
+
]);
|
|
201
|
+
const handleNodeClick = (node) => {
|
|
202
|
+
setSelectedNodeId(node.id);
|
|
203
|
+
onMessage?.('info', `Selected: ${node.name}`);
|
|
204
|
+
if (node.type === 'folder' || (node.type === 'section' && node.children)) {
|
|
205
|
+
setExpandedNodes((prev) => {
|
|
206
|
+
const newExpanded = new Set(prev);
|
|
207
|
+
if (newExpanded.has(node.id)) {
|
|
208
|
+
newExpanded.delete(node.id);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
newExpanded.add(node.id);
|
|
212
|
+
}
|
|
213
|
+
return newExpanded;
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
const renderTreeNode = (node, level = 0) => {
|
|
218
|
+
const isExpanded = expandedNodes.has(node.id);
|
|
219
|
+
const isSelected = selectedNodeId === node.id;
|
|
220
|
+
const hasChildren = node.children && node.children.length > 0;
|
|
221
|
+
return (React.createElement("div", { key: node.id },
|
|
222
|
+
React.createElement("div", { className: `flex items-center px-2 py-1 cursor-pointer hover:bg-gray-100 ${isSelected ? 'bg-blue-50 border-r-2 border-blue-500' : ''}`, style: { paddingLeft: `${8 + level * 16}px` }, onClick: () => handleNodeClick(node) },
|
|
223
|
+
hasChildren && (React.createElement("div", { className: "w-4 h-4 mr-1 flex items-center justify-center" }, isExpanded ? (React.createElement(ChevronDownIcon, { className: "w-3 h-3 text-gray-500" })) : (React.createElement(ChevronRightIcon, { className: "w-3 h-3 text-gray-500" })))),
|
|
224
|
+
!hasChildren && React.createElement("div", { className: "w-5 mr-1" }),
|
|
225
|
+
React.createElement("div", { className: "w-4 h-4 mr-2 flex items-center justify-center" }, node.type === 'folder' ? (isExpanded ? (React.createElement(FolderOpenIcon, { className: "w-4 h-4 text-blue-500" })) : (React.createElement(FolderIcon, { className: "w-4 h-4 text-blue-500" }))) : node.type === 'resource' ? (React.createElement(DocumentTextIcon, { className: "w-4 h-4 text-green-500" })) : (React.createElement(CubeIcon, { className: "w-4 h-4 text-purple-500" }))),
|
|
226
|
+
React.createElement("span", { className: `text-sm ${isSelected ? 'font-medium text-blue-900' : 'text-gray-700'}` }, node.name)),
|
|
227
|
+
hasChildren && isExpanded && (React.createElement("div", null, node.children.map((child) => renderTreeNode(child, level + 1))))));
|
|
228
|
+
};
|
|
229
|
+
if (!resources) {
|
|
230
|
+
return (React.createElement("div", { className: `p-6 ${className}` },
|
|
231
|
+
React.createElement("div", { className: "flex items-center space-x-3 mb-6" },
|
|
232
|
+
React.createElement(CubeIcon, { className: "h-8 w-8 text-blue-600" }),
|
|
233
|
+
React.createElement("h2", { className: "text-2xl font-bold text-gray-900" }, "Compiled Resources")),
|
|
234
|
+
React.createElement("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 p-8 text-center" },
|
|
235
|
+
React.createElement("div", { className: "max-w-2xl mx-auto" },
|
|
236
|
+
React.createElement("h3", { className: "text-xl font-semibold text-gray-900 mb-4" }, "No Compiled Resources"),
|
|
237
|
+
React.createElement("p", { className: "text-gray-600 mb-6" }, "Import resources to explore the compiled resource collection.")))));
|
|
238
|
+
}
|
|
239
|
+
const selectedNode = selectedNodeId ? findNodeById(treeData, selectedNodeId) : null;
|
|
240
|
+
return (React.createElement("div", { className: `p-6 ${className}` },
|
|
241
|
+
React.createElement("div", { className: "flex items-center justify-between mb-6" },
|
|
242
|
+
React.createElement("div", { className: "flex items-center space-x-3" },
|
|
243
|
+
React.createElement(CubeIcon, { className: "h-8 w-8 text-blue-600" }),
|
|
244
|
+
React.createElement("h2", { className: "text-2xl font-bold text-gray-900" }, "Compiled Resources"),
|
|
245
|
+
isFilteringActive && (React.createElement("span", { className: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-purple-100 text-purple-800" }, "Filtered"))),
|
|
246
|
+
activeProcessedResources && (React.createElement("div", { className: "flex items-center space-x-2" },
|
|
247
|
+
React.createElement("button", { onClick: handleExportCompiledData, className: "inline-flex items-center px-3 py-1.5 border border-gray-300 text-xs font-medium rounded text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" },
|
|
248
|
+
React.createElement(DocumentArrowDownIcon, { className: "h-4 w-4 mr-1" }),
|
|
249
|
+
"Export JSON"),
|
|
250
|
+
React.createElement("button", { onClick: handleExportBundle, className: "inline-flex items-center px-3 py-1.5 border border-blue-300 text-xs font-medium rounded text-blue-700 bg-blue-50 hover:bg-blue-100 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" },
|
|
251
|
+
React.createElement(ArchiveBoxIcon, { className: "h-4 w-4 mr-1" }),
|
|
252
|
+
"Export Bundle")))),
|
|
253
|
+
activeProcessedResources && (React.createElement("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 p-4 mb-6" },
|
|
254
|
+
React.createElement("div", { className: "flex items-center justify-between" },
|
|
255
|
+
React.createElement("div", { className: "flex items-center space-x-6" },
|
|
256
|
+
React.createElement("div", { className: "flex items-center space-x-2" },
|
|
257
|
+
resources?.isLoadedFromBundle ? (React.createElement(ArchiveBoxIcon, { className: "h-4 w-4 text-blue-600" })) : (React.createElement(CubeIcon, { className: "h-4 w-4 text-gray-600" })),
|
|
258
|
+
React.createElement("label", { className: "text-sm font-medium text-gray-700" }, "Normalize Output:"),
|
|
259
|
+
React.createElement("button", { onClick: () => setUseNormalization(!useNormalization), className: `relative inline-flex h-5 w-9 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 ${useNormalization ? 'bg-blue-600' : 'bg-gray-300'}` },
|
|
260
|
+
React.createElement("span", { className: `inline-block h-3 w-3 transform rounded-full bg-white transition-transform ${useNormalization ? 'translate-x-5' : 'translate-x-1'}` })),
|
|
261
|
+
React.createElement("span", { className: "text-xs text-gray-500" }, useNormalization ? 'ON' : 'OFF')),
|
|
262
|
+
React.createElement("button", { onClick: () => setShowJsonView(!showJsonView), className: "inline-flex items-center px-3 py-1.5 text-sm font-medium text-gray-700 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500" },
|
|
263
|
+
React.createElement(CodeBracketIcon, { className: "h-4 w-4 mr-2" }),
|
|
264
|
+
showJsonView ? 'Hide' : 'Show',
|
|
265
|
+
" JSON",
|
|
266
|
+
showJsonView ? (React.createElement(ChevronUpIcon, { className: "h-4 w-4 ml-2" })) : (React.createElement(ChevronDownIcon, { className: "h-4 w-4 ml-2" }))))),
|
|
267
|
+
showJsonView && (React.createElement("div", { className: "mt-4" },
|
|
268
|
+
React.createElement("div", { className: "bg-gray-50 rounded-lg border border-gray-200 p-4" },
|
|
269
|
+
React.createElement("pre", { className: "text-xs text-gray-800 bg-white p-3 rounded border overflow-x-auto max-h-64 overflow-y-auto" }, JSON.stringify(activeProcessedResources.compiledCollection, null, 2))))))),
|
|
270
|
+
React.createElement("div", { className: "bg-white rounded-lg shadow-sm border border-gray-200 p-6" },
|
|
271
|
+
React.createElement("div", { className: "flex flex-col lg:flex-row gap-6 h-[600px]" },
|
|
272
|
+
React.createElement("div", { className: "lg:w-1/2 flex flex-col" },
|
|
273
|
+
React.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-4" }, "Compiled Collection"),
|
|
274
|
+
React.createElement("div", { className: "flex-1 overflow-y-auto border border-gray-200 rounded-lg bg-gray-50" }, treeData && renderTreeNode(treeData))),
|
|
275
|
+
React.createElement("div", { className: "lg:w-1/2 flex flex-col" }, selectedNode ? (React.createElement(NodeDetail, { node: selectedNode })) : (React.createElement("div", { className: "flex-1 flex items-center justify-center border border-gray-200 rounded-lg bg-gray-50" },
|
|
276
|
+
React.createElement("div", { className: "text-center" },
|
|
277
|
+
React.createElement(CubeIcon, { className: "h-12 w-12 text-gray-400 mx-auto mb-4" }),
|
|
278
|
+
React.createElement("p", { className: "text-gray-500" }, "Select an item to view details")))))))));
|
|
279
|
+
};
|
|
280
|
+
// Helper function to find node by ID
|
|
281
|
+
const findNodeById = (tree, id) => {
|
|
282
|
+
if (tree.id === id)
|
|
283
|
+
return tree;
|
|
284
|
+
if (tree.children) {
|
|
285
|
+
for (const child of tree.children) {
|
|
286
|
+
const found = findNodeById(child, id);
|
|
287
|
+
if (found)
|
|
288
|
+
return found;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return null;
|
|
292
|
+
};
|
|
293
|
+
const NodeDetail = ({ node }) => {
|
|
294
|
+
const [showRawJson, setShowRawJson] = useState(false);
|
|
295
|
+
const renderDetails = () => {
|
|
296
|
+
if (!node.data) {
|
|
297
|
+
return (React.createElement("div", { className: "space-y-4" },
|
|
298
|
+
React.createElement("div", { className: "bg-white rounded-lg border p-4" },
|
|
299
|
+
React.createElement("h4", { className: "font-medium text-gray-700 mb-2" },
|
|
300
|
+
"\uD83D\uDCC1 ",
|
|
301
|
+
node.name),
|
|
302
|
+
React.createElement("p", { className: "text-sm text-gray-600" }, node.children ? `Contains ${node.children.length} items` : 'Empty folder'))));
|
|
303
|
+
}
|
|
304
|
+
const { type, resourceId, manager } = node.data;
|
|
305
|
+
switch (type) {
|
|
306
|
+
case 'runtime-resource':
|
|
307
|
+
return renderRuntimeResource(resourceId, manager);
|
|
308
|
+
case 'qualifiers':
|
|
309
|
+
case 'qualifier-types':
|
|
310
|
+
case 'resource-types':
|
|
311
|
+
case 'conditions':
|
|
312
|
+
case 'condition-sets':
|
|
313
|
+
case 'decisions':
|
|
314
|
+
return renderRuntimeCollection(type, manager);
|
|
315
|
+
default:
|
|
316
|
+
return renderRawData();
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
// New function that uses runtime objects instead of manual JSON manipulation
|
|
320
|
+
const renderRuntimeResource = (resourceId, manager) => {
|
|
321
|
+
// Get the full runtime resource object with all its rich data
|
|
322
|
+
const resourceResult = manager.getBuiltResource(resourceId);
|
|
323
|
+
if (resourceResult.isFailure()) {
|
|
324
|
+
return (React.createElement("div", { className: "bg-white rounded-lg border p-4" },
|
|
325
|
+
React.createElement("h4", { className: "font-medium text-red-700 mb-2" }, "Error Loading Resource"),
|
|
326
|
+
React.createElement("p", { className: "text-sm text-red-600" }, resourceResult.message)));
|
|
327
|
+
}
|
|
328
|
+
const resource = resourceResult.value;
|
|
329
|
+
return (React.createElement("div", { className: "space-y-6" },
|
|
330
|
+
React.createElement("div", { className: "bg-gray-50 rounded-lg p-4" },
|
|
331
|
+
React.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-4" }, "Compiled Resource Details"),
|
|
332
|
+
React.createElement("div", { className: "bg-white rounded-lg border p-4 space-y-3" },
|
|
333
|
+
React.createElement("div", { className: "flex items-start" },
|
|
334
|
+
React.createElement("span", { className: "font-semibold text-gray-700 w-32" }, "ID:"),
|
|
335
|
+
React.createElement("span", { className: "font-mono text-gray-900" }, resource.id)),
|
|
336
|
+
React.createElement("div", { className: "flex items-start" },
|
|
337
|
+
React.createElement("span", { className: "font-semibold text-gray-700 w-32" }, "Resource Type:"),
|
|
338
|
+
React.createElement("span", { className: "text-gray-900" },
|
|
339
|
+
resource.resourceType.name || resource.resourceType.key,
|
|
340
|
+
React.createElement("span", { className: "ml-2 text-xs font-mono bg-gray-100 px-2 py-1 rounded" },
|
|
341
|
+
"(",
|
|
342
|
+
resource.resourceType.index,
|
|
343
|
+
")"))),
|
|
344
|
+
React.createElement("div", { className: "flex items-start" },
|
|
345
|
+
React.createElement("span", { className: "font-semibold text-gray-700 w-32" }, "Decision:"),
|
|
346
|
+
React.createElement("span", { className: "text-gray-900" },
|
|
347
|
+
React.createElement("span", { className: "font-mono" },
|
|
348
|
+
"Decision ",
|
|
349
|
+
resource.decision.baseDecision?.index ?? resource.decision.index ?? 'unknown',
|
|
350
|
+
' ',
|
|
351
|
+
"with ",
|
|
352
|
+
resource.decision.candidates.length,
|
|
353
|
+
" candidates"))))),
|
|
354
|
+
React.createElement("div", { className: "bg-gray-50 rounded-lg p-4" },
|
|
355
|
+
React.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-4" }, "Candidates"),
|
|
356
|
+
React.createElement("div", { className: "space-y-4" }, resource.candidates.map((candidate, candidateIdx) => {
|
|
357
|
+
// Get the corresponding decision candidate to access condition sets
|
|
358
|
+
const decisionCandidate = resource.decision.candidates[candidateIdx];
|
|
359
|
+
return (React.createElement("div", { key: candidateIdx, className: "bg-white rounded-lg border p-4" },
|
|
360
|
+
React.createElement("div", { className: "mb-3" },
|
|
361
|
+
React.createElement("h4", { className: "font-semibold text-gray-900" },
|
|
362
|
+
"Candidate ",
|
|
363
|
+
candidateIdx + 1,
|
|
364
|
+
candidate.isPartial && (React.createElement("span", { className: "ml-2 bg-yellow-100 text-yellow-800 px-2 py-1 rounded text-xs" }, "Partial")))),
|
|
365
|
+
React.createElement("div", { className: "bg-gray-50 rounded p-3 mb-3" },
|
|
366
|
+
React.createElement("h6", { className: "text-sm font-semibold text-gray-700 mb-2" }, "Resource Content:"),
|
|
367
|
+
React.createElement("pre", { className: "text-sm font-mono text-gray-800 whitespace-pre-wrap" }, JSON.stringify(candidate.json, null, 2))),
|
|
368
|
+
decisionCandidate?.conditionSet &&
|
|
369
|
+
decisionCandidate.conditionSet.conditions.length > 0 && (React.createElement("div", { className: "border-t pt-3" },
|
|
370
|
+
React.createElement("h5", { className: "text-sm font-semibold text-gray-700 mb-2" },
|
|
371
|
+
"Condition Set ",
|
|
372
|
+
decisionCandidate.conditionSet.index,
|
|
373
|
+
":"),
|
|
374
|
+
React.createElement("div", { className: "space-y-2" }, decisionCandidate.conditionSet.conditions.map((condition, idx) => (React.createElement("div", { key: idx, className: "flex items-center text-sm bg-blue-50 rounded px-3 py-2" },
|
|
375
|
+
React.createElement("span", { className: "font-mono text-blue-700 mr-2 text-xs" },
|
|
376
|
+
condition.index.toString().padStart(2, '0'),
|
|
377
|
+
":"),
|
|
378
|
+
React.createElement("span", { className: "font-medium text-blue-900 mr-2" }, condition.qualifier.name),
|
|
379
|
+
React.createElement("span", { className: "text-blue-700 mr-2" }, condition.operator),
|
|
380
|
+
React.createElement("span", { className: "font-mono text-blue-800" }, condition.value),
|
|
381
|
+
React.createElement("span", { className: "ml-auto text-xs text-blue-600" },
|
|
382
|
+
"Priority: ",
|
|
383
|
+
condition.priority,
|
|
384
|
+
condition.scoreAsDefault !== undefined && (React.createElement("span", { className: "ml-2" },
|
|
385
|
+
"Default: ",
|
|
386
|
+
condition.scoreAsDefault))))))))),
|
|
387
|
+
(!decisionCandidate?.conditionSet ||
|
|
388
|
+
decisionCandidate.conditionSet.conditions.length === 0) && (React.createElement("div", { className: "border-t pt-3" },
|
|
389
|
+
React.createElement("span", { className: "text-xs text-gray-500 bg-gray-100 px-2 py-1 rounded" }, "No conditions (default candidate)")))));
|
|
390
|
+
})))));
|
|
391
|
+
};
|
|
392
|
+
// New function that uses runtime collections instead of raw JSON
|
|
393
|
+
const renderRuntimeCollection = (collectionType, manager) => {
|
|
394
|
+
let collector;
|
|
395
|
+
let title;
|
|
396
|
+
switch (collectionType) {
|
|
397
|
+
case 'qualifiers':
|
|
398
|
+
collector = manager.qualifiers;
|
|
399
|
+
title = 'Qualifiers';
|
|
400
|
+
break;
|
|
401
|
+
case 'qualifier-types':
|
|
402
|
+
collector = manager.qualifierTypes;
|
|
403
|
+
title = 'Qualifier Types';
|
|
404
|
+
break;
|
|
405
|
+
case 'resource-types':
|
|
406
|
+
collector = manager.resourceTypes;
|
|
407
|
+
title = 'Resource Types';
|
|
408
|
+
break;
|
|
409
|
+
case 'conditions':
|
|
410
|
+
collector = manager.conditions;
|
|
411
|
+
title = 'Conditions';
|
|
412
|
+
break;
|
|
413
|
+
case 'condition-sets':
|
|
414
|
+
collector = manager.conditionSets;
|
|
415
|
+
title = 'Condition Sets';
|
|
416
|
+
break;
|
|
417
|
+
case 'decisions':
|
|
418
|
+
collector = manager.decisions;
|
|
419
|
+
title = 'Decisions';
|
|
420
|
+
break;
|
|
421
|
+
default:
|
|
422
|
+
return (React.createElement("div", { className: "bg-white rounded-lg border p-4" },
|
|
423
|
+
React.createElement("p", { className: "text-sm text-gray-500" },
|
|
424
|
+
"Unknown collection type: ",
|
|
425
|
+
collectionType)));
|
|
426
|
+
}
|
|
427
|
+
const items = Array.from(collector.values());
|
|
428
|
+
return (React.createElement("div", { className: "bg-gray-50 rounded-lg p-4" },
|
|
429
|
+
React.createElement("h3", { className: "text-lg font-semibold text-gray-900 mb-4" },
|
|
430
|
+
title,
|
|
431
|
+
" ",
|
|
432
|
+
React.createElement("span", { className: "text-sm font-normal text-gray-600" },
|
|
433
|
+
"(",
|
|
434
|
+
items.length,
|
|
435
|
+
")")),
|
|
436
|
+
items.length === 0 ? (React.createElement("div", { className: "bg-white rounded-lg border p-4" },
|
|
437
|
+
React.createElement("p", { className: "text-sm text-gray-500" },
|
|
438
|
+
"No ",
|
|
439
|
+
title.toLowerCase(),
|
|
440
|
+
" available"))) : (React.createElement("div", { className: "space-y-3 max-h-96 overflow-y-auto" }, items.map((item, index) => (React.createElement("div", { key: index, className: "bg-white rounded-lg border p-4" },
|
|
441
|
+
React.createElement("div", { className: "flex items-start justify-between mb-3" },
|
|
442
|
+
React.createElement("div", null,
|
|
443
|
+
React.createElement("h4", { className: "font-semibold text-gray-900" }, getItemDisplayName(item, collectionType, index)),
|
|
444
|
+
React.createElement("p", { className: "text-sm text-gray-600 font-mono mt-1" }, getItemDisplayKey(item, collectionType))),
|
|
445
|
+
item.index !== undefined && (React.createElement("span", { className: "bg-gray-100 text-gray-700 px-2 py-1 rounded text-xs font-mono" },
|
|
446
|
+
"Index: ",
|
|
447
|
+
item.index))),
|
|
448
|
+
React.createElement("div", { className: "border-t pt-3" }, renderRuntimeItemDetail(item, collectionType)))))))));
|
|
449
|
+
};
|
|
450
|
+
// Helper functions for runtime object display
|
|
451
|
+
const getItemDisplayName = (item, collectionType, index) => {
|
|
452
|
+
switch (collectionType) {
|
|
453
|
+
case 'qualifiers':
|
|
454
|
+
return `${item.index}: ${item.name} (${item.type.name})`;
|
|
455
|
+
case 'qualifier-types':
|
|
456
|
+
return `${item.index}: ${item.name} (${item.systemType})`;
|
|
457
|
+
case 'resource-types':
|
|
458
|
+
return `${item.index}: ${item.name || item.key}`;
|
|
459
|
+
case 'conditions':
|
|
460
|
+
return `${item.index.toString().padStart(2, '0')}: ${item.qualifier.name} ${item.operator} ${item.value}`;
|
|
461
|
+
case 'condition-sets':
|
|
462
|
+
return `${item.index}: ${item.conditions.length === 0 ? 'Unconditional' : `${item.conditions.length} conditions`}`;
|
|
463
|
+
case 'decisions':
|
|
464
|
+
return `${item.baseDecision?.index ?? item.index}: Decision with ${item.candidates.length} candidates`;
|
|
465
|
+
default:
|
|
466
|
+
return `${index}: Item ${index}`;
|
|
467
|
+
}
|
|
468
|
+
};
|
|
469
|
+
const getItemDisplayKey = (item, collectionType) => {
|
|
470
|
+
try {
|
|
471
|
+
switch (collectionType) {
|
|
472
|
+
case 'qualifiers':
|
|
473
|
+
return `defaultPriority: ${item?.defaultPriority ?? 'N/A'}`;
|
|
474
|
+
case 'qualifier-types':
|
|
475
|
+
return `allowContextList: ${item?.allowContextList ?? 'N/A'}`;
|
|
476
|
+
case 'resource-types':
|
|
477
|
+
return `key: ${item?.key ?? 'N/A'}`;
|
|
478
|
+
case 'conditions':
|
|
479
|
+
return `priority: ${item?.priority ?? 'N/A'}`;
|
|
480
|
+
case 'condition-sets':
|
|
481
|
+
return (item?.conditions
|
|
482
|
+
?.map((c) => `${c?.qualifier?.name ?? 'unknown'}=${c?.value ?? 'unknown'}`)
|
|
483
|
+
.join(', ') || 'default');
|
|
484
|
+
case 'decisions':
|
|
485
|
+
return `${item?.conditionSets?.length ?? 0} condition sets`;
|
|
486
|
+
default:
|
|
487
|
+
return '';
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
catch (error) {
|
|
491
|
+
console.warn('Error in getItemDisplayKey:', error, { item, collectionType });
|
|
492
|
+
return 'Display error';
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
const renderRuntimeItemDetail = (item, collectionType) => {
|
|
496
|
+
switch (collectionType) {
|
|
497
|
+
case 'qualifiers':
|
|
498
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
499
|
+
React.createElement("div", null,
|
|
500
|
+
React.createElement("span", { className: "font-medium" }, "Type:"),
|
|
501
|
+
" ",
|
|
502
|
+
item.type.name),
|
|
503
|
+
React.createElement("div", null,
|
|
504
|
+
React.createElement("span", { className: "font-medium" }, "Default Priority:"),
|
|
505
|
+
" ",
|
|
506
|
+
item.defaultPriority)));
|
|
507
|
+
case 'qualifier-types':
|
|
508
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
509
|
+
React.createElement("div", null,
|
|
510
|
+
React.createElement("span", { className: "font-medium" }, "System Type:"),
|
|
511
|
+
" ",
|
|
512
|
+
item.systemType),
|
|
513
|
+
React.createElement("div", null,
|
|
514
|
+
React.createElement("span", { className: "font-medium" }, "Allow Context List:"),
|
|
515
|
+
" ",
|
|
516
|
+
item.allowContextList ? 'Yes' : 'No'),
|
|
517
|
+
item.enumeratedValues && (React.createElement("div", null,
|
|
518
|
+
React.createElement("span", { className: "font-medium" }, "Enumerated Values:"),
|
|
519
|
+
" ",
|
|
520
|
+
item.enumeratedValues.join(', ')))));
|
|
521
|
+
case 'resource-types':
|
|
522
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
523
|
+
React.createElement("div", null,
|
|
524
|
+
React.createElement("span", { className: "font-medium" }, "Key:"),
|
|
525
|
+
" ",
|
|
526
|
+
item.key),
|
|
527
|
+
React.createElement("div", null,
|
|
528
|
+
React.createElement("span", { className: "font-medium" }, "Name:"),
|
|
529
|
+
" ",
|
|
530
|
+
item.name)));
|
|
531
|
+
case 'conditions':
|
|
532
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
533
|
+
React.createElement("div", null,
|
|
534
|
+
React.createElement("span", { className: "font-medium" }, "Qualifier:"),
|
|
535
|
+
" ",
|
|
536
|
+
item.qualifier.name),
|
|
537
|
+
React.createElement("div", null,
|
|
538
|
+
React.createElement("span", { className: "font-medium" }, "Operator:"),
|
|
539
|
+
" ",
|
|
540
|
+
item.operator),
|
|
541
|
+
React.createElement("div", null,
|
|
542
|
+
React.createElement("span", { className: "font-medium" }, "Value:"),
|
|
543
|
+
" ",
|
|
544
|
+
item.value),
|
|
545
|
+
React.createElement("div", null,
|
|
546
|
+
React.createElement("span", { className: "font-medium" }, "Priority:"),
|
|
547
|
+
" ",
|
|
548
|
+
item.priority),
|
|
549
|
+
item.scoreAsDefault !== undefined && (React.createElement("div", null,
|
|
550
|
+
React.createElement("span", { className: "font-medium" }, "Score As Default:"),
|
|
551
|
+
" ",
|
|
552
|
+
item.scoreAsDefault))));
|
|
553
|
+
case 'condition-sets':
|
|
554
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
555
|
+
React.createElement("div", null,
|
|
556
|
+
React.createElement("span", { className: "font-medium" }, "Conditions:"),
|
|
557
|
+
" ",
|
|
558
|
+
item.conditions?.length ?? 0),
|
|
559
|
+
(item.conditions?.length ?? 0) > 0 && (React.createElement("div", { className: "space-y-1" }, item.conditions?.map((condition, idx) => (React.createElement("div", { key: idx, className: "text-xs bg-blue-50 rounded px-2 py-1" },
|
|
560
|
+
condition.qualifier.name,
|
|
561
|
+
" ",
|
|
562
|
+
condition.operator,
|
|
563
|
+
" ",
|
|
564
|
+
condition.value,
|
|
565
|
+
" (p:",
|
|
566
|
+
condition.priority,
|
|
567
|
+
")")))))));
|
|
568
|
+
case 'decisions':
|
|
569
|
+
return (React.createElement("div", { className: "space-y-2" },
|
|
570
|
+
React.createElement("div", null,
|
|
571
|
+
React.createElement("span", { className: "font-medium" }, "Condition Sets:"),
|
|
572
|
+
" ",
|
|
573
|
+
item.conditionSets?.length ?? 0),
|
|
574
|
+
React.createElement("div", null,
|
|
575
|
+
React.createElement("span", { className: "font-medium" }, "Candidates:"),
|
|
576
|
+
" ",
|
|
577
|
+
item.candidates?.length ?? 0)));
|
|
578
|
+
default:
|
|
579
|
+
return (React.createElement("pre", { className: "text-xs bg-gray-50 p-2 rounded overflow-x-auto" }, JSON.stringify(item, null, 2)));
|
|
580
|
+
}
|
|
581
|
+
};
|
|
582
|
+
const renderRawData = () => {
|
|
583
|
+
return (React.createElement("div", { className: "bg-white rounded-lg border p-4" },
|
|
584
|
+
React.createElement("h4", { className: "font-medium text-gray-700 mb-2" }, node.name),
|
|
585
|
+
React.createElement("pre", { className: "text-xs bg-gray-50 p-2 rounded overflow-x-auto max-h-96 overflow-y-auto" }, JSON.stringify(node.data, null, 2))));
|
|
586
|
+
};
|
|
587
|
+
return (React.createElement("div", { className: "flex flex-col h-full" },
|
|
588
|
+
React.createElement("div", { className: "flex items-center justify-between mb-4" },
|
|
589
|
+
React.createElement("h3", { className: "text-lg font-semibold text-gray-900" }, "Details"),
|
|
590
|
+
React.createElement("button", { onClick: () => setShowRawJson(!showRawJson), className: "text-xs text-gray-500 hover:text-gray-700 px-2 py-1 rounded hover:bg-gray-100" }, showRawJson ? 'Rich View' : 'Raw JSON')),
|
|
591
|
+
React.createElement("div", { className: "flex-1 overflow-y-auto" }, showRawJson ? (React.createElement("div", { className: "bg-white rounded-lg border p-4" },
|
|
592
|
+
React.createElement("pre", { className: "text-xs bg-gray-50 p-3 rounded overflow-x-auto" }, JSON.stringify(node.data, null, 2)))) : (renderDetails()))));
|
|
593
|
+
};
|
|
594
|
+
export default CompiledView;
|
|
595
|
+
//# sourceMappingURL=index.js.map
|