first commit

This commit is contained in:
f4ilji
2024-09-19 16:06:49 +05:00
commit b686638a39
1664 changed files with 428174 additions and 0 deletions
@@ -0,0 +1,208 @@
<?php
namespace App\Filament\Components\Forms\ItemForm\CustomForm;
use App\Enums\CustomFormStatus;
use App\Enums\PostStatus;
use App\Filament\Components\Forms\ItemForm\CustomForm\components\rules\RuleLengthLimitComponent;
use App\Filament\Components\Forms\ItemForm\CustomForm\components\rules\RuleRequiredComponent;
use App\Filament\Components\Forms\ItemForm\CustomForm\components\rules\RuleUniqueComponent;
use App\Helpers\ByteConverter;
use App\Models\Category;
use App\Models\CustomForm;
use App\Models\Page;
use App\Models\Post;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class FormBuilderItem
{
public static function getItem()
{
return Builder::make('columns')
->schema([
Builder\Block::make('email')
->label('Почта')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
Section::make('Настройка')
->collapsed()
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
RuleUniqueComponent::getComponent(),
RuleLengthLimitComponent::getComponent(),
]),
]),
Builder\Block::make('phone')
->label('Телефон')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
RuleUniqueComponent::getComponent(),
RuleLengthLimitComponent::getComponent(),
]),
]),
Builder\Block::make('text')
->label('Короткий текст')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
RuleLengthLimitComponent::getComponent(),
]),
]),
Builder\Block::make('textarea')
->label('Длинный текст текст')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
RuleLengthLimitComponent::getComponent(),
]),
]),
Builder\Block::make('date')
->label('Дата')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
]),
]),
Builder\Block::make('url')
->label('Ссылка')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
RuleUniqueComponent::getComponent(),
RuleLengthLimitComponent::getComponent(),
]),
]),
Builder\Block::make('multiple_choice')
->label('Несколько вариантов')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(), Forms\Components\Repeater::make('columns')->schema([
TextInput::make('title_field')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
])->collapsed(),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
]),
]),
Builder\Block::make('single_choice')
->label('Один вариант')
->schema([
TextInput::make('title_field')
->label('Заголовок поля')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(), Forms\Components\Repeater::make('columns')->schema([
TextInput::make('title_field')
->live(onBlur: true)
->afterStateUpdated(function (string $operation, string $state, Forms\Set $set) {
$set('name_field', Str::slug($state) . Carbon::now()->timestamp );
}),
Forms\Components\Hidden::make('name_field')->required(),
Forms\Components\Textarea::make('description')->label('Описание поля (опционально)'),
])->collapsed(),
Section::make('Настройка')
->statePath('rules')
->schema([
RuleRequiredComponent::getComponent(),
]),
]),
])
->label('')
->addActionLabel('Добавить поле')
->collapsed();
}
}
@@ -0,0 +1,42 @@
<?php
namespace App\Filament\Components\Forms\ItemForm\CustomForm\components\rules;
use App\Enums\CustomFormStatus;
use App\Enums\PostStatus;
use App\Helpers\ByteConverter;
use App\Models\Category;
use App\Models\CustomForm;
use App\Models\Page;
use App\Models\Post;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class RuleLengthLimitComponent
{
public static function getComponent() : Section
{
return Section::make('Ограничить количество символов в ответе')
->schema([
Forms\Components\Grid::make(2)->schema([
Forms\Components\TextInput::make('min')->label('От')->integer(),
Forms\Components\TextInput::make('max')->label('До')->integer()
]),
Forms\Components\Toggle::make('show_length')->label('Показывать максимальное количество символов под колонкой'),
]);
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Filament\Components\Forms\ItemForm\CustomForm\components\rules;
use App\Enums\CustomFormStatus;
use App\Enums\PostStatus;
use App\Helpers\ByteConverter;
use App\Models\Category;
use App\Models\CustomForm;
use App\Models\Page;
use App\Models\Post;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class RuleRequiredComponent
{
public static function getComponent() : Toggle
{
return Toggle::make('required')->label('Обязательное поле');
}
}
@@ -0,0 +1,35 @@
<?php
namespace App\Filament\Components\Forms\ItemForm\CustomForm\components\rules;
use App\Enums\CustomFormStatus;
use App\Enums\PostStatus;
use App\Helpers\ByteConverter;
use App\Models\Category;
use App\Models\CustomForm;
use App\Models\Page;
use App\Models\Post;
use Filament\Forms;
use Filament\Forms\Components\Builder;
use Filament\Forms\Components\FileUpload;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\RichEditor;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Forms\Form;
use Illuminate\Support\Carbon;
use Illuminate\Support\Str;
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
use Mohamedsabil83\FilamentFormsTinyeditor\Components\TinyEditor;
class RuleUniqueComponent
{
public static function getComponent() : Toggle
{
return Toggle::make('unique')->label('Уникальное поле');
}
}