templates/vitekit/__/vite-template-main/js/files/forms/datepicker.ts
2026-04-12 21:03:18 +03:00

23 lines
927 B
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import datepicker from 'js-datepicker'
import { flsModules } from '../modules.ts'
import 'js-datepicker/src/datepicker'
const datepickerSelectors = document.querySelectorAll<HTMLElement>('[data-datepicker]')
if (datepickerSelectors.length) {
datepickerSelectors.forEach((datepickerSelector) => {
const picker = datepicker(datepickerSelector, {
customDays: ['Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб', 'Вс'],
customMonths: ['Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'],
overlayButton: 'Применить',
overlayPlaceholder: 'Год (4 цифры)',
startDay: 1,
formatter: (input, date) => {
const value = date.toLocaleDateString()
input.value = value
},
})
flsModules.datepicker = picker
})
}