digital-creative/expandable-table-row

Provides an easy way to append extra data to each row of your resource tables.

Fund package maintenance!
milewski

Installs: 11 372

Dependents: 0

Suggesters: 0

Security: 0

Stars: 16

Watchers: 3

Forks: 1

Open Issues: 2

Language:Vue

v0.2.0 2023-10-25 14:59 UTC

This package is auto-updated.

Last update: 2024-11-28 11:03:57 UTC


README

Latest Version on Packagist Total Downloads License

Provides an easy way to append extra data to each row of your resource tables.

Installation

You can install the package via composer:

composer require digital-creative/expandable-table-row

Basic Usage

To use the new functionality, all you need to do is add the ->expandableRowData() method to your field definition and return any class that extends Nova Field or an array of fields.

class UserResource extends Resource
{
    public function fields(NovaRequest $request): array
    {
        return [
            //...
            Text::make('First Name')->expandableRowData(function () {
                return [
                    Line::make(null)->displayUsing(fn () => 'Name')->asSubTitle(),
                    Text::make('Full Name', fn (User $user) => sprintf('%s %s',$user->first_name, $user->last_name))->copyable(),
                    Text::make('Email')->copyable(),
                ];
            }),
    
            Text::make('Last Name')->expandableRowData(function () {
                return [
                    Line::make(null)->displayUsing(fn () => 'Address')->asSubTitle(),
                    Text::make('Country'),
                    Text::make('Address', fn (User $user) => sprintf(
                        '%s, %s, %s - %s', $user->city, $user->state, $user->address, $user->zipcode
                    ))->copyable(),
                ];
            }),
            //...          
        ];
    }
}

Settings

You can configure several options by using ->expandableRowOptions(). Below, you'll find an explanation of each.

public function fields(NovaRequest $request): array
{
    return [
        Text::make('...')->expandableRowOptions([
            'span' => 2, // This makes the metadata take X much more columns.
            'expanded_by_default' => true, // This makes the table row start expanded by default.
            'preallocate_column_width' => true, // This will avoid the table column shifting when expanding / collapsing.
        ]),
    ];
}

⭐️ Show Your Support

Please give a ⭐️ if this project helped you!

Other Packages You Might Like

License

The MIT License (MIT). Please see License File for more information.