Skip to content
Merged
1 change: 1 addition & 0 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Before submitting a pull request:

- Check the codebase to ensure that your feature doesn't already exist.
- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
- Link resolved issues in the PR body using [GitHub keywords](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue) (`Closes #123`, `Fixes #123`, or `Resolves #123`) so they auto-close on merge.

## Requirements

Expand Down
13 changes: 13 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
## Summary

<!-- What changed and why? -->

## Linked issues

<!-- Use GitHub keywords so issues auto-close when this PR is merged. -->

Closes #

## Test plan

- [ ]
42 changes: 42 additions & 0 deletions .github/scripts/install-smoke-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -euo pipefail

LARAVEL="${1}"
PHP="${2}"
FILAMENT="${3}"

case "${LARAVEL}" in
13.*)
TESTBENCH='^11.0'
CARBON='^3.8.6'
PEST='^4.4.1'
PEST_PLUGIN_LARAVEL='^4.1'
;;
12.*)
TESTBENCH='^10.0'
CARBON='^3.8.6'
PEST='^3.8.6'
PEST_PLUGIN_LARAVEL='^3.1'
;;
*)
echo "Unsupported Laravel version for smoke tests: ${LARAVEL}" >&2
exit 1
;;
esac

composer require \
"laravel/framework:${LARAVEL}" \
"filament/forms:^${FILAMENT}" \
"filament/support:^${FILAMENT}" \
--no-interaction --no-update

composer require --dev \
"orchestra/testbench:${TESTBENCH}" \
"nesbot/carbon:${CARBON}" \
"filament/filament:^${FILAMENT}" \
"pestphp/pest:${PEST}" \
"pestphp/pest-plugin-laravel:${PEST_PLUGIN_LARAVEL}" \
--no-interaction --no-update

composer update --prefer-stable --prefer-dist --no-interaction
42 changes: 42 additions & 0 deletions .github/scripts/install-test-dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env bash

set -euo pipefail

LARAVEL="${1}"
STABILITY="${2}"

composer require "laravel/framework:${LARAVEL}" --no-interaction --no-update

case "${LARAVEL}" in
13.*)
TESTBENCH='^11.0'
CARBON='^3.8.6'
PEST='^4.4.1'
PEST_PLUGIN_LARAVEL='^4.1'
;;
12.*)
TESTBENCH='^10.0'
CARBON='^3.8.6'
PEST='^3.8.6'
PEST_PLUGIN_LARAVEL='^3.1'
;;
11.*)
TESTBENCH='^9.0'
CARBON='^3.8.4'
PEST='^3.8.6'
PEST_PLUGIN_LARAVEL='^3.1'
;;
*)
echo "Unsupported Laravel version: ${LARAVEL}" >&2
exit 1
;;
esac

composer require --dev \
"orchestra/testbench:${TESTBENCH}" \
"nesbot/carbon:${CARBON}" \
"pestphp/pest:${PEST}" \
"pestphp/pest-plugin-laravel:${PEST_PLUGIN_LARAVEL}" \
--no-interaction --no-update

composer update "--${STABILITY}" --prefer-dist --no-interaction
69 changes: 53 additions & 16 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,25 @@ on:
pull_request:
branches: [main]

defaults:
run:
shell: bash

jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest]
php: [8.4, 8.3, 8.2]
laravel: [12.*, 11.*]
php: [8.5, 8.4, 8.3, 8.2]
laravel: [13.*, 12.*, 11.*]
stability: [prefer-lowest, prefer-stable]
include:
- laravel: 12.*
testbench: ^10.0
carbon: ^3.8.6
pest-plugin-laravel: ^3.1
larastan: ^3.1
exclude:
- laravel: 13.*
php: 8.2
- laravel: 11.*
testbench: ^9.0
carbon: ^3.8.4
pest-plugin-laravel: ^3.1
larastan: ^3.1
php: 8.5

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }}

Expand All @@ -36,7 +34,6 @@ jobs:

- name: Configure Git line endings
if: runner.os == 'Windows'
shell: bash
run: git config --global core.autocrlf false

- name: Setup PHP
Expand All @@ -52,9 +49,7 @@ jobs:
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Install dependencies
run: |
composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.carbon }}" "pestphp/pest-plugin-laravel:${{ matrix.pest-plugin-laravel }}" "nunomaduro/larastan:${{ matrix.larastan }}" --no-interaction --no-update
composer update --${{ matrix.stability }} --prefer-dist --no-interaction
run: bash .github/scripts/install-test-dependencies.sh "${{ matrix.laravel }}" "${{ matrix.stability }}"

- name: List Installed Dependencies
run: composer show -D
Expand All @@ -64,3 +59,45 @@ jobs:

- name: Execute tests
run: vendor/bin/pest --ci --coverage --min=0

