@progress/kendo-react-dateinputs 5.17.0-dev.202308081122 → 5.17.0-dev.202308081128

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,6 +44,7 @@ export interface MultiViewCalendarState {
44
44
  value: Date | Date[] | SelectionRange | null;
45
45
  activeView: CalendarViewEnum;
46
46
  focusedDate: Date;
47
+ navigateDate: Date;
47
48
  }
48
49
  /** @hidden */
49
50
  export declare class MultiViewCalendarWithoutContext extends React.Component<MultiViewCalendarProps, MultiViewCalendarState> {
@@ -155,9 +156,9 @@ export declare class MultiViewCalendarWithoutContext extends React.Component<Mul
155
156
  protected rangeWithFocused: (range: SelectionRange, focusedDate: Date) => SelectionRange;
156
157
  protected generateRange: (candidate: Date, value: SelectionRange) => SelectionRange;
157
158
  protected canNavigate: (action: Action) => boolean;
158
- protected isListInRange: (list: Date[]) => boolean;
159
- protected navigate: (action: Action) => void;
160
- protected move: (action: Action) => Date;
159
+ protected isInMonth(date: Date, month: Date): boolean;
160
+ protected navigate: (action: Action, date: Date) => void;
161
+ protected move: (action: Action, date: Date) => Date;
161
162
  protected clampDate: (value: Date) => Date;
162
163
  protected shouldAutoCorrect: (candidate: Date, value: SelectionRange) => boolean;
163
164
  private handleCellEnter;
@@ -28,7 +28,7 @@ import * as React from 'react';
28
28
  import * as PropTypes from 'prop-types';
29
29
  import { registerForIntl, provideIntlService, registerForLocalization, provideLocalizationService } from '@progress/kendo-react-intl';
30
30
  import { classNames, guid, Keys, createPropsContext, withPropsContext } from '@progress/kendo-react-common';
31
- import { cloneDate, isEqualDate, getDate } from '@progress/kendo-date-math';
31
+ import { cloneDate, isEqualDate, getDate, firstDayOfMonth, lastDayOfMonth } from '@progress/kendo-date-math';
32
32
  import { Button } from '@progress/kendo-react-buttons';
33
33
  import { chevronLeftIcon, chevronRightIcon } from '@progress/kendo-svg-icons';
34
34
  import { Action, CalendarViewEnum, EMPTY_SELECTIONRANGE } from '../models';
@@ -122,17 +122,13 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
122
122
  || _this.service.isInSameView(candidate, _this.min)
123
123
  || _this.service.isInSameView(candidate, _this.max);
124
124
  };
