improve the page, sections, components
This commit is contained in:
183
lang/lang.go
183
lang/lang.go
@ -88,16 +88,20 @@ type ResponseSpec struct {
|
||||
Fields []string `parser:"('fields' '[' @Ident (',' @Ident)* ']')?"`
|
||||
}
|
||||
|
||||
// Page definitions for frontend with clean syntax
|
||||
// Enhanced Page definitions with layout containers and composition
|
||||
type Page struct {
|
||||
Name string `parser:"'page' @Ident"`
|
||||
Path string `parser:"'at' @String"`
|
||||
Layout string `parser:"'layout' @Ident"`
|
||||
Title *string `parser:"('title' @String)?"`
|
||||
Description *string `parser:"('desc' @String)?"`
|
||||
Auth bool `parser:"@'auth'?"`
|
||||
Meta []MetaTag `parser:"@@*"`
|
||||
Components []Component `parser:"@@*"`
|
||||
Name string `parser:"'page' @Ident"`
|
||||
Path string `parser:"'at' @String"`
|
||||
Layout string `parser:"'layout' @Ident"`
|
||||
Title *string `parser:"('title' @String)?"`
|
||||
Description *string `parser:"('desc' @String)?"`
|
||||
Auth bool `parser:"@'auth'?"`
|
||||
LayoutType *string `parser:"('layout' @String)?"`
|
||||
Meta []MetaTag `parser:"@@*"`
|
||||
MasterDetail *MasterDetail `parser:"@@?"`
|
||||
Containers []Container `parser:"@@*"`
|
||||
Components []Component `parser:"@@*"`
|
||||
Modals []Modal `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Meta tags for SEO
|
||||
@ -106,14 +110,153 @@ type MetaTag struct {
|
||||
Content string `parser:"@String"`
|
||||
}
|
||||
|
||||
// Component definitions with endpoint references
|
||||
type Component struct {
|
||||
Type string `parser:"'component' @Ident"`
|
||||
Entity *string `parser:"('for' @Ident)?"`
|
||||
Config []ComponentAttr `parser:"@@*"`
|
||||
// Container types for layout organization
|
||||
type Container struct {
|
||||
Type string `parser:"'container' @Ident"`
|
||||
Class *string `parser:"('class' @String)?"`
|
||||
Sections []Section `parser:"@@*"`
|
||||
Tabs []Tab `parser:"@@*"`
|
||||
Components []Component `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Component attributes and configurations
|
||||
// Sections within containers
|
||||
type Section struct {
|
||||
Name string `parser:"'section' @Ident"`
|
||||
Class *string `parser:"('class' @String)?"`
|
||||
Components []Component `parser:"@@*"`
|
||||
Panels []Panel `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Tab definitions for tabbed interfaces
|
||||
type Tab struct {
|
||||
Name string `parser:"'tab' @Ident"`
|
||||
Label string `parser:"'label' @String"`
|
||||
Active bool `parser:"@'active'?"`
|
||||
Components []Component `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Panel definitions for slide-out or overlay interfaces
|
||||
type Panel struct {
|
||||
Name string `parser:"'panel' @Ident"`
|
||||
Entity *string `parser:"('for' @Ident)?"`
|
||||
Trigger string `parser:"'trigger' @String"`
|
||||
Position *string `parser:"('position' @String)?"`
|
||||
Components []Component `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Modal definitions
|
||||
type Modal struct {
|
||||
Name string `parser:"'modal' @Ident"`
|
||||
Trigger string `parser:"'trigger' @String"`
|
||||
Components []Component `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Master-detail layout components - simplified parsing
|
||||
type MasterDetail struct {
|
||||
Master *MasterSection `parser:"'master' @@"`
|
||||
Detail *DetailSection `parser:"'detail' @@"`
|
||||
}
|
||||
|
||||
type MasterSection struct {
|
||||
Name string `parser:"@Ident"`
|
||||
Components []Component `parser:"@@*"`
|
||||
}
|
||||
|
||||
type DetailSection struct {
|
||||
Name string `parser:"@Ident"`
|
||||
Trigger *string `parser:"('trigger' @String)?"`
|
||||
Components []Component `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Enhanced Component definitions with detailed field configurations
|
||||
type Component struct {
|
||||
Type string `parser:"'component' @Ident"`
|
||||
Entity *string `parser:"('for' @Ident)?"`
|
||||
Elements []ComponentElement `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Union type for component elements to allow flexible ordering
|
||||
type ComponentElement struct {
|
||||
Config *ComponentAttr `parser:"@@"`
|
||||
Field *ComponentField `parser:"| @@"`
|
||||
Condition *WhenCondition `parser:"| @@"`
|
||||
Section *ComponentSection `parser:"| @@"`
|
||||
Action *ComponentButtonAttr `parser:"| @@"`
|
||||
}
|
||||
|
||||
// Enhanced component field with detailed configuration using flexible attributes
|
||||
type ComponentField struct {
|
||||
Name string `parser:"'field' @Ident"`
|
||||
Type string `parser:"'type' @Ident"`
|
||||
Attributes []ComponentFieldAttribute `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Flexible field attribute system
|
||||
type ComponentFieldAttribute struct {
|
||||
Label *string `parser:"('label' @String)"`
|
||||
Placeholder *string `parser:"| ('placeholder' @String)"`
|
||||
Required bool `parser:"| @'required'"`
|
||||
Sortable bool `parser:"| @'sortable'"`
|
||||
Searchable bool `parser:"| @'searchable'"`
|
||||
Thumbnail bool `parser:"| @'thumbnail'"`
|
||||
Default *string `parser:"| ('default' @String)"`
|
||||
Options []string `parser:"| ('options' '[' @String (',' @String)* ']')"`
|
||||
Accept *string `parser:"| ('accept' @String)"`
|
||||
Rows *int `parser:"| ('rows' @Int)"`
|
||||
Format *string `parser:"| ('format' @String)"`
|
||||
Size *string `parser:"| ('size' @String)"`
|
||||
Display *string `parser:"| ('display' @String)"`
|
||||
Value *string `parser:"| ('value' @String)"`
|
||||
Source *string `parser:"| ('source' @String)"`
|
||||
Relates *FieldRelation `parser:"| @@"`
|
||||
Validation *ComponentValidation `parser:"| @@"`
|
||||
}
|
||||
|
||||
// Field relationship for autocomplete and select fields
|
||||
type FieldRelation struct {
|
||||
Type string `parser:"'relates' 'to' @Ident"`
|
||||
}
|
||||
|
||||
// Component validation
|
||||
type ComponentValidation struct {
|
||||
Type string `parser:"'validate' @Ident"`
|
||||
Value *string `parser:"@String?"`
|
||||
}
|
||||
|
||||
// Conditional rendering
|
||||
type WhenCondition struct {
|
||||
Field string `parser:"'when' @Ident"`
|
||||
Operator string `parser:"@('equals' | 'not_equals' | 'contains')"`
|
||||
Value string `parser:"@String"`
|
||||
Fields []ComponentField `parser:"@@*"`
|
||||
Sections []ComponentSection `parser:"@@*"`
|
||||
Buttons []ComponentButtonAttr `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Component sections for grouping
|
||||
type ComponentSection struct {
|
||||
Name string `parser:"'section' @Ident"`
|
||||
Class *string `parser:"('class' @String)?"`
|
||||
Fields []ComponentField `parser:"@@*"`
|
||||
Buttons []ComponentButtonAttr `parser:"@@*"`
|
||||
Actions []ComponentButtonAttr `parser:"@@*"`
|
||||
}
|
||||
|
||||
// Enhanced component buttons/actions with detailed configuration
|
||||
type ComponentButtonAttr struct {
|
||||
Name string `parser:"'button' @Ident"`
|
||||
Label string `parser:"'label' @String"`
|
||||
Style *string `parser:"('style' @String)?"`
|
||||
Icon *string `parser:"('icon' @String)?"`
|
||||
Loading *string `parser:"('loading' @String)?"`
|
||||
Disabled *string `parser:"('disabled' 'when' @Ident)?"`
|
||||
Confirm *string `parser:"('confirm' @String)?"`
|
||||
Target *string `parser:"('target' @Ident)?"`
|
||||
Position *string `parser:"('position' @String)?"`
|
||||
Via *string `parser:"('via' @String)?"`
|
||||
}
|
||||
|
||||
// Component attributes and configurations (keeping existing for backward compatibility)
|
||||
type ComponentAttr struct {
|
||||
Fields *ComponentFields `parser:"@@"`
|
||||
Actions *ComponentActions `parser:"| @@"`
|
||||
@ -124,19 +267,25 @@ type ComponentAttr struct {
|
||||
Validation bool `parser:"| @'validate'"`
|
||||
}
|
||||
|
||||
// Component field specification
|
||||
// Component field specification (simple version for backward compatibility)
|
||||
type ComponentFields struct {
|
||||
Fields []string `parser:"'fields' '[' @Ident (',' @Ident)* ']'"`
|
||||
}
|
||||
|
||||
// Component actions (can reference endpoints)
|
||||
// Enhanced component actions
|
||||
type ComponentActions struct {
|
||||
Actions []ComponentAction `parser:"'actions' '[' @@ (',' @@)* ']'"`
|
||||
}
|
||||
|
||||
type ComponentAction struct {
|
||||
Name string `parser:"@Ident"`
|
||||
Label *string `parser:"('label' @String)?"`
|
||||
Icon *string `parser:"('icon' @String)?"`
|
||||
Style *string `parser:"('style' @String)?"`
|
||||
Endpoint *string `parser:"('via' @String)?"`
|
||||
Target *string `parser:"('target' @Ident)?"`
|
||||
Position *string `parser:"('position' @String)?"`
|
||||
Confirm *string `parser:"('confirm' @String)?"`
|
||||
}
|
||||
|
||||
// Data source configuration (can reference endpoints)
|
||||
|
Reference in New Issue
Block a user