anish/maskable-entry

A powerful Filament PHP infolist component that enables seamless maskable entry. Features include maskable entry, preview functionality, and easy integration with Laravel. Perfect for maskable values in infolists.

Fund package maintenance!
anishregminaglibang/

Installs: 21

Dependents: 0

Suggesters: 0

Security: 0

Stars: 8

Watchers: 0

Forks: 4

Open Issues: 1

pkg:composer/anish/maskable-entry

v1.0.2 2025-12-10 09:49 UTC

README

maskable-entry

A reusable maskable entry component for Filament Infolists.

A powerful Filament PHP infolist component that enables seamless maskable entry. Ideal for hiding and toggling sensitive values such as passwords, social security numbers, credit card numbers, and API keys.

Features

  • πŸ”’ Maskable Display β€” Hide sensitive data with custom mask patterns
  • πŸ‘οΈ Toggle Visibility β€” One click to reveal or hide the actual value
  • 🎨 Native Filament v4 Integration β€” Works like any infolist entry
  • βš™οΈ Fully Configurable β€” Custom patterns, masking characters, closures
  • πŸ“± Responsive β€” Works across all device sizes

Requirements

  • PHP 8.1+
  • Laravel 10+
  • Filament 4.x

Installation

composer require anish/maskable-entry

The package auto-discovers its service providerβ€”no manual setup required.

Basic Usage

use Anish\MaskableEntry\Components\MaskableEntry;
use Illuminate\Support\Facades\Auth;
use Filament\Schemas\Schema;

public static function configure(Schema $schema): Schema
{
    return $schema->components([
        MaskableEntry::make('social_security_number')
            ->maskValue('XXX-XX-XXXX')
            ->actualValue(fn ($record) => $record->social_security_number)
            ->toggleable(Auth::user()->can('view_social_security_number'))
            ->label('Social Security Number'),
    ]);
}

Note:

If you are using a custom theme add the plugin's views to your theme css file or your app's css file.

@source '../../../../vendor/anish/maskable-entry/resources/views/**/*.blade.php

Advanced Usage

Custom Mask Pattern

MaskableEntry::make('credit_card')
    ->maskValue('XXXX-XXXX-XXXX-XXXX')
    ->actualValue(fn ($record) => $record->credit_card_number)
    ->label('Credit Card Number');

Using a Closure for Actual Value

MaskableEntry::make('password')
    ->maskValue('XXXXXXXX')
    ->actualValue(fn (User $record) => $record->password)
    ->label('Password');

Custom Masking Character

MaskableEntry::make('api_key')
    ->maskValue('****-****-****-****')
    ->actualValue(fn ($record) => $record->api_key)
    ->maskingChar('*')
    ->label('API Key');

Available Methods

maskValue(string $value)

The pattern shown in masked mode. Use X (or your custom char) to represent masked digits.

->maskValue('XXX-XX-XXXX')

actualValue(string|Closure|null $value)

Defines the value revealed on toggle.

->actualValue(fn ($record) => $record->social_security_number)
// or
->actualValue('123-45-6789')

maskingChar(string $char)

Changes the masking character. Default: X.

->maskingChar('*')

Supports All Standard TextEntry Methods

MaskableEntry::make('field')
    ->maskValue('XXX-XX-XXXX')
    ->actualValue(fn ($record) => $record->value)
    ->label('Custom Label')
    ->placeholder('N/A')
    ->copyable()
    ->icon('heroicon-o-shield-check');

How It Works

  1. Masked State β€” Displays the mask pattern (XXX-XX-XXXX)
  2. Toggle Button β€” Eye icon switches visibility
  3. Revealed State β€” Shows the actual value formatted
  4. Formatting β€” Automatically aligns characters to mask structure

Examples

SSN Number

MaskableEntry::make('ssn')
    ->maskValue('XXX-XX-XXXX')
    ->actualValue(fn ($record) => $record->ssn)
    ->label('Social Security Number');

Credit Card Number

MaskableEntry::make('credit_card')
    ->maskValue('XXXX-XXXX-XXXX-XXXX')
    ->actualValue(fn ($record) => $record->credit_card)
    ->label('Credit Card');

Phone Number

MaskableEntry::make('phone')
    ->maskValue('(XXX) XXX-XXXX')
    ->actualValue(fn ($record) => $record->phone)
    ->label('Phone Number');

Password

MaskableEntry::make('password')
    ->maskValue('XXXXXXXX')
    ->actualValue(fn ($record) => $record->password)
    ->label('Password');

Testing

composer test

Code Style

This package uses Laravel Pint:

composer format

Contributing

Contributions are welcome!

Development Setup

  1. Clone the repo
  2. composer install
  3. Create a new branch
  4. Write your feature
  5. Run tests & Pint
  6. Submit PR

Security

If you find a security issue, please email: anishregminaglibang@gmail.com

Changelog

See CHANGELOG.

Credits

License

MIT