- name: Upload coverage to Codecov
if: matrix.os == 'ubuntu-latest' && matrix.php == '8.4' && matrix.laravel == '13.*' && matrix.stability == 'prefer-stable'
uses: codecov/codecov-action@v5
with:
files: build/logs/clover.xml
fail_ci_if_error: false

platform-smoke:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- php: 8.5
laravel: 13.*
filament: '5.0'
- php: 8.4
laravel: 13.*
filament: '5.0'
- php: 8.2
laravel: 12.*
filament: '4.0'

name: Smoke P${{ matrix.php }} - L${{ matrix.laravel }} - F${{ matrix.filament }}

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo
coverage: none

- name: Install dependencies
run: bash .github/scripts/install-smoke-dependencies.sh "${{ matrix.laravel }}" "${{ matrix.php }}" "${{ matrix.filament }}"

- name: Execute tests
run: vendor/bin/pest --ci --no-coverage
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
<p align="center">
<a href="https://github.com/coolsam726/flatpickr/actions?query=workflow%3Arun-tests+branch%3Amain"><img alt="Tests" src="https://img.shields.io/github/actions/workflow/status/coolsam726/flatpickr/run-tests.yml?branch=main&label=tests&style=for-the-badge&logo=github"></a>
<a href='https://github.com/coolsam726/flatpickr/actions/workflows/fix-php-code-style-issues.yml?query=workflow%3A%22Fix+PHP+Code+Styling%22+branch%3Amain'><img alt="Styling" src="https://img.shields.io/github/actions/workflow/status/coolsam726/flatpickr/fix-php-code-style-issues.yml?branch=main&label=code%20style&style=for-the-badge&logo=github"></a>
<a href="https://laravel.com"><img alt="Laravel v12.x" src="https://img.shields.io/badge/Laravel-v12.x-FF2D20?style=for-the-badge&logo=laravel"></a>
<a href="https://filamentphp.com"><img alt="Filament v4.x" src="https://img.shields.io/badge/FilamentPHP-v4.x-FB70A9?style=for-the-badge&logo=filament"></a>
<a href="https://tailwindcss.com"><img alt="Tailwind v4.x" src="https://img.shields.io/badge/Tailwindcss-v4.x-FB70A9?style=for-the-badge&logo=tailwindcss"></a>
<a href="https://php.net"><img alt="PHP 8.4" src="https://img.shields.io/badge/PHP-8.4-777BB4?style=for-the-badge&logo=php"></a>
<a href="https://packagist.org/packages/coolsam/flatpickr"><img alt="Packagist" src="https://img.shields.io/packagist/dt/coolsam/flatpickr.svg?style=for-the-badge&logo=count"></a>
<a href="https://github.com/coolsam726/flatpickr/actions/workflows/run-tests.yml"><img src="https://github.com/coolsam726/flatpickr/actions/workflows/run-tests.yml/badge.svg" alt="CI"></a>
<a href="https://codecov.io/gh/coolsam726/flatpickr"><img src="https://codecov.io/gh/coolsam726/flatpickr/branch/main/graph/badge.svg" alt="Coverage"></a>
<a href="https://packagist.org/packages/coolsam/flatpickr"><img src="https://img.shields.io/packagist/v/coolsam/flatpickr.svg" alt="Latest Version on Packagist"></a>
<a href="https://packagist.org/packages/coolsam/flatpickr"><img src="https://img.shields.io/packagist/dt/coolsam/flatpickr.svg" alt="Total Downloads"></a>
</p>

Use **[Flatpickr](https://flatpickr.js.org/)** as your datepicker in the Filament Forms and Panels.
![image](https://github.com/user-attachments/assets/334ea64a-48c3-48bc-a640-72162802a646)
Use **[Flatpickr](https://flatpickr.js.org/)** as your datepicker in Filament Forms and Panels.

![image](https://github.com/user-attachments/assets/334ea64a-48c3-48bc-a640-72162802a646)

## Supported Versions
| Package Version | Supported Filament Version(s) |
|-----------------|-------------------------------|
| v2.x | Filament v2 |
| v4.x | Filament v3 |
| v5.x | Filament v4 |

| Package | Filament | Laravel | PHP |
|---------|----------|---------|-----|
| **v5.x** (current) | 4.x, 5.x | 11.x – 13.x | 8.2 – 8.5 (PHP 8.5 from Laravel 12+; Laravel 13 from PHP 8.3+) |
| v4.x | 3.x | 10.x – 11.x | 8.1 – 8.3 |
| v2.x | 2.x | 9.x – 10.x | 8.0 – 8.2 |

## Installation

Expand Down Expand Up @@ -50,15 +48,16 @@ You can use the Flatpickr component from this package as:
* Week Picker,
* Multiple-Date Picker
* Month Picker
* Year Picker

Most of the fluent config methods are similar to [Flatpickr's official](https://flatpickr.js.org/options/) options in naming.

This package is also an extension of [Filament's DateTimePicker](https://filamentphp.com/docs/3.x/forms/fields/date-time-picker), so most of the methods are similar to the ones in the DateTimePicker component. You can use the Flatpickr component as a drop-in replacement for the DateTimePicker component.
This package is inspired by [Filament's DateTimePicker](https://filamentphp.com/docs/4.x/forms/overview) and can be used as a flexible alternative with Flatpickr-specific options.

Here are some examples of the methods. Refer to Flatpickr's Official Documentation for details on each of the configurations.

```php
use Coolsam\FilamentFlatpickr\Forms\Components\Flatpickr;
use Coolsam\Flatpickr\Forms\Components\Flatpickr;

// Basic, Date Field
Flatpickr::make('test_field') // Minimal Config as a datepicker
Expand All @@ -84,17 +83,18 @@ Flatpickr::make('test_field')
->conjunction(',') // Applicable only for the MultiDatePicker: Separate inputs using this conjunction. The package will use this conjunction to explode the inputs to an array.
->inline(true) // Display the datepicker inline with the input, instead of using a popover.
->disableMobile(true) // Disable mobile-version of the datepicker on mobile devices.
->mode(\Coolsam\FilamentFlatpickr\Enums\FlatpickrMode::RANGE) // Set the mode as single, range or multiple. Alternatively, you can just use ->range() or ->multiple()
->monthSelectorType(\Coolsam\FilamentFlatpickr\Enums\FlatpickrMonthSelectorType::DROPDOWN)
->mode(\Coolsam\Flatpickr\Enums\FlatpickrMode::RANGE) // Set the mode as single, range or multiple. Alternatively, you can just use ->range() or ->multiple()
->monthSelectorType(\Coolsam\Flatpickr\Enums\FlatpickrMonthSelectorType::DROPDOWN)
->shorthandCurrentMonth(true)
->noCalendar(true) // use this in conjunction with `time()` to have a timePicker
->position(\Coolsam\FilamentFlatpickr\Enums\FlatpickrPosition::AUTO_CENTER)
->position(\Coolsam\Flatpickr\Enums\FlatpickrPosition::AUTO_CENTER)
->showMonths(1)
->weekNumbers(true)
->time24hr(true)
->timePicker() // Configure a timepicker out of the box
->weekPicker() // configure a week picker out of the box
->monthPicker() // configure a month picker out of the box
->yearPicker() // configure a year picker out of the box
->rangePicker() // configure a date range picker out of the box
->multiplePicker() // Configure a multiple date picker out of the box
;
Expand All @@ -106,6 +106,7 @@ Flatpickr::make('test_field')
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('start_time')->timePicker(),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('week_number')->weekPicker()->format('W Y'),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('month')->monthPicker()->format('Y-m')->displayFormat('F Y'),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('year')->yearPicker(),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('range')->rangePicker(),
\Coolsam\Flatpickr\Forms\Components\Flatpickr::make('occupied_slots')->multiplePicker()->format('Y-m-d')->displayFormat('F j, Y'),
```
Expand All @@ -117,7 +118,7 @@ You can set the package's theme globally under the `theme` config in the `confi
The `\Coolsam\Flatpickr\Enums\FlatpickrTheme::DEFAULT` theme is already set by default and conforms to the filament design system.

```php
use Coolsam\FilamentFlatpickr\Enums\FlatpickrTheme;
use Coolsam\Flatpickr\Enums\FlatpickrTheme;
return [
'theme' => FlatpickrTheme::AIRBNB,
];
Expand All @@ -126,7 +127,7 @@ See the screenshots below for the different themes.

## State Types
The package supports the following state types:
- `string` or `CarbonInterface` for DateTimePicker, DatePicker, TimePicker, WeekPicker, MonthPicker
- `string` or `CarbonInterface` for DateTimePicker, DatePicker, TimePicker, WeekPicker, MonthPicker, YearPicker
- `array` for RangePicker, MultiplePicker (an array of date strings or CarbonInterface instances)

## Screenshots
Expand Down
7 changes: 3 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
"filament/filament": "^4.0|^5.0",
"laravel/pint": "^1.0",
"nunomaduro/larastan": "^3.1.0",
"orchestra/testbench": "^9.12",
"pestphp/pest-plugin-laravel": "^3.1",
"pestphp/pest-plugin-livewire": "^3.0",
"orchestra/testbench": "^10.0|^11.0",
"pestphp/pest-plugin-laravel": "^3.1|^4.1",
"phpstan/extension-installer": "^1.4.3",
"spatie/laravel-ray": "^1.39"
},
Expand Down Expand Up @@ -73,4 +72,4 @@
},
"minimum-stability": "dev",
"prefer-stable": true
}
}
Loading
Loading