From fdd1828fda78448d3e42391311d5f9b91e168cb3 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Sun, 18 Jan 2026 18:26:39 +0000 Subject: [PATCH] Move wrapper/icon resolution into JSON registry --- json-components-registry.json | 240 +++++++++++++++---- schemas/json-components-registry-schema.json | 10 + src/lib/json-ui/component-registry.ts | 80 ++----- 3 files changed, 226 insertions(+), 104 deletions(-) diff --git a/json-components-registry.json b/json-components-registry.json index 9a23f7b..575f4c0 100644 --- a/json-components-registry.json +++ b/json-components-registry.json @@ -80,7 +80,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "ComponentBindingDialog" + "wrapperFor": "ComponentBindingDialog", + "load": { + "export": "ComponentBindingDialogWrapper" + } }, { "type": "Container", @@ -122,7 +125,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "DataSourceEditorDialog" + "wrapperFor": "DataSourceEditorDialog", + "load": { + "export": "DataSourceEditorDialogWrapper" + } }, { "type": "Dialog", @@ -724,7 +730,10 @@ "canHaveChildren": false, "description": "ArrowLeft icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "ArrowLeft" + } }, { "type": "ArrowRight", @@ -733,7 +742,10 @@ "canHaveChildren": false, "description": "ArrowRight icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "ArrowRight" + } }, { "type": "Check", @@ -742,7 +754,10 @@ "canHaveChildren": false, "description": "Check icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Check" + } }, { "type": "X", @@ -751,7 +766,10 @@ "canHaveChildren": false, "description": "X icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "X" + } }, { "type": "Plus", @@ -760,7 +778,10 @@ "canHaveChildren": false, "description": "Plus icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Plus" + } }, { "type": "Minus", @@ -769,7 +790,10 @@ "canHaveChildren": false, "description": "Minus icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Minus" + } }, { "type": "Search", @@ -778,7 +802,10 @@ "canHaveChildren": false, "description": "Search icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "MagnifyingGlass" + } }, { "type": "Filter", @@ -787,7 +814,10 @@ "canHaveChildren": false, "description": "Filter icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Funnel" + } }, { "type": "Download", @@ -796,7 +826,10 @@ "canHaveChildren": false, "description": "Download icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Download" + } }, { "type": "Upload", @@ -805,7 +838,10 @@ "canHaveChildren": false, "description": "Upload icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Upload" + } }, { "type": "Edit", @@ -814,7 +850,10 @@ "canHaveChildren": false, "description": "Edit icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "PencilSimple" + } }, { "type": "Trash", @@ -823,7 +862,10 @@ "canHaveChildren": false, "description": "Trash icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Trash" + } }, { "type": "Eye", @@ -832,7 +874,10 @@ "canHaveChildren": false, "description": "Eye icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Eye" + } }, { "type": "EyeOff", @@ -841,7 +886,10 @@ "canHaveChildren": false, "description": "EyeOff icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "EyeClosed" + } }, { "type": "ChevronUp", @@ -850,7 +898,10 @@ "canHaveChildren": false, "description": "ChevronUp icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "CaretUp" + } }, { "type": "ChevronDown", @@ -859,7 +910,10 @@ "canHaveChildren": false, "description": "ChevronDown icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "CaretDown" + } }, { "type": "ChevronLeft", @@ -868,7 +922,10 @@ "canHaveChildren": false, "description": "ChevronLeft icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "CaretLeft" + } }, { "type": "ChevronRight", @@ -877,7 +934,10 @@ "canHaveChildren": false, "description": "ChevronRight icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "CaretRight" + } }, { "type": "Settings", @@ -886,7 +946,10 @@ "canHaveChildren": false, "description": "Settings icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Gear" + } }, { "type": "User", @@ -895,7 +958,10 @@ "canHaveChildren": false, "description": "User icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "User" + } }, { "type": "Bell", @@ -904,7 +970,10 @@ "canHaveChildren": false, "description": "Bell icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Bell" + } }, { "type": "Mail", @@ -913,7 +982,10 @@ "canHaveChildren": false, "description": "Mail icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Envelope" + } }, { "type": "Calendar", @@ -922,7 +994,10 @@ "canHaveChildren": false, "description": "Calendar icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Calendar" + } }, { "type": "Clock", @@ -931,7 +1006,10 @@ "canHaveChildren": false, "description": "Clock icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Clock" + } }, { "type": "Star", @@ -940,7 +1018,10 @@ "canHaveChildren": false, "description": "Star icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Star" + } }, { "type": "Heart", @@ -949,7 +1030,10 @@ "canHaveChildren": false, "description": "Heart icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Heart" + } }, { "type": "Share", @@ -958,7 +1042,10 @@ "canHaveChildren": false, "description": "Share icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "ShareNetwork" + } }, { "type": "Link", @@ -967,7 +1054,10 @@ "canHaveChildren": false, "description": "Link icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "LinkSimple" + } }, { "type": "Copy", @@ -976,7 +1066,10 @@ "canHaveChildren": false, "description": "Copy icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Copy" + } }, { "type": "Save", @@ -985,7 +1078,10 @@ "canHaveChildren": false, "description": "Save icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "FloppyDisk" + } }, { "type": "RefreshCw", @@ -994,7 +1090,10 @@ "canHaveChildren": false, "description": "RefreshCw icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "ArrowClockwise" + } }, { "type": "AlertCircle", @@ -1003,7 +1102,10 @@ "canHaveChildren": false, "description": "AlertCircle icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "WarningCircle" + } }, { "type": "Info", @@ -1012,7 +1114,10 @@ "canHaveChildren": false, "description": "Info icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Info" + } }, { "type": "HelpCircle", @@ -1021,7 +1126,10 @@ "canHaveChildren": false, "description": "HelpCircle icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "Question" + } }, { "type": "Home", @@ -1030,7 +1138,10 @@ "canHaveChildren": false, "description": "Home icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "House" + } }, { "type": "Menu", @@ -1039,7 +1150,10 @@ "canHaveChildren": false, "description": "Menu icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "List" + } }, { "type": "MoreVertical", @@ -1048,7 +1162,10 @@ "canHaveChildren": false, "description": "MoreVertical icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "DotsThreeVertical" + } }, { "type": "MoreHorizontal", @@ -1057,7 +1174,10 @@ "canHaveChildren": false, "description": "MoreHorizontal icon", "status": "supported", - "source": "icons" + "source": "icons", + "load": { + "export": "DotsThree" + } }, { "type": "Breadcrumb", @@ -1275,7 +1395,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "GitHubBuildStatus" + "wrapperFor": "GitHubBuildStatus", + "load": { + "export": "GitHubBuildStatusWrapper" + } }, { "type": "InfoBox", @@ -1437,7 +1560,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "LazyBarChart" + "wrapperFor": "LazyBarChart", + "load": { + "export": "LazyBarChartWrapper" + } }, { "type": "LazyD3BarChart", @@ -1460,7 +1586,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "LazyD3BarChart" + "wrapperFor": "LazyD3BarChart", + "load": { + "export": "LazyD3BarChartWrapper" + } }, { "type": "LazyLineChart", @@ -1483,7 +1612,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "LazyLineChart" + "wrapperFor": "LazyLineChart", + "load": { + "export": "LazyLineChartWrapper" + } }, { "type": "List", @@ -1542,7 +1674,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "SeedDataManager" + "wrapperFor": "SeedDataManager", + "load": { + "export": "SeedDataManagerWrapper" + } }, { "type": "StatCard", @@ -1829,7 +1964,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "ComponentTree" + "wrapperFor": "ComponentTree", + "load": { + "export": "ComponentTreeWrapper" + } }, { "type": "ComponentTreeNode", @@ -2072,7 +2210,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "SaveIndicator" + "wrapperFor": "SaveIndicator", + "load": { + "export": "SaveIndicatorWrapper" + } }, { "type": "SchemaEditorCanvas", @@ -2236,7 +2377,10 @@ "status": "json-compatible", "source": "wrappers", "jsonCompatible": true, - "wrapperFor": "StorageSettings" + "wrapperFor": "StorageSettings", + "load": { + "export": "StorageSettingsWrapper" + } }, { "type": "Timestamp", diff --git a/schemas/json-components-registry-schema.json b/schemas/json-components-registry-schema.json index e2160a4..9b9d424 100644 --- a/schemas/json-components-registry-schema.json +++ b/schemas/json-components-registry-schema.json @@ -73,6 +73,16 @@ "wrapperFor": { "type": "string" }, + "load": { + "type": "object", + "properties": { + "export": { + "type": "string" + } + }, + "required": ["export"], + "additionalProperties": false + }, "deprecated": { "type": "object", "properties": { diff --git a/src/lib/json-ui/component-registry.ts b/src/lib/json-ui/component-registry.ts index 371c40d..d18b342 100644 --- a/src/lib/json-ui/component-registry.ts +++ b/src/lib/json-ui/component-registry.ts @@ -16,6 +16,9 @@ interface JsonRegistryEntry { wrapperRequired?: boolean wrapperComponent?: string wrapperFor?: string + load?: { + export?: string + } deprecated?: DeprecatedComponentInfo } @@ -30,26 +33,29 @@ export interface DeprecatedComponentInfo { const jsonRegistry = jsonComponentsRegistry as JsonComponentRegistry -const getRegistryEntryName = (entry: JsonRegistryEntry): string | undefined => - entry.export ?? entry.name ?? entry.type +const getRegistryEntryKey = (entry: JsonRegistryEntry): string | undefined => + entry.name ?? entry.type + +const getRegistryEntryExportName = (entry: JsonRegistryEntry): string | undefined => + entry.load?.export ?? entry.export ?? getRegistryEntryKey(entry) const jsonRegistryEntries = jsonRegistry.components ?? [] const registryEntryByType = new Map( jsonRegistryEntries .map((entry) => { - const entryName = getRegistryEntryName(entry) - return entryName ? [entryName, entry] : null + const entryKey = getRegistryEntryKey(entry) + return entryKey ? [entryKey, entry] : null }) .filter((entry): entry is [string, JsonRegistryEntry] => Boolean(entry)) ) const deprecatedComponentInfo = jsonRegistryEntries.reduce>( (acc, entry) => { - const entryName = getRegistryEntryName(entry) - if (!entryName) { + const entryKey = getRegistryEntryKey(entry) + if (!entryKey) { return acc } if (entry.status === 'deprecated' || entry.deprecated) { - acc[entryName] = entry.deprecated ?? {} + acc[entryKey] = entry.deprecated ?? {} } return acc }, @@ -110,29 +116,6 @@ const sourceAliases: Record> = { wrappers: {}, } -const iconAliases: Record = { - Search: 'MagnifyingGlass', - Filter: 'Funnel', - Edit: 'PencilSimple', - EyeOff: 'EyeClosed', - ChevronUp: 'CaretUp', - ChevronDown: 'CaretDown', - ChevronLeft: 'CaretLeft', - ChevronRight: 'CaretRight', - Settings: 'Gear', - Mail: 'Envelope', - Share: 'ShareNetwork', - Link: 'LinkSimple', - Save: 'FloppyDisk', - RefreshCw: 'ArrowClockwise', - AlertCircle: 'WarningCircle', - HelpCircle: 'Question', - Home: 'House', - Menu: 'List', - MoreVertical: 'DotsThreeVertical', - MoreHorizontal: 'DotsThree', -} - const explicitComponentAllowlist: Record> = { JSONUIShowcase, } @@ -145,36 +128,18 @@ const buildRegistryFromEntries = ( return jsonRegistryEntries .filter((entry) => entry.source === source) .reduce((registry, entry) => { - const entryName = getRegistryEntryName(entry) - if (!entryName) { + const entryKey = getRegistryEntryKey(entry) + const entryExportName = getRegistryEntryExportName(entry) + if (!entryKey || !entryExportName) { return registry } - const aliasName = aliases[entryName] + const aliasName = aliases[entryKey] const component = - componentMap[entryName] ?? + componentMap[entryExportName] ?? (aliasName ? componentMap[aliasName] : undefined) ?? - explicitComponentAllowlist[entryName] + explicitComponentAllowlist[entryKey] if (component) { - registry[entryName] = component - } - return registry - }, {}) -} - -const buildIconRegistry = (): UIComponentRegistry => { - return jsonRegistryEntries - .filter((entry) => entry.source === 'icons') - .reduce((registry, entry) => { - const entryName = getRegistryEntryName(entry) - if (!entryName) { - return registry - } - const aliasName = iconAliases[entryName] - const component = - iconComponentMap[entryName] ?? - (aliasName ? iconComponentMap[aliasName] : undefined) - if (component) { - registry[entryName] = component + registry[entryKey] = component } return registry }, {}) @@ -229,7 +194,10 @@ export const jsonWrapperComponents: UIComponentRegistry = buildRegistryFromEntri sourceAliases.wrappers ) -export const iconComponents: UIComponentRegistry = buildIconRegistry() +export const iconComponents: UIComponentRegistry = buildRegistryFromEntries( + 'icons', + iconComponentMap +) export const uiComponentRegistry: UIComponentRegistry = { ...primitiveComponents,