Skip to content

Commit

Permalink
Merge branch '3.x' into laravel-11
Browse files Browse the repository at this point in the history
  • Loading branch information
coolsam726 authored Mar 21, 2024
2 parents 2250564 + f31b1d4 commit 257b6a5
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 23 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/fix-php-code-style-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Fix PHP code style issues
uses: aglipanci/[email protected]

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
name: phpstan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
ref: main

Expand All @@ -24,7 +24,7 @@ jobs:
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v4
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
],
"require": {
"php": "^8.1",
"filament/filament": "^3.0",
"spatie/laravel-package-tools": "^1.14.0",
"illuminate/contracts": "^10.0|^11.0"
},
Expand Down
7 changes: 4 additions & 3 deletions resources/js/components/flatpickr.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,13 @@ export default function flatpickrDatepicker(args) {
el.href = this.attribs.darkThemeAsset;
}
}

if (this.attribs.monthSelect) {
config.plugins.push(new MonthSelect({
shorthand: false, //defaults to false
dateFormat: "F Y", //defaults to "F Y"
altInput: true,
altFormat: "F, Y", //defaults to "F Y"
dateFormat: args.packageConfig.dateFormat ?? "F Y", //defaults to "F Y"
altInput: args.packageConfig.altInput ?? true,
altFormat: args.packageConfig.altFormat ?? "F, Y",
theme: this.mode // defaults to "light"
}))
} else if (this.attribs.weekSelect) {
Expand Down
2 changes: 1 addition & 1 deletion resources/js/dist/components/flatpickr-component.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions resources/views/forms/components/flatpickr.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
ax-load-src="{{\Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('flatpickr-component',package: \Coolsam\FilamentFlatpickr\FilamentFlatpickr::getPackageName())}}"
>
<x-filament::input.wrapper
wire:ignore
:disabled="$isDisabled"
:inline-prefix="$isPrefixInline"
:inline-suffix="$isSuffixInline"
Expand Down
36 changes: 23 additions & 13 deletions src/Forms/Components/Flatpickr.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Filament\Forms\Components\Contracts;
use Filament\Forms\Components\Field;
use Filament\Support\Concerns\HasExtraAlpineAttributes;
use Closure;

class Flatpickr extends Field implements Contracts\CanBeLengthConstrained, Contracts\HasAffixActions
{
Expand Down Expand Up @@ -85,9 +86,9 @@ class Flatpickr extends Field implements Contracts\CanBeLengthConstrained, Contr

protected bool $inline = false;

protected Carbon|string|null $maxDate = null;
protected Carbon|string|null|Closure $maxDate = null;

protected Carbon|string|null $minDate = null;
protected Carbon|string|null|Closure $minDate = null;

protected ?string $maxTime = null;

Expand Down Expand Up @@ -146,17 +147,23 @@ public function getConfig(): array
$this->enableTime(false);
$this->time(false);
$this->range(false);
$this->dateFormat('Y-m');
$this->altFormat('F J');
$this->altInput();
if (\Str::of($this->getDateFormat())->contains('d', ignoreCase: true)) {
$this->dateFormat('Y-m'); // Setting default date format to Y-m if no date format is set by user
}
if (\Str::of($this->getAltFormat())->contains('d', ignoreCase: true)) {
$this->altFormat('F Y'); // Setting default alt format to F Y if no alt format is set by user
}
} elseif ($this->isWeekSelect()) {
$this->mode(FlatpickrMode::SINGLE);
$this->enableTime(false);
$this->time(false);
$this->range(false);
$this->dateFormat('W');
$this->altFormat('\Week W');
$this->altInput();
if (\Str::of($this->getDateFormat())->contains(['d', 'y'], ignoreCase: true)) {
$this->dateFormat('W'); // Setting default date format to W if no date format is set by user
}
if (\Str::of($this->getAltFormat())->contains(['d', 'y'], ignoreCase: true)) {
$this->altFormat('\Week W'); // Setting default alt format to Week W if no alt format is set by user
}
}
$config = [
'monthSelect' => $this->monthSelect,
Expand Down Expand Up @@ -238,9 +245,12 @@ protected function setUp(): void
'
);
$this->theme(config('coolsam-flatpickr.default_theme', FlatpickrTheme::DEFAULT));
$this->dehydrateStateUsing(static function (Flatpickr $component, $state) {
return self::dehydratePickerState($component, $state);
});

if(! $this->dehydrateStateUsing){
$this->dehydrateStateUsing(static function (Flatpickr $component, $state) {
return self::dehydratePickerState($component, $state);
});
}

/*$this->rule(
'date',
Expand Down Expand Up @@ -477,7 +487,7 @@ public function getMaxDate(): Carbon|string|null
return $this->maxDate;
}

public function maxDate(Carbon|string|null $maxDate = 'now'): static
public function maxDate(Carbon|string|null|Closure $maxDate = 'now'): static
{
$this->maxDate = $maxDate ? Carbon::parse($maxDate) : $maxDate;

Expand All @@ -489,7 +499,7 @@ public function getMinDate(): Carbon|string|null
return $this->minDate;
}

public function minDate(Carbon|string|null $minDate): static
public function minDate(Carbon|string|null $minDate|Closure): static
{
$this->minDate = $minDate ? Carbon::parse($minDate) : $minDate;

Expand Down

0 comments on commit 257b6a5

Please sign in to comment.