Skip to content

Schema Components

Component

Base class for all components.

Namespace

php
Lartrix\Schema\Components\Component

Common Methods

MethodParametersDescription
make($text = null)stringCreate component instance
props(array $props)arraySet properties
children($children)array|stringSet child components
on($event, $handler)string, arrayBind event
slot($name, $content)string, arrayDefine slot
if($condition)stringv-if condition
show($condition)stringv-show condition
for($expression, $key = null)string, stringv-for loop
model($path)string|arrayv-model binding
data(array $data)arraySet reactive data
methods(array $methods)arraySet methods
onMounted($actions)arrayMount callback

Conversion Methods

MethodDescription
toArray()Convert to array
toJson()Convert to JSON
build()Build complete schema

NaiveUI Components

Button

Button component.

php
use Lartrix\Schema\Components\NaiveUI\Button;

Button::make('Text')
    ->type('primary')
    ->size('large')
    ->on('click', [...]);

Input

Input component.

php
use Lartrix\Schema\Components\NaiveUI\Input;

Input::make()
    ->props(['placeholder' => 'Hint'])
    ->model('form.name');

Select

Select component.

php
use Lartrix\Schema\Components\NaiveUI\Select;

Select::make()
    ->options([
        ['label' => 'Option 1', 'value' => 1],
    ])
    ->model('form.status');

SwitchC

Switch component (Switch is a PHP reserved word).

php
use Lartrix\Schema\Components\NaiveUI\SwitchC;

SwitchC::make()
    ->props(['checkedValue' => true])
    ->model('form.status');

Card

Card component.

php
use Lartrix\Schema\Components\NaiveUI\Card;

Card::make()
    ->title('Title')
    ->children([...]);

Form / FormItem

Form components.

php
use Lartrix\Schema\Components\NaiveUI\{Form, FormItem};

Form::make()
    ->model('formData')
    ->children([
        FormItem::make('Label', 'name')
            ->child(Input::make()),
    ]);

Modal dialog component.

php
use Lartrix\Schema\Components\NaiveUI\Modal;

Modal::make()
    ->show('visible')
    ->on('update:show', SetAction::make('visible', '{{ $event }}'))
    ->children([...]);

Drawer

Drawer component.

php
use Lartrix\Schema\Components\NaiveUI\Drawer;

Drawer::make()
    ->show('drawerVisible')
    ->props(['title' => 'Details'])
    ->children([...]);

Table

Table component.

php
use Lartrix\Schema\Components\NaiveUI\Table;

Table::make()
    ->props([
        'data' => '{{ list }}',
        'columns' => [...],
    ]);

Business Components

CrudPage

CRUD page component.

php
use Lartrix\Schema\Components\Business\CrudPage;

CrudPage::make('Title')
    ->apiPrefix('/api/users')
    ->columns([...])
    ->search([...])
    ->toolbarLeft([...]);

OptForm

Operation form component.

php
use Lartrix\Schema\Components\Business\OptForm;

OptForm::make('formData')
    ->fields([
        ['Label', 'name', Input::make()],
    ])
    ->buttons([...]);

MarkdownEditor

Markdown editor.

php
use Lartrix\Schema\Components\Business\MarkdownEditor;

MarkdownEditor::make()
    ->model('form.content');

RichEditor

Rich text editor.

php
use Lartrix\Schema\Components\Business\RichEditor;

RichEditor::make()
    ->model('form.content');

基于 MIT 许可发布