@@ -92,6 +92,7 @@ import {
9292 provide ,
9393 watch ,
9494 InputHTMLAttributes ,
95+ computed ,
9596} from ' vue' ;
9697
9798import {
@@ -111,7 +112,7 @@ import {
111112} from ' @variantjs/core' ;
112113import { Options , Placement } from ' @popperjs/core' ;
113114import useConfigurationWithClassesList from ' ../use/useConfigurationWithClassesList' ;
114- import { useSelectedDate , useActiveDate , useCalendarView , useDateFormatting , useDateParsing , useCalendarState , useVisibleDate } from ' ../use/datepicker' ;
115+ import { useSelectedDate , useActiveDate , useCalendarView , useDateFormatting , useDateParsing , useCalendarState , useVisibleDate , useDateLocale } from ' ../use/datepicker' ;
115116import { getVariantPropsWithClassesList } from ' ../utils/getVariantProps' ;
116117import { TDatepickerOptions , TDatepickerValue } from ' ../types' ;
117118import DatepickerDropdown from ' ./TDatepicker/DatepickerDropdown.vue' ;
@@ -275,7 +276,7 @@ export default defineComponent({
275276 },
276277 closeOnSelect: {
277278 type: Boolean ,
278- default: true ,
279+ default: undefined ,
279280 },
280281 show: {
281282 type: Boolean ,
@@ -289,6 +290,10 @@ export default defineComponent({
289290 type: [String , Object ] as PropType <string | HTMLElement >,
290291 default: ' body' ,
291292 },
293+ showOkButton: {
294+ type: Boolean ,
295+ default: undefined ,
296+ },
292297 },
293298 emits: {
294299 change : (e : CustomEvent ) => e instanceof CustomEvent ,
@@ -308,17 +313,28 @@ export default defineComponent({
308313 // - In multiple add an ok button
309314 // - Add a clear button
310315 const { configuration, attributes } = useConfigurationWithClassesList <TDatepickerOptions >(TDatepickerConfig , TDatepickerClassesKeys );
311- const { parseDate } = useDateParsing (configuration );
316+ const locale = useDateLocale ({ configuration });
317+ const { parseDate } = useDateParsing ({ configuration , locale });
312318 const { selectedDate, selectedDateHolder, setSelectedDate, addSelectedDate, getInitialSelectedDate, resetRangeSelection } = useSelectedDate (props , configuration , parseDate );
313319 const { activeDate, activeDateIsVisible, initActiveDate, setActiveDate, hideActiveDate, showActiveDate } = useActiveDate ({
314320 configuration , selectedDate , parseDate ,
315321 });
316- const { formatDate, formattedDate, userFormattedDate } = useDateFormatting (configuration , selectedDate );
322+ const { formatDate, formattedDate, userFormattedDate } = useDateFormatting ({ configuration , selectedDate , locale } );
317323 const { currentView, initView, setCurrentView } = useCalendarView (configuration );
318- const { shown, doShow, doHide, isMultiple, isDropdownClosed, isDropdownOpened } = useCalendarState (configuration );
319-
324+ const { shown, doShow, doHide, isMultiple, isRange, isDropdownClosed, isDropdownOpened } = useCalendarState (configuration );
320325 const { visibleDate, resetVisibleDate } = useVisibleDate ({ activeDate , configuration });
326+ const shouldCloseOnSelect = computed <boolean >(() => {
327+ if (configuration .closeOnSelect === undefined ) {
328+ return isRange .value || ! isMultiple .value ;
329+ }
321330
331+ return configuration .closeOnSelect ;
332+ });
333+
334+ const okButtonHandler = () => {
335+ doHide ();
336+ };
337+
322338 const initAllViewData = () => {
323339 initView ();
324340 initActiveDate ();
@@ -350,7 +366,7 @@ export default defineComponent({
350366 emit (' input' , event );
351367 emit (' update:modelValue' , formattedDate .value );
352368
353- if (configuration . closeOnSelect && isDropdownOpened .value ) {
369+ if (shouldCloseOnSelect . value && isDropdownOpened .value ) {
354370 doHide ();
355371 }
356372 });
@@ -537,6 +553,10 @@ export default defineComponent({
537553 provide (' currentView' , currentView );
538554
539555 provide (' userFormattedDate' , userFormattedDate );
556+
557+ provide (' locale' , locale );
558+
559+ provide (' okButtonHandler' , okButtonHandler );
540560
541561 return {
542562 configuration ,
0 commit comments