mirror of
https://github.com/filamentphp/filament.git
synced 2026-10-24 01:58:00 +08:00
Merge branch '3.x' into upg3
This commit is contained in:
@@ -10,7 +10,6 @@ export default {
|
||||
danger: colors.rose,
|
||||
info: colors.blue,
|
||||
primary: colors.blue,
|
||||
secondary: colors.gray,
|
||||
success: colors.green,
|
||||
warning: colors.yellow,
|
||||
},
|
||||
|
||||
@@ -72,7 +72,7 @@ Action::make('edit')
|
||||
|
||||
## Setting a color
|
||||
|
||||
Buttons may have a color to indicate their significance. It may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
Buttons may have a color to indicate their significance. It may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
Action::make('delete')
|
||||
@@ -174,7 +174,7 @@ Action::make('filter')
|
||||
|
||||
<AutoScreenshot name="actions/trigger-button/indicator" alt="Trigger with indicator" version="3.x" />
|
||||
|
||||
You can also pass a color to be used for the indicator, which can be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` and `warning`:
|
||||
You can also pass a color to be used for the indicator, which can be either `danger`, `gray`, `info`, `primary`, `success` and `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Actions\Action;
|
||||
|
||||
@@ -112,7 +112,7 @@ TextInput::make('password')
|
||||
|
||||
### Changing the text color of the hint
|
||||
|
||||
You can change the text color of the hint. By default it's gray, but you may use `danger`, `gray`, `info`, `primary`, `secondary`, `success` and `warning`:
|
||||
You can change the text color of the hint. By default it's gray, but you may use `danger`, `gray`, `info`, `primary`, `success` and `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
@@ -190,7 +190,7 @@ You may hide a field:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
|
||||
TextInput::make('name')
|
||||
->hidden()
|
||||
```
|
||||
@@ -199,7 +199,7 @@ Optionally, you may pass a boolean value to control if the field should be hidde
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\TextInput;
|
||||
|
||||
|
||||
TextInput::make('name')
|
||||
->hidden(! auth()->user()->isAdmin())
|
||||
```
|
||||
|
||||
@@ -43,7 +43,7 @@ Toggle::make('is_admin')
|
||||
|
||||
## Customizing the color of the toggle button
|
||||
|
||||
You may also customize the color representing the "on" or "off" state of the toggle. These may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`. To add a color to the "on" state, use the `onColor()` method. To add a color to the "off" state, use the `offColor()` method:
|
||||
You may also customize the color representing the "on" or "off" state of the toggle. These may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`. To add a color to the "on" state, use the `onColor()` method. To add a color to the "off" state, use the `offColor()` method:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Toggle;
|
||||
|
||||
@@ -119,7 +119,7 @@ Tabs::make('Heading')
|
||||
|
||||
### Setting the tab icon color
|
||||
|
||||
The icon of the tab may have a color to indicate its significance using the `iconColor()` method. It may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
The icon of the tab may have a color to indicate its significance using the `iconColor()` method. It may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Forms\Components\Tabs;
|
||||
|
||||
@@ -74,7 +74,7 @@ DateTimePicker::make('published_at')
|
||||
|
||||
#### Secondary color
|
||||
|
||||
Filament v2 had a `secondary` color for many components which was gray. Now, you can define a non-gray `secondary` color alongside `primary`. All references to `secondary` should be replaced with `gray` to preserve the same appearance.
|
||||
Filament v2 had a `secondary` color for many components which was gray. All references to `secondary` should be replaced with `gray` to preserve the same appearance. This frees `secondary` to be registered to a new custom color of your choice.
|
||||
|
||||
#### `$get` and `$set` closure parameters
|
||||
|
||||
|
||||
@@ -222,7 +222,7 @@ TextEntry::make('updated_at')
|
||||
|
||||
## Customizing the color
|
||||
|
||||
You may set a color for the text, either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
You may set a color for the text, either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Components\TextEntry;
|
||||
|
||||
@@ -34,7 +34,7 @@ IconEntry::make('is_featured')
|
||||
|
||||
## Customizing the color
|
||||
|
||||
Icon entries may also have a set of icon colors, using the same syntax. They may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
Icon entries may also have a set of icon colors, using the same syntax. They may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
@@ -97,7 +97,7 @@ IconEntry::make('is_featured')
|
||||
|
||||
### Customizing the boolean colors
|
||||
|
||||
You may customize the icon color representing each state. These may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
You may customize the icon color representing each state. These may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Components\IconEntry;
|
||||
|
||||
@@ -119,7 +119,7 @@ Tabs::make('Heading')
|
||||
|
||||
### Setting the tab icon color
|
||||
|
||||
The icon of the tab may have a color to indicate its significance using the `iconColor()` method. It may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
The icon of the tab may have a color to indicate its significance using the `iconColor()` method. It may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Infolists\Components\Tabs;
|
||||
|
||||
@@ -326,11 +326,11 @@ You can also `dispatchSelf` and `dispatchTo`:
|
||||
|
||||
```php
|
||||
Action::make('undo')
|
||||
->color('secondary')
|
||||
->color('gray')
|
||||
->dispatchSelf('undoEditingPost', [$post->id])
|
||||
|
||||
Action::make('undo')
|
||||
->color('secondary')
|
||||
->color('gray')
|
||||
->dispatchTo('another_component', 'undoEditingPost', [$post->id])
|
||||
```
|
||||
|
||||
@@ -357,11 +357,11 @@ Similarly, `dispatchSelf` and `dispatchTo` are also available:
|
||||
|
||||
```js
|
||||
new NotificationAction('undo')
|
||||
.color('secondary')
|
||||
.color('gray')
|
||||
.dispatchSelf('undoEditingPost')
|
||||
|
||||
new NotificationAction('undo')
|
||||
.color('secondary')
|
||||
.color('gray')
|
||||
.dispatchTo('another_component', 'undoEditingPost')
|
||||
```
|
||||
|
||||
|
||||
@@ -55,4 +55,4 @@ The Heroicons library has been updated to v2. This means that any icons you use
|
||||
|
||||
#### Secondary color
|
||||
|
||||
Filament v2 had a `secondary` color for many components which was gray. Now, you can define a non-gray `secondary` color alongside `primary`. All references to `secondary` should be replaced with `gray` to preserve the same appearance.
|
||||
Filament v2 had a `secondary` color for many components which was gray. All references to `secondary` should be replaced with `gray` to preserve the same appearance. This frees `secondary` to be registered to a new custom color of your choice.
|
||||
|
||||
Vendored
-1
File diff suppressed because one or more lines are too long
@@ -410,6 +410,9 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
->modifyQueryUsing(fn (Builder $query) => $query->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]))
|
||||
->columns([
|
||||
// ...
|
||||
])
|
||||
@@ -432,14 +435,6 @@ public function table(Table $table): Table
|
||||
]),
|
||||
]);
|
||||
}
|
||||
|
||||
protected function getTableQuery(): Builder
|
||||
{
|
||||
return parent::getTableQuery()
|
||||
->withoutGlobalScopes([
|
||||
SoftDeletingScope::class,
|
||||
]);
|
||||
}
|
||||
```
|
||||
|
||||
### Customizing the `DeleteAction`
|
||||
|
||||
@@ -60,7 +60,7 @@ public static function getNavigationBadge(): ?string
|
||||
}
|
||||
```
|
||||
|
||||
If a badge value is returned by `getNavigationBadge()`, it will display using the primary color by default. To style the badge contextually, return either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning` from the `getNavigationBadgeColor()` method:
|
||||
If a badge value is returned by `getNavigationBadge()`, it will display using the primary color by default. To style the badge contextually, return either `danger`, `gray`, `info`, `primary`, `success` or `warning` from the `getNavigationBadgeColor()` method:
|
||||
|
||||
```php
|
||||
public static function getNavigationBadgeColor(): ?string
|
||||
|
||||
@@ -19,7 +19,6 @@ public function panel(Panel $panel): Panel
|
||||
'gray' => Color::Gray,
|
||||
'info' => Color::Blue,
|
||||
'primary' => Color::Indigo,
|
||||
'secondary' => Color::Sky,
|
||||
'success' => Color::Emerald,
|
||||
'warning' => Color::Orange,
|
||||
]);
|
||||
@@ -58,7 +57,7 @@ $panel
|
||||
->colors([
|
||||
'primary' => '#6366f1',
|
||||
])
|
||||
|
||||
|
||||
$panel
|
||||
->colors([
|
||||
'primary' => 'rgb(99, 102, 241)',
|
||||
|
||||
@@ -205,7 +205,7 @@ it('can validate input', function () {
|
||||
|
||||
##### Deleting
|
||||
|
||||
You can test the `DeleteAction` using `callPageAction()`:
|
||||
You can test the `DeleteAction` using `callAction()`:
|
||||
|
||||
```php
|
||||
use Filament\Actions\DeleteAction;
|
||||
@@ -217,13 +217,13 @@ it('can delete', function () {
|
||||
livewire(PostResource\Pages\EditPost::class, [
|
||||
'record' => $post->getRouteKey(),
|
||||
])
|
||||
->callPageAction(DeleteAction::class);
|
||||
->callAction(DeleteAction::class);
|
||||
|
||||
$this->assertModelMissing($post);
|
||||
});
|
||||
```
|
||||
|
||||
You can ensure that a particular user is not able to see a `DeleteAction` using `assertPageActionHidden()`:
|
||||
You can ensure that a particular user is not able to see a `DeleteAction` using `assertActionHidden()`:
|
||||
|
||||
```php
|
||||
use Filament\Actions\DeleteAction;
|
||||
@@ -235,7 +235,7 @@ it('can not delete', function () {
|
||||
livewire(PostResource\Pages\EditPost::class, [
|
||||
'record' => $post->getRouteKey(),
|
||||
])
|
||||
->assertPageActionHidden(DeleteAction::class);
|
||||
->assertActionHidden(DeleteAction::class);
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ DateTimePicker::make('published_at')
|
||||
|
||||
#### Secondary color
|
||||
|
||||
Filament v2 had a `secondary` color for many components which was gray. Now, you can define a non-gray `secondary` color alongside `primary`. All references to `secondary` should be replaced with `gray` to preserve the same appearance.
|
||||
Filament v2 had a `secondary` color for many components which was gray. All references to `secondary` should be replaced with `gray` to preserve the same appearance. This frees `secondary` to be registered to a new custom color of your choice.
|
||||
|
||||
#### `$get` and `$set` closure parameters
|
||||
|
||||
|
||||
@@ -127,25 +127,21 @@ class MakeRelationManagerCommand extends Command
|
||||
|
||||
$tableBulkActions[] = 'Tables\Actions\DeleteBulkAction::make(),';
|
||||
|
||||
$eloquentQuery = '';
|
||||
$modifyQueryUsing = '';
|
||||
|
||||
if ($this->option('soft-deletes')) {
|
||||
$modifyQueryUsing .= '->modifyQueryUsing(fn (Builder $query) => $query->withoutGlobalScopes([';
|
||||
$modifyQueryUsing .= PHP_EOL . ' SoftDeletingScope::class,';
|
||||
$modifyQueryUsing .= PHP_EOL . ']))';
|
||||
|
||||
$tableBulkActions[] = 'Tables\Actions\RestoreBulkAction::make(),';
|
||||
$tableBulkActions[] = 'Tables\Actions\ForceDeleteBulkAction::make(),';
|
||||
|
||||
$eloquentQuery .= PHP_EOL . PHP_EOL . 'protected function getTableQuery(): Builder';
|
||||
$eloquentQuery .= PHP_EOL . '{';
|
||||
$eloquentQuery .= PHP_EOL . ' return parent::getTableQuery()';
|
||||
$eloquentQuery .= PHP_EOL . ' ->withoutGlobalScopes([';
|
||||
$eloquentQuery .= PHP_EOL . ' SoftDeletingScope::class,';
|
||||
$eloquentQuery .= PHP_EOL . ' ]);';
|
||||
$eloquentQuery .= PHP_EOL . '}';
|
||||
}
|
||||
|
||||
$tableBulkActions = implode(PHP_EOL, $tableBulkActions);
|
||||
|
||||
$this->copyStubToApp('RelationManager', $path, [
|
||||
'eloquentQuery' => $this->indentString($eloquentQuery, 1),
|
||||
'modifyQueryUsing' => $this->indentString($modifyQueryUsing, 3),
|
||||
'namespace' => "{$resourceNamespace}\\{$resource}\\RelationManagers",
|
||||
'managerClass' => $managerClass,
|
||||
'recordTitleAttribute' => $recordTitleAttribute,
|
||||
|
||||
@@ -4,7 +4,6 @@ namespace Filament\Resources\Pages;
|
||||
|
||||
use Filament\Pages\Page as BasePage;
|
||||
use Filament\Panel;
|
||||
use Filament\Resources\Resource;
|
||||
use Illuminate\Routing\Route;
|
||||
use Illuminate\Support\Facades\Route as RouteFacade;
|
||||
|
||||
@@ -74,7 +73,7 @@ abstract class Page extends BasePage
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Resource>
|
||||
* @return class-string
|
||||
*/
|
||||
public static function getResource(): string
|
||||
{
|
||||
|
||||
@@ -29,6 +29,7 @@ class {{ managerClass }} extends RelationManager
|
||||
public function table(Table $table): Table
|
||||
{
|
||||
return $table
|
||||
{{ modifyQueryUsing }}
|
||||
->columns([
|
||||
Tables\Columns\TextColumn::make('{{ recordTitleAttribute }}'),
|
||||
])
|
||||
@@ -46,5 +47,5 @@ class {{ managerClass }} extends RelationManager
|
||||
{{ tableBulkActions }}
|
||||
]),
|
||||
]);
|
||||
}{{ eloquentQuery }}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@ FilamentColor::register([
|
||||
'gray' => Color::Gray,
|
||||
'info' => Color::Blue,
|
||||
'primary' => Color::Amber,
|
||||
'secondary' => Color::Gray,
|
||||
'success' => Color::Green,
|
||||
'warning' => Color::Amber,
|
||||
]);
|
||||
@@ -92,4 +91,4 @@ FilamentColor::register([
|
||||
]);
|
||||
```
|
||||
|
||||
Now, you can use this color anywhere you would normally add `primary`, `secondary`, `danger`, etc.
|
||||
Now, you can use this color anywhere you would normally add `primary`, `danger`, etc.
|
||||
|
||||
@@ -68,7 +68,6 @@ class ColorManager
|
||||
'gray' => Color::Gray,
|
||||
'info' => Color::Blue,
|
||||
'primary' => Color::Amber,
|
||||
'secondary' => Color::Gray,
|
||||
'success' => Color::Green,
|
||||
'warning' => Color::Amber,
|
||||
...$this->colors,
|
||||
|
||||
@@ -72,19 +72,6 @@ export default {
|
||||
900: 'rgba(var(--primary-900), <alpha-value>)',
|
||||
950: 'rgba(var(--primary-950), <alpha-value>)',
|
||||
},
|
||||
secondary: {
|
||||
50: 'rgba(var(--secondary-50), <alpha-value>)',
|
||||
100: 'rgba(var(--secondary-100), <alpha-value>)',
|
||||
200: 'rgba(var(--secondary-200), <alpha-value>)',
|
||||
300: 'rgba(var(--secondary-300), <alpha-value>)',
|
||||
400: 'rgba(var(--secondary-400), <alpha-value>)',
|
||||
500: 'rgba(var(--secondary-500), <alpha-value>)',
|
||||
600: 'rgba(var(--secondary-600), <alpha-value>)',
|
||||
700: 'rgba(var(--secondary-700), <alpha-value>)',
|
||||
800: 'rgba(var(--secondary-800), <alpha-value>)',
|
||||
900: 'rgba(var(--secondary-900), <alpha-value>)',
|
||||
950: 'rgba(var(--secondary-950), <alpha-value>)',
|
||||
},
|
||||
success: {
|
||||
50: 'rgba(var(--success-50), <alpha-value>)',
|
||||
100: 'rgba(var(--success-100), <alpha-value>)',
|
||||
|
||||
@@ -382,6 +382,26 @@ TextColumn::make('title')
|
||||
->tooltip(fn (Model $record): string => "By {$record->author->name}")
|
||||
```
|
||||
|
||||
## Aligning column content
|
||||
|
||||
Table columns are aligned to the start (left in LTR interfaces or right in RTL interfaces) by default. You may change the alignment using the `alignment()` method, and passing it `start`, `center`, `end`, `left`, `right` or `justify` options:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
|
||||
TextColumn::make('name')
|
||||
->alignment('end')
|
||||
```
|
||||
|
||||
Alternatively, you may use shorthand methods like `alignEnd()`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
|
||||
TextColumn::make('name')
|
||||
->alignEnd()
|
||||
```
|
||||
|
||||
## Custom attributes
|
||||
|
||||
The HTML of columns can be customized, by passing an array of `extraAttributes()`:
|
||||
|
||||
@@ -244,7 +244,7 @@ TextColumn::make('updated_at')
|
||||
|
||||
## Customizing the color
|
||||
|
||||
You may set a color for the text, either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
You may set a color for the text, either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Columns\TextColumn;
|
||||
|
||||
@@ -34,7 +34,7 @@ IconColumn::make('is_featured')
|
||||
|
||||
## Customizing the color
|
||||
|
||||
Icon columns may also have a set of icon colors, using the same syntax. They may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
Icon columns may also have a set of icon colors, using the same syntax. They may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
@@ -97,7 +97,7 @@ IconColumn::make('is_featured')
|
||||
|
||||
### Customizing the boolean colors
|
||||
|
||||
You may customize the icon color representing each state. These may be either `danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`:
|
||||
You may customize the icon color representing each state. These may be either `danger`, `gray`, `info`, `primary`, `success` or `warning`:
|
||||
|
||||
```php
|
||||
use Filament\Tables\Columns\IconColumn;
|
||||
|
||||
@@ -63,4 +63,4 @@ The Heroicons library has been updated to v2. This means that any icons you use
|
||||
|
||||
#### Secondary color
|
||||
|
||||
Filament v2 had a `secondary` color for many components which was gray. Now, you can define a non-gray `secondary` color alongside `primary`. All references to `secondary` should be replaced with `gray` to preserve the same appearance.
|
||||
Filament v2 had a `secondary` color for many components which was gray. All references to `secondary` should be replaced with `gray` to preserve the same appearance. This frees `secondary` to be registered to a new custom color of your choice.
|
||||
|
||||
@@ -64,8 +64,7 @@ export default {
|
||||
colors: {
|
||||
danger: colors.red,
|
||||
info: colors.blue,
|
||||
primary: colors.amber,
|
||||
secondary: colors.gray,
|
||||
primary: colors.amber,,
|
||||
success: colors.green,
|
||||
warning: colors.amber,
|
||||
},
|
||||
@@ -78,7 +77,7 @@ export default {
|
||||
}
|
||||
```
|
||||
|
||||
Of course, you may specify your own custom `danger`, `gray`, `info`, `primary`, `secondary`, `success` and `warning` colors, which will be used instead. But each color needs to be a [Tailwind CSS color](https://tailwindcss.com/docs/customizing-colors#color-palette-reference), or have all 50 - 950 variants specified - a single hex code or RGB value won't work here.
|
||||
Of course, you may specify your own custom `danger`, `gray`, `info`, `primary`, `success` and `warning` colors, which will be used instead. But each color needs to be a [Tailwind CSS color](https://tailwindcss.com/docs/customizing-colors#color-palette-reference), or have all 50 - 950 variants specified - a single hex code or RGB value won't work here.
|
||||
|
||||
### Configuring styles
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ protected function getCards(): array
|
||||
|
||||
## Changing the color of the card
|
||||
|
||||
You may also give cards a `color()` (`danger`, `gray`, `info`, `primary`, `secondary`, `success` or `warning`):
|
||||
You may also give cards a `color()` (`danger`, `gray`, `info`, `primary`, `success` or `warning`):
|
||||
|
||||
```php
|
||||
protected function getCards(): array
|
||||
|
||||
@@ -28,7 +28,6 @@ it('can send notifications', function () {
|
||||
'gray',
|
||||
'info',
|
||||
'primary',
|
||||
'secondary',
|
||||
'success',
|
||||
'warning',
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user