mirror of
https://github.com/johndoe6345789/low-code-react-app-b.git
synced 2026-04-24 13:44:54 +00:00
Merge pull request #118 from johndoe6345789/codex/rename-component-definitions.ts-to-json
Convert component definitions to JSON
This commit is contained in:
21
src/lib/component-definitions-utils.ts
Normal file
21
src/lib/component-definitions-utils.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ComponentType } from '@/types/json-ui'
|
||||
import componentDefinitionsData from '@/lib/component-definitions.json'
|
||||
|
||||
export interface ComponentDefinition {
|
||||
type: ComponentType
|
||||
label: string
|
||||
category: 'layout' | 'input' | 'display' | 'navigation' | 'feedback' | 'data' | 'custom'
|
||||
icon: string
|
||||
defaultProps?: Record<string, any>
|
||||
canHaveChildren?: boolean
|
||||
}
|
||||
|
||||
export const componentDefinitions = componentDefinitionsData as ComponentDefinition[]
|
||||
|
||||
export function getCategoryComponents(category: string): ComponentDefinition[] {
|
||||
return componentDefinitions.filter(component => component.category === category)
|
||||
}
|
||||
|
||||
export function getComponentDef(type: ComponentType): ComponentDefinition | undefined {
|
||||
return componentDefinitions.find(component => component.type === type)
|
||||
}
|
||||
Reference in New Issue
Block a user