125
- _this.isListInRange = function (list) {
126
- return _this.min < list[0]
127
- && _this.max > list[Math.max(0, (_this.props.views || MultiViewCalendarWithoutContext.defaultProps.views) - 1)];
128
- };
129
- _this.navigate = function (action) {
125
+ _this.navigate = function (action, date) {
130
126
  _this.calculateFocusFromValue = false;
131
- var candidate = _this.move(action);
132
- _this.setState({ focusedDate: candidate });
127
+ var candidate = _this.move(action, date);
128
+ _this.setState({ navigateDate: candidate, focusedDate: candidate });
133
129
  };
134
- _this.move = function (action) {
135
- return _this.clampDate(_this.service.move(_this.focusedDate, action));
130
+ _this.move = function (action, date) {
131
+ return _this.clampDate(_this.service.move(date, action));
136
132
  };
137
133
  _this.clampDate = function (value) {
138
134
  return dateInRange(value, _this.min, _this.max);
@@ -192,10 +188,19 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
192
188
  _this.handleDateChange(event);
193
189
  };
194
190
  _this.handlePrevButtonClick = function () {
195
- _this.navigate(Action.PrevView);
191
+ var action = Action.PrevView;
192
+ if (_this.state.activeView > 0 && _this.focusedDate.getFullYear() > _this.dates[0].getFullYear()) {
193
+ _this.navigate(action, _this.move(action, _this.focusedDate));
194
+ }
195
+ else {
196
+ var inMonthDate = _this.isInMonth(_this.focusedDate, _this.dates[1])
197
+ ? _this.move(action, _this.focusedDate)
198
+ : _this.focusedDate;
199
+ _this.navigate(action, inMonthDate);
200
+ }
196
201
  };
197
202
  _this.handleNextButtonClick = function () {
198
- _this.navigate(Action.NextView);
203
+ _this.navigate(Action.NextView, _this.focusedDate);
199
204
  };
200
205
  _this.handleKeyDown = function (event) {
201
206
  var keyCode = event.keyCode;
@@ -213,6 +218,10 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
213
218
  if (isEqualDate(_this.focusedDate, candidate)) {
214
219
  return;
215
220
  }
221
+ if (_this.dates && _this.service && !_this.service.isInArray(candidate, _this.dates)) {
222
+ _this.setState({ navigateDate: candidate });
223
+ }
224
+ ;
216
225
  _this.calculateFocusFromValue = false;
217
226
  _this.setState({ focusedDate: candidate });
218
227
  }
@@ -221,7 +230,7 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
221
230
  _this.handleViewChange = function (_a) {
222
231
  var view = _a.view;
223
232
  _this.calculateFocusFromValue = false;
224
- _this.setState({ activeView: view });
233
+ _this.setState(function (state) { return ({ activeView: view, navigateDate: state.focusedDate }); });
225
234
  };
226
235
  _this.handleDateChange = function (event) {
227
236
  var focusedDate = cloneDate(event.value);
@@ -282,6 +291,9 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
282
291
  break;
283
292
  }
284
293
  _this.valueDuringOnChange = value;
294
+ if (event.isTodayClick) {
295
+ _this.setState({ navigateDate: focusedDate });
296
+ }
285
297
  _this.setState({ value: value, focusedDate: focusedDate });
286
298
  _this.valueDuringOnChange = value;
287
299
  var onChange = _this.props.onChange;
@@ -308,7 +320,8 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
308
320
  _this.state = {
309
321
  value: value,
310
322
  activeView: activeView,
311
- focusedDate: focusedDate
323
+ focusedDate: focusedDate,
324
+ navigateDate: focusedDate
312
325
  };
313
326
  _this.activeRangeEnd = extractActiveRange(selectedRange, selectedDate);
314
327
  _this.bus = new BusViewService(_this.handleViewChange);
@@ -445,6 +458,7 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
445
458
  this.bus.configure(this.bottomView, this.topView);
446
459
  var activeView = viewInRange(this.state.activeView, this.bottomView, this.topView);
447
460
  this.service = this.bus.service(activeView, this.intl);
461
+ // console.log('this.service', this.service);
448
462
  this.selectedDate = extractDateFromValue(this.min, this.max, this.value);
449
463
  this.selectedMultiple = extractMultipleFromValue(this.min, this.max, this.value);
450
464
  this.selectedRange = extractRangeFromValue(this.value);
@@ -463,10 +477,10 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
463
477
  var prevBtnAria = { 'aria-disabled': isPrevDisabled };
464
478
  var nextBtnAria = { 'aria-disabled': isNextDisabled };
465
479
  var didViewChange = this.lastView !== activeView;
466
- var isDateInList = this.dates && this.service.isInArray(this.focusedDate, this.dates);
480
+ var isDateInMonth = this.dates && this.isInMonth(this.state.navigateDate, this.dates[0]);
467
481
  var didViewsCountChange = this.lastViewsCount !== this.props.views;
468
- if (!isDateInList || didViewChange || didViewsCountChange) {
469
- this.dates = this.service.datesList(this.focusedDate, this.props.views || HorizontalViewList.defaultProps.views);
482
+ if (!isDateInMonth || didViewChange || didViewsCountChange) {
483
+ this.dates = this.service.datesList(this.state.navigateDate, this.props.views || HorizontalViewList.defaultProps.views);
470
484
  }
471
485
  var activeDate = cloneDate(this.dates && this.dates[0] ? this.dates[0] : getToday());
472
486
  return (React.createElement("div", { ref: function (el) { _this._element = el; }, className: wrapperClassName, id: this.props.id || this.wrapperID, "aria-labelledby": this.props.ariaLabelledBy, "aria-describedby": this.props.ariaDescribedBy, tabIndex: !this.props.disabled ? this.props.tabIndex : undefined, onFocus: this.handleFocus, onBlur: this.handleBlur, onMouseDown: this.handleMouseDown, onClick: this.handleClick, onKeyDown: this.handleKeyDown, "aria-disabled": this.props.disabled, dir: this.props.dir },
@@ -476,6 +490,13 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
476
490
  React.createElement(Button, __assign({ type: "button", className: "k-calendar-nav-next", icon: this.isRtl ? 'chevron-left' : 'chevron-right', svgIcon: this.isRtl ? chevronLeftIcon : chevronRightIcon, fillMode: "flat", title: nextViewTittle, disabled: isNextDisabled, onClick: this.handleNextButtonClick }, nextBtnAria)))) }),
477
491
  React.createElement(HorizontalViewList, { ref: function (el) { _this.calendarViewList = el; }, dates: this.dates, activeView: activeView, focusedDate: this.focusedDate, min: this.min, max: this.max, bus: this.bus, service: this.service, selectionRange: visualizedRange, value: this.selectedMultiple || this.selectedDate, cellUID: this.cellUID, views: this.props.views, onChange: this.handleDateChange, showWeekNumbers: this.props.weekNumber, onCellEnter: this.handleCellEnter, cell: this.props.cell, weekCell: this.props.weekCell, headerTitle: this.props.headerTitle, verticalView: this.props.mobileMode })));
