1
0
mirror of https://github.com/axzilla/templui.git synced 2025-02-21 00:53:18 +00:00

hotfix: make datepicker work again

This commit is contained in:
axzilla 2024-11-25 15:59:26 +07:00
parent 0485471ba9
commit a5d3e6e065
2 changed files with 40 additions and 18 deletions

View File

@ -27,6 +27,8 @@ type DatepickerProps struct {
// Class adds custom CSS classes
Class string
Value string
// Attributes for additional HTML attributes and Alpine.js bindings
Attributes templ.Attributes
}
@ -45,9 +47,10 @@ type DatepickerProps struct {
templ Datepicker(props DatepickerProps) {
<div
data-date-format={ props.Format }
data-date-value={ props.Value }
x-data="{
datePickerOpen: false,
datePickerValue: '',
datePickerValue: $el.getAttribute('data-date-value'),
datePickerFormat: $el.getAttribute('data-date-format'),
datePickerMonth: '',
datePickerYear: '',
@ -153,6 +156,9 @@ templ Datepicker(props DatepickerProps) {
}"
x-init="
currentDate = new Date();
if (datePickerValue) {
currentDate = new Date(Date.parse(datePickerValue));
}
datePickerMonth = currentDate.getMonth();
datePickerYear = currentDate.getFullYear();
datePickerDay = currentDate.getDate();
@ -168,6 +174,7 @@ templ Datepicker(props DatepickerProps) {
id={ props.ID }
name={ props.Name }
placeholder={ props.Placeholder }
:value="datePickerValue"
x-modelable="datePickerValue"
@click="toggleDatePicker()"
x-on:keydown.escape="datePickerOpen = false"

File diff suppressed because one or more lines are too long