pepperfm/filament-json

处理 JSON 字段的 Filament 插件

1.1.6 2024-07-17 14:49 UTC

This package is auto-updated.

Last update: 2024-09-17 15:08:52 UTC


README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

安装

您可以通过 composer 安装此包

composer require pepperfm/filament-json

您可以使用以下命令发布配置文件

php artisan vendor:publish --tag="filament-json-config"

可选,您可以使用以下命令发布视图

php artisan vendor:publish --tag="filament-json-views"

用法

use PepperFM\FilamentJson\Columns\JsonColumn;

JsonColumn::make('properties');

JsonColumn::make('properties')
    ->asDrawer();

JsonColumn::make('properties')
    ->asModal();

自定义按钮和模态属性

use PepperFM\FilamentJson\Columns\JsonColumn;

$buttonConfig = [
    'color' => 'warning',
    'size' => 'xs',
];
$modalConfig = literal(
    icon: 'heroicon-m-sparkles',
    alignment: 'start',
    width: 'xl',
    closedButton: false,
);

JsonColumn::make('properties')
    ->asModal()
    ->button($buttonConfig)
    ->modal($modalConfig);

代码 button()modal() 方法接受类型为 array|Arrayable|\stdClass,并实现了 Filament 文档中 Blade 组件的基本属性:核心概念 - Blade 组件

以下是实现组件配置的 DTO 类

class ButtonConfigDto
{
    public string $color = 'primary';

    public string $icon = 'heroicon-o-swatch';

    public ?string $label = null;

    public ?string $tooltip = null;

    public string $size = 'md';

    public ?string $href = null;

    public ?string $tag = null;
}

class ModalConfigDto
{
    public ?string $id = null;

    public string $icon = 'heroicon-o-swatch';

    public string $iconColor = 'primary';

    public string $alignment = 'start';

    public string $width = 'xl';

    public bool $closeByClickingAway = true;

    public bool $closedByEscaping = true;

    public bool $closedButton = true;

    public bool $autofocus = true;
}

测试

composer test

变更日志

请参阅 CHANGELOG 了解最近更改的详细信息。

贡献

请参阅 CONTRIBUTING 了解详细信息。

安全漏洞

请审查 我们的安全策略 了解如何报告安全漏洞。

鸣谢

许可证

MIT 许可证 (MIT)。请参阅 许可证文件 了解更多信息。