saade / filament-autograph

用于管理签名的丝束包。

v3.1.0 2024-03-12 16:15 UTC

README

Latest Version on Packagist Total Downloads

Banner

安装

您可以通过 composer 安装此包

composer require saade/filament-autograph

使用

use Saade\FilamentAutograph\Forms\Components\SignaturePad;

SignaturePad::make('signature')

配置

SignaturePad 选项。

参考: https://github.com/szimek/signature_pad#options

use Saade\FilamentAutograph\Forms\Components\SignaturePad;

SignaturePad::make('signature')
    ->label(__('Sign here'))
    ->dotSize(2.0)
    ->lineMinWidth(0.5)
    ->lineMaxWidth(2.5)
    ->throttle(16)
    ->minDistance(5)
    ->velocityFilterWeight(0.7)

自定义画板背景和笔色。

use Saade\FilamentAutograph\Forms\Components\SignaturePad;

SignaturePad::make('signature')
    ->backgroundColor('rgba(0,0,0,0)')  // Background color on light mode
    ->backgroundColorOnDark('#f0a')     // Background color on dark mode (defaults to backgroundColor)
    ->exportBackgroundColor('#f00')     // Background color on export (defaults to backgroundColor)
    ->penColor('#000')                  // Pen color on light mode
    ->penColorOnDark('#fff')            // Pen color on dark mode (defaults to penColor)
    ->exportPenColor('#0f0')            // Pen color on export (defaults to penColor)

允许下载签名。

use Saade\FilamentAutograph\Forms\Components\SignaturePad;
use Saade\FilamentAutograph\Forms\Components\Enums\DownloadableFormat;

SignaturePad::make('signature')
    ->filename('autograph')             // Filename of the downloaded file (defaults to 'signature')
    ->downloadable()                    // Allow download of the signature (defaults to false)
    ->downloadableFormats([             // Available formats for download (defaults to all)
        DownloadableFormat::PNG,
        DownloadableFormat::JPG,
        DownloadableFormat::SVG,
    ])
    ->downloadActionDropdownPlacement('center-end')     // Dropdown placement of the download action (defaults to 'bottom-end')

禁用清除、下载、撤销和完成操作。

use Saade\FilamentAutograph\Forms\Components\SignaturePad;

SignaturePad::make('signature')
    ->clearable(false)
    ->downloadable(false)
    ->undoable(false)
    ->confirmable(false)

需要确认(完成按钮)。

SignaturePad::make('signature')
    ->confirmable()                 // Requires user to click on 'Done' (defaults to false)

自定义操作

use Saade\FilamentAutograph\Forms\Components\SignaturePad;
use Filament\Forms\Actions\Action;

SignaturePad::make('signature')
    ->clearAction(fn (Action $action) => $action->button())
    ->downloadAction(fn (Action $action) => $action->color('primary'))
    ->undoAction(fn (Action $action) => $action->icon('heroicon-o-ctrl-z'))
    ->doneAction(fn (Action $action) => $action->iconButton()->icon('heroicon-o-thumbs-up'))

变更日志

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

贡献

请参阅 CONTRIBUTING 了解详情。

安全漏洞

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

致谢

许可证

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

Sponsor Saade