yepsua / filament-rating-field
用于 Filament 表单的评分字段
v0.5.0
2024-09-05 14:01 UTC
Requires
- php: ^8.0
- filament/forms: ^3.0
- filament/tables: ^3.0
- illuminate/contracts: ^8.0|^9.0|^10.0|^11.0
- spatie/laravel-package-tools: ^1.9.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- nunomaduro/collision: ^6.0
- nunomaduro/larastan: ^2.0.1
- orchestra/testbench: ^7.0
- pestphp/pest: ^1.21
- pestphp/pest-plugin-laravel: ^1.1
- phpstan/extension-installer: ^1.1
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- spatie/laravel-ray: ^1.26
This package is auto-updated.
Last update: 2024-09-05 14:02:07 UTC
README

安装
您可以通过 composer 安装此包
composer require yepsua/filament-rating-field
可选,您可以使用以下命令发布视图
php artisan vendor:publish --tag="filament-rating-field-views"
用法
表单字段
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ... ]; } ...

默认情况下,范围值从 1 到 5,显示的图标为 heroicon-o-star
评分字段提供了一些选项来自定义其行为。以下是一些常用选项:
禁用
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->disabled() ... ]; } ...

最小和最大值
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->min(5) ->max(10) ... ]; } ...

自定义图标和颜色
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->icons('heroicon-o-moon', 'heroicon-s-sun') ->color('orange') ... ]; } ...

自定义大小
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->size(10) ... ]; } ...

无鼠标效果
禁用鼠标悬停和鼠标离开动画。
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->effects(false) ... ]; } ...
可清除
允许用户清除评分选择。
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->clearable() ->clearIconColor('red') ->clearIconTooltip('Clear') ... ]; } ...

光标
光标的值基于 Tailwind 光标。前缀 cursor-
在值中不是必需的。
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->cursor('default') ->clearIconTooltip('none') ... ]; } ...
工具提示
use Yepsua\Filament\Forms\Components\Rating ... protected function getFormSchema(): array { return [ ... Rating::make('rating') ->options([ 'Acceptable', 'Good', 'Very Good', 'Excellent', ]) ... ]; } ...

字段选项。
- ->颜色(): 设置评分字段的图标颜色。
- ->禁用颜色(): 设置字段禁用时的图标颜色。
- ->清除图标颜色(): 设置清除图标的颜色。
- ->图标(): 设置默认项的图标。
- ->选中图标(): 设置选中项的实心图标。
- ->清除图标(): 设置清除动作的图标。
- ->最小(): 设置评分字段的最小值。默认:1
- ->最大(): 设置评分字段的最大值。默认:5
- ->宽度(): 设置字段中每个项的宽度值:默认:6
- ->高度(): 设置字段中每个项的高度值:默认:6
- ->大小(): 设置宽度和高度属性相同的值。
- ->效果(): 启用/禁用鼠标悬停和鼠标离开效果。默认:true (启用)
- ->可清除(): 在评分图标末尾添加一个额外的图标。默认:false
- ->光标(): 设置默认光标
- ->禁用光标(): 设置字段禁用时显示的光标
- ->清除图标工具提示(): 设置清除图标的工具提示。
您可以在类 App\Forms\Components\Rating
中查看上述选项和其他选项的默认值。
表格列
use Yepsua\Filament\Tables\Components\RatingColumn; // ... protected function getTableColumns(): array { return [ // .. RatingColumn::make('rating'), // .. ]; } ...
评分列选项。
RatingColumn::make('rating')->颜色()
设置评分字段的图标颜色。RatingColumn::make('rating')->图标()
设置默认项的图标。RatingColumn::make('rating')->选中图标()
设置选中项的实心图标。RatingColumn::make('rating')->图标()
设置默认项和选中项的图标。RatingColumn::make('rating')->最小值()
设置评分字段的最小值。默认:1RatingColumn::make('rating')->最大值()
设置评分字段的最大值。默认:5RatingColumn::make('rating')->宽度()
设置字段中每个项的宽度值:默认:6RatingColumn::make('rating')->高度()
设置字段中每个项的高度值:默认:6RatingColumn::make('rating')->大小()
设置宽度和高度属性相同的值。RatingColumn::make('rating')->选项()
设置工具提示
测试
composer test
变更日志
请参阅 CHANGELOG 了解最近更改的详细信息。
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全漏洞
请查阅我们的安全策略,了解如何报告安全漏洞。
致谢
许可证
MIT许可证(MIT)。更多信息请参阅许可证文件。