2019-07-13 11:35:57 +02:00
|
|
|
<script>
|
2020-02-03 10:50:30 +01:00
|
|
|
import flatpickr from "flatpickr"
|
|
|
|
import "flatpickr/dist/flatpickr.css"
|
|
|
|
import { onMount } from "svelte"
|
2020-09-01 23:00:30 +02:00
|
|
|
import { Label, Input } from "@budibase/bbui"
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
export let value
|
|
|
|
export let label
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
let input
|
|
|
|
let fpInstance
|
2019-08-07 10:03:49 +02:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
$: if (fpInstance) fpInstance.setDate(value)
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
onMount(() => {
|
|
|
|
fpInstance = flatpickr(input, {})
|
2019-07-13 11:35:57 +02:00
|
|
|
|
|
|
|
fpInstance.config.onChange.push(selectedDates => {
|
2020-02-03 10:50:30 +01:00
|
|
|
if (selectedDates.length > 0) value = new Date(selectedDates[0])
|
|
|
|
})
|
2019-07-13 11:35:57 +02:00
|
|
|
|
2020-02-03 10:50:30 +01:00
|
|
|
return fpInstance
|
|
|
|
})
|
2019-07-13 11:35:57 +02:00
|
|
|
</script>
|
|
|
|
|
2020-08-22 22:34:46 +02:00
|
|
|
<div class="bb-margin-m">
|
2020-09-01 22:28:38 +02:00
|
|
|
<Label small forAttr={'datepicker-label'}>{label}</Label>
|
2020-09-01 23:00:30 +02:00
|
|
|
<Input thin bind:this={input} />
|
2019-07-13 11:35:57 +02:00
|
|
|
</div>
|
2020-09-01 23:00:30 +02:00
|
|
|
|
|
|
|
<!-- TODO: Verify DatePicker Input works as expected when datetime property used again
|
|
|
|
in CreateEditColumn -->
|