Merge pull request #7225 from Budibase/feature/24hr-date-picker

24hr date picker
This commit is contained in:
melohagan 2022-08-11 12:10:59 +01:00 committed by GitHub
commit 015b0568c0
4 changed files with 19 additions and 1 deletions

View File

@ -16,6 +16,7 @@
export let appendTo = undefined export let appendTo = undefined
export let timeOnly = false export let timeOnly = false
export let ignoreTimezones = false export let ignoreTimezones = false
export let time24hr = false
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
const flatpickrId = `${uuid()}-wrapper` const flatpickrId = `${uuid()}-wrapper`
@ -37,6 +38,7 @@
enableTime: timeOnly || enableTime || false, enableTime: timeOnly || enableTime || false,
noCalendar: timeOnly || false, noCalendar: timeOnly || false,
altInput: true, altInput: true,
time_24hr: time24hr || false,
altFormat: timeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y", altFormat: timeOnly ? "H:i" : enableTime ? "F j Y, H:i" : "F j, Y",
wrap: true, wrap: true,
appendTo, appendTo,
@ -49,6 +51,12 @@
}, },
} }
$: redrawOptions = {
timeOnly,
enableTime,
time24hr,
}
const handleChange = event => { const handleChange = event => {
const [dates] = event.detail const [dates] = event.detail
const noTimezone = enableTime && !timeOnly && ignoreTimezones const noTimezone = enableTime && !timeOnly && ignoreTimezones
@ -142,7 +150,7 @@
} }
</script> </script>
{#key timeOnly} {#key redrawOptions}
<Flatpickr <Flatpickr
bind:flatpickr bind:flatpickr
value={parseDate(value)} value={parseDate(value)}

View File

@ -10,6 +10,7 @@
export let error = null export let error = null
export let enableTime = true export let enableTime = true
export let timeOnly = false export let timeOnly = false
export let time24hr = false
export let placeholder = null export let placeholder = null
export let appendTo = undefined export let appendTo = undefined
export let ignoreTimezones = false export let ignoreTimezones = false
@ -30,6 +31,7 @@
{placeholder} {placeholder}
{enableTime} {enableTime}
{timeOnly} {timeOnly}
{time24hr}
{appendTo} {appendTo}
{ignoreTimezones} {ignoreTimezones}
on:change={onChange} on:change={onChange}

View File

@ -2875,6 +2875,12 @@
"key": "timeOnly", "key": "timeOnly",
"defaultValue": false "defaultValue": false
}, },
{
"type": "boolean",
"label": "24-Hour time",
"key": "time24hr",
"defaultValue": false
},
{ {
"type": "boolean", "type": "boolean",
"label": "Ignore time zones", "label": "Ignore time zones",

View File

@ -8,6 +8,7 @@
export let disabled = false export let disabled = false
export let enableTime = false export let enableTime = false
export let timeOnly = false export let timeOnly = false
export let time24hr = false
export let ignoreTimezones = false export let ignoreTimezones = false
export let validation export let validation
export let defaultValue export let defaultValue
@ -44,6 +45,7 @@
appendTo={document.getElementById("flatpickr-root")} appendTo={document.getElementById("flatpickr-root")}
{enableTime} {enableTime}
{timeOnly} {timeOnly}
{time24hr}
{ignoreTimezones} {ignoreTimezones}
{placeholder} {placeholder}
/> />