@@ -16,7 +16,7 @@ import {
1616 focusEvent ,
1717} from "../../controls/eventHandlerControl" ;
1818import { LabelControl } from "../../controls/labelControl" ;
19- import { stringExposingStateControl } from "../../controls/codeStateControl" ;
19+ import { stringExposingStateControl , withLinkedDefaultValue } from "../../controls/codeStateControl" ;
2020import { UICompBuilder , withDefault } from "../../generators" ;
2121import { CommonNameConfig , depsConfig , withExposingConfigs } from "../../generators/withExposing" ;
2222import { formDataChildren , FormDataPropertyView } from "../formComp/formDataConstants" ;
@@ -229,19 +229,14 @@ const getFormattedDate = (
229229}
230230
231231const DatePickerTmpCmp = new UICompBuilder ( childrenMap , ( props ) => {
232- const defaultValue = { ...props . defaultValue } . value ;
233232 const value = { ...props . value } . value ;
234-
233+
235234 let time : dayjs . Dayjs | null = null ;
236235 if ( value !== '' ) {
237236 time = dayjs ( value , DateParser ) ;
238237 }
239-
240- const [ tempValue , setTempValue ] = useState < dayjs . Dayjs | null > ( time ) ;
241238
242- useEffect ( ( ) => {
243- props . value . onChange ( defaultValue ) ;
244- } , [ defaultValue ] ) ;
239+ const [ tempValue , setTempValue ] = useState < dayjs . Dayjs | null > ( time ) ;
245240
246241 useEffect ( ( ) => {
247242 const newValue = value ? dayjs ( value , DateParser ) : null ;
@@ -380,7 +375,10 @@ const DatePickerTmpCmp = new UICompBuilder(childrenMap, (props) => {
380375 . setExposeMethodConfigs ( dateRefMethods )
381376 . build ( ) ;
382377
383- export const datePickerControl = migrateOldData ( DatePickerTmpCmp , fixOldInputCompData ) ;
378+ export const datePickerControl = migrateOldData (
379+ withLinkedDefaultValue ( DatePickerTmpCmp , "defaultValue" , "value" ) ,
380+ fixOldInputCompData
381+ ) ;
384382
385383export function fixOldDateOrTimeRangeData ( oldData : any ) {
386384 if ( ! oldData ) return oldData ;
@@ -414,17 +412,14 @@ let DateRangeTmpCmp = (function () {
414412 } ;
415413
416414 return new UICompBuilder ( childrenMap , ( props ) => {
417- const defaultStart = { ...props . defaultStart } . value ;
418415 const startValue = { ...props . start } . value ;
419-
420- const defaultEnd = { ...props . defaultEnd } . value ;
421416 const endValue = { ...props . end } . value ;
422417
423418 let start : dayjs . Dayjs | null = null ;
424419 if ( startValue !== '' ) {
425420 start = dayjs ( startValue , DateParser ) ;
426421 }
427-
422+
428423 let end : dayjs . Dayjs | null = null ;
429424 if ( endValue !== '' ) {
430425 end = dayjs ( endValue , DateParser ) ;
@@ -433,14 +428,6 @@ let DateRangeTmpCmp = (function () {
433428 const [ tempStartValue , setTempStartValue ] = useState < dayjs . Dayjs | null > ( start ) ;
434429 const [ tempEndValue , setTempEndValue ] = useState < dayjs . Dayjs | null > ( end ) ;
435430
436- useEffect ( ( ) => {
437- props . start . onChange ( defaultStart ) ;
438- } , [ defaultStart ] ) ;
439-
440- useEffect ( ( ) => {
441- props . end . onChange ( defaultEnd ) ;
442- } , [ defaultEnd ] ) ;
443-
444431 useEffect ( ( ) => {
445432 const value = startValue ? dayjs ( startValue , DateParser ) : null ;
446433 setTempStartValue ( value ) ;
@@ -600,7 +587,14 @@ let DateRangeTmpCmp = (function () {
600587 . build ( ) ;
601588} ) ( ) ;
602589
603- export const dateRangeControl = migrateOldData ( DateRangeTmpCmp , fixOldDateOrTimeRangeData ) ;
590+ export const dateRangeControl = migrateOldData (
591+ withLinkedDefaultValue (
592+ withLinkedDefaultValue ( DateRangeTmpCmp , "defaultStart" , "start" ) ,
593+ "defaultEnd" ,
594+ "end"
595+ ) ,
596+ fixOldDateOrTimeRangeData
597+ ) ;
604598
605599const getTimeZoneInfo = ( timeZone : any , otherTimeZone : any ) => {
606600 const tz = timeZone === 'UserChoice' ? otherTimeZone : timeZone ;
0 commit comments