@@ -37,7 +37,9 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
37
37
watch (
38
38
internalModelValue ,
39
39
( ) => {
40
- emit ( 'internal-model-change' , internalModelValue . value ) ;
40
+ if ( typeof props . onInternalModelChange === 'function' ) {
41
+ emit ( 'internal-model-change' , internalModelValue . value , emitModelValue ( true ) ) ;
42
+ }
41
43
} ,
42
44
{ deep : true } ,
43
45
) ;
@@ -228,8 +230,10 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
228
230
( ( internalModelValue . value as Date [ ] ) || [ ] ) . map ( ( date ) => toModelType ( date ) as string ) ;
229
231
230
232
// Parent internal to external function mapper that will return proper date format based on provided config
231
- const mapInternalDatesToExternal = ( ) => {
232
- sanitizeModelValue ( ) ;
233
+ const mapInternalDatesToExternal = ( noSanitize : boolean = false ) => {
234
+ if ( ! noSanitize ) {
235
+ sanitizeModelValue ( ) ;
236
+ }
233
237
if ( props . modelAuto ) return getModelAutoForExternal ( ) ;
234
238
if ( defaultedMultiDates . value . enabled ) return getMultiDatesForExternal ( ) ;
235
239
if ( Array . isArray ( internalModelValue . value ) ) {
@@ -343,7 +347,8 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
343
347
return convertZonedModelToLocal ( val ) ;
344
348
} ;
345
349
346
- const emitValue = ( value : ModelValue , useTz = false ) : void => {
350
+ const emitValue = ( value : ModelValue , useTz = false , returnOnly = false ) => {
351
+ if ( returnOnly ) return value ;
347
352
emit ( 'update:model-value' , value ) ;
348
353
if ( defaultedTz . value . emitTimezone && useTz ) {
349
354
const zonedValue = Array . isArray ( value )
@@ -384,20 +389,27 @@ export const useExternalInternalMapper = (emit: VueEmit, props: AllPropsType, is
384
389
} ;
385
390
386
391
// eslint-disable-next-line @typescript-eslint/no-explicit-any
387
- const modeEmitter = ( mapper : any ) => emitValue ( convertType ( mapInternalToSpecificExternal ( mapper ) ) ) ;
392
+ const modeEmitter = ( mapper : any , returnOnly : boolean ) =>
393
+ emitValue ( convertType ( mapInternalToSpecificExternal ( mapper ) ) , false , returnOnly ) ;
394
+
395
+ const emitWeekPicker = ( returnOnly : boolean ) => {
396
+ const value = mapInternalWeekPickerToExternal ( ) ;
397
+ if ( returnOnly ) return value ;
398
+ return emit ( 'update:model-value' , mapInternalWeekPickerToExternal ( ) ) ;
399
+ } ;
388
400
389
401
/**
390
402
* When date is selected, emit event to update modelValue on external,
391
403
* and format input value
392
404
*/
393
- const emitModelValue = ( ) : void => {
405
+ const emitModelValue = ( returnOnly : boolean = false ) => {
394
406
formatInputValue ( ) ;
395
407
396
- if ( props . monthPicker ) return modeEmitter ( getMonthVal ) ;
397
- if ( props . timePicker ) return modeEmitter ( getTimeVal ) ;
398
- if ( props . yearPicker ) return modeEmitter ( getYear ) ;
399
- if ( props . weekPicker ) return emit ( 'update:model-value' , mapInternalWeekPickerToExternal ( ) ) ;
400
- return emitValue ( mapInternalDatesToExternal ( ) , true ) ;
408
+ if ( props . monthPicker ) return modeEmitter ( getMonthVal , returnOnly ) ;
409
+ if ( props . timePicker ) return modeEmitter ( getTimeVal , returnOnly ) ;
410
+ if ( props . yearPicker ) return modeEmitter ( getYear , returnOnly ) ;
411
+ if ( props . weekPicker ) return emitWeekPicker ( returnOnly ) ;
412
+ return emitValue ( mapInternalDatesToExternal ( returnOnly ) , true , returnOnly ) ;
401
413
} ;
402
414
403
415
// Check if there is any selection before emitting value, to prevent null setting
0 commit comments