+
+
+
+ {selectedClasses.length} selected
+
+
+
{selectedClasses.map(cls => (
@@ -175,15 +183,46 @@ export function CssClassBuilder({ open, onClose, initialValue = '', onSave }: Cs
))}
-
+
{selectedClasses.join(' ')}
+ ) : (
+
+ No classes selected yet. Choose classes to preview and apply.
+
)}
-
-
-
+
+
+
+
+
Preview element
+
+ This sample updates as you add or remove classes.
+
+
+ Sample button
+
+
+
+
+
+ {filteredCategories.length === 0 && categories.length === 0 && (
+
+ No CSS categories available yet. Add some in the CSS Classes tab.
+
+ )}
+
+ {filteredCategories.length === 0 && categories.length > 0 && normalizedSearch && (
+
+ No classes match "{searchQuery}".
+
+ )}
+
+
+
+
{filteredCategories.map(category => (
{category.name}
@@ -191,7 +230,7 @@ export function CssClassBuilder({ open, onClose, initialValue = '', onSave }: Cs
))}
Custom
-
+
{filteredCategories.map(category => (
diff --git a/frontends/nextjs/src/lib/components/component-registry.ts b/frontends/nextjs/src/lib/components/component-registry.ts
index 0a82ea576..3da82e93b 100644
--- a/frontends/nextjs/src/lib/components/component-registry.ts
+++ b/frontends/nextjs/src/lib/components/component-registry.ts
@@ -1,63 +1,5 @@
-import { componentCatalog } from './component-catalog'
-import type { ComponentDefinition } from './builder-types'
+export type { ComponentTypeDefinition } from './component-registry/types'
-export interface ComponentTypeDefinition extends ComponentDefinition {
- renderingLogic?: {
- type: 'shadcn' | 'declarative' | 'custom'
- componentName?: string
- customRenderer?: string
- }
-}
-
-export class ComponentRegistry {
- private components: Map = new Map()
-
- constructor() {
- this.loadFromCatalog()
- }
-
- private loadFromCatalog(): void {
- componentCatalog.forEach(comp => {
- this.registerComponent(comp as ComponentTypeDefinition)
- })
- }
-
- registerComponent(component: ComponentTypeDefinition): void {
- this.components.set(component.type, component)
- }
-
- registerComponents(components: ComponentTypeDefinition[]): void {
- components.forEach(comp => this.registerComponent(comp))
- }
-
- getComponent(type: string): ComponentTypeDefinition | undefined {
- return this.components.get(type)
- }
-
- getAllComponents(): ComponentTypeDefinition[] {
- return Array.from(this.components.values())
- }
-
- getComponentsByCategory(category: string): ComponentTypeDefinition[] {
- return Array.from(this.components.values()).filter(
- comp => comp.category === category
- )
- }
-
- hasComponent(type: string): boolean {
- return this.components.has(type)
- }
-}
-
-let registryInstance: ComponentRegistry | null = null
-
-export function getComponentRegistry(): ComponentRegistry {
- if (!registryInstance) {
- registryInstance = new ComponentRegistry()
- }
- return registryInstance
-}
-
-export async function initializeComponentRegistry(): Promise {
- getComponentRegistry()
-}
+export { ComponentRegistry } from './component-registry/registry-class'
+export { getComponentRegistry } from './component-registry/get-component-registry'
+export { initializeComponentRegistry } from './component-registry/initialize-component-registry'
diff --git a/frontends/nextjs/src/lib/components/component-registry/get-component-registry.ts b/frontends/nextjs/src/lib/components/component-registry/get-component-registry.ts
new file mode 100644
index 000000000..2d25b9abc
--- /dev/null
+++ b/frontends/nextjs/src/lib/components/component-registry/get-component-registry.ts
@@ -0,0 +1,9 @@
+import { ComponentRegistry } from './registry-class'
+import { componentRegistryState } from './registry-singleton'
+
+export function getComponentRegistry(): ComponentRegistry {
+ if (!componentRegistryState.instance) {
+ componentRegistryState.instance = new ComponentRegistry()
+ }
+ return componentRegistryState.instance
+}
diff --git a/frontends/nextjs/src/lib/components/component-registry/initialize-component-registry.ts b/frontends/nextjs/src/lib/components/component-registry/initialize-component-registry.ts
new file mode 100644
index 000000000..b06ff76c1
--- /dev/null
+++ b/frontends/nextjs/src/lib/components/component-registry/initialize-component-registry.ts
@@ -0,0 +1,5 @@
+import { getComponentRegistry } from './get-component-registry'
+
+export async function initializeComponentRegistry(): Promise {
+ getComponentRegistry()
+}