From 3688fb4918b02ce83aa1dcd328f8d2b5c0d6a9bd Mon Sep 17 00:00:00 2001 From: luanfreitasdev Date: Wed, 18 Sep 2024 16:14:33 -0300 Subject: [PATCH] Adjust PowerGrid facade --- .../upgrade-guide.md | 4 +- .../component-configuration.md | 37 ++++++++++--------- docs/table-features/exporting-data.md | 20 ++++++---- docs/table-features/pagination.md | 26 ++++++------- 4 files changed, 45 insertions(+), 42 deletions(-) diff --git a/docs/release-notes-and-upgrade/upgrade-guide.md b/docs/release-notes-and-upgrade/upgrade-guide.md index 99b35c7..4cc8250 100644 --- a/docs/release-notes-and-upgrade/upgrade-guide.md +++ b/docs/release-notes-and-upgrade/upgrade-guide.md @@ -22,9 +22,7 @@ use PowerComponents\LivewirePowerGrid\Facades\PowerGrid;// [!code ++] ```js import './../../vendor/power-components/livewire-powergrid/dist/powergrid.css' // [!code --] -import './../../vendor/power-components/livewire-powergrid/dist/bootstrap5.css' // [!code ++] -// or -import './../../vendor/power-components/livewire-powergrid/dist/tailwind.css' // [!code ++] +import './../../vendor/power-components/livewire-powergrid/dist/tailwind.css' // [!code ++] // bootstrap5.css ``` diff --git a/docs/table-component/component-configuration.md b/docs/table-component/component-configuration.md index 674f2f4..63301ed 100644 --- a/docs/table-component/component-configuration.md +++ b/docs/table-component/component-configuration.md @@ -250,14 +250,14 @@ Example: // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Responsive;// [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Responsive::make()// [!code ++:2] + PowerGrid::responsive()// [!code ++:2] ->fixedColumns('id', 'name', Responsive::ACTIONS_COLUMN_NAME), ]; } @@ -300,14 +300,14 @@ Example: // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Detail; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Detail::make()// [!code ++:4] + PowerGrid::detail()// [!code ++:4] ->view('components.detail') ->showCollapseIcon() ->params(['name' => 'Luan', 'custom_data' => 'foobar']), @@ -330,14 +330,14 @@ By default, PowerGrid will keep the open state of other details when you toggle // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Detail; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Detail::make()// [!code ++:5] + PowerGrid::detail()// [!code ++:5] ->view('components.detail') ->params(['name' => 'Luan', 'custom_parameter' => 'foobar']) ->showCollapseIcon() @@ -365,14 +365,14 @@ In the next example, only 25 lines will be loaded initially. Additional items wi // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Lazy;// [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Lazy::make()// [!code ++:2] + PowerGrid::lazy()// [!code ++:2] ->rowsPerChildren(25), ]; } @@ -399,7 +399,7 @@ When calling `toggleDetail` on the child component, `toggleDetailFromChild` will // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Lazy;// [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] use Livewire\Attributes\On;// [!code ++] class DishTable extends PowerGridComponent @@ -407,7 +407,7 @@ class DishTable extends PowerGridComponent public function setUp(): array { return [ - Lazy::make()// [!code ++:3] + PowerGrid::lazy()// [!code ++:3] ->rowsPerChildren(25) ->dispatchAfterToggleDetail('toggleDetailFromChild'), ]; @@ -491,15 +491,16 @@ The next example demonstrates how to use Cache in your Component, prefixing the // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Cache; +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { - Cache::make()// [!code ++:3] - ->forever() - ->prefix(auth()->id . '_'), //result: 1_powergrid-dish-DishTable + return [ + PowerGrid::cache()// [!code ++:3] + ->prefix(auth()->id . '_'), //result: 1_powergrid-dish-DishTable + ] } } ``` @@ -511,9 +512,10 @@ use PowerComponents\LivewirePowerGrid\Cache; public function setUp(): array { - Cache::make()// [!code ++:3] - ->forever(), - ->customTag('my-custom-tag'), + return [ + PowerGrid::cache()// [!code ++:3] + ->customTag('my-custom-tag'), + ] } ``` @@ -556,7 +558,6 @@ Here you can find all the methods available in the `LivewirePowerGrid\Cache` cla | Method | Description | |-------|--------------| -| `forever()` | Creates a cache using the [rememberForever](https://laravel.com/docs/cache#retrieve-store) method. | | `ttl()` | Maximum time in seconds for which the data can be cached. | | `customTag()` | Allows you to set a custom cache tag. | | `prefix()` | Sets a prefix for the cache tag. | diff --git a/docs/table-features/exporting-data.md b/docs/table-features/exporting-data.md index f1b16ce..3f04401 100644 --- a/docs/table-features/exporting-data.md +++ b/docs/table-features/exporting-data.md @@ -38,6 +38,7 @@ To configure the feature, proceed to chain to `make()` as many [Data Export Conf use PowerComponents\LivewirePowerGrid\PowerGridComponent; use PowerComponents\LivewirePowerGrid\Traits\WithExport; use PowerComponents\LivewirePowerGrid\Exportable; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; class DishTable extends PowerGridComponent { @@ -45,7 +46,7 @@ class DishTable extends PowerGridComponent public function setUp(): array { - Exportable::make(fileName: 'my-export-file') // [!code ++] + PowerGrid::exportable(fileName: 'my-export-file') // [!code ++] ->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV), // [!code ++] } } @@ -114,6 +115,7 @@ Example: use PowerComponents\LivewirePowerGrid\PowerGridComponent; use PowerComponents\LivewirePowerGrid\Traits\WithExport; use PowerComponents\LivewirePowerGrid\Exportable; +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; class DishTable extends PowerGridComponent { @@ -121,7 +123,7 @@ class DishTable extends PowerGridComponent public function setUp(): array { - Exportable::make(fileName: 'my-export-file') // [!code ++:5] + PowerGRid::exportable(fileName: 'my-export-file') // [!code ++:5] ->columnWidth([ 2 => 30, 4 => 20, @@ -146,6 +148,7 @@ Example: use PowerComponents\LivewirePowerGrid\PowerGridComponent; use PowerComponents\LivewirePowerGrid\Traits\WithExport; use PowerComponents\LivewirePowerGrid\Exportable; +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; class DishTable extends PowerGridComponent { @@ -153,7 +156,7 @@ class DishTable extends PowerGridComponent public function setUp(): array { - Exportable::make(fileName: 'my-export-file') // [!code ++:2] + PowerGrid::exportable(fileName: 'my-export-file') // [!code ++:2] ->stripe('A6ACCD'), } } @@ -203,13 +206,14 @@ Example: use PowerComponents\LivewirePowerGrid\PowerGridComponent; use PowerComponents\LivewirePowerGrid\Traits\WithExport; use PowerComponents\LivewirePowerGrid\Exportable; +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; class DishTable extends PowerGridComponent { public function setUp() { return [ - Exportable::make('export')// [!code ++:6] + PowerGrid::exportable('export')// [!code ++:6] ->striped() ->type(Exportable::TYPE_XLS, Exportable::TYPE_CSV) ->queues(6) @@ -300,14 +304,14 @@ class DishTable extends PowerGridComponent ### make() -Make new `PowerGrid\Exportable` class. +Make new `\PowerComponents\LivewirePowerGrid\Facades\PowerGrid;` facade. | Parameters | Description | |-----------------------|---------------------------------------------------| | (string) $fileName | Name of the file that will contain exported data | ```php -Exportable::make(fileName: 'my-export-file'), +PowerGrid::exportable(fileName: 'my-export-file'), ``` --- @@ -323,7 +327,7 @@ Set the file types available for data exporting. Example: ```php -Exportable::make('my-export-file') +PowerGrid::exportable('my-export-file') ->type(types: Exportable::TYPE_XLS, Exportable::TYPE_CSV), ``` @@ -339,7 +343,7 @@ When exporting to CSV, you may configure the `field separator` and `field delimi | (string) $delimiter | CSV Delimiter | ```php -Exportable::make('my-export-file') +PowerGrid::exportable('my-export-file') ->type(Exportable::TYPE_CSV) ->csvSeparator(separator: '|') ->csvDelimiter(delimiter: "'"), diff --git a/docs/table-features/pagination.md b/docs/table-features/pagination.md index 2cebd02..10b2101 100644 --- a/docs/table-features/pagination.md +++ b/docs/table-features/pagination.md @@ -18,7 +18,7 @@ On this page, you can find information on customizing pagination settings. You m PowerGrid includes an easy-to-configure built-in Pagination system. -To enable pagination, you must add a call to the `Footer::make()` class in your Component's `setUp()` method. Then, proceed to chain the `showPerPage()` method to the `Footer` class. +To enable pagination, you must add a call to the `PowerGrid::footer()` class in your Component's `setUp()` method. Then, proceed to chain the `showPerPage()` method to the `Footer` class. Example: @@ -26,14 +26,14 @@ Example: // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Footer; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Footer::make()// [!code ++] + PowerGrid::footer()// [!code ++] ->showPerPage(perPage: 10, perPageValues: [0, 50, 100, 500]), // [!code ++] ]; } @@ -54,14 +54,14 @@ Example: // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Footer; +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Footer::make()// [!code ++] + PowerGrid::footer()// [!code ++] ->showPerPage() // [!code --] ->showRecordCount(mode: 'full'), // [!code ++] ]; @@ -89,14 +89,14 @@ Example: // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Footer; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Footer::make()// [!code ++] + PowerGrid::footer()// [!code ++] ->showRecordCount(mode: 'full'), // [!code ++] ]; } @@ -117,14 +117,14 @@ The `DishTable` component uses the `dishPage` parameter from the URL, while the // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Footer; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Footer::make()// [!code ++:2] + PowerGrid::footer()// [!code ++:2] ->pageName('dishPage'), ]; } @@ -135,14 +135,14 @@ class DishTable extends PowerGridComponent // app/Livewire/UserTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Footer; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class UserTable extends PowerGridComponent { public function setUp(): array { return [ - Footer::make()// [!code ++:2] + PowerGrid::footer()// [!code ++:2] ->pageName('userPage'), ]; } @@ -172,14 +172,14 @@ Your custom component will have access to the `$perPage` and `$perPageValues` pr // app/Livewire/DishTable.php use PowerComponents\LivewirePowerGrid\PowerGridComponent; -use PowerComponents\LivewirePowerGrid\Footer; // [!code ++] +use PowerComponents\LivewirePowerGrid\Facades\PowerGrid; // [!code ++] class DishTable extends PowerGridComponent { public function setUp(): array { return [ - Footer::make()// [!code ++] + PowerGrid::footer()// [!code ++] ->showPerPage(25)// [!code ++] ->showRecordCount()// [!code ++] ->pagination(viewPath: 'components.pagination'),// [!code ++]