Migration from V1
Importing
I has changed from 4 actions (datePicker, monthPicker, dateRangePicker and monthRangePicker) into only 1 action that you can name it by yourself.
<script>
import {
datePicker,
monthPicker,
dateRangePicker,
monthRangePicker
} from 'svelte-flatpickr-plus';
import svlatepickr from 'svelte-flatpickr-plus';
</script> Date picker
With a normally date picker you can just using your named action into use: directive.
<script>
import svlatepickr from 'svelte-flatpickr-plus';
</script>
<input use:datepicker />
<input use:svlatepickr /> Date range picker
With a date range picker you need to adding options object with mode: 'range' and passing it into your named action
<script>
import svlatepickr from 'svelte-flatpickr-plus';
const options ={
mode: 'range'
};
</script>
<input use:svlatepickr={options} /> Month picker
With a month picker you need to adding options object with isMonthPicker: true and passing it into your named action
<script>
import svlatepickr from 'svelte-flatpickr-plus';
const options ={
isMonthPicker: true
};
</script>
<input use:svlatepickr={options} /> Month range picker
With a month range picker you need to adding options object with isMonthPicker: true and mode: 'range' then passing it into your named action
<script>
import svlatepickr from 'svelte-flatpickr-plus';
const options ={
isMonthPicker: true,
mode: 'range'
};
</script>
<input use:svlatepickr={options} /> Theme Changer
Before user should import it from flatpickr_plus/dist/plugins/themeChanger for now has been renamed into themeChanger and can be imported from
svelte-flatpickr-plus directly and you can get a correct theme name from
themeNames object that you can import from the same directory.
<script>
import fpThemeChanger from 'flatpickr_plus/dist/plugins/themeChanger';
import { themeChanger, themeNames } from 'svelte-flatpickr-plus';
let themeName = $state(themeNames.default);
onMount(() => {
if (theme) {
const flatpickrThemePath = 'node_modules/flatpickr_plus/dist/themes/';
fpThemeChanger(themeName, flatpickrThemePath);
}
});
$effect(async () => {
if (themeName) {
themeChanger(themeName);
}
});
</script>