@@ -65,6 +65,7 @@ export type CalendarBarConfig = {
65
65
export interface DateListWindow {
66
66
list: Array <Date >
67
67
currentDate: Date
68
+ inputHandler: (value : Date ) => Date
68
69
selectDate(date : Date ): DateListWindow
69
70
nextDay(): DateListWindow
70
71
prevDay(): DateListWindow
@@ -79,11 +80,13 @@ class DateListWindowImpl implements DateListWindow {
79
80
startWeekOn: StartWeekOn
80
81
currentDate: Date
81
82
list: Array <Date >
83
+ inputHandler: (value : Date ) => Date
82
84
83
85
constructor (
84
86
view : View = ' Week' ,
85
87
startWeekOn : StartWeekOn = ' Monday' ,
86
- date : Date = new Date ()
88
+ date : Date = new Date (),
89
+ inputHandler : (value : Date ) => Date
87
90
) {
88
91
this .view = view
89
92
this .startWeekOn = view === ' Weekday' ? ' Monday' : startWeekOn
@@ -96,6 +99,7 @@ class DateListWindowImpl implements DateListWindow {
96
99
this .startWeekOn ,
97
100
this .currentDate
98
101
)
102
+ this .inputHandler = inputHandler
99
103
}
100
104
101
105
nextDay(): DateListWindow {
@@ -128,6 +132,9 @@ class DateListWindowImpl implements DateListWindow {
128
132
isValid (date ) ? date : new Date ()
129
133
)
130
134
this .list = this .generateDateList ()
135
+
136
+ // CalendarBar を経由して変更を通知
137
+ this .inputHandler (this .currentDate )
131
138
return this
132
139
}
133
140
@@ -211,28 +218,18 @@ export default class CalendarBar extends Vue {
211
218
dateListWindow: DateListWindow = new DateListWindowImpl (
212
219
this .config ?.view ?? ' Week' ,
213
220
this .config ?.startWeekOn ?? ' Monday' ,
214
- this .date ?? new Date ()
221
+ this .value ?? new Date (),
222
+ this .input
215
223
)
216
224
217
- @Emit (' changeCurrentDate' )
218
- changeCurrentDate(): Date {
219
- return this .dateListWindow .currentDate
220
- }
221
-
222
- private get date(): Date {
223
- return this .value
224
- }
225
-
226
225
@Emit ()
227
226
public input(value : Date ) {
228
227
return value
229
228
}
230
229
231
- @Watch (' dateListWindow.currentDate' , { immediate: true })
232
- // @Watch('dateListWindow.currentDate')
233
- onChangeCurrentDate() {
234
- this .input (this .dateListWindow .currentDate )
235
- this .changeCurrentDate ()
230
+ @Watch (' value' , { immediate: true })
231
+ onValueChanged(newValue : Date ) {
232
+ this .dateListWindow .selectDate (newValue )
236
233
}
237
234
238
235
get currentMonthString(): string {
0 commit comments