@progress/kendo-react-dateinputs 4.13.0-dev.202111291459 → 4.13.0-dev.202111300702

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.
Files changed (43) hide show
  1. package/dist/cdn/js/kendo-react-dateinputs.js +1 -1
  2. package/dist/es/calendar/components/Calendar.d.ts +43 -9
  3. package/dist/es/calendar/components/Calendar.js +48 -28
  4. package/dist/es/calendar/components/MultiViewCalendar.d.ts +51 -19
  5. package/dist/es/calendar/components/MultiViewCalendar.js +64 -37
  6. package/dist/es/dateinput/DateInput.d.ts +46 -4
  7. package/dist/es/dateinput/DateInput.js +64 -43
  8. package/dist/es/datepicker/DatePicker.d.ts +63 -9
  9. package/dist/es/datepicker/DatePicker.js +68 -47
  10. package/dist/es/daterangepicker/DateRangePicker.d.ts +51 -11
  11. package/dist/es/daterangepicker/DateRangePicker.js +60 -32
  12. package/dist/es/datetimepicker/DateTimePicker.d.ts +54 -4
  13. package/dist/es/datetimepicker/DateTimePicker.js +54 -33
  14. package/dist/es/hooks/usePickerFloatingLabel.d.ts +1 -1
  15. package/dist/es/main.d.ts +8 -8
  16. package/dist/es/main.js +8 -8
  17. package/dist/es/package-metadata.js +1 -1
  18. package/dist/es/timepicker/TimePicker.d.ts +58 -4
  19. package/dist/es/timepicker/TimePicker.js +59 -38
  20. package/dist/es/utils.d.ts +4 -0
  21. package/dist/es/utils.js +20 -0
  22. package/dist/npm/calendar/components/Calendar.d.ts +43 -9
  23. package/dist/npm/calendar/components/Calendar.js +48 -28
  24. package/dist/npm/calendar/components/MultiViewCalendar.d.ts +51 -19
  25. package/dist/npm/calendar/components/MultiViewCalendar.js +62 -35
  26. package/dist/npm/dateinput/DateInput.d.ts +46 -4
  27. package/dist/npm/dateinput/DateInput.js +64 -43
  28. package/dist/npm/datepicker/DatePicker.d.ts +63 -9
  29. package/dist/npm/datepicker/DatePicker.js +67 -46
  30. package/dist/npm/daterangepicker/DateRangePicker.d.ts +51 -11
  31. package/dist/npm/daterangepicker/DateRangePicker.js +58 -30
  32. package/dist/npm/datetimepicker/DateTimePicker.d.ts +54 -4
  33. package/dist/npm/datetimepicker/DateTimePicker.js +53 -32
  34. package/dist/npm/hooks/usePickerFloatingLabel.d.ts +1 -1
  35. package/dist/npm/main.d.ts +8 -8
  36. package/dist/npm/main.js +7 -0
  37. package/dist/npm/package-metadata.js +1 -1
  38. package/dist/npm/timepicker/TimePicker.d.ts +58 -4
  39. package/dist/npm/timepicker/TimePicker.js +58 -37
  40. package/dist/npm/utils.d.ts +4 -0
  41. package/dist/npm/utils.js +21 -0
  42. package/dist/systemjs/kendo-react-dateinputs.js +1 -1
  43. package/package.json +14 -9
@@ -35,7 +35,7 @@ import * as React from 'react';
35
35
  import * as PropTypes from 'prop-types';
36
36
  import { Popup } from '@progress/kendo-react-popup';
37
37
  import { getDate, cloneDate } from '@progress/kendo-date-math';
38
- import { classNames, guid, Keys, AsyncFocusBlur } from '@progress/kendo-react-common';
38
+ import { classNames, guid, Keys, AsyncFocusBlur, createPropsContext, withPropsContext } from '@progress/kendo-react-common';
39
39
  import { validatePackage } from '@progress/kendo-react-common';
40
40
  import { packageMetadata } from '../package-metadata';
41
41
  import { DateInput } from '../dateinput/DateInput';
@@ -47,9 +47,10 @@ import { registerForLocalization, provideLocalizationService } from '@progress/k
47
47
  import { ToggleButton } from './ToggleButton';
48
48
  import { PickerWrap } from '../common/PickerWrap';
49
49
  import { PickerFloatingLabel } from '../hooks/usePickerFloatingLabel';
50
- var DatePicker = /** @class */ (function (_super) {
51
- __extends(DatePicker, _super);
52
- function DatePicker(props) {
50
+ /** @hidden */
51
+ var DatePickerWithoutContext = /** @class */ (function (_super) {
52
+ __extends(DatePickerWithoutContext, _super);
53
+ function DatePickerWithoutContext(props) {
53
54
  var _this = _super.call(this, props) || this;
54
55
  _this._popupId = guid();
55
56
  _this._element = null;
@@ -139,15 +140,15 @@ var DatePicker = /** @class */ (function (_super) {
139
140
  };
140
141
  validatePackage(packageMetadata);
141
142
  _this.state = {
142
- value: _this.props.defaultValue || DatePicker.defaultProps.defaultValue,
143
- show: _this.props.defaultShow || DatePicker.defaultProps.defaultShow,
143
+ value: _this.props.defaultValue || DatePickerWithoutContext.defaultProps.defaultValue,
144
+ show: _this.props.defaultShow || DatePickerWithoutContext.defaultProps.defaultShow,
144
145
  focused: false
145
146
  };
146
147
  return _this;
147
148
  }
148
- Object.defineProperty(DatePicker.prototype, "element", {
149
+ Object.defineProperty(DatePickerWithoutContext.prototype, "element", {
149
150
  /**
150
- * Gets the wrapping element of the DatePicker.
151
+ * Gets the wrapping element of the DatePickerWithoutContext.
151
152
  */
152
153
  get: function () {
153
154
  return this._element;
@@ -155,7 +156,7 @@ var DatePicker = /** @class */ (function (_super) {
155
156
  enumerable: true,
156
157
  configurable: true
157
158
  });
158
- Object.defineProperty(DatePicker.prototype, "dateInput", {
159
+ Object.defineProperty(DatePickerWithoutContext.prototype, "dateInput", {
159
160
  /**
160
161
  * Gets the DateInput component inside the DatePicker component.
161
162
  */
@@ -165,7 +166,7 @@ var DatePicker = /** @class */ (function (_super) {
165
166
  enumerable: true,
166
167
  configurable: true
167
168
  });
168
- Object.defineProperty(DatePicker.prototype, "calendar", {
169
+ Object.defineProperty(DatePickerWithoutContext.prototype, "calendar", {
169
170
  /**
170
171
  * Gets the Calendar component inside the DatePicker component.
171
172
  */
@@ -175,9 +176,9 @@ var DatePicker = /** @class */ (function (_super) {
175
176
  enumerable: true,
176
177
  configurable: true
177
178
  });
178
- Object.defineProperty(DatePicker.prototype, "value", {
179
+ Object.defineProperty(DatePickerWithoutContext.prototype, "value", {
179
180
  /**
180
- * Gets the value of the DatePicker.
181
+ * Gets the value of the DatePickerWithoutContext.
181
182
  */
182
183
  get: function () {
183
184
  var value = this.valueDuringOnChange !== undefined
@@ -190,9 +191,9 @@ var DatePicker = /** @class */ (function (_super) {
190
191
  enumerable: true,
191
192
  configurable: true
192
193
  });
193
- Object.defineProperty(DatePicker.prototype, "show", {
194
+ Object.defineProperty(DatePickerWithoutContext.prototype, "show", {
194
195
  /**
195
- * Gets the popup state of the DatePicker.
196
+ * Gets the popup state of the DatePickerWithoutContext.
196
197
  */
197
198
  get: function () {
198
199
  return this.showDuringOnChange !== undefined
@@ -204,9 +205,9 @@ var DatePicker = /** @class */ (function (_super) {
204
205
  enumerable: true,
205
206
  configurable: true
206
207
  });
207
- Object.defineProperty(DatePicker.prototype, "name", {
208
+ Object.defineProperty(DatePickerWithoutContext.prototype, "name", {
208
209
  /**
209
- * Gets the `name` property of the DatePicker.
210
+ * Gets the `name` property of the DatePickerWithoutContext.
210
211
  */
211
212
  get: function () {
212
213
  return this.props.name;
@@ -214,60 +215,60 @@ var DatePicker = /** @class */ (function (_super) {
214
215
  enumerable: true,
215
216
  configurable: true
216
217
  });
217
- Object.defineProperty(DatePicker.prototype, "min", {
218
+ Object.defineProperty(DatePickerWithoutContext.prototype, "min", {
218
219
  get: function () {
219
220
  return this.props.min !== undefined
220
221
  ? this.props.min
221
- : DatePicker.defaultProps.min;
222
+ : DatePickerWithoutContext.defaultProps.min;
222
223
  },
223
224
  enumerable: true,
224
225
  configurable: true
225
226
  });
226
- Object.defineProperty(DatePicker.prototype, "max", {
227
+ Object.defineProperty(DatePickerWithoutContext.prototype, "max", {
227
228
  get: function () {
228
229
  return this.props.max !== undefined
229
230
  ? this.props.max
230
- : DatePicker.defaultProps.max;
231
+ : DatePickerWithoutContext.defaultProps.max;
231
232
  },
232
233
  enumerable: true,
233
234
  configurable: true
234
235
  });
235
- Object.defineProperty(DatePicker.prototype, "dateInputComp", {
236
+ Object.defineProperty(DatePickerWithoutContext.prototype, "dateInputComp", {
236
237
  get: function () {
237
- return this.props.dateInput || DatePicker.defaultProps.dateInput;
238
+ return this.props.dateInput || DatePickerWithoutContext.defaultProps.dateInput;
238
239
  },
239
240
  enumerable: true,
240
241
  configurable: true
241
242
  });
242
- Object.defineProperty(DatePicker.prototype, "toggleButtonComp", {
243
+ Object.defineProperty(DatePickerWithoutContext.prototype, "toggleButtonComp", {
243
244
  get: function () {
244
- return this.props.toggleButton || DatePicker.defaultProps.toggleButton;
245
+ return this.props.toggleButton || DatePickerWithoutContext.defaultProps.toggleButton;
245
246
  },
246
247
  enumerable: true,
247
248
  configurable: true
248
249
  });
249
- Object.defineProperty(DatePicker.prototype, "calendarComp", {
250
+ Object.defineProperty(DatePickerWithoutContext.prototype, "calendarComp", {
250
251
  get: function () {
251
- return this.props.calendar || DatePicker.defaultProps.calendar;
252
+ return this.props.calendar || DatePickerWithoutContext.defaultProps.calendar;
252
253
  },
253
254
  enumerable: true,
254
255
  configurable: true
255
256
  });
256
- Object.defineProperty(DatePicker.prototype, "popupComp", {
257
+ Object.defineProperty(DatePickerWithoutContext.prototype, "popupComp", {
257
258
  get: function () {
258
- return this.props.popup || DatePicker.defaultProps.popup;
259
+ return this.props.popup || DatePickerWithoutContext.defaultProps.popup;
259
260
  },
260
261
  enumerable: true,
261
262
  configurable: true
262
263
  });
263
- Object.defineProperty(DatePicker.prototype, "pickerWrapComp", {
264
+ Object.defineProperty(DatePickerWithoutContext.prototype, "pickerWrapComp", {
264
265
  get: function () {
265
- return this.props.pickerWrap || DatePicker.defaultProps.pickerWrap;
266
+ return this.props.pickerWrap || DatePickerWithoutContext.defaultProps.pickerWrap;
266
267
  },
267
268
  enumerable: true,
268
269
  configurable: true
269
270
  });
270
- Object.defineProperty(DatePicker.prototype, "validity", {
271
+ Object.defineProperty(DatePickerWithoutContext.prototype, "validity", {
271
272
  /**
272
273
  * Represents the validity state into which the DatePicker is set.
273
274
  */
@@ -287,26 +288,26 @@ var DatePicker = /** @class */ (function (_super) {
287
288
  enumerable: true,
288
289
  configurable: true
289
290
  });
290
- Object.defineProperty(DatePicker.prototype, "validityStyles", {
291
+ Object.defineProperty(DatePickerWithoutContext.prototype, "validityStyles", {
291
292
  /**
292
293
  * @hidden
293
294
  */
294
295
  get: function () {
295
296
  return this.props.validityStyles !== undefined
296
297
  ? this.props.validityStyles
297
- : DatePicker.defaultProps.validityStyles;
298
+ : DatePickerWithoutContext.defaultProps.validityStyles;
298
299
  },
299
300
  enumerable: true,
300
301
  configurable: true
301
302
  });
302
- Object.defineProperty(DatePicker.prototype, "required", {
303
+ Object.defineProperty(DatePickerWithoutContext.prototype, "required", {
303
304
  /**
304
305
  * @hidden
305
306
  */
306
307
  get: function () {
307
308
  return this.props.required !== undefined
308
309
  ? this.props.required
309
- : DatePicker.defaultProps.required;
310
+ : DatePickerWithoutContext.defaultProps.required;
310
311
  },
311
312
  enumerable: true,
312
313
  configurable: true
@@ -314,7 +315,7 @@ var DatePicker = /** @class */ (function (_super) {
314
315
  /**
315
316
  * @hidden
316
317
  */
317
- DatePicker.prototype.componentDidMount = function () {
318
+ DatePickerWithoutContext.prototype.componentDidMount = function () {
318
319
  if (this.show) {
319
320
  // If defaultShow is true during the initial render, the popup is not aligned.
320
321
  this.forceUpdate();
@@ -323,7 +324,7 @@ var DatePicker = /** @class */ (function (_super) {
323
324
  /**
324
325
  * @hidden
325
326
  */
326
- DatePicker.prototype.componentDidUpdate = function () {
327
+ DatePickerWithoutContext.prototype.componentDidUpdate = function () {
327
328
  if (this._calendar && this._calendar.element && this.show && !this.prevShow) {
328
329
  this._calendar.element.focus({ preventScroll: true });
329
330
  }
@@ -339,13 +340,13 @@ var DatePicker = /** @class */ (function (_super) {
339
340
  /**
340
341
  * @hidden
341
342
  */
342
- DatePicker.prototype.componentWillUnmount = function () {
343
+ DatePickerWithoutContext.prototype.componentWillUnmount = function () {
343
344
  clearTimeout(this.nextTickId);
344
345
  };
345
346
  /**
346
347
  * @hidden
347
348
  */
348
- DatePicker.prototype.render = function () {
349
+ DatePickerWithoutContext.prototype.render = function () {
349
350
  var _this = this;
350
351
  var _a = this.props, disabled = _a.disabled, tabIndex = _a.tabIndex, title = _a.title, id = _a.id, format = _a.format, formatPlaceholder = _a.formatPlaceholder, min = _a.min, max = _a.max, weekNumber = _a.weekNumber, focusedDate = _a.focusedDate, className = _a.className, width = _a.width, name = _a.name, validationMessage = _a.validationMessage, required = _a.required, validityStyles = _a.validityStyles, ariaLabelledBy = _a.ariaLabelledBy, ariaDescribedBy = _a.ariaDescribedBy;
351
352
  var _b = this.props.popupSettings, popupClass = _b.popupClass, otherPopupSettings = __rest(_b, ["popupClass"]);
@@ -414,16 +415,16 @@ var DatePicker = /** @class */ (function (_super) {
414
415
  ? (React.createElement(PickerFloatingLabel, { dateInput: this._dateInput, label: this.props.label, editorId: id, editorValid: isValid, editorDisabled: this.props.disabled, children: datepicker, style: { width: this.props.width } }))
415
416
  : datepicker;
416
417
  };
417
- DatePicker.prototype.setShow = function (show) {
418
+ DatePickerWithoutContext.prototype.setShow = function (show) {
418
419
  if (this.show === show) {
419
420
  return;
420
421
  }
421
422
  this.setState({ show: show });
422
423
  };
423
- DatePicker.prototype.mergeTime = function (value) {
424
+ DatePickerWithoutContext.prototype.mergeTime = function (value) {
424
425
  return this.value && value ? setTime(value, this.value) : value;
425
426
  };
426
- DatePicker.prototype.nextTick = function (f) {
427
+ DatePickerWithoutContext.prototype.nextTick = function (f) {
427
428
  // XXX: use window.setTimeout due to async focus/blur events in IE, and missing relatedTarget prop.
428
429
  // XXX: https://github.com/facebook/react/issues/3751
429
430
  // Handles multiple focus events happening at the same time.
@@ -433,7 +434,11 @@ var DatePicker = /** @class */ (function (_super) {
433
434
  /**
434
435
  * @hidden
435
436
  */
436
- DatePicker.propTypes = {
437
+ DatePickerWithoutContext.displayName = 'DatePicker';
438
+ /**
439
+ * @hidden
440
+ */
441
+ DatePickerWithoutContext.propTypes = {
437
442
  className: PropTypes.string,
438
443
  defaultShow: PropTypes.bool,
439
444
  defaultValue: PropTypes.instanceOf(Date),
@@ -495,7 +500,7 @@ var DatePicker = /** @class */ (function (_super) {
495
500
  /**
496
501
  * @hidden
497
502
  */
498
- DatePicker.defaultProps = {
503
+ DatePickerWithoutContext.defaultProps = {
499
504
  defaultShow: false,
500
505
  defaultValue: null,
501
506
  dateInput: DateInput,
@@ -513,7 +518,23 @@ var DatePicker = /** @class */ (function (_super) {
513
518
  required: false,
514
519
  validityStyles: true
515
520
  };
516
- return DatePicker;
521
+ return DatePickerWithoutContext;
517
522
  }(React.Component));
518
- export { DatePicker };
519
- registerForLocalization(DatePicker);
523
+ export { DatePickerWithoutContext };
524
+ /**
525
+ * Represents the PropsContext of the `DatePicker` component.
526
+ * Used for global configuration of all `DatePicker` instances.
527
+ *
528
+ * For more information, refer to the [DateInputs Props Context]({% slug props-context_dateinputs %}) article.
529
+ */
530
+ export var DatePickerPropsContext = createPropsContext();
531
+ /* eslint-disable @typescript-eslint/no-redeclare */
532
+ /**
533
+ * Represents the KendoReact DatePicker Component.
534
+ *
535
+ * Accepts properties of type [DatePickerProps]({% slug api_dateinputs_datepickerprops %}).
536
+ * Obtaining the `ref` returns an object of type [DatePickerHandle]({% slug api_dateinputs_datepickerhandle %}).
537
+ */
538
+ export var DatePicker = withPropsContext(DatePickerPropsContext, DatePickerWithoutContext);
539
+ DatePicker.displayName = 'KendoReactDatePicker';
540
+ registerForLocalization(DatePickerWithoutContext);
@@ -54,7 +54,12 @@ export interface DateRangePickerState {
54
54
  show: boolean;
55
55
  value: SelectionRange;
56
56
  }
57
- export declare class DateRangePicker extends React.Component<DateRangePickerProps, DateRangePickerState> {
57
+ /** @hidden */
58
+ export declare class DateRangePickerWithoutContext extends React.Component<DateRangePickerProps, DateRangePickerState> {
59
+ /**
60
+ * @hidden
61
+ */
62
+ static displayName: string;
58
63
  /**
59
64
  * @hidden
60
65
  */
@@ -63,10 +68,7 @@ export declare class DateRangePicker extends React.Component<DateRangePickerProp
63
68
  calendarSettings: PropTypes.Requireable<any>;
64
69
  className: PropTypes.Requireable<string>;
65
70
  defaultShow: PropTypes.Requireable<boolean>;
66
- defaultValue: PropTypes.Requireable<PropTypes.InferProps<{
67
- start: PropTypes.Requireable<Date>;
68
- end: PropTypes.Requireable<Date>;
69
- }>>;
71
+ defaultValue: PropTypes.Validator<SelectionRange>;
70
72
  disabled: PropTypes.Requireable<boolean>;
71
73
  endDateInputSettings: PropTypes.Requireable<PropTypes.InferProps<{
72
74
  value: PropTypes.Requireable<Date>;
@@ -87,7 +89,7 @@ export declare class DateRangePicker extends React.Component<DateRangePickerProp
87
89
  second: PropTypes.Requireable<string>;
88
90
  timeZoneName: PropTypes.Requireable<string>;
89
91
  }>>;
90
- formatPlaceholder: PropTypes.Requireable<string | PropTypes.InferProps<{
92
+ formatPlaceholder: PropTypes.Requireable<"narrow" | "short" | "wide" | "formatPattern" | PropTypes.InferProps<{
91
93
  year: PropTypes.Requireable<string>;
92
94
  month: PropTypes.Requireable<string>;
93
95
  day: PropTypes.Requireable<string>;
@@ -116,7 +118,7 @@ export declare class DateRangePicker extends React.Component<DateRangePickerProp
116
118
  id: PropTypes.Requireable<string>;
117
119
  ariaLabelledBy: PropTypes.Requireable<string>;
118
120
  ariaDescribedBy: PropTypes.Requireable<string>;
119
- ariaExpanded: PropTypes.Requireable<string | boolean>;
121
+ ariaExpanded: PropTypes.Requireable<boolean>;
120
122
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
121
123
  validationMessage: PropTypes.Requireable<string>;
122
124
  required: PropTypes.Requireable<boolean>;
@@ -155,10 +157,7 @@ export declare class DateRangePicker extends React.Component<DateRangePickerProp
155
157
  style: PropTypes.Requireable<any>;
156
158
  swapButton: PropTypes.Requireable<any>;
157
159
  tabIndex: PropTypes.Requireable<number>;
158
- value: PropTypes.Requireable<PropTypes.InferProps<{
159
- start: PropTypes.Requireable<Date>;
160
- end: PropTypes.Requireable<Date>;
161
- }>>;
160
+ value: PropTypes.Validator<SelectionRange>;
162
161
  };
163
162
  /**
164
163
  * @hidden
@@ -251,3 +250,44 @@ export declare class DateRangePicker extends React.Component<DateRangePickerProp
251
250
  private handleKeyDown;
252
251
  private handleChange;
253
252
  }
253
+ /**
254
+ * Represents the PropsContext of the `DateRangePicker` component.
255
+ * Used for global configuration of all `DateRangePicker` instances.
256
+ *
257
+ * For more information, refer to the [DateInputs Props Context]({% slug props-context_dateinputs %}) article.
258
+ */
259
+ export declare const DateRangePickerPropsContext: React.Context<(p: DateRangePickerProps) => DateRangePickerProps>;
260
+ /**
261
+ * Represent the `ref` of the DateRangePicker component.
262
+ */
263
+ export interface DateRangePickerHandle extends Pick<DateRangePickerWithoutContext, keyof DateRangePickerWithoutContext> {
264
+ /**
265
+ * Gets the MultiVieCalendar inside the DateRangePicker.
266
+ */
267
+ calendar: MultiViewCalendar | null;
268
+ /**
269
+ * Returns the HTML element of the DateRangePicker component.
270
+ */
271
+ element: HTMLSpanElement | null;
272
+ /**
273
+ * Gets the end DateInput component inside the DateRangePicker component.
274
+ */
275
+ endDateInput: DateInput | null;
276
+ /**
277
+ * Gets the start DateInput component inside the DateRangePicker component.
278
+ */
279
+ startDateInput: DateInput | null;
280
+ /**
281
+ * Gets the value of the DateRangePicker.
282
+ */
283
+ value: SelectionRange;
284
+ }
285
+ /** @hidden */
286
+ export declare type DateRangePicker = DateRangePickerHandle;
287
+ /**
288
+ * Represents the KendoReact DateRangePicker Component.
289
+ *
290
+ * Accepts properties of type [DateRangePickerProps]({% slug api_dateinputs_daterangepickerprops %}).
291
+ * Obtaining the `ref` returns an object of type [DateRangePickerHandle]({% slug api_dateinputs_daterangepickerhandle %}).
292
+ */
293
+ export declare const DateRangePicker: React.ForwardRefExoticComponent<DateRangePickerProps & React.RefAttributes<any>>;
@@ -26,20 +26,22 @@ import * as React from 'react';
26
26
  import * as PropTypes from 'prop-types';
27
27
  import { Popup } from '@progress/kendo-react-popup';
28
28
  import { cloneDate } from '@progress/kendo-date-math';
29
- import { guid, classNames, Keys } from '@progress/kendo-react-common';
29
+ import { guid, classNames, Keys, createPropsContext, withPropsContext } from '@progress/kendo-react-common';
30
30
  import { provideLocalizationService, registerForLocalization } from '@progress/kendo-react-intl';
31
31
  import { validatePackage } from '@progress/kendo-react-common';
32
32
  import { packageMetadata } from '../package-metadata';
33
- import { DateInput } from '../dateinput/DateInput';
33
+ import { DateInput, DateInputWithoutContext } from '../dateinput/DateInput';
34
34
  import { MultiViewCalendar } from '../calendar/components/MultiViewCalendar';
35
35
  import { EMPTY_SELECTIONRANGE } from '../calendar/models';
36
36
  import { MIN_DATE, MAX_DATE } from '../defaults';
37
37
  import { swapStartEnd, start, end, separator, messages } from '../messages';
38
38
  import { Button } from '@progress/kendo-react-buttons';
39
+ import { nullable } from '../utils';
39
40
  var WRAPPER_STYLES = { display: 'inline-block' };
40
- var DateRangePicker = /** @class */ (function (_super) {
41
- __extends(DateRangePicker, _super);
42
- function DateRangePicker(props) {
41
+ /** @hidden */
42
+ var DateRangePickerWithoutContext = /** @class */ (function (_super) {
43
+ __extends(DateRangePickerWithoutContext, _super);
44
+ function DateRangePickerWithoutContext(props) {
43
45
  var _this = _super.call(this, props) || this;
44
46
  _this._element = null;
45
47
  _this._wrapper = null;
@@ -193,8 +195,8 @@ var DateRangePicker = /** @class */ (function (_super) {
193
195
  };
194
196
  validatePackage(packageMetadata);
195
197
  _this.state = {
196
- show: _this.props.show || _this.props.defaultShow || DateRangePicker.defaultProps.defaultShow,
197
- value: _this.props.value || _this.props.defaultValue || DateRangePicker.defaultProps.defaultValue
198
+ show: _this.props.show || _this.props.defaultShow || DateRangePickerWithoutContext.defaultProps.defaultShow,
199
+ value: _this.props.value || _this.props.defaultValue || DateRangePickerWithoutContext.defaultProps.defaultValue
198
200
  };
199
201
  _this.nextTick = _this.nextTick.bind(_this);
200
202
  _this.setShow = _this.setShow.bind(_this);
@@ -202,7 +204,7 @@ var DateRangePicker = /** @class */ (function (_super) {
202
204
  _this.focusDateInputElement = _this.focusDateInputElement.bind(_this);
203
205
  return _this;
204
206
  }
205
- Object.defineProperty(DateRangePicker.prototype, "element", {
207
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "element", {
206
208
  /**
207
209
  * Gets the wrapping element of the DateRangePicker.
208
210
  */
@@ -212,7 +214,7 @@ var DateRangePicker = /** @class */ (function (_super) {
212
214
  enumerable: true,
213
215
  configurable: true
214
216
  });
215
- Object.defineProperty(DateRangePicker.prototype, "startDateInput", {
217
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "startDateInput", {
216
218
  /**
217
219
  * Gets the start DateInput component inside the DatePicker component.
218
220
  */
@@ -222,7 +224,7 @@ var DateRangePicker = /** @class */ (function (_super) {
222
224
  enumerable: true,
223
225
  configurable: true
224
226
  });
225
- Object.defineProperty(DateRangePicker.prototype, "endDateInput", {
227
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "endDateInput", {
226
228
  /**
227
229
  * Gets the end DateInput component inside the DatePicker component.
228
230
  */
@@ -232,7 +234,7 @@ var DateRangePicker = /** @class */ (function (_super) {
232
234
  enumerable: true,
233
235
  configurable: true
234
236
  });
235
- Object.defineProperty(DateRangePicker.prototype, "calendar", {
237
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "calendar", {
236
238
  /**
237
239
  * Gets the MultiVieCalendar inside the DateRangePicker.
238
240
  */
@@ -242,7 +244,7 @@ var DateRangePicker = /** @class */ (function (_super) {
242
244
  enumerable: true,
243
245
  configurable: true
244
246
  });
245
- Object.defineProperty(DateRangePicker.prototype, "value", {
247
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "value", {
246
248
  /**
247
249
  * Gets the value of the DateRangePicker.
248
250
  */
@@ -257,7 +259,7 @@ var DateRangePicker = /** @class */ (function (_super) {
257
259
  enumerable: true,
258
260
  configurable: true
259
261
  });
260
- Object.defineProperty(DateRangePicker.prototype, "show", {
262
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "show", {
261
263
  /**
262
264
  * Gets the popup state of the DateRangePicker.
263
265
  */
@@ -271,20 +273,20 @@ var DateRangePicker = /** @class */ (function (_super) {
271
273
  enumerable: true,
272
274
  configurable: true
273
275
  });
274
- Object.defineProperty(DateRangePicker.prototype, "min", {
276
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "min", {
275
277
  get: function () {
276
278
  return this.props.min !== undefined
277
279
  ? this.props.min
278
- : DateRangePicker.defaultProps.min;
280
+ : DateRangePickerWithoutContext.defaultProps.min;
279
281
  },
280
282
  enumerable: true,
281
283
  configurable: true
282
284
  });
283
- Object.defineProperty(DateRangePicker.prototype, "max", {
285
+ Object.defineProperty(DateRangePickerWithoutContext.prototype, "max", {
284
286
  get: function () {
285
287
  return this.props.max !== undefined
286
288
  ? this.props.max
287
- : DateRangePicker.defaultProps.max;
289
+ : DateRangePickerWithoutContext.defaultProps.max;
288
290
  },
289
291
  enumerable: true,
290
292
  configurable: true
@@ -292,7 +294,7 @@ var DateRangePicker = /** @class */ (function (_super) {
292
294
  /**
293
295
  * @hidden
294
296
  */
295
- DateRangePicker.prototype.componentDidMount = function () {
297
+ DateRangePickerWithoutContext.prototype.componentDidMount = function () {
296
298
  if (this.show) {
297
299
  // If defaultShow is true during the initial render, the popup is not aligned.
298
300
  this.forceUpdate();
@@ -301,7 +303,7 @@ var DateRangePicker = /** @class */ (function (_super) {
301
303
  /**
302
304
  * @hidden
303
305
  */
304
- DateRangePicker.prototype.componentDidUpdate = function () {
306
+ DateRangePickerWithoutContext.prototype.componentDidUpdate = function () {
305
307
  if (this.shouldFocusCalendar) {
306
308
  this.focusCalendarElement();
307
309
  }
@@ -314,13 +316,13 @@ var DateRangePicker = /** @class */ (function (_super) {
314
316
  /**
315
317
  * @hidden
316
318
  */
317
- DateRangePicker.prototype.componentWillUnmount = function () {
319
+ DateRangePickerWithoutContext.prototype.componentWillUnmount = function () {
318
320
  clearTimeout(this.nextTickId);
319
321
  };
320
322
  /**
321
323
  * @hidden
322
324
  */
323
- DateRangePicker.prototype.render = function () {
325
+ DateRangePickerWithoutContext.prototype.render = function () {
324
326
  var _this = this;
325
327
  var value = this.value || EMPTY_SELECTIONRANGE;
326
328
  var startDateInputId = (this.props.startDateInputSettings || {}).id || this._startInputId;
@@ -373,7 +375,7 @@ var DateRangePicker = /** @class */ (function (_super) {
373
375
  ? React.createElement(this.props.popup, __assign({}, popupProps), calendar)
374
376
  : React.createElement(Popup, __assign({}, popupProps), calendar)));
375
377
  };
376
- DateRangePicker.prototype.focusDateInputElement = function () {
378
+ DateRangePickerWithoutContext.prototype.focusDateInputElement = function () {
377
379
  if (!document || !this.startDateInput || !this.startDateInput.element
378
380
  || !this.endDateInput || !this.endDateInput.element) {
379
381
  return;
@@ -386,14 +388,14 @@ var DateRangePicker = /** @class */ (function (_super) {
386
388
  this.endDateInput.element.focus({ preventScroll: true });
387
389
  }
388
390
  };
389
- DateRangePicker.prototype.nextTick = function (f) {
391
+ DateRangePickerWithoutContext.prototype.nextTick = function (f) {
390
392
  // XXX: use window.setTimeout due to async focus/blur events in IE, and missing relatedTarget prop.
391
393
  // XXX: https://github.com/facebook/react/issues/3751
392
394
  // Handles multiple focus events happening at the same time.
393
395
  clearTimeout(this.nextTickId);
394
396
  this.nextTickId = window.setTimeout(function () { return f(); });
395
397
  };
396
- DateRangePicker.prototype.setShow = function (show) {
398
+ DateRangePickerWithoutContext.prototype.setShow = function (show) {
397
399
  if (this.show === show) {
398
400
  return;
399
401
  }
@@ -402,14 +404,21 @@ var DateRangePicker = /** @class */ (function (_super) {
402
404
  /**
403
405
  * @hidden
404
406
  */
405
- DateRangePicker.propTypes = {
407
+ DateRangePickerWithoutContext.displayName = 'DateRangePicker';
408
+ /**
409
+ * @hidden
410
+ */
411
+ DateRangePickerWithoutContext.propTypes = {
406
412
  allowReverse: PropTypes.bool,
407
413
  calendarSettings: PropTypes.any,
408
414
  className: PropTypes.string,
409
415
  defaultShow: PropTypes.bool,
410
- defaultValue: PropTypes.shape({ start: PropTypes.instanceOf(Date), end: PropTypes.instanceOf(Date) }),
416
+ defaultValue: PropTypes.shape({
417
+ start: nullable(PropTypes.instanceOf(Date).isRequired),
418
+ end: nullable(PropTypes.instanceOf(Date).isRequired)
419
+ }),
411
420
  disabled: PropTypes.bool,
412
- endDateInputSettings: PropTypes.shape(DateInput.propTypes),
421
+ endDateInputSettings: PropTypes.shape(DateInputWithoutContext.propTypes),
413
422
  focusedDate: PropTypes.instanceOf(Date),
414
423
  format: PropTypes.oneOfType([
415
424
  PropTypes.string,
@@ -445,12 +454,15 @@ var DateRangePicker = /** @class */ (function (_super) {
445
454
  style: PropTypes.any,
446
455
  swapButton: PropTypes.any,
447
456
  tabIndex: PropTypes.number,
448
- value: PropTypes.shape({ start: PropTypes.instanceOf(Date), end: PropTypes.instanceOf(Date) })
457
+ value: PropTypes.shape({
458
+ start: nullable(PropTypes.instanceOf(Date).isRequired),
459
+ end: nullable(PropTypes.instanceOf(Date).isRequired)
460
+ })
449
461
  };
450
462
  /**
451
463
  * @hidden
452
464
  */
453
- DateRangePicker.defaultProps = {
465
+ DateRangePickerWithoutContext.defaultProps = {
454
466
  allowReverse: false,
455
467
  defaultShow: false,
456
468
  defaultValue: EMPTY_SELECTIONRANGE,
@@ -460,7 +472,23 @@ var DateRangePicker = /** @class */ (function (_super) {
460
472
  min: MIN_DATE,
461
473
  swapButton: false
462
474
  };
463
- return DateRangePicker;
475
+ return DateRangePickerWithoutContext;
464
476
  }(React.Component));
465
- export { DateRangePicker };
466
- registerForLocalization(DateRangePicker);
477
+ export { DateRangePickerWithoutContext };
478
+ /**
479
+ * Represents the PropsContext of the `DateRangePicker` component.
480
+ * Used for global configuration of all `DateRangePicker` instances.
481
+ *
482
+ * For more information, refer to the [DateInputs Props Context]({% slug props-context_dateinputs %}) article.
483
+ */
484
+ export var DateRangePickerPropsContext = createPropsContext();
485
+ /* eslint-disable @typescript-eslint/no-redeclare */
486
+ /**
487
+ * Represents the KendoReact DateRangePicker Component.
488
+ *
489
+ * Accepts properties of type [DateRangePickerProps]({% slug api_dateinputs_daterangepickerprops %}).
490
+ * Obtaining the `ref` returns an object of type [DateRangePickerHandle]({% slug api_dateinputs_daterangepickerhandle %}).
491
+ */
492
+ export var DateRangePicker = withPropsContext(DateRangePickerPropsContext, DateRangePickerWithoutContext);
493
+ DateRangePicker.displayName = 'KendoReactDateRangePicker';
494
+ registerForLocalization(DateRangePickerWithoutContext);