Skip to content

Schema Language ​

Syntax and properties that schepta understands β€” the "vocabulary" for defining dynamic interfaces.

Schema Language

Schema Language defines how to write JSON that schepta can interpret:

πŸ”§ Essential Properties: ​

PropertyFunctionValueResult
x-componentDefines which component to use"InputText"Specific React/Vue component
x-component-propsProps for the component{ placeholder: "Email" }Props passed directly
x-uiLayout and visual{ order: 1 }Ordering and positioning
x-rulesValidation and rules{ required: true }Automatic validation
nameUnique identifier"email"Identified field

πŸ“Š Basic Syntax: ​

Form Field:

json
{
  "name": "email",
  "x-component": "InputText",
  "x-component-props": {
    "placeholder": "Enter your email"
  },
  "x-rules": {
    "required": true,
    "pattern": "email"
  }
}

Menu Item:

json
{
  "type": "object",
  "x-component": "MenuLink",
  "x-component-props": {
    "label": "Dashboard",
    "href": "/dashboard",
    "icon": "dashboard"
  },
  "active": "\{\{ $segment.role === 'admin' \}\}"
}

πŸ’‘ Result: Structured JSON β†’ Working React/Vue component. Simple and powerful syntax!


πŸš€ Core Properties ​

Fundamental properties that every schema should know:

🎯 Component Definition: ​

PropertyRequiredTypeDescriptionExample
x-componentβœ… YesstringComponent name"InputText", "MenuLink"
x-component-props❌ NoobjectComponent props{ variant: "outlined" }
type❌ ContextstringSchema type"string", "object"
name❌ FormsstringField identifier"email", "password"

🎨 Visual & Layout: ​

PropertyRequiredTypeDescriptionExample
x-ui❌ NoobjectUI configuration{ order: 1, grid: { xs: 12 } }
title❌ NostringDisplay label"Email Address"
description❌ NostringHelp text"Enter your work email"
placeholder❌ NostringInput placeholder"user@company.com"

⚑ Behavior & Logic: ​

PropertyRequiredTypeDescriptionExample
x-rules❌ NoobjectValidation rules{ required: true, minLength: 8 }
x-reactions❌ NoobjectDynamic behavior{ visible: "\{\{ $form.type === 'admin' \}\}" }
active❌ Menusboolean/stringActive statetrue or "\{\{ $segment.role === 'admin' \}\}"
visible❌ Noboolean/stringVisibility control"\{\{ $form.plan !== 'basic' \}\}"

πŸ“Š Schema Types ​

Different schema types for different use cases:

πŸ“ Form Schemas: ​

Field Schema Structure:

json
{
  "name": "fieldName",
  "x-component": "ComponentName",
  "x-component-props": {
    "prop1": "value1",
    "prop2": "value2"
  },
  "x-rules": {
    "required": true,
    "pattern": "regex",
    "minLength": 5
  },
  "x-ui": {
    "order": 1,
    "grid": { "xs": 12, "md": 6 }
  }
}

Form Container Schema:

json
{
  "type": "object",
  "x-component": "form-container",
  "properties": {
    "fieldKey1": { /* field schema */ },
    "fieldKey2": { /* field schema */ }
  }
}

βš™οΈ Advanced Properties ​

Advanced properties for specific cases:

πŸ”§ Component Extensions: ​

PropertyPurposeUsageExample
x-decoratorWrapper componentField decoration"FormItem"
x-decorator-propsDecorator propsDecorator configuration{ label: "Field Label" }
x-contentStatic contentText/HTML content"Submit Form"
x-dataStatic dataPre-filled data{ options: ["A", "B"] }

🎯 Conditional Logic: ​

PropertyTypePurposeExample
x-visibleboolean/stringShow/hide component"\{\{ $form.type === 'premium' \}\}"
x-disabledboolean/stringEnable/disable"\{\{ $form.readonly \}\}"
x-patternobjectDisplay patterns{ loading: "\{\{ $form.isLoading \}\}" }
x-validatorstring/functionCustom validation"validateCPF"

πŸ“± Responsive & Layout: ​

PropertyConfigurationPurposeExample
x-ui.gridGrid systemResponsive layout{ xs: 12, md: 6, lg: 4 }
x-ui.ordernumberDisplay order1, 2, 3
x-ui.spannumberColumn span2 (spans 2 columns)
x-ui.offsetnumberColumn offset1 (offset by 1 column)

πŸ” Expression Language ​

Syntax for dynamic expressions within schemas:

πŸ“Š Expression Types: ​

Expression TypeSyntaxContextExample
Form State\{\{ $form.fieldName \}\}Form values"\{\{ $form.email \}\}"
Segment Context\{\{ $segment.property \}\}User context"\{\{ $segment.role \}\}"
Association Target\{\{ $target.property \}\}Linked configs"\{\{ $target.locale.title \}\}"
External Context\{\{ $context.property \}\}External data"\{\{ $context.user.name \}\}"

⚑ Operators Available: ​

OperatorUsageExampleResult
===, !==Equality"\{\{ $segment.role === 'admin' \}\}"boolean
&&, ||Logical"\{\{ $form.type === 'user' && $segment.plan === 'premium' \}\}"boolean
>, <, >=, <=Comparison"\{\{ $form.age >= 18 \}\}"boolean
contains()Array/string contains"\{\{ contains($segment.roles, 'admin') \}\}"boolean
startsWith()String starts"\{\{ startsWith($form.email, 'admin') \}\}"boolean

Schema Language is the "syntax" that connects all concepts: