diff --git a/src/Enums/FlatpickrMode.php b/src/Enums/FlatpickrMode.php index 9197653..c1d16dc 100644 --- a/src/Enums/FlatpickrMode.php +++ b/src/Enums/FlatpickrMode.php @@ -1,8 +1,11 @@ '; + protected ?string $prevArrow = '<'; + protected bool $noCalendar = false; + protected bool $shorthandCurrentMonth = false; protected bool $static = false; + protected bool $use24hr = false; + protected bool $weekNumbers = false; + protected bool $wrap = false; + protected int $showMonths = 1; protected FlatpickrPosition $position = FlatpickrPosition::AUTO; + protected FlatpickrMonthSelectorType $monthSelectorType = FlatpickrMonthSelectorType::DROPDOWN; + protected bool $animate = true; + protected bool $closeOnSelect = true; public function getConfig(): array @@ -71,10 +114,10 @@ public function getConfig(): array $this->mode(FlatpickrMode::MULTIPLE); } if ($this->isEnableTime()) { - if (!\Str::of($this->getDateFormat())->contains('H',ignoreCase: true)) { + if (! \Str::of($this->getDateFormat())->contains('H', ignoreCase: true)) { $this->dateFormat('Y-m-d H:i:s'); } - if (!\Str::of($this->getAltFormat())->contains('H',ignoreCase: true)) { + if (! \Str::of($this->getAltFormat())->contains('H', ignoreCase: true)) { $this->altFormat('F j Y H:i K'); } } @@ -146,12 +189,10 @@ public function getConfig(): array if ($this->getEnabledDates()) { $config['enabled'] = $this->getEnabledDates(); } + return $config; } - /** - * @return bool - */ public function isTime(): bool { return $this->time; @@ -160,6 +201,7 @@ public function isTime(): bool public function time(bool $time = true): static { $this->time = $time; + return $this; } @@ -197,9 +239,11 @@ public static function dehydratePickerState($component, $state) return $state; } + public function mode(FlatpickrMode $mode): static { $this->mode = $mode; + return $this; } @@ -211,6 +255,7 @@ public function getMode(): string public function altInputClass(?string $altInputClass = ''): static { $this->altInputClass = $altInputClass; + return $this; } @@ -222,6 +267,7 @@ public function getAltInputClass(): ?string public function allowInput(bool $allowInput = true): static { $this->allowInput = $allowInput; + return $this; } @@ -238,6 +284,7 @@ public function isAllowInvalidPreload(): bool public function allowInvalidPreload(bool $allowInvalidPreload = true): static { $this->allowInvalidPreload = $allowInvalidPreload; + return $this; } @@ -249,6 +296,7 @@ public function getAriaDateFormat(): ?string public function ariaDateFormat(?string $ariaDateFormat): static { $this->ariaDateFormat = $ariaDateFormat; + return $this; } @@ -260,6 +308,7 @@ public function getConjunction(): ?string public function conjunction(?string $conjunction): static { $this->conjunction = $conjunction; + return $this; } @@ -271,6 +320,7 @@ public function isClickOpens(): bool public function clickOpens(bool $clickOpens = true): static { $this->clickOpens = $clickOpens; + return $this; } @@ -292,6 +342,7 @@ public function getDefaultMinute(): int public function defaultMinute(int $defaultMinute): static { $this->defaultMinute = $defaultMinute; + return $this; } @@ -303,6 +354,7 @@ public function getDefaultSeconds(): int public function defaultSeconds(int $defaultSeconds): static { $this->defaultSeconds = $defaultSeconds; + return $this; } @@ -314,6 +366,7 @@ public function getDisabledDates(): array public function disabledDates(array $disabledDates = []): static { $this->disabledDates = $disabledDates; + return $this; } @@ -325,6 +378,7 @@ public function getEnabledDates(): ?array public function enabledDates(array $enabledDates = []): static { $this->enabledDates = $enabledDates; + return $this; } @@ -336,6 +390,7 @@ public function isDisableMobile(): bool public function disableMobile(bool $disableMobile = true): static { $this->disableMobile = $disableMobile; + return $this; } @@ -347,6 +402,7 @@ public function isEnableSeconds(): bool public function enableSeconds(bool $enableSeconds = true): static { $this->enableSeconds = $enableSeconds; + return $this; } @@ -358,6 +414,7 @@ public function getHourIncrement(): int public function hourIncrement(int $hourIncrement = 1): static { $this->hourIncrement = $hourIncrement; + return $this; } @@ -369,6 +426,7 @@ public function getMinuteIncrement(): int public function minuteIncrement(int $minuteIncrement = 5): static { $this->minuteIncrement = $minuteIncrement; + return $this; } @@ -380,6 +438,7 @@ public function isInline(): bool public function inline(bool $inline = true): static { $this->inline = $inline; + return $this; } @@ -391,6 +450,7 @@ public function getMaxDate(): Carbon|string|null public function maxDate(Carbon|string|null $maxDate = 'now'): static { $this->maxDate = $maxDate ? Carbon::parse($maxDate) : $maxDate; + return $this; } @@ -402,6 +462,7 @@ public function getMinDate(): Carbon|string|null public function minDate(Carbon|string|null $minDate): static { $this->minDate = $minDate ? Carbon::parse($minDate) : $minDate; + return $this; } @@ -413,6 +474,7 @@ public function getMaxTime(): ?string public function maxTime(?string $maxTime): static { $this->maxTime = $maxTime; + return $this; } @@ -424,6 +486,7 @@ public function getMinTime(): ?string public function minTime(?string $minTime): static { $this->minTime = $minTime; + return $this; } @@ -435,6 +498,7 @@ public function getNextArrow(): ?string public function nextArrow(?string $nextArrow = '>'): static { $this->nextArrow = $nextArrow; + return $this; } @@ -446,6 +510,7 @@ public function isNoCalendar(): bool public function noCalendar(bool $noCalendar = true): static { $this->noCalendar = $noCalendar; + return $this; } @@ -457,6 +522,7 @@ public function isShorthandCurrentMonth(): bool public function shorthandCurrentMonth(bool $shorthandCurrentMonth = true): static { $this->shorthandCurrentMonth = $shorthandCurrentMonth; + return $this; } @@ -468,6 +534,7 @@ public function isStatic(): bool public function static(bool $static = true): static { $this->static = $static; + return $this; } @@ -479,6 +546,7 @@ public function isUse24hr(): bool public function use24hr(bool $use24hr = true): static { $this->use24hr = $use24hr; + return $this; } @@ -490,6 +558,7 @@ public function isWeekNumbers(): bool public function weekNumbers(bool $weekNumbers = true): static { $this->weekNumbers = $weekNumbers; + return $this; } @@ -501,6 +570,7 @@ public function isWrap(): bool public function wrap(bool $wrap = true): static { $this->wrap = $wrap; + return $this; } @@ -512,6 +582,7 @@ public function getShowMonths(): int public function showMonths(int $showMonths = 1): static { $this->showMonths = $showMonths; + return $this; } @@ -523,6 +594,7 @@ public function getPosition(): string public function position(FlatpickrPosition $position): static { $this->position = $position; + return $this; } @@ -534,12 +606,10 @@ public function getMonthSelectorType(): string public function monthSelectorType(FlatpickrMonthSelectorType $monthSelectorType): static { $this->monthSelectorType = $monthSelectorType; + return $this; } - /** - * @return bool - */ public function isAnimate(): bool { return $this->animate; @@ -548,6 +618,7 @@ public function isAnimate(): bool public function animate(bool $animate = true): static { $this->animate = $animate; + return $this; } @@ -559,6 +630,7 @@ public function isCloseOnSelect(): bool public function closeOnSelect(bool $closeOnSelect = true): static { $this->closeOnSelect = $closeOnSelect; + return $this; } @@ -570,12 +642,14 @@ public function getPrevArrow(): ?string public function prevArrow(?string $prevArrow): static { $this->prevArrow = $prevArrow; + return $this; } public function weekSelect(bool $weekSelect = true): static { $this->weekSelect = $weekSelect; + return $this; } @@ -587,6 +661,7 @@ public function isWeekSelect(): bool public function customConfig(array|\Closure $config): static { $this->config = $config; + return $this; } @@ -598,6 +673,7 @@ public function getCustomConfig(): array public function range(bool $rangePicker = true): static { $this->rangePicker = $rangePicker; + return $this; } @@ -609,6 +685,7 @@ public function isRangePicker(): bool public function multiple(bool $multiplePicker = true): static { $this->multiplePicker = $multiplePicker; + return $this; } @@ -620,6 +697,7 @@ public function isMultiplePicker(): bool public function monthSelect(?bool $monthSelect = true): static { $this->monthSelect = $monthSelect; + return $this; } @@ -631,6 +709,7 @@ public function isMonthSelect(): bool public function altInput(bool $altInput = true): static { $this->altInput = $altInput; + return $this; } @@ -642,6 +721,7 @@ public function isAltInput(): bool public function enableTime(bool $enableTime = true): static { $this->enableTime = $enableTime; + return $this; } @@ -691,15 +771,17 @@ public function getThemeAsset(): string if ($this->getTheme() === FlatpickrTheme::DEFAULT->value) { $this->theme(FlatpickrTheme::LIGHT); } - return asset("vendor/".\Savannabits\Flatpickr\Flatpickr::PACKAGE_NAME."/flatpickr/themes/".$this->getTheme().".css"); + + return asset('vendor/'.\Savannabits\Flatpickr\Flatpickr::PACKAGE_NAME.'/flatpickr/themes/'.$this->getTheme().'.css'); } + public function getDarkThemeAsset(): string { - return asset("vendor/".\Savannabits\Flatpickr\Flatpickr::PACKAGE_NAME."/flatpickr/themes/dark.css"); + return asset('vendor/'.\Savannabits\Flatpickr\Flatpickr::PACKAGE_NAME.'/flatpickr/themes/dark.css'); } + public function getLightThemeAsset(): string { - return asset("vendor/".\Savannabits\Flatpickr\Flatpickr::PACKAGE_NAME."/flatpickr/themes/light.css"); + return asset('vendor/'.\Savannabits\Flatpickr\Flatpickr::PACKAGE_NAME.'/flatpickr/themes/light.css'); } - } diff --git a/src/FlatpickrServiceProvider.php b/src/FlatpickrServiceProvider.php index c123d2e..ead59f9 100644 --- a/src/FlatpickrServiceProvider.php +++ b/src/FlatpickrServiceProvider.php @@ -3,26 +3,25 @@ namespace Savannabits\Flatpickr; use Filament\FilamentManager; -use Filament\PluginServiceProvider; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; class FlatpickrServiceProvider extends PackageServiceProvider { protected array $styles = [ - 'flatpickr-css' => __DIR__ . '/../resources/dist/flatpickr/flatpickr.css', - 'month-select-style' => __DIR__ . '/../resources/dist/flatpickr/plugins/monthSelect/style.css', - 'confirm-date-style' => __DIR__ . '/../resources/dist/flatpickr/plugins/confirmDate/confirmDate.css', + 'flatpickr-css' => __DIR__.'/../resources/dist/flatpickr/flatpickr.css', + 'month-select-style' => __DIR__.'/../resources/dist/flatpickr/plugins/monthSelect/style.css', + 'confirm-date-style' => __DIR__.'/../resources/dist/flatpickr/plugins/confirmDate/confirmDate.css', ]; protected array $beforeCoreScripts = [ -// 'flatpickr-core' => __DIR__ . '/../public/dist/flatpickr.min.js', -// 'flatpickr-range-plugin' => __DIR__ . '/../public/dist/plugins/rangePlugin.js', -// 'flatpickr-month-select' => __DIR__ . '/../public/dist/plugins/monthSelect/index.js', -// 'flatpickr-week-select' => __DIR__ . '/../public/dist/plugins/weekSelect/weekSelect.js', -// 'flatpickr-confirm-date' => __DIR__ . '/../public/dist/plugins/confirmDate/confirmDate.js', -// 'async-alpine' => "https://cdn.jsdelivr.net/npm/async-alpine@1.x.x/dist/async-alpine.script.js" -// 'filament-flatpickr' => __DIR__.'/../resources/dist/datepicker.js', + // 'flatpickr-core' => __DIR__ . '/../public/dist/flatpickr.min.js', + // 'flatpickr-range-plugin' => __DIR__ . '/../public/dist/plugins/rangePlugin.js', + // 'flatpickr-month-select' => __DIR__ . '/../public/dist/plugins/monthSelect/index.js', + // 'flatpickr-week-select' => __DIR__ . '/../public/dist/plugins/weekSelect/weekSelect.js', + // 'flatpickr-confirm-date' => __DIR__ . '/../public/dist/plugins/confirmDate/confirmDate.js', + // 'async-alpine' => "https://cdn.jsdelivr.net/npm/async-alpine@1.x.x/dist/async-alpine.script.js" + // 'filament-flatpickr' => __DIR__.'/../resources/dist/datepicker.js', ]; protected array $scripts = [