478
492
  };
493
+ // protected isListInRange = (list: Date[]): boolean => {
494
+ // return this.min < list[0]
495
+ // && this.max > list[Math.max(0, (this.props.views || MultiViewCalendarWithoutContext.defaultProps.views) - 1)];
496
+ // };
497
+ MultiViewCalendarWithoutContext.prototype.isInMonth = function (date, month) {
498
+ return !!month && firstDayOfMonth(month) <= date && date <= lastDayOfMonth(month);
499
+ };
479
500
  /**
480
501
  * @hidden
481
502
  */
@@ -5,7 +5,7 @@ export var packageMetadata = {
5
5
  name: '@progress/kendo-react-dateinputs',
6
6
  productName: 'KendoReact',
7
7
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
8
- publishDate: 1691491628,
8
+ publishDate: 1691491790,
9
9
  version: '',
10
10
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
11
11
  };
@@ -44,6 +44,7 @@ export interface MultiViewCalendarState {
44
44
  value: Date | Date[] | SelectionRange | null;
45
45
  activeView: CalendarViewEnum;
46
46
  focusedDate: Date;
47
+ navigateDate: Date;
47
48
  }
48
49
  /** @hidden */
49
50
  export declare class MultiViewCalendarWithoutContext extends React.Component<MultiViewCalendarProps, MultiViewCalendarState> {
@@ -155,9 +156,9 @@ export declare class MultiViewCalendarWithoutContext extends React.Component<Mul
155
156
  protected rangeWithFocused: (range: SelectionRange, focusedDate: Date) => SelectionRange;
156
157
  protected generateRange: (candidate: Date, value: SelectionRange) => SelectionRange;
157
158
  protected canNavigate: (action: Action) => boolean;
158
- protected isListInRange: (list: Date[]) => boolean;
159
- protected navigate: (action: Action) => void;
160
- protected move: (action: Action) => Date;
159
+ protected isInMonth(date: Date, month: Date): boolean;
160
+ protected navigate: (action: Action, date: Date) => void;
161
+ protected move: (action: Action, date: Date) => Date;
161
162
  protected clampDate: (value: Date) => Date;
162
163
  protected shouldAutoCorrect: (candidate: Date, value: SelectionRange) => boolean;
163
164
  private handleCellEnter;
@@ -125,17 +125,13 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
125
125
  || _this.service.isInSameView(candidate, _this.min)
126
126
  || _this.service.isInSameView(candidate, _this.max);
127
127
  };
128
- _this.isListInRange = function (list) {
129
- return _this.min < list[0]
130
- && _this.max > list[Math.max(0, (_this.props.views || MultiViewCalendarWithoutContext.defaultProps.views) - 1)];
131
- };
132
- _this.navigate = function (action) {
128
+ _this.navigate = function (action, date) {
133
129
  _this.calculateFocusFromValue = false;
134
- var candidate = _this.move(action);
135
- _this.setState({ focusedDate: candidate });
130
+ var candidate = _this.move(action, date);
131
+ _this.setState({ navigateDate: candidate, focusedDate: candidate });
136
132
  };
137
- _this.move = function (action) {
138
- return _this.clampDate(_this.service.move(_this.focusedDate, action));
133
+ _this.move = function (action, date) {
134
+ return _this.clampDate(_this.service.move(date, action));
139
135
  };
140
136
  _this.clampDate = function (value) {
141
137
  return (0, utils_2.dateInRange)(value, _this.min, _this.max);
@@ -195,10 +191,19 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
195
191
  _this.handleDateChange(event);
196
192
  };
197
193
  _this.handlePrevButtonClick = function () {
198
- _this.navigate(models_1.Action.PrevView);
194
+ var action = models_1.Action.PrevView;
195
+ if (_this.state.activeView > 0 && _this.focusedDate.getFullYear() > _this.dates[0].getFullYear()) {
196
+ _this.navigate(action, _this.move(action, _this.focusedDate));
197
+ }
198
+ else {
199
+ var inMonthDate = _this.isInMonth(_this.focusedDate, _this.dates[1])
200
+ ? _this.move(action, _this.focusedDate)
201
+ : _this.focusedDate;
202
+ _this.navigate(action, inMonthDate);
203
+ }
199
204
  };
200
205
  _this.handleNextButtonClick = function () {
201
- _this.navigate(models_1.Action.NextView);
206
+ _this.navigate(models_1.Action.NextView, _this.focusedDate);
202
207
  };
203
208
  _this.handleKeyDown = function (event) {
204
209
  var keyCode = event.keyCode;
@@ -216,6 +221,10 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
216
221
  if ((0, kendo_date_math_1.isEqualDate)(_this.focusedDate, candidate)) {
217
222
  return;
218
223
  }
224
+ if (_this.dates && _this.service && !_this.service.isInArray(candidate, _this.dates)) {
225
+ _this.setState({ navigateDate: candidate });
226
+ }
227
+ ;
219
228
  _this.calculateFocusFromValue = false;
220
229
  _this.setState({ focusedDate: candidate });
221
230
  }
@@ -224,7 +233,7 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
224
233
  _this.handleViewChange = function (_a) {
225
234
  var view = _a.view;
226
235
  _this.calculateFocusFromValue = false;
227
- _this.setState({ activeView: view });
236
+ _this.setState(function (state) { return ({ activeView: view, navigateDate: state.focusedDate }); });
228
237
  };
229
238
  _this.handleDateChange = function (event) {
230
239
  var focusedDate = (0, kendo_date_math_1.cloneDate)(event.value);
@@ -285,6 +294,9 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
285
294
  break;
286
295
  }
287
296
  _this.valueDuringOnChange = value;
297
+ if (event.isTodayClick) {
298
+ _this.setState({ navigateDate: focusedDate });
299
+ }
288
300
  _this.setState({ value: value, focusedDate: focusedDate });
289
301
  _this.valueDuringOnChange = value;
290
302
  var onChange = _this.props.onChange;
@@ -311,7 +323,8 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
311
323
  _this.state = {
312
324
  value: value,
313
325
  activeView: activeView,
314
- focusedDate: focusedDate
326
+ focusedDate: focusedDate,
327
+ navigateDate: focusedDate
315
328
  };
316
329
  _this.activeRangeEnd = extractActiveRange(selectedRange, selectedDate);
317
330
  _this.bus = new services_1.BusViewService(_this.handleViewChange);
@@ -448,6 +461,7 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
448
461
  this.bus.configure(this.bottomView, this.topView);
449
462
  var activeView = (0, utils_2.viewInRange)(this.state.activeView, this.bottomView, this.topView);
450
463
  this.service = this.bus.service(activeView, this.intl);
464
+ // console.log('this.service', this.service);
451
465
  this.selectedDate = extractDateFromValue(this.min, this.max, this.value);
452
466
  this.selectedMultiple = extractMultipleFromValue(this.min, this.max, this.value);
453
467
  this.selectedRange = extractRangeFromValue(this.value);
@@ -466,10 +480,10 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
466
480
  var prevBtnAria = { 'aria-disabled': isPrevDisabled };
467
481
  var nextBtnAria = { 'aria-disabled': isNextDisabled };
468
482
  var didViewChange = this.lastView !== activeView;
469
- var isDateInList = this.dates && this.service.isInArray(this.focusedDate, this.dates);
483
+ var isDateInMonth = this.dates && this.isInMonth(this.state.navigateDate, this.dates[0]);
470
484
  var didViewsCountChange = this.lastViewsCount !== this.props.views;
471
- if (!isDateInList || didViewChange || didViewsCountChange) {
472
- this.dates = this.service.datesList(this.focusedDate, this.props.views || HorizontalViewList_1.HorizontalViewList.defaultProps.views);
485
+ if (!isDateInMonth || didViewChange || didViewsCountChange) {
486
+ this.dates = this.service.datesList(this.state.navigateDate, this.props.views || HorizontalViewList_1.HorizontalViewList.defaultProps.views);
473
487
  }
474
488
  var activeDate = (0, kendo_date_math_1.cloneDate)(this.dates && this.dates[0] ? this.dates[0] : (0, utils_2.getToday)());
475
489
  return (React.createElement("div", { ref: function (el) { _this._element = el; }, className: wrapperClassName, id: this.props.id || this.wrapperID, "aria-labelledby": this.props.ariaLabelledBy, "aria-describedby": this.props.ariaDescribedBy, tabIndex: !this.props.disabled ? this.props.tabIndex : undefined, onFocus: this.handleFocus, onBlur: this.handleBlur, onMouseDown: this.handleMouseDown, onClick: this.handleClick, onKeyDown: this.handleKeyDown, "aria-disabled": this.props.disabled, dir: this.props.dir },
@@ -479,6 +493,13 @@ var MultiViewCalendarWithoutContext = /** @class */ (function (_super) {
479
493
  React.createElement(kendo_react_buttons_1.Button, __assign({ type: "button", className: "k-calendar-nav-next", icon: this.isRtl ? 'chevron-left' : 'chevron-right', svgIcon: this.isRtl ? kendo_svg_icons_1.chevronLeftIcon : kendo_svg_icons_1.chevronRightIcon, fillMode: "flat", title: nextViewTittle, disabled: isNextDisabled, onClick: this.handleNextButtonClick }, nextBtnAria)))) }),
480
494
  React.createElement(HorizontalViewList_1.HorizontalViewList, { ref: function (el) { _this.calendarViewList = el; }, dates: this.dates, activeView: activeView, focusedDate: this.focusedDate, min: this.min, max: this.max, bus: this.bus, service: this.service, selectionRange: visualizedRange, value: this.selectedMultiple || this.selectedDate, cellUID: this.cellUID, views: this.props.views, onChange: this.handleDateChange, showWeekNumbers: this.props.weekNumber, onCellEnter: this.handleCellEnter, cell: this.props.cell, weekCell: this.props.weekCell, headerTitle: this.props.headerTitle, verticalView: this.props.mobileMode })));
481
495
  };
496
+ // protected isListInRange = (list: Date[]): boolean => {
497
+ // return this.min < list[0]
498
+ // && this.max > list[Math.max(0, (this.props.views || MultiViewCalendarWithoutContext.defaultProps.views) - 1)];
499
+ // };
500
+ MultiViewCalendarWithoutContext.prototype.isInMonth = function (date, month) {
501
+ return !!month && (0, kendo_date_math_1.firstDayOfMonth)(month) <= date && date <= (0, kendo_date_math_1.lastDayOfMonth)(month);
502
+ };
482
503
  /**
483
504
  * @hidden
484
505
  */
@@ -8,7 +8,7 @@ exports.packageMetadata = {
8
8
  name: '@progress/kendo-react-dateinputs',
9
9
  productName: 'KendoReact',
10
10
  productCodes: ['KENDOUIREACT', 'KENDOUICOMPLETE'],
11
- publishDate: 1691491628,
11
+ publishDate: 1691491790,
12
12
  version: '',
13
13
  licensingDocsUrl: 'https://www.telerik.com/kendo-react-ui/my-license/?utm_medium=product&utm_source=kendoreact&utm_campaign=kendo-ui-react-purchase-license-keys-warning'
14
14
  };