Skip to content

Commit

Permalink
v3.3.3 (#1792)
Browse files Browse the repository at this point in the history
* Add more FlatpickrJS options
  • Loading branch information
lrljoe authored Jul 23, 2024
1 parent e74d834 commit b5d299d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 11 deletions.
24 changes: 24 additions & 0 deletions docs/filter-types/filters-daterange.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,30 @@ public function filters(): array
}
```

A full list of options is below, please see the Flatpickr documentation for reference as to purpose:
| Config Option | Type | Default | Description |
| ------------- | ------------- | ------------- | ------------- |
| allowInput | Boolean | false | Allows the user to enter a date directly into the input field. By default, direct entry is disabled. |
| altFormat | String | "F j, Y" | Exactly the same as date format, but for the altInput field |
| altInput | Boolean | false | Show the user a readable date (as per altFormat), but return something totally different to the server. |
| ariaDateFormat | String | "F j, Y" | Defines how the date will be formatted in the aria-label for calendar days, using the same tokens as dateFormat. If you change this, you should choose a value that will make sense if a screen reader reads it out loud. |
| dateFormat | String | 'Y-m-d' | A string of characters which are used to define how the date will be displayed in the input box |
| defaultDate | String | null | Sets the initial selected date |
| defaultHour | Number | 12 | Initial value of the hour element. |
| defaultMinute | Number | 0 | Initial value of the minute element. |
| earliestDate | String/Date | null | The minimum date that a user can start picking from (inclusive) |
| enableTime | Boolean | false | Enables time picker |
| enableSeconds | Boolean | false | Enables seconds in the time picker. |
| hourIncrement | Integer | 1 | Adjusts the step for the hour input (incl. scrolling) |
| latestDate | String/Date | null | The maximum date that a user can pick to (inclusive) |
| locale | String | en | The locale used (see below) |
| minuteIncrement | Integer | 5 | Adjusts the step for the minute input (incl. scrolling) |
| placeholder | String | null | Set a placeholder value for the input field |
| shorthandCurrentMonth | Boolean | false | Show the month using the shorthand version (ie, Sep instead of September). |
| time_24hr | Boolean | false | Displays time picker in 24 hour mode without AM/PM selection when enabled. |
| weekNumbers | Boolean | false | Enables display of week numbers in calendar. |


## Configuration
By default, this filter will inject the Flatpickr JS Library and CSS. However, you can customise this behaviour using the configuration file.

Expand Down
29 changes: 19 additions & 10 deletions resources/js/laravel-livewire-tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,26 @@ document.addEventListener('alpine:init', () => {
wireValues: wire.entangle('filterComponents.' + filterKey),
flatpickrInstance: flatpickr(refLocation, {
mode: 'range',
clickOpens: true,
altFormat: filterConfig['altFormat'] ?? "F j, Y",
altInput: filterConfig['altInput'] ?? false,
allowInput: filterConfig['allowInput'] ?? false,
allowInvalidPreload: true,
defaultDate: [],
ariaDateFormat: filterConfig['ariaDateFormat'],
allowInput: filterConfig['allowInput'],
altFormat: filterConfig['altFormat'],
altInput: filterConfig['altInput'],
dateFormat: filterConfig['dateFormat'],
locale: 'en',
minDate: filterConfig['earliestDate'],
maxDate: filterConfig['latestDate'],
ariaDateFormat: filterConfig['ariaDateFormat'] ?? "F j, Y",
clickOpens: true,
dateFormat: filterConfig['dateFormat'] ?? "Y-m-d",
defaultDate: filterConfig['defaultDate'] ?? null,
defaultHour: filterConfig['defaultHour'] ?? 12,
defaultMinute: filterConfig['defaultMinute'] ?? 0,
enableTime: filterConfig['enableTime'] ?? false,
enableSeconds: filterConfig['enableSeconds'] ?? false,
hourIncrement: filterConfig['hourIncrement'] ?? 1,
locale: filterConfig['locale'] ?? 'en',
minDate: filterConfig['earliestDate'] ?? null,
maxDate: filterConfig['latestDate'] ?? null,
minuteIncrement: filterConfig['minuteIncrement'] ?? 5,
shorthandCurrentMonth: filterConfig['shorthandCurrentMonth'] ?? false,
time_24hr: filterConfig['time_24hr'] ?? false,
weekNumbers: filterConfig['weekNumbers'] ?? false,
onOpen: function () {
window.childElementOpen = true;
},
Expand Down
2 changes: 1 addition & 1 deletion resources/js/laravel-livewire-tables.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b5d299d

Please sign in to comment.