@skbkontur/react-ui 3.12.5 → 3.12.7-datepicker.0

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 (80) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/cjs/components/DateInput/DateInput.styles.js +2 -2
  3. package/cjs/components/DateInput/DateInput.styles.js.map +1 -1
  4. package/cjs/components/DatePicker/DatePicker.d.ts +19 -0
  5. package/cjs/components/DatePicker/DatePicker.js +26 -2
  6. package/cjs/components/DatePicker/DatePicker.js.map +1 -1
  7. package/cjs/components/DatePicker/DatePicker.md +22 -0
  8. package/cjs/components/DatePicker/Picker.d.ts +3 -1
  9. package/cjs/components/DatePicker/Picker.js +5 -1
  10. package/cjs/components/DatePicker/Picker.js.map +1 -1
  11. package/cjs/components/Tooltip/Tooltip.d.ts +1 -1
  12. package/cjs/components/Tooltip/Tooltip.js +2 -2
  13. package/cjs/components/Tooltip/Tooltip.js.map +1 -1
  14. package/cjs/internal/Calendar/Calendar.d.ts +11 -1
  15. package/cjs/internal/Calendar/Calendar.js +63 -20
  16. package/cjs/internal/Calendar/Calendar.js.map +1 -1
  17. package/cjs/internal/Calendar/Calendar.styles.js +1 -1
  18. package/cjs/internal/Calendar/Calendar.styles.js.map +1 -1
  19. package/cjs/internal/Calendar/DayCellView.d.ts +2 -0
  20. package/cjs/internal/Calendar/DayCellView.js +3 -2
  21. package/cjs/internal/Calendar/DayCellView.js.map +1 -1
  22. package/cjs/internal/Calendar/DayCellView.styles.js +5 -5
  23. package/cjs/internal/Calendar/DayCellView.styles.js.map +1 -1
  24. package/cjs/internal/Calendar/Month.d.ts +1 -0
  25. package/cjs/internal/Calendar/Month.js +9 -4
  26. package/cjs/internal/Calendar/Month.js.map +1 -1
  27. package/cjs/internal/Calendar/MonthView.styles.js +1 -1
  28. package/cjs/internal/Calendar/MonthView.styles.js.map +1 -1
  29. package/cjs/internal/Calendar/MonthViewModel.js +2 -2
  30. package/cjs/internal/Calendar/MonthViewModel.js.map +1 -1
  31. package/cjs/internal/Calendar/config.d.ts +2 -1
  32. package/cjs/internal/Calendar/config.js +6 -3
  33. package/cjs/internal/Calendar/config.js.map +1 -1
  34. package/cjs/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
  35. package/cjs/internal/themes/DefaultTheme.d.ts +4 -0
  36. package/cjs/internal/themes/DefaultTheme.js +12 -2
  37. package/cjs/internal/themes/DefaultTheme.js.map +1 -1
  38. package/cjs/internal/themes/Theme8px.d.ts +2 -1
  39. package/cjs/internal/themes/Theme8px.js +2 -1
  40. package/cjs/internal/themes/Theme8px.js.map +1 -1
  41. package/components/DateInput/DateInput.styles/DateInput.styles.js +2 -2
  42. package/components/DateInput/DateInput.styles/DateInput.styles.js.map +1 -1
  43. package/components/DatePicker/DatePicker/DatePicker.js +9 -2
  44. package/components/DatePicker/DatePicker/DatePicker.js.map +1 -1
  45. package/components/DatePicker/DatePicker.d.ts +19 -0
  46. package/components/DatePicker/DatePicker.md +22 -0
  47. package/components/DatePicker/Picker/Picker.js +3 -1
  48. package/components/DatePicker/Picker/Picker.js.map +1 -1
  49. package/components/DatePicker/Picker.d.ts +3 -1
  50. package/components/Tooltip/Tooltip/Tooltip.js +2 -2
  51. package/components/Tooltip/Tooltip/Tooltip.js.map +1 -1
  52. package/components/Tooltip/Tooltip.d.ts +1 -1
  53. package/internal/Calendar/Calendar/Calendar.js +55 -22
  54. package/internal/Calendar/Calendar/Calendar.js.map +1 -1
  55. package/internal/Calendar/Calendar.d.ts +11 -1
  56. package/internal/Calendar/Calendar.styles/Calendar.styles.js +1 -1
  57. package/internal/Calendar/Calendar.styles/Calendar.styles.js.map +1 -1
  58. package/internal/Calendar/DayCellView/DayCellView.js +3 -2
  59. package/internal/Calendar/DayCellView/DayCellView.js.map +1 -1
  60. package/internal/Calendar/DayCellView.d.ts +2 -0
  61. package/internal/Calendar/DayCellView.styles/DayCellView.styles.js +1 -1
  62. package/internal/Calendar/DayCellView.styles/DayCellView.styles.js.map +1 -1
  63. package/internal/Calendar/Month/Month.js +8 -3
  64. package/internal/Calendar/Month/Month.js.map +1 -1
  65. package/internal/Calendar/Month.d.ts +1 -0
  66. package/internal/Calendar/MonthView.styles/MonthView.styles.js +1 -1
  67. package/internal/Calendar/MonthView.styles/MonthView.styles.js.map +1 -1
  68. package/internal/Calendar/MonthViewModel/MonthViewModel.js +2 -2
  69. package/internal/Calendar/MonthViewModel/MonthViewModel.js.map +1 -1
  70. package/internal/Calendar/config/config.js +4 -3
  71. package/internal/Calendar/config/config.js.map +1 -1
  72. package/internal/Calendar/config.d.ts +2 -1
  73. package/internal/ThemeShowcase/VariablesCollector.d.ts +1 -1
  74. package/internal/themes/DefaultTheme/DefaultTheme.js +17 -0
  75. package/internal/themes/DefaultTheme/DefaultTheme.js.map +1 -1
  76. package/internal/themes/DefaultTheme.d.ts +4 -0
  77. package/internal/themes/Theme8px/Theme8px.js +2 -1
  78. package/internal/themes/Theme8px/Theme8px.js.map +1 -1
  79. package/internal/themes/Theme8px.d.ts +2 -1
  80. package/package.json +3 -3
@@ -29,6 +29,13 @@ var _CalendarDateShape = require("./CalendarDateShape");
29
29
 
30
30
 
31
31
 
32
+
33
+
34
+
35
+
36
+
37
+
38
+
32
39
 
33
40
 
34
41
 
@@ -93,6 +100,19 @@ Calendar = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default
93
100
 
94
101
 
95
102
 
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+
113
+
114
+
115
+
96
116
 
97
117
 
98
118
 
@@ -209,15 +229,13 @@ Calendar = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default
209
229
 
210
230
 
211
231
  renderMain = function () {
212
- var positions = _this.getMonthPositions();
232
+ var monthsForRender = _this.getVisibleMonths(_this.state);
213
233
  var wrapperStyle = { height: (0, _config.themeConfig)(_this.theme).WRAPPER_HEIGHT };
234
+
214
235
  return /*#__PURE__*/(
215
236
  _react.default.createElement("div", { ref: _this.refRoot, className: _Calendar.styles.root(_this.theme), "data-tid": "Calendar" }, /*#__PURE__*/
216
237
  _react.default.createElement("div", { style: wrapperStyle, className: _Calendar.styles.wrapper() },
217
- _this.state.months.
218
- map(function (x, i) {return [positions[i], x];}).
219
- filter(function (_ref2) {var top = _ref2[0],month = _ref2[1];return CalendarUtils.isMonthVisible(top, month, _this.theme);}).
220
- map(_this.renderMonth, (0, _assertThisInitialized2.default)(_this)))));
238
+ monthsForRender.map(_this.renderMonth, (0, _assertThisInitialized2.default)(_this)))));
221
239
 
222
240
 
223
241
 
@@ -250,16 +268,6 @@ Calendar = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default
250
268
 
251
269
 
252
270
 
253
-
254
-
255
-
256
-
257
-
258
-
259
-
260
-
261
-
262
-
263
271
 
264
272
 
265
273
 
@@ -276,7 +284,7 @@ Calendar = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default
276
284
  };_this.
277
285
 
278
286
  executeAnimations = function (pixelY) {
279
- _this.setState(function (_ref3) {var months = _ref3.months,scrollPosition = _ref3.scrollPosition;
287
+ _this.setState(function (_ref2) {var months = _ref2.months,scrollPosition = _ref2.scrollPosition;
280
288
  var targetPosition = CalendarUtils.calculateScrollPosition(
281
289
  months,
282
290
  scrollPosition,
@@ -337,7 +345,7 @@ Calendar = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default
337
345
  scrollToNearestWeek = function () {var _this$state =
338
346
  _this.state,scrollTarget = _this$state.scrollTarget,scrollDirection = _this$state.scrollDirection;
339
347
 
340
- var trasholdHeight = (0, _config.themeConfig)(_this.theme).MONTH_TITLE_OFFSET_HEIGHT + (0, _config.themeConfig)(_this.theme).DAY_SIZE;
348
+ var trasholdHeight = (0, _config.themeConfig)(_this.theme).MONTH_TITLE_OFFSET_HEIGHT + (0, _config.themeConfig)(_this.theme).DAY_HEIGHT;
341
349
 
342
350
  if (scrollTarget < trasholdHeight) {
343
351
  var targetPosition = 0;
@@ -364,12 +372,47 @@ Calendar = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default
364
372
  return _this.animation.animate(
365
373
  scrollAmmount,
366
374
  function (deltaY) {return (
367
- _this.setState(function (_ref4) {var scrollPosition = _ref4.scrollPosition;return {
375
+ _this.setState(function (_ref3) {var scrollPosition = _ref3.scrollPosition;return {
368
376
  scrollPosition: scrollPosition + deltaY };}));},
369
377
 
370
378
  onEnd);
371
379
 
372
- };var today = getTodayDate();var initialMonth = props.initialMonth == null ? today.month : props.initialMonth;var initialYear = props.initialYear == null ? today.year : props.initialYear;_this.state = { scrollPosition: 0, months: CalendarUtils.getMonths(initialMonth, initialYear), today: today, scrollDirection: 1, scrollTarget: 0, touchStart: 0 };return _this;}var _proto = Calendar.prototype;_proto.componentWillUnmount = function componentWillUnmount() {if (this.animation.inProgress()) {this.animation.cancel();}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});} /**
380
+ };_this.
381
+
382
+
383
+
384
+
385
+
386
+
387
+
388
+
389
+
390
+
391
+
392
+
393
+
394
+
395
+
396
+
397
+
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+
407
+
408
+
409
+
410
+
411
+
412
+
413
+
414
+
415
+ getViewModel = function (item) {return item[1];};var today = getTodayDate();var initialMonth = props.initialMonth == null ? today.month : props.initialMonth;var initialYear = props.initialYear == null ? today.year : props.initialYear;_this.state = { scrollPosition: 0, months: CalendarUtils.getMonths(initialMonth, initialYear), today: today, scrollDirection: 1, scrollTarget: 0, touchStart: 0 };return _this;}var _proto = Calendar.prototype;_proto.componentWillUnmount = function componentWillUnmount() {if (this.animation.inProgress()) {this.animation.cancel();}};_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {if (this.props.onMonthChange) {var visibleMonthsModels = this.getVisibleMonths(this.state).map(this.getViewModel);var prevFirstVisibleMonthModels = this.getVisibleMonths(prevState).map(this.getViewModel);var currentMonth = visibleMonthsModels[0].month;var prevCurrentMonth = prevFirstVisibleMonthModels[0].month;if (currentMonth !== prevCurrentMonth) {this.monthsChangeHandle(this.props.onMonthChange, visibleMonthsModels);}}};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});} /**
373
416
  * Scrolls calendar to given date
374
417
  * @public
375
- */;_proto.renderMonth = function renderMonth(_ref5) {var top = _ref5[0],month = _ref5[1];return /*#__PURE__*/_react.default.createElement(_Month.Month, { key: month.month + '-' + month.year, top: top, month: month, maxDate: this.props.maxDate, minDate: this.props.minDate, today: this.state.today, value: this.props.value, onDateClick: this.props.onSelect, onMonthYearChange: this.handleMonthYearChange, isHoliday: this.props.isHoliday });};_proto.getMonthPositions = function getMonthPositions() {var _this$state2 = this.state,scrollPosition = _this$state2.scrollPosition,months = _this$state2.months;var positions = [scrollPosition - months[0].getHeight(this.theme)];for (var i = 1; i < months.length; i++) {var position = positions[i - 1] + months[i - 1].getHeight(this.theme);positions.push(position);}return positions;};return Calendar;}(_react.default.Component);exports.Calendar = Calendar;Calendar.__KONTUR_REACT_UI__ = 'Calendar';Calendar.defaultProps = { holidays: [], minDate: { year: _constants.MIN_YEAR, month: _constants.MIN_MONTH, date: _constants.MIN_DATE }, maxDate: { year: _constants.MAX_YEAR, month: _constants.MAX_MONTH, date: _constants.MAX_DATE } };
418
+ */;_proto.renderMonth = function renderMonth(_ref4) {var top = _ref4[0],month = _ref4[1];return /*#__PURE__*/_react.default.createElement(_Month.Month, { key: month.month + '-' + month.year, top: top, month: month, maxDate: this.props.maxDate, minDate: this.props.minDate, today: this.state.today, value: this.props.value, onDateClick: this.props.onSelect, onMonthYearChange: this.handleMonthYearChange, isHoliday: this.props.isHoliday, renderDay: this.props.renderDay });};_proto.getMonthPositions = function getMonthPositions(months, scrollPosition) {var positions = [scrollPosition - months[0].getHeight(this.theme)];for (var i = 1; i < months.length; i++) {var position = positions[i - 1] + months[i - 1].getHeight(this.theme);positions.push(position);}return positions;};_proto.getVisibleMonths = function getVisibleMonths(state) {var _this3 = this;var months = state.months,scrollPosition = state.scrollPosition;var positions = this.getMonthPositions(months, scrollPosition);return months.map(function (x, i) {return [positions[i], x];}).filter(function (_ref5) {var top = _ref5[0],month = _ref5[1];return CalendarUtils.isMonthVisible(top, month, _this3.theme);});};_proto.monthsChangeHandle = function monthsChangeHandle(handler, visibleMonths) {var currentMonth = visibleMonths[0];var changeInfo = { month: currentMonth.month, year: currentMonth.year };handler(changeInfo);};return Calendar;}(_react.default.Component);exports.Calendar = Calendar;Calendar.__KONTUR_REACT_UI__ = 'Calendar';Calendar.defaultProps = { holidays: [], minDate: { year: _constants.MIN_YEAR, month: _constants.MIN_MONTH, date: _constants.MIN_DATE }, maxDate: { year: _constants.MAX_YEAR, month: _constants.MAX_MONTH, date: _constants.MAX_DATE } };
@@ -1 +1 @@
1
- {"version":3,"sources":["Calendar.tsx"],"names":["getTodayDate","date","Date","getDate","month","getMonth","year","getFullYear","Calendar","props","theme","wheelEndTimeout","root","animation","touchStartY","scrollToMonth","inProgress","finish","Promise","r","setTimeout","minDate","maxDate","currentMonth","state","months","diffInMonths","scrollTo","maxMonthsToAdd","MAX_MONTHS_TO_APPEND_ON_SCROLL","onEnd","setState","CalendarUtils","getMonths","scrollPosition","isYearChanges","Math","abs","monthsToPrependCount","min","monthsToPrepend","Array","from","length","_","index","MonthViewModel","create","yearChanges","isFirstInYear","isLastInYear","concat","getMonthsHeight","targetPosition","getHeight","monthsToAppendCount","monthsToAppend","slice","renderMain","positions","getMonthPositions","wrapperStyle","height","WRAPPER_HEIGHT","refRoot","styles","wrapper","map","x","i","filter","top","isMonthVisible","renderMonth","element","isMobile","addEventListener","handleTouchStart","throttledHandleTouchMove","handleWheel","passive","removeEventListener","handleMonthYearChange","executeAnimations","pixelY","calculateScrollPosition","scrollTarget","handleWheelEnd","animate","deltaY","applyDelta","CalendarScrollEvents","emit","event","TouchEvent","clientY","targetTouches","handleTouchMove","changedTouches","WheelEvent","preventDefault","clearTimeout","window","scrollToNearestWeek","scrollDirection","trasholdHeight","MONTH_TITLE_OFFSET_HEIGHT","DAY_SIZE","amount","pos","scrollAmmount","scrollAmount","today","initialMonth","initialYear","touchStart","componentWillUnmount","cancel","render","value","onSelect","isHoliday","position","push","React","Component","__KONTUR_REACT_UI__","defaultProps","holidays","MIN_YEAR","MIN_MONTH","MIN_DATE","MAX_YEAR","MAX_MONTH","MAX_DATE"],"mappings":"8mBAAA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;AAqBA,IAAMA,YAAY,GAAG,SAAfA,YAAe,GAAM;AACzB,MAAMC,IAAI,GAAG,IAAIC,IAAJ,EAAb;AACA,SAAO;AACLD,IAAAA,IAAI,EAAEA,IAAI,CAACE,OAAL,EADD;AAELC,IAAAA,KAAK,EAAEH,IAAI,CAACI,QAAL,EAFF;AAGLC,IAAAA,IAAI,EAAEL,IAAI,CAACM,WAAL,EAHD,EAAP;;AAKD,CAPD,C;;AASaC,Q;;;;;;;;;;;;;;;;;;;;;;;AAuBX,oBAAYC,KAAZ,EAAkC;AAChC,wCAAMA,KAAN,UADgC,MAN1BC,KAM0B,gBAL1BC,eAK0B,gBAJ1BC,IAI0B,gBAH1BC,SAG0B,GAHd,2BAGc,OAF1BC,WAE0B,GAFM,IAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuC3BC,IAAAA,aAvC2B,gHAuCX,iBAAOX,KAAP,EAAsBE,IAAtB;AACjB,sBAAKO,SAAL,CAAeG,UAAf,EADiB;AAEnB,sBAAKH,SAAL,CAAeI,MAAf;AACA;AAHmB,yCAIb,IAAIC,OAAJ,CAAY,UAACC,CAAD,UAAOC,UAAU,CAACD,CAAD,CAAjB,EAAZ,CAJa;;;AAOQ,sBAAKV,KAPb,EAObY,OA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T,MADE,gBACFA,MADE,CAG1B,IAAMkC,SAAS,GAAG,CAACzB,cAAc,GAAGT,MAAM,CAAC,CAAD,CAAN,CAAU6B,SAAV,CAAoB,KAAK5C,KAAzB,CAAlB,CAAlB,CACA,KAAK,IAAI2D,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAG5C,MAAM,CAACkB,MAA3B,EAAmC0B,CAAC,EAApC,EAAwC,CACtC,IAAMqD,QAAQ,GAAG/D,SAAS,CAACU,CAAC,GAAG,CAAL,CAAT,GAAmB5C,MAAM,CAAC4C,CAAC,GAAG,CAAL,CAAN,CAAcf,SAAd,CAAwB,KAAK5C,KAA7B,CAApC,CACAiD,SAAS,CAACgE,IAAV,CAAeD,QAAf,EACD,CACD,OAAO/D,SAAP,CACD,C,mBAhO2BiE,eAAMC,S,8BAAvBrH,Q,CACGsH,mB,GAAsB,U,CADzBtH,Q,CAGGuH,Y,GAAe,EAC3BC,QAAQ,EAAE,EADiB,EAE3B3G,OAAO,EAAE,EACPf,IAAI,EAAE2H,mBADC,EAEP7H,KAAK,EAAE8H,oBAFA,EAGPjI,IAAI,EAAEkI,mBAHC,EAFkB,EAO3B7G,OAAO,EAAE,EACPhB,IAAI,EAAE8H,mBADC,EAEPhI,KAAK,EAAEiI,oBAFA,EAGPpI,IAAI,EAAEqI,mBAHC,EAPkB,E","sourcesContent":["import React from 'react';\nimport normalizeWheel from 'normalize-wheel';\nimport throttle from 'lodash.throttle';\n\nimport { MAX_DATE, MAX_MONTH, MAX_YEAR, MIN_DATE, MIN_MONTH, MIN_YEAR } from '../../lib/date/constants';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Animation } from '../../lib/animation';\nimport { isMobile } from '../../lib/client';\n\nimport { themeConfig } from './config';\nimport * as CalendarUtils from './CalendarUtils';\nimport { MonthViewModel } from './MonthViewModel';\nimport * as CalendarScrollEvents from './CalendarScrollEvents';\nimport { Month } from './Month';\nimport { styles } from './Calendar.styles';\nimport { CalendarDateShape, create, isGreater, isLess } from './CalendarDateShape';\n\nexport interface CalendarProps {\n initialMonth?: number;\n initialYear?: number;\n onSelect?: (date: CalendarDateShape) => void;\n value?: Nullable<CalendarDateShape>;\n maxDate?: CalendarDateShape;\n minDate?: CalendarDateShape;\n isHoliday?: (day: CalendarDateShape & { isWeekend: boolean }) => boolean;\n}\n\nexport interface CalendarState {\n scrollPosition: number;\n months: MonthViewModel[];\n today: CalendarDateShape;\n scrollDirection: number;\n scrollTarget: number;\n touchStart: number;\n}\n\nconst getTodayDate = () => {\n const date = new Date();\n return {\n date: date.getDate(),\n month: date.getMonth(),\n year: date.getFullYear(),\n };\n};\n\nexport class Calendar extends React.Component<CalendarProps, CalendarState> {\n public static __KONTUR_REACT_UI__ = 'Calendar';\n\n public static defaultProps = {\n holidays: [],\n minDate: {\n year: MIN_YEAR,\n month: MIN_MONTH,\n date: MIN_DATE,\n },\n maxDate: {\n year: MAX_YEAR,\n month: MAX_MONTH,\n date: MAX_DATE,\n },\n };\n\n private theme!: Theme;\n private wheelEndTimeout: Nullable<number>;\n private root: Nullable<HTMLElement>;\n private animation = Animation();\n private touchStartY: Nullable<number> = null;\n\n constructor(props: CalendarProps) {\n super(props);\n\n const today = getTodayDate();\n\n const initialMonth = props.initialMonth == null ? today.month : props.initialMonth;\n const initialYear = props.initialYear == null ? today.year : props.initialYear;\n\n this.state = {\n scrollPosition: 0,\n months: CalendarUtils.getMonths(initialMonth, initialYear),\n today,\n scrollDirection: 1,\n scrollTarget: 0,\n touchStart: 0,\n };\n }\n\n public componentWillUnmount() {\n if (this.animation.inProgress()) {\n this.animation.cancel();\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /**\n * Scrolls calendar to given date\n * @public\n */\n public scrollToMonth = async (month: number, year: number) => {\n if (this.animation.inProgress()) {\n this.animation.finish();\n // FIXME: Dirty hack to await batched updates\n await new Promise((r) => setTimeout(r));\n }\n\n const { minDate, maxDate } = this.props;\n\n if (minDate && isGreater(minDate, create(32, month, year))) {\n this.scrollToMonth(minDate.month, minDate.year);\n return;\n }\n\n if (maxDate && isLess(maxDate, create(0, month, year))) {\n this.scrollToMonth(maxDate.month, maxDate.year);\n return;\n }\n\n const currentMonth = this.state.months[1];\n const diffInMonths = currentMonth.month + currentMonth.year * 12 - month - year * 12;\n\n if (diffInMonths === 0) {\n this.scrollTo(0);\n return;\n }\n\n const maxMonthsToAdd = themeConfig(this.theme).MAX_MONTHS_TO_APPEND_ON_SCROLL;\n\n const onEnd = () =>\n this.setState({\n months: CalendarUtils.getMonths(month, year),\n scrollPosition: 0,\n });\n\n const isYearChanges = (state: CalendarState) =>\n state.months[1].year !== year &&\n // if diff in months is 2 or less,\n // either year is not changing either months already\n // have right isFirstInYear/isLastInYear flags\n Math.abs(diffInMonths) > 2;\n\n // If scrolling upwards, prepend maximum maxMonthsToAdd months\n // and scroll to the first month\n if (diffInMonths > 0) {\n const monthsToPrependCount = Math.min(Math.abs(diffInMonths) - 1, maxMonthsToAdd);\n const monthsToPrepend = Array.from({ length: monthsToPrependCount }, (_, index) =>\n MonthViewModel.create(month + index, year),\n );\n this.setState(\n (state) => {\n const yearChanges = isYearChanges(state);\n if (yearChanges) {\n // Mutating here can lead to some unexpected bugs\n // but we couldn't find any yet\n state.months[0].isFirstInYear = true;\n if (monthsToPrepend.length) {\n // Mutating item here is safe as it was just created\n monthsToPrepend[monthsToPrepend.length - 1].isLastInYear = true;\n }\n }\n return {\n months: monthsToPrepend.concat(state.months),\n scrollPosition: -CalendarUtils.getMonthsHeight(monthsToPrepend, this.theme),\n };\n },\n () => {\n const targetPosition = this.state.months[0].getHeight(this.theme);\n this.scrollTo(targetPosition, onEnd);\n },\n );\n }\n\n // If scrolling downwards, append maximum maxMonthsToAdd months\n // and scroll to the last but one month\n if (diffInMonths < 0) {\n const monthsToAppendCount = Math.min(Math.abs(diffInMonths), maxMonthsToAdd);\n const monthsToAppend = Array.from({ length: monthsToAppendCount }, (_, index) =>\n MonthViewModel.create(month + index - monthsToAppendCount + 2, year),\n );\n this.setState(\n (state) => {\n if (isYearChanges(state)) {\n // Mutating here can lead to some unexpected bugs\n // but we couldn't find any yet\n state.months[state.months.length - 1].isLastInYear = true;\n // Mutating item here is safe as it was just created\n if (monthsToAppend[0]) {\n monthsToAppend[0].isFirstInYear = true;\n }\n }\n return { months: state.months.concat(monthsToAppend) };\n },\n () => {\n const targetPosition = -1 * CalendarUtils.getMonthsHeight(this.state.months.slice(1, -2), this.theme);\n this.scrollTo(targetPosition, onEnd);\n },\n );\n }\n };\n\n private renderMain = () => {\n const positions = this.getMonthPositions();\n const wrapperStyle = { height: themeConfig(this.theme).WRAPPER_HEIGHT };\n return (\n <div ref={this.refRoot} className={styles.root(this.theme)} data-tid=\"Calendar\">\n <div style={wrapperStyle} className={styles.wrapper()}>\n {this.state.months\n .map<[number, MonthViewModel]>((x, i) => [positions[i], x])\n .filter(([top, month]) => CalendarUtils.isMonthVisible(top, month, this.theme))\n .map(this.renderMonth, this)}\n </div>\n </div>\n );\n };\n\n private refRoot = (element: HTMLElement | null) => {\n if (!this.root && element) {\n if (isMobile) {\n element.addEventListener('touchstart', this.handleTouchStart);\n element.addEventListener('touchmove', this.throttledHandleTouchMove);\n } else {\n element.addEventListener('wheel', this.handleWheel, { passive: false });\n }\n }\n if (this.root && !element) {\n if (isMobile) {\n this.root.removeEventListener('touchstart', this.handleTouchStart);\n this.root.removeEventListener('touchmove', this.throttledHandleTouchMove);\n } else {\n this.root.removeEventListener('wheel', this.handleWheel);\n }\n }\n this.root = element;\n };\n\n private renderMonth([top, month]: [number, MonthViewModel]) {\n return (\n <Month\n key={month.month + '-' + month.year}\n top={top}\n month={month}\n maxDate={this.props.maxDate}\n minDate={this.props.minDate}\n today={this.state.today}\n value={this.props.value}\n onDateClick={this.props.onSelect}\n onMonthYearChange={this.handleMonthYearChange}\n isHoliday={this.props.isHoliday}\n />\n );\n }\n\n private getMonthPositions() {\n const { scrollPosition, months } = this.state;\n\n const positions = [scrollPosition - months[0].getHeight(this.theme)];\n for (let i = 1; i < months.length; i++) {\n const position = positions[i - 1] + months[i - 1].getHeight(this.theme);\n positions.push(position);\n }\n return positions;\n }\n\n private handleMonthYearChange = (month: number, year: number) => {\n this.scrollToMonth(month, year);\n };\n\n private executeAnimations = (pixelY: number) => {\n this.setState(({ months, scrollPosition }) => {\n const targetPosition = CalendarUtils.calculateScrollPosition(\n months,\n scrollPosition,\n pixelY,\n this.theme,\n ).scrollPosition;\n return { scrollTarget: targetPosition };\n }, this.handleWheelEnd);\n\n this.animation.animate(pixelY, (deltaY) =>\n // FIXME: Typescript not resolving setState cb type\n this.setState(CalendarUtils.applyDelta(deltaY, this.theme) as any),\n );\n\n CalendarScrollEvents.emit();\n };\n\n private handleTouchStart = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n const clientY = event.targetTouches[0].clientY;\n this.touchStartY = clientY;\n };\n\n private handleTouchMove = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n const { clientY } = event.changedTouches[0];\n\n const deltaY = (this.touchStartY || 0) - clientY;\n this.touchStartY = clientY;\n\n this.executeAnimations(deltaY);\n };\n\n private throttledHandleTouchMove = throttle(this.handleTouchMove, 10);\n\n private handleWheel = (event: Event) => {\n if (!(event instanceof WheelEvent)) {\n return;\n }\n event.preventDefault();\n const { pixelY } = normalizeWheel(event);\n\n this.executeAnimations(pixelY);\n };\n\n private handleWheelEnd = () => {\n if (this.wheelEndTimeout) {\n clearTimeout(this.wheelEndTimeout);\n }\n this.wheelEndTimeout = window.setTimeout(this.scrollToNearestWeek, 300);\n };\n private scrollToNearestWeek = () => {\n const { scrollTarget, scrollDirection } = this.state;\n\n const trasholdHeight = themeConfig(this.theme).MONTH_TITLE_OFFSET_HEIGHT + themeConfig(this.theme).DAY_SIZE;\n\n if (scrollTarget < trasholdHeight) {\n let targetPosition = 0;\n if (scrollDirection < 0) {\n targetPosition = trasholdHeight;\n }\n\n this.setState({ scrollTarget: targetPosition }, () => {\n const amount = scrollTarget - targetPosition;\n this.animation.animate(amount, (deltaY) =>\n // FIXME: Typescript not resolving setState cb type\n this.setState(CalendarUtils.applyDelta(deltaY, this.theme) as any),\n );\n });\n }\n };\n\n private scrollTo = (pos: number, onEnd?: () => void) => {\n const scrollAmmount = pos - this.state.scrollPosition;\n return this.scrollAmount(scrollAmmount, onEnd);\n };\n\n private scrollAmount = (scrollAmmount: number, onEnd?: () => void) => {\n return this.animation.animate(\n scrollAmmount,\n (deltaY) =>\n this.setState(({ scrollPosition }) => ({\n scrollPosition: scrollPosition + deltaY,\n })),\n onEnd,\n );\n };\n}\n"]}
1
+ {"version":3,"sources":["Calendar.tsx"],"names":["getTodayDate","date","Date","getDate","month","getMonth","year","getFullYear","Calendar","props","theme","wheelEndTimeout","root","animation","touchStartY","scrollToMonth","inProgress","finish","Promise","r","setTimeout","minDate","maxDate","currentMonth","state","months","diffInMonths","scrollTo","maxMonthsToAdd","MAX_MONTHS_TO_APPEND_ON_SCROLL","onEnd","setState","CalendarUtils","getMonths","scrollPosition","isYearChanges","Math","abs","monthsToPrependCount","min","monthsToPrepend","Array","from","length","_","index","MonthViewModel","create","yearChanges","isFirstInYear","isLastInYear","concat","getMonthsHeight","targetPosition","getHeight","monthsToAppendCount","monthsToAppend","slice","renderMain","monthsForRender","getVisibleMonths","wrapperStyle","height","WRAPPER_HEIGHT","refRoot","styles","wrapper","map","renderMonth","element","isMobile","addEventListener","handleTouchStart","throttledHandleTouchMove","handleWheel","passive","removeEventListener","handleMonthYearChange","executeAnimations","pixelY","calculateScrollPosition","scrollTarget","handleWheelEnd","animate","deltaY","applyDelta","CalendarScrollEvents","emit","event","TouchEvent","clientY","targetTouches","handleTouchMove","changedTouches","WheelEvent","preventDefault","clearTimeout","window","scrollToNearestWeek","scrollDirection","trasholdHeight","MONTH_TITLE_OFFSET_HEIGHT","DAY_HEIGHT","amount","pos","scrollAmmount","scrollAmount","getViewModel","item","today","initialMonth","initialYear","touchStart","componentWillUnmount","cancel","componentDidUpdate","prevProps","prevState","onMonthChange","visibleMonthsModels","prevFirstVisibleMonthModels","prevCurrentMonth","monthsChangeHandle","render","top","value","onSelect","isHoliday","renderDay","getMonthPositions","positions","i","position","push","x","filter","isMonthVisible","handler","visibleMonths","changeInfo","React","Component","__KONTUR_REACT_UI__","defaultProps","holidays","MIN_YEAR","MIN_MONTH","MIN_DATE","MAX_YEAR","MAX_MONTH","MAX_DATE"],"mappings":"8mBAAA;AACA;AACA;;AAEA;;;AAGA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAMA,YAAY,GAAG,SAAfA,YAAe,GAAM;AACzB,MAAMC,IAAI,GAAG,IAAIC,IAAJ,EAAb;AACA,SAAO;AACLD,IAAAA,IAAI,EAAEA,IAAI,CAACE,OAAL,EADD;AAELC,IAAAA,KAAK,EAAEH,IAAI,CAACI,QAAL,EAFF;AAGLC,IAAAA,IAAI,EAAEL,IAAI,CAACM,WAAL,EAHD,EAAP;;AAKD,CAPD,C;;AASaC,Q;;;;;;;;;;;;;;;;;;;;;;;AAuBX,oBAAYC,KAAZ,EAAkC;AAChC,wCAAMA,KAAN,UADgC,MAN1BC,KAM0B,gBAL1BC,eAK0B,gBAJ1BC,IAI0B,gBAH1BC,SAG0B,GAHd,2BAGc,OAF1BC,WAE0B,GAFM,IAEN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoD3BC,IAAAA,aApD2B,gHAoDX,iBAAOX,KAAP,EAAsBE,IAAtB;AACjB,sBAAKO,SAAL,CAAeG,UAAf,EADiB;AAEnB,sBAAKH,SAAL,CAAeI,MAAf;AACA;AAHmB,yCAIb,IAAIC,OAAJ,CAAY,UAACC,CAAD,UAAOC,UA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AAM,CACV0C,GADI,CAC0B,UAACmE,CAAD,EAAIH,CAAJ,UAAU,CAACD,SAAS,CAACC,CAAD,CAAV,EAAeG,CAAf,CAAV,EAD1B,EAEJC,MAFI,CAEG,sBAAEX,GAAF,YAAOxH,KAAP,mBAAkB4B,aAAa,CAACwG,cAAd,CAA6BZ,GAA7B,EAAkCxH,KAAlC,EAAyC,MAAI,CAACM,KAA9C,CAAlB,EAFH,CAAP,CAGD,C,QAEOgH,kB,GAAR,4BACEe,OADF,EAEEC,aAFF,EAGQ,CACN,IAAMnH,YAAY,GAAGmH,aAAa,CAAC,CAAD,CAAlC,CACA,IAAMC,UAAU,GAAG,EACjBvI,KAAK,EAAEmB,YAAY,CAACnB,KADH,EAEjBE,IAAI,EAAEiB,YAAY,CAACjB,IAFF,EAAnB,CAKAmI,OAAO,CAACE,UAAD,CAAP,CACD,C,mBAtW2BC,eAAMC,S,8BAAvBrI,Q,CACGsI,mB,GAAsB,U,CADzBtI,Q,CAGGuI,Y,GAAe,EAC3BC,QAAQ,EAAE,EADiB,EAE3B3H,OAAO,EAAE,EACPf,IAAI,EAAE2I,mBADC,EAEP7I,KAAK,EAAE8I,oBAFA,EAGPjJ,IAAI,EAAEkJ,mBAHC,EAFkB,EAO3B7H,OAAO,EAAE,EACPhB,IAAI,EAAE8I,mBADC,EAEPhJ,KAAK,EAAEiJ,oBAFA,EAGPpJ,IAAI,EAAEqJ,mBAHC,EAPkB,E","sourcesContent":["import React from 'react';\nimport normalizeWheel from 'normalize-wheel';\nimport throttle from 'lodash.throttle';\n\nimport { MAX_DATE, MAX_MONTH, MAX_YEAR, MIN_DATE, MIN_MONTH, MIN_YEAR } from '../../lib/date/constants';\nimport { Nullable } from '../../typings/utility-types';\nimport { Theme } from '../../lib/theming/Theme';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Animation } from '../../lib/animation';\nimport { isMobile } from '../../lib/client';\n\nimport { themeConfig } from './config';\nimport * as CalendarUtils from './CalendarUtils';\nimport { MonthViewModel } from './MonthViewModel';\nimport * as CalendarScrollEvents from './CalendarScrollEvents';\nimport { Month } from './Month';\nimport { styles } from './Calendar.styles';\nimport { CalendarDateShape, create, isGreater, isLess } from './CalendarDateShape';\n\nexport interface CalendarMonthChangeInfo {\n month: number;\n year: number;\n}\n\nexport interface CalendarProps {\n initialMonth?: number;\n initialYear?: number;\n onSelect?: (date: CalendarDateShape) => void;\n value?: Nullable<CalendarDateShape>;\n maxDate?: CalendarDateShape;\n minDate?: CalendarDateShape;\n isHoliday?: (day: CalendarDateShape & { isWeekend: boolean }) => boolean;\n renderDay?: (date: CalendarDateShape) => React.ReactNode;\n onMonthChange?: (changeInfo: CalendarMonthChangeInfo) => void;\n}\n\nexport interface CalendarState {\n scrollPosition: number;\n months: MonthViewModel[];\n today: CalendarDateShape;\n scrollDirection: number;\n scrollTarget: number;\n touchStart: number;\n}\n\nconst getTodayDate = () => {\n const date = new Date();\n return {\n date: date.getDate(),\n month: date.getMonth(),\n year: date.getFullYear(),\n };\n};\n\nexport class Calendar extends React.Component<CalendarProps, CalendarState> {\n public static __KONTUR_REACT_UI__ = 'Calendar';\n\n public static defaultProps = {\n holidays: [],\n minDate: {\n year: MIN_YEAR,\n month: MIN_MONTH,\n date: MIN_DATE,\n },\n maxDate: {\n year: MAX_YEAR,\n month: MAX_MONTH,\n date: MAX_DATE,\n },\n };\n\n private theme!: Theme;\n private wheelEndTimeout: Nullable<number>;\n private root: Nullable<HTMLElement>;\n private animation = Animation();\n private touchStartY: Nullable<number> = null;\n\n constructor(props: CalendarProps) {\n super(props);\n\n const today = getTodayDate();\n\n const initialMonth = props.initialMonth == null ? today.month : props.initialMonth;\n const initialYear = props.initialYear == null ? today.year : props.initialYear;\n\n this.state = {\n scrollPosition: 0,\n months: CalendarUtils.getMonths(initialMonth, initialYear),\n today,\n scrollDirection: 1,\n scrollTarget: 0,\n touchStart: 0,\n };\n }\n\n public componentWillUnmount() {\n if (this.animation.inProgress()) {\n this.animation.cancel();\n }\n }\n\n public componentDidUpdate(prevProps: Readonly<CalendarProps>, prevState: Readonly<CalendarState>) {\n if (this.props.onMonthChange) {\n const visibleMonthsModels = this.getVisibleMonths(this.state).map(this.getViewModel);\n const prevFirstVisibleMonthModels = this.getVisibleMonths(prevState).map(this.getViewModel);\n const currentMonth = visibleMonthsModels[0].month;\n const prevCurrentMonth = prevFirstVisibleMonthModels[0].month;\n\n if (currentMonth !== prevCurrentMonth) {\n this.monthsChangeHandle(this.props.onMonthChange, visibleMonthsModels);\n }\n }\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n /**\n * Scrolls calendar to given date\n * @public\n */\n public scrollToMonth = async (month: number, year: number) => {\n if (this.animation.inProgress()) {\n this.animation.finish();\n // FIXME: Dirty hack to await batched updates\n await new Promise((r) => setTimeout(r));\n }\n\n const { minDate, maxDate } = this.props;\n\n if (minDate && isGreater(minDate, create(32, month, year))) {\n this.scrollToMonth(minDate.month, minDate.year);\n return;\n }\n\n if (maxDate && isLess(maxDate, create(0, month, year))) {\n this.scrollToMonth(maxDate.month, maxDate.year);\n return;\n }\n\n const currentMonth = this.state.months[1];\n const diffInMonths = currentMonth.month + currentMonth.year * 12 - month - year * 12;\n\n if (diffInMonths === 0) {\n this.scrollTo(0);\n return;\n }\n\n const maxMonthsToAdd = themeConfig(this.theme).MAX_MONTHS_TO_APPEND_ON_SCROLL;\n\n const onEnd = () =>\n this.setState({\n months: CalendarUtils.getMonths(month, year),\n scrollPosition: 0,\n });\n\n const isYearChanges = (state: CalendarState) =>\n state.months[1].year !== year &&\n // if diff in months is 2 or less,\n // either year is not changing either months already\n // have right isFirstInYear/isLastInYear flags\n Math.abs(diffInMonths) > 2;\n\n // If scrolling upwards, prepend maximum maxMonthsToAdd months\n // and scroll to the first month\n if (diffInMonths > 0) {\n const monthsToPrependCount = Math.min(Math.abs(diffInMonths) - 1, maxMonthsToAdd);\n const monthsToPrepend = Array.from({ length: monthsToPrependCount }, (_, index) =>\n MonthViewModel.create(month + index, year),\n );\n this.setState(\n (state) => {\n const yearChanges = isYearChanges(state);\n if (yearChanges) {\n // Mutating here can lead to some unexpected bugs\n // but we couldn't find any yet\n state.months[0].isFirstInYear = true;\n if (monthsToPrepend.length) {\n // Mutating item here is safe as it was just created\n monthsToPrepend[monthsToPrepend.length - 1].isLastInYear = true;\n }\n }\n return {\n months: monthsToPrepend.concat(state.months),\n scrollPosition: -CalendarUtils.getMonthsHeight(monthsToPrepend, this.theme),\n };\n },\n () => {\n const targetPosition = this.state.months[0].getHeight(this.theme);\n this.scrollTo(targetPosition, onEnd);\n },\n );\n }\n\n // If scrolling downwards, append maximum maxMonthsToAdd months\n // and scroll to the last but one month\n if (diffInMonths < 0) {\n const monthsToAppendCount = Math.min(Math.abs(diffInMonths), maxMonthsToAdd);\n const monthsToAppend = Array.from({ length: monthsToAppendCount }, (_, index) =>\n MonthViewModel.create(month + index - monthsToAppendCount + 2, year),\n );\n this.setState(\n (state) => {\n if (isYearChanges(state)) {\n // Mutating here can lead to some unexpected bugs\n // but we couldn't find any yet\n state.months[state.months.length - 1].isLastInYear = true;\n // Mutating item here is safe as it was just created\n if (monthsToAppend[0]) {\n monthsToAppend[0].isFirstInYear = true;\n }\n }\n return { months: state.months.concat(monthsToAppend) };\n },\n () => {\n const targetPosition = -1 * CalendarUtils.getMonthsHeight(this.state.months.slice(1, -2), this.theme);\n this.scrollTo(targetPosition, onEnd);\n },\n );\n }\n };\n\n private renderMain = () => {\n const monthsForRender = this.getVisibleMonths(this.state);\n const wrapperStyle = { height: themeConfig(this.theme).WRAPPER_HEIGHT };\n\n return (\n <div ref={this.refRoot} className={styles.root(this.theme)} data-tid=\"Calendar\">\n <div style={wrapperStyle} className={styles.wrapper()}>\n {monthsForRender.map(this.renderMonth, this)}\n </div>\n </div>\n );\n };\n\n private refRoot = (element: HTMLElement | null) => {\n if (!this.root && element) {\n if (isMobile) {\n element.addEventListener('touchstart', this.handleTouchStart);\n element.addEventListener('touchmove', this.throttledHandleTouchMove);\n } else {\n element.addEventListener('wheel', this.handleWheel, { passive: false });\n }\n }\n if (this.root && !element) {\n if (isMobile) {\n this.root.removeEventListener('touchstart', this.handleTouchStart);\n this.root.removeEventListener('touchmove', this.throttledHandleTouchMove);\n } else {\n this.root.removeEventListener('wheel', this.handleWheel);\n }\n }\n this.root = element;\n };\n\n private renderMonth([top, month]: [number, MonthViewModel]) {\n return (\n <Month\n key={month.month + '-' + month.year}\n top={top}\n month={month}\n maxDate={this.props.maxDate}\n minDate={this.props.minDate}\n today={this.state.today}\n value={this.props.value}\n onDateClick={this.props.onSelect}\n onMonthYearChange={this.handleMonthYearChange}\n isHoliday={this.props.isHoliday}\n renderDay={this.props.renderDay}\n />\n );\n }\n\n private handleMonthYearChange = (month: number, year: number) => {\n this.scrollToMonth(month, year);\n };\n\n private executeAnimations = (pixelY: number) => {\n this.setState(({ months, scrollPosition }) => {\n const targetPosition = CalendarUtils.calculateScrollPosition(\n months,\n scrollPosition,\n pixelY,\n this.theme,\n ).scrollPosition;\n return { scrollTarget: targetPosition };\n }, this.handleWheelEnd);\n\n this.animation.animate(pixelY, (deltaY) =>\n // FIXME: Typescript not resolving setState cb type\n this.setState(CalendarUtils.applyDelta(deltaY, this.theme) as any),\n );\n\n CalendarScrollEvents.emit();\n };\n\n private handleTouchStart = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n const clientY = event.targetTouches[0].clientY;\n this.touchStartY = clientY;\n };\n\n private handleTouchMove = (event: Event) => {\n if (!(event instanceof TouchEvent)) {\n return;\n }\n\n const { clientY } = event.changedTouches[0];\n\n const deltaY = (this.touchStartY || 0) - clientY;\n this.touchStartY = clientY;\n\n this.executeAnimations(deltaY);\n };\n\n private throttledHandleTouchMove = throttle(this.handleTouchMove, 10);\n\n private handleWheel = (event: Event) => {\n if (!(event instanceof WheelEvent)) {\n return;\n }\n event.preventDefault();\n const { pixelY } = normalizeWheel(event);\n\n this.executeAnimations(pixelY);\n };\n\n private handleWheelEnd = () => {\n if (this.wheelEndTimeout) {\n clearTimeout(this.wheelEndTimeout);\n }\n this.wheelEndTimeout = window.setTimeout(this.scrollToNearestWeek, 300);\n };\n private scrollToNearestWeek = () => {\n const { scrollTarget, scrollDirection } = this.state;\n\n const trasholdHeight = themeConfig(this.theme).MONTH_TITLE_OFFSET_HEIGHT + themeConfig(this.theme).DAY_HEIGHT;\n\n if (scrollTarget < trasholdHeight) {\n let targetPosition = 0;\n if (scrollDirection < 0) {\n targetPosition = trasholdHeight;\n }\n\n this.setState({ scrollTarget: targetPosition }, () => {\n const amount = scrollTarget - targetPosition;\n this.animation.animate(amount, (deltaY) =>\n // FIXME: Typescript not resolving setState cb type\n this.setState(CalendarUtils.applyDelta(deltaY, this.theme) as any),\n );\n });\n }\n };\n\n private scrollTo = (pos: number, onEnd?: () => void) => {\n const scrollAmmount = pos - this.state.scrollPosition;\n return this.scrollAmount(scrollAmmount, onEnd);\n };\n\n private scrollAmount = (scrollAmmount: number, onEnd?: () => void) => {\n return this.animation.animate(\n scrollAmmount,\n (deltaY) =>\n this.setState(({ scrollPosition }) => ({\n scrollPosition: scrollPosition + deltaY,\n })),\n onEnd,\n );\n };\n\n private getMonthPositions(months: MonthViewModel[], scrollPosition: number) {\n const positions = [scrollPosition - months[0].getHeight(this.theme)];\n\n for (let i = 1; i < months.length; i++) {\n const position = positions[i - 1] + months[i - 1].getHeight(this.theme);\n positions.push(position);\n }\n\n return positions;\n }\n\n private getVisibleMonths(state: Readonly<CalendarState>): [number, MonthViewModel][] {\n const { months, scrollPosition } = state;\n const positions = this.getMonthPositions(months, scrollPosition);\n\n return months\n .map<[number, MonthViewModel]>((x, i) => [positions[i], x])\n .filter(([top, month]) => CalendarUtils.isMonthVisible(top, month, this.theme));\n }\n\n private monthsChangeHandle(\n handler: (changeInfo: CalendarMonthChangeInfo) => void,\n visibleMonths: MonthViewModel[],\n ): void {\n const currentMonth = visibleMonths[0];\n const changeInfo = {\n month: currentMonth.month,\n year: currentMonth.year,\n };\n\n handler(changeInfo);\n }\n\n private getViewModel = (item: [number, MonthViewModel]): MonthViewModel => item[1];\n}\n"]}
@@ -3,7 +3,7 @@
3
3
 
4
4
  var styles = (0, _Emotion.memoizeStyle)({
5
5
  root: function root(t) {
6
- var width = parseInt(t.calendarCellSize) * 7;
6
+ var width = parseInt(t.calendarCellWidth) * 7;
7
7
  return (0, _Emotion.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["\n box-sizing: content-box;\n color: ", ";\n display: block;\n padding: 0 ", ";\n width: ", "px;\n overflow: hidden;\n touch-action: none;\n "])),
8
8
 
9
9
  t.textColorDefault,
@@ -1 +1 @@
1
- {"version":3,"sources":["Calendar.styles.ts"],"names":["styles","root","t","width","parseInt","calendarCellSize","css","textColorDefault","calendarPaddingX","wrapper"],"mappings":"4QAAA,oD;;;AAGO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,IADiC,gBAC5BC,CAD4B,EAClB;AACb,QAAMC,KAAK,GAAGC,QAAQ,CAACF,CAAC,CAACG,gBAAH,CAAR,GAA+B,CAA7C;AACA,eAAOC,YAAP;;AAEWJ,IAAAA,CAAC,CAACK,gBAFb;;AAIeL,IAAAA,CAAC,CAACM,gBAJjB;AAKWL,IAAAA,KALX;;;;AASD,GAZgC;;AAcjCM,EAAAA,OAdiC,qBAcvB;AACR,eAAOH,YAAP;;;;AAID,GAnBgC,EAAb,CAAf,C","sourcesContent":["import { css, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\n\nexport const styles = memoizeStyle({\n root(t: Theme) {\n const width = parseInt(t.calendarCellSize) * 7;\n return css`\n box-sizing: content-box;\n color: ${t.textColorDefault};\n display: block;\n padding: 0 ${t.calendarPaddingX};\n width: ${width}px;\n overflow: hidden;\n touch-action: none;\n `;\n },\n\n wrapper() {\n return css`\n font-size: 14px;\n position: relative;\n `;\n },\n});\n"]}
1
+ {"version":3,"sources":["Calendar.styles.ts"],"names":["styles","root","t","width","parseInt","calendarCellWidth","css","textColorDefault","calendarPaddingX","wrapper"],"mappings":"4QAAA,oD;;;AAGO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,IADiC,gBAC5BC,CAD4B,EAClB;AACb,QAAMC,KAAK,GAAGC,QAAQ,CAACF,CAAC,CAACG,iBAAH,CAAR,GAAgC,CAA9C;AACA,eAAOC,YAAP;;AAEWJ,IAAAA,CAAC,CAACK,gBAFb;;AAIeL,IAAAA,CAAC,CAACM,gBAJjB;AAKWL,IAAAA,KALX;;;;AASD,GAZgC;;AAcjCM,EAAAA,OAdiC,qBAcvB;AACR,eAAOH,YAAP;;;;AAID,GAnBgC,EAAb,CAAf,C","sourcesContent":["import { css, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\n\nexport const styles = memoizeStyle({\n root(t: Theme) {\n const width = parseInt(t.calendarCellWidth) * 7;\n return css`\n box-sizing: content-box;\n color: ${t.textColorDefault};\n display: block;\n padding: 0 ${t.calendarPaddingX};\n width: ${width}px;\n overflow: hidden;\n touch-action: none;\n `;\n },\n\n wrapper() {\n return css`\n font-size: 14px;\n position: relative;\n `;\n },\n});\n"]}
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { Nullable } from '../../typings/utility-types';
2
3
  import * as CDS from './CalendarDateShape';
3
4
  interface DayCellViewProps {
@@ -8,6 +9,7 @@ interface DayCellViewProps {
8
9
  maxDate?: CDS.CalendarDateShape;
9
10
  onDateClick?: (day: CDS.CalendarDateShape) => void;
10
11
  isWeekend?: boolean;
12
+ renderItem: (date: CDS.CalendarDateShape) => React.ReactNode | number;
11
13
  }
12
14
  export declare function DayCellView(props: DayCellViewProps): JSX.Element;
13
15
  export {};
@@ -17,8 +17,9 @@ var _DayCellView = require("./DayCellView.styles");
17
17
 
18
18
 
19
19
 
20
+
20
21
  function DayCellView(props) {var _cx;var
21
- date = props.date,minDate = props.minDate,maxDate = props.maxDate,today = props.today,value = props.value,isWeekend = props.isWeekend,onDateClick = props.onDateClick;
22
+ date = props.date,minDate = props.minDate,maxDate = props.maxDate,today = props.today,value = props.value,isWeekend = props.isWeekend,onDateClick = props.onDateClick,renderItem = props.renderItem;
22
23
  var theme = (0, _react.useContext)(_ThemeContext.ThemeContext);
23
24
 
24
25
  var handleClick = function handleClick() {var _props$date =
@@ -38,7 +39,7 @@ function DayCellView(props) {var _cx;var
38
39
 
39
40
  onClick: handleClick },
40
41
 
41
- date.date));
42
+ renderItem(date)));
42
43
 
43
44
 
44
45
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["DayCellView.tsx"],"names":["DayCellView","props","date","minDate","maxDate","today","value","isWeekend","onDateClick","theme","ThemeContext","handleClick","month","year","CDS","isBetween","styles","cell","Boolean","isEqual","selected","weekend"],"mappings":"gKAAA;;;AAGA;AACA;;AAEA;AACA;;;;;;;;;;;;AAYO,SAASA,WAAT,CAAqBC,KAArB,EAA8C;AAC3CC,EAAAA,IAD2C,GACsBD,KADtB,CAC3CC,IAD2C,CACrCC,OADqC,GACsBF,KADtB,CACrCE,OADqC,CAC5BC,OAD4B,GACsBH,KADtB,CAC5BG,OAD4B,CACnBC,KADmB,GACsBJ,KADtB,CACnBI,KADmB,CACZC,KADY,GACsBL,KADtB,CACZK,KADY,CACLC,SADK,GACsBN,KADtB,CACLM,SADK,CACMC,WADN,GACsBP,KADtB,CACMO,WADN;AAEnD,MAAMC,KAAK,GAAG,uBAAWC,0BAAX,CAAd;;AAEA,MAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM;AACMV,IAAAA,KAAK,CAACC,IADZ,CAChBA,IADgB,eAChBA,IADgB,CACVU,KADU,eACVA,KADU,CACHC,IADG,eACHA,IADG;AAExBL,IAAAA,WAAW,QAAX,YAAAA,WAAW,CAAG,EAAEN,IAAI,EAAJA,IAAF,EAAQU,KAAK,EAALA,KAAR,EAAeC,IAAI,EAAJA,IAAf,EAAH,CAAX;AACD,GAHD;;AAKA;AACE;AACE,MAAA,QAAQ,EAAE,CAAC,CADb;AAEE,MAAA,QAAQ,EAAE,CAACC,GAAG,CAACC,SAAJ,CAAcb,IAAd,EAAoBC,OAApB,EAA6BC,OAA7B,CAFb;AAGE,MAAA,SAAS,EAAE;AACRY,0BAAOC,IAAP,CAAYR,KAAZ,CADQ,IACa,IADb;AAERO,0BAAOX,KAAP,CAAaI,KAAb,CAFQ,IAEcS,OAAO,CAACb,KAAK,IAAIS,GAAG,CAACK,OAAJ,CAAYjB,IAAZ,EAAkBG,KAAlB,CAAV,CAFrB;AAGRW,0BAAOI,QAAP,CAAgBX,KAAhB,CAHQ,IAGiBS,OAAO,CAACZ,KAAK,IAAIQ,GAAG,CAACK,OAAJ,CAAYjB,IAAZ,EAAkBI,KAAlB,CAAV,CAHxB;AAIRU,0BAAOK,OAAP,CAAeZ,KAAf,CAJQ,IAIgBS,OAAO,CAACX,SAAD,CAJvB,OAHb;;AASE,MAAA,OAAO,EAAEI,WATX;;AAWGT,IAAAA,IAAI,CAACA,IAXR,CADF;;;AAeD","sourcesContent":["import React, { useContext } from 'react';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { cx } from '../../lib/theming/Emotion';\n\nimport * as CDS from './CalendarDateShape';\nimport { styles } from './DayCellView.styles';\n\ninterface DayCellViewProps {\n date: CDS.CalendarDateShape;\n today?: CDS.CalendarDateShape;\n value?: Nullable<CDS.CalendarDateShape>;\n minDate?: CDS.CalendarDateShape;\n maxDate?: CDS.CalendarDateShape;\n onDateClick?: (day: CDS.CalendarDateShape) => void;\n isWeekend?: boolean;\n}\n\nexport function DayCellView(props: DayCellViewProps) {\n const { date, minDate, maxDate, today, value, isWeekend, onDateClick } = props;\n const theme = useContext(ThemeContext);\n\n const handleClick = () => {\n const { date, month, year } = props.date;\n onDateClick?.({ date, month, year });\n };\n\n return (\n <button\n tabIndex={-1}\n disabled={!CDS.isBetween(date, minDate, maxDate)}\n className={cx({\n [styles.cell(theme)]: true,\n [styles.today(theme)]: Boolean(today && CDS.isEqual(date, today)),\n [styles.selected(theme)]: Boolean(value && CDS.isEqual(date, value)),\n [styles.weekend(theme)]: Boolean(isWeekend),\n })}\n onClick={handleClick}\n >\n {date.date}\n </button>\n );\n}\n"]}
1
+ {"version":3,"sources":["DayCellView.tsx"],"names":["DayCellView","props","date","minDate","maxDate","today","value","isWeekend","onDateClick","renderItem","theme","ThemeContext","handleClick","month","year","CDS","isBetween","styles","cell","Boolean","isEqual","selected","weekend"],"mappings":"gKAAA;;;AAGA;AACA;;AAEA;AACA;;;;;;;;;;;;;AAaO,SAASA,WAAT,CAAqBC,KAArB,EAA8C;AAC3CC,EAAAA,IAD2C,GACkCD,KADlC,CAC3CC,IAD2C,CACrCC,OADqC,GACkCF,KADlC,CACrCE,OADqC,CAC5BC,OAD4B,GACkCH,KADlC,CAC5BG,OAD4B,CACnBC,KADmB,GACkCJ,KADlC,CACnBI,KADmB,CACZC,KADY,GACkCL,KADlC,CACZK,KADY,CACLC,SADK,GACkCN,KADlC,CACLM,SADK,CACMC,WADN,GACkCP,KADlC,CACMO,WADN,CACmBC,UADnB,GACkCR,KADlC,CACmBQ,UADnB;AAEnD,MAAMC,KAAK,GAAG,uBAAWC,0BAAX,CAAd;;AAEA,MAAMC,WAAW,GAAG,SAAdA,WAAc,GAAM;AACMX,IAAAA,KAAK,CAACC,IADZ,CAChBA,IADgB,eAChBA,IADgB,CACVW,KADU,eACVA,KADU,CACHC,IADG,eACHA,IADG;AAExBN,IAAAA,WAAW,QAAX,YAAAA,WAAW,CAAG,EAAEN,IAAI,EAAJA,IAAF,EAAQW,KAAK,EAALA,KAAR,EAAeC,IAAI,EAAJA,IAAf,EAAH,CAAX;AACD,GAHD;;AAKA;AACE;AACE,MAAA,QAAQ,EAAE,CAAC,CADb;AAEE,MAAA,QAAQ,EAAE,CAACC,GAAG,CAACC,SAAJ,CAAcd,IAAd,EAAoBC,OAApB,EAA6BC,OAA7B,CAFb;AAGE,MAAA,SAAS,EAAE;AACRa,0BAAOC,IAAP,CAAYR,KAAZ,CADQ,IACa,IADb;AAERO,0BAAOZ,KAAP,CAAaK,KAAb,CAFQ,IAEcS,OAAO,CAACd,KAAK,IAAIU,GAAG,CAACK,OAAJ,CAAYlB,IAAZ,EAAkBG,KAAlB,CAAV,CAFrB;AAGRY,0BAAOI,QAAP,CAAgBX,KAAhB,CAHQ,IAGiBS,OAAO,CAACb,KAAK,IAAIS,GAAG,CAACK,OAAJ,CAAYlB,IAAZ,EAAkBI,KAAlB,CAAV,CAHxB;AAIRW,0BAAOK,OAAP,CAAeZ,KAAf,CAJQ,IAIgBS,OAAO,CAACZ,SAAD,CAJvB,OAHb;;AASE,MAAA,OAAO,EAAEK,WATX;;AAWGH,IAAAA,UAAU,CAACP,IAAD,CAXb,CADF;;;AAeD","sourcesContent":["import React, { useContext } from 'react';\n\nimport { Nullable } from '../../typings/utility-types';\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { cx } from '../../lib/theming/Emotion';\n\nimport * as CDS from './CalendarDateShape';\nimport { styles } from './DayCellView.styles';\n\ninterface DayCellViewProps {\n date: CDS.CalendarDateShape;\n today?: CDS.CalendarDateShape;\n value?: Nullable<CDS.CalendarDateShape>;\n minDate?: CDS.CalendarDateShape;\n maxDate?: CDS.CalendarDateShape;\n onDateClick?: (day: CDS.CalendarDateShape) => void;\n isWeekend?: boolean;\n renderItem: (date: CDS.CalendarDateShape) => React.ReactNode | number;\n}\n\nexport function DayCellView(props: DayCellViewProps) {\n const { date, minDate, maxDate, today, value, isWeekend, onDateClick, renderItem } = props;\n const theme = useContext(ThemeContext);\n\n const handleClick = () => {\n const { date, month, year } = props.date;\n onDateClick?.({ date, month, year });\n };\n\n return (\n <button\n tabIndex={-1}\n disabled={!CDS.isBetween(date, minDate, maxDate)}\n className={cx({\n [styles.cell(theme)]: true,\n [styles.today(theme)]: Boolean(today && CDS.isEqual(date, today)),\n [styles.selected(theme)]: Boolean(value && CDS.isEqual(date, value)),\n [styles.weekend(theme)]: Boolean(isWeekend),\n })}\n onClick={handleClick}\n >\n {renderItem(date)}\n </button>\n );\n}\n"]}
@@ -4,7 +4,7 @@ var _Mixins = require("../../lib/styles/Mixins");var _templateObject, _templateO
4
4
 
5
5
  var styles = (0, _Emotion.memoizeStyle)({
6
6
  cell: function cell(t) {
7
- return (0, _Emotion.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["\n ", ";\n\n background: ", ";\n border: 1px solid transparent;\n display: inline-block;\n font-size: 14px;\n padding: 0;\n text-align: center;\n user-select: none;\n position: relative;\n\n width: ", ";\n height: ", ";\n line-height: ", "px;\n border-radius: 50%;\n\n &:hover {\n background-color: ", ";\n color: ", ";\n cursor: pointer;\n }\n &:disabled {\n opacity: 0.5;\n pointer-events: none;\n }\n &:active:hover {\n color: ", ";\n }\n "])),
7
+ return (0, _Emotion.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteralLoose2.default)(["\n ", ";\n\n background: ", ";\n border: 1px solid transparent;\n display: inline-block;\n font-size: 14px;\n padding: 0;\n text-align: center;\n user-select: none;\n position: relative;\n\n width: ", ";\n height: ", ";\n line-height: ", ";\n border-radius: ", ";\n\n &:hover {\n background-color: ", ";\n color: ", ";\n cursor: pointer;\n }\n &:disabled {\n opacity: 0.5;\n pointer-events: none;\n }\n &:active:hover {\n color: ", ";\n }\n "])),
8
8
  (0, _Mixins.resetButton)(),
9
9
 
10
10
  t.calendarCellBg,
@@ -16,10 +16,10 @@ var styles = (0, _Emotion.memoizeStyle)({
16
16
 
17
17
 
18
18
 
19
- t.calendarCellSize,
20
- t.calendarCellSize,
21
- parseInt(t.calendarCellSize) - 2,
22
-
19
+ t.calendarCellWidth,
20
+ t.calendarCellHeight,
21
+ t.calendarCellLineHeight,
22
+ t.calendarCellBorderRadius,
23
23
 
24
24
 
25
25
  t.calendarCellHoverBgColor,
@@ -1 +1 @@
1
- {"version":3,"sources":["DayCellView.styles.ts"],"names":["styles","cell","t","css","calendarCellBg","calendarCellSize","parseInt","calendarCellHoverBgColor","calendarCellHoverColor","calendarCellActiveHoverColor","selected","calendarCellSelectedBgColor","calendarCellSelectedFontColor","weekend","calendarCellWeekendColor","today","calendarCellTodayBorder"],"mappings":"4QAAA;;AAEA,iD;;AAEO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,IADiC,gBAC5BC,CAD4B,EAClB;AACb,eAAOC,YAAP;AACI,8BADJ;;AAGgBD,IAAAA,CAAC,CAACE,cAHlB;;;;;;;;;AAYWF,IAAAA,CAAC,CAACG,gBAZb;AAaYH,IAAAA,CAAC,CAACG,gBAbd;AAciBC,IAAAA,QAAQ,CAACJ,CAAC,CAACG,gBAAH,CAAR,GAA+B,CAdhD;;;;AAkBwBH,IAAAA,CAAC,CAACK,wBAlB1B;AAmBaL,IAAAA,CAAC,CAACM,sBAnBf;;;;;;;;AA2BaN,IAAAA,CAAC,CAACO,4BA3Bf;;;AA8BD,GAhCgC;;AAkCjCC,EAAAA,QAlCiC,oBAkCxBR,CAlCwB,EAkCd;AACjB,eAAOC,YAAP;AACsBD,IAAAA,CAAC,CAACS,2BADxB;AAEWT,IAAAA,CAAC,CAACU,6BAFb;;AAID,GAvCgC;;AAyCjCC,EAAAA,OAzCiC,mBAyCzBX,CAzCyB,EAyCf;AAChB,eAAOC,YAAP;AACWD,IAAAA,CAAC,CAACY,wBADb;;AAGD,GA7CgC;;AA+CjCC,EAAAA,KA/CiC,iBA+C3Bb,CA/C2B,EA+CjB;AACd,eAAOC,YAAP;AACYD,IAAAA,CAAC,CAACc,uBADd;;AAGD,GAnDgC,EAAb,CAAf,C","sourcesContent":["import { css, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\nimport { resetButton } from '../../lib/styles/Mixins';\n\nexport const styles = memoizeStyle({\n cell(t: Theme) {\n return css`\n ${resetButton()};\n\n background: ${t.calendarCellBg};\n border: 1px solid transparent;\n display: inline-block;\n font-size: 14px;\n padding: 0;\n text-align: center;\n user-select: none;\n position: relative;\n\n width: ${t.calendarCellSize};\n height: ${t.calendarCellSize};\n line-height: ${parseInt(t.calendarCellSize) - 2}px;\n border-radius: 50%;\n\n &:hover {\n background-color: ${t.calendarCellHoverBgColor};\n color: ${t.calendarCellHoverColor};\n cursor: pointer;\n }\n &:disabled {\n opacity: 0.5;\n pointer-events: none;\n }\n &:active:hover {\n color: ${t.calendarCellActiveHoverColor};\n }\n `;\n },\n\n selected(t: Theme) {\n return css`\n background-color: ${t.calendarCellSelectedBgColor};\n color: ${t.calendarCellSelectedFontColor};\n `;\n },\n\n weekend(t: Theme) {\n return css`\n color: ${t.calendarCellWeekendColor};\n `;\n },\n\n today(t: Theme) {\n return css`\n border: ${t.calendarCellTodayBorder};\n `;\n },\n});\n"]}
1
+ {"version":3,"sources":["DayCellView.styles.ts"],"names":["styles","cell","t","css","calendarCellBg","calendarCellWidth","calendarCellHeight","calendarCellLineHeight","calendarCellBorderRadius","calendarCellHoverBgColor","calendarCellHoverColor","calendarCellActiveHoverColor","selected","calendarCellSelectedBgColor","calendarCellSelectedFontColor","weekend","calendarCellWeekendColor","today","calendarCellTodayBorder"],"mappings":"4QAAA;;AAEA,iD;;AAEO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,IADiC,gBAC5BC,CAD4B,EAClB;AACb,eAAOC,YAAP;AACI,8BADJ;;AAGgBD,IAAAA,CAAC,CAACE,cAHlB;;;;;;;;;AAYWF,IAAAA,CAAC,CAACG,iBAZb;AAaYH,IAAAA,CAAC,CAACI,kBAbd;AAciBJ,IAAAA,CAAC,CAACK,sBAdnB;AAemBL,IAAAA,CAAC,CAACM,wBAfrB;;;AAkBwBN,IAAAA,CAAC,CAACO,wBAlB1B;AAmBaP,IAAAA,CAAC,CAACQ,sBAnBf;;;;;;;;AA2BaR,IAAAA,CAAC,CAACS,4BA3Bf;;;AA8BD,GAhCgC;;AAkCjCC,EAAAA,QAlCiC,oBAkCxBV,CAlCwB,EAkCd;AACjB,eAAOC,YAAP;AACsBD,IAAAA,CAAC,CAACW,2BADxB;AAEWX,IAAAA,CAAC,CAACY,6BAFb;;AAID,GAvCgC;;AAyCjCC,EAAAA,OAzCiC,mBAyCzBb,CAzCyB,EAyCf;AAChB,eAAOC,YAAP;AACWD,IAAAA,CAAC,CAACc,wBADb;;AAGD,GA7CgC;;AA+CjCC,EAAAA,KA/CiC,iBA+C3Bf,CA/C2B,EA+CjB;AACd,eAAOC,YAAP;AACYD,IAAAA,CAAC,CAACgB,uBADd;;AAGD,GAnDgC,EAAb,CAAf,C","sourcesContent":["import { css, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\nimport { resetButton } from '../../lib/styles/Mixins';\n\nexport const styles = memoizeStyle({\n cell(t: Theme) {\n return css`\n ${resetButton()};\n\n background: ${t.calendarCellBg};\n border: 1px solid transparent;\n display: inline-block;\n font-size: 14px;\n padding: 0;\n text-align: center;\n user-select: none;\n position: relative;\n\n width: ${t.calendarCellWidth};\n height: ${t.calendarCellHeight};\n line-height: ${t.calendarCellLineHeight};\n border-radius: ${t.calendarCellBorderRadius};\n\n &:hover {\n background-color: ${t.calendarCellHoverBgColor};\n color: ${t.calendarCellHoverColor};\n cursor: pointer;\n }\n &:disabled {\n opacity: 0.5;\n pointer-events: none;\n }\n &:active:hover {\n color: ${t.calendarCellActiveHoverColor};\n }\n `;\n },\n\n selected(t: Theme) {\n return css`\n background-color: ${t.calendarCellSelectedBgColor};\n color: ${t.calendarCellSelectedFontColor};\n `;\n },\n\n weekend(t: Theme) {\n return css`\n color: ${t.calendarCellWeekendColor};\n `;\n },\n\n today(t: Theme) {\n return css`\n border: ${t.calendarCellTodayBorder};\n `;\n },\n});\n"]}
@@ -14,6 +14,7 @@ interface MonthProps {
14
14
  isHoliday?: (day: CDS.CalendarDateShape & {
15
15
  isWeekend: boolean;
16
16
  }) => boolean;
17
+ renderDay?: (date: CDS.CalendarDateShape) => React.ReactNode;
17
18
  }
18
19
  export declare class Month extends React.Component<MonthProps> {
19
20
  private theme;
@@ -25,6 +25,7 @@ var CalendarScrollEvents = _interopRequireWildcard(require("./CalendarScrollEven
25
25
 
26
26
 
27
27
 
28
+
28
29
  Month = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default)(Month, _React$Component);function Month() {var _this;for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {args[_key] = arguments[_key];}_this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;_this.
29
30
  theme = void 0;_this.
30
31
 
@@ -101,6 +102,7 @@ Month = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default)(M
101
102
 
102
103
 
103
104
 
105
+
104
106
 
105
107
 
106
108
  closeSelects = function () {
@@ -126,7 +128,8 @@ Month = /*#__PURE__*/function (_React$Component) {(0, _inheritsLoose2.default)(M
126
128
 
127
129
  handleYearSelect = function (year) {
128
130
  _this.props.onMonthYearChange(_this.props.month.month, year);
129
- };return _this;}var _proto = Month.prototype;_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {if (this.props.top !== nextProps.top) {return true;}if (!CDS.isEqual(nextProps.value, this.props.value)) {return true;}if (!CDS.isEqual(nextProps.today, this.props.today)) {return true;}if (!CDS.isEqual(nextProps.minDate, this.props.minDate)) {return true;}if (!CDS.isEqual(nextProps.maxDate, this.props.maxDate)) {return true;}return this.props.month !== nextProps.month;};_proto.componentDidMount = function componentDidMount() {CalendarScrollEvents.addListener(this.closeSelects);};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});};_proto.renderMain = function renderMain() {var _this$props = this.props,month = _this$props.month,maxDate = _this$props.maxDate,minDate = _this$props.minDate,top = _this$props.top;return /*#__PURE__*/_react.default.createElement(_MonthView.MonthView, { firstDayOffset: month.offset, height: month.getHeight(this.theme), isFirstInYear: month.isFirstInYear, isLastInYear: month.isLastInYear, maxDate: maxDate, minDate: minDate, month: month.month, top: top, year: month.year, onMonthSelect: this.handleMonthSelect, onYearSelect: this.handleYearSelect, monthSelectRef: this.monthRef, yearSelectRef: this.yearRef }, this.renderCells());};_proto.renderCells = function renderCells() {return /*#__PURE__*/_react.default.createElement(MonthDayGrid, { days: this.props.month.days, offset: this.props.month.offset, minDate: this.props.minDate, maxDate: this.props.maxDate, today: this.props.today, value: this.props.value, onDateClick: this.props.onDateClick, isHoliday: this.props.isHoliday });};return Month;}(_react.default.Component);exports.Month = Month;var
131
+ };return _this;}var _proto = Month.prototype;_proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {if (this.props.top !== nextProps.top) {return true;}if (!CDS.isEqual(nextProps.value, this.props.value)) {return true;}if (!CDS.isEqual(nextProps.today, this.props.today)) {return true;}if (!CDS.isEqual(nextProps.minDate, this.props.minDate)) {return true;}if (!CDS.isEqual(nextProps.maxDate, this.props.maxDate)) {return true;}return this.props.month !== nextProps.month;};_proto.componentDidMount = function componentDidMount() {CalendarScrollEvents.addListener(this.closeSelects);};_proto.render = function render() {var _this2 = this;return /*#__PURE__*/_react.default.createElement(_ThemeContext.ThemeContext.Consumer, null, function (theme) {_this2.theme = theme;return _this2.renderMain();});};_proto.renderMain = function renderMain() {var _this$props = this.props,month = _this$props.month,maxDate = _this$props.maxDate,minDate = _this$props.minDate,top = _this$props.top;return /*#__PURE__*/_react.default.createElement(_MonthView.MonthView, { firstDayOffset: month.offset, height: month.getHeight(this.theme), isFirstInYear: month.isFirstInYear, isLastInYear: month.isLastInYear, maxDate: maxDate, minDate: minDate, month: month.month, top: top, year: month.year, onMonthSelect: this.handleMonthSelect, onYearSelect: this.handleYearSelect, monthSelectRef: this.monthRef, yearSelectRef: this.yearRef }, this.renderCells());};_proto.renderCells = function renderCells() {return /*#__PURE__*/_react.default.createElement(MonthDayGrid, { days: this.props.month.days, offset: this.props.month.offset, minDate: this.props.minDate, maxDate: this.props.maxDate, today: this.props.today, value: this.props.value, onDateClick: this.props.onDateClick, isHoliday: this.props.isHoliday, renderItem: this.props.renderDay });};return Month;}(_react.default.Component);exports.Month = Month;var
132
+
130
133
 
131
134
 
132
135
 
@@ -147,6 +150,7 @@ MonthDayGrid = /*#__PURE__*/function (_React$Component2) {(0, _inheritsLoose2.de
147
150
 
148
151
 
149
152
 
153
+
150
154
  shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
151
155
  if (!CDS.isEqual(nextProps.value, this.props.value)) {
152
156
  return true;
@@ -179,7 +183,7 @@ MonthDayGrid = /*#__PURE__*/function (_React$Component2) {(0, _inheritsLoose2.de
179
183
  _react.default.createElement("div", null, /*#__PURE__*/
180
184
  _react.default.createElement("div", {
181
185
  style: {
182
- width: this.props.offset * (0, _config.themeConfig)(this.theme).DAY_SIZE,
186
+ width: this.props.offset * (0, _config.themeConfig)(this.theme).DAY_WIDTH,
183
187
  display: 'inline-block' } }),
184
188
 
185
189
 
@@ -195,10 +199,11 @@ MonthDayGrid = /*#__PURE__*/function (_React$Component2) {(0, _inheritsLoose2.de
195
199
  today: _this5.props.today,
196
200
  value: _this5.props.value,
197
201
  isWeekend: isWeekend,
198
- onDateClick: _this5.props.onDateClick }));
202
+ onDateClick: _this5.props.onDateClick,
203
+ renderItem: _this5.props.renderItem }));
199
204
 
200
205
 
201
206
  })));
202
207
 
203
208
 
204
- };return MonthDayGrid;}(_react.default.Component);MonthDayGrid.defaultProps = { isHoliday: function isHoliday(day) {return day.isWeekend;} };
209
+ };return MonthDayGrid;}(_react.default.Component);MonthDayGrid.defaultProps = { isHoliday: function isHoliday(day) {return day.isWeekend;}, renderItem: function renderItem(date) {return date.date;} };
@@ -1 +1 @@
1
- {"version":3,"sources":["Month.tsx"],"names":["Month","theme","monthSelect","yearSelect","closeSelects","close","monthRef","yearRef","handleMonthSelect","month","props","onMonthYearChange","year","handleYearSelect","shouldComponentUpdate","nextProps","top","CDS","isEqual","value","today","minDate","maxDate","componentDidMount","CalendarScrollEvents","addListener","render","renderMain","offset","getHeight","isFirstInYear","isLastInYear","renderCells","days","onDateClick","isHoliday","React","Component","MonthDayGrid","width","DAY_SIZE","display","map","day","isWeekend","date","defaultProps"],"mappings":"wUAAA;;AAEA;;;;;AAKA;AACA;;;AAGA;AACA;AACA,sF;;;;;;;;;;;;;;AAcaA,K;AACHC,IAAAA,K;;AAEAC,IAAAA,W,GAAiC,I;AACjCC,IAAAA,U,GAAgC,I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0EhCC,IAAAA,Y,GAAe,YAAM;AAC3B,UAAI,MAAKF,WAAT,EAAsB;AACpB,cAAKA,WAAL,CAAiBG,KAAjB;AACD;AACD,UAAI,MAAKF,UAAT,EAAqB;AACnB,cAAKA,UAAL,CAAgBE,KAAhB;AACD;AACF,K;;AAEOC,IAAAA,Q,GAAW,UAACJ,WAAD,EAAoC;AACrD,YAAKA,WAAL,GAAmBA,WAAnB;AACD,K;;AAEOK,IAAAA,O,GAAU,UAACJ,UAAD,EAAmC;AACnD,YAAKA,UAAL,GAAkBA,UAAlB;AACD,K;;AAEOK,IAAAA,iB,GAAoB,UAACC,KAAD,EAAmB;AAC7C,YAAKC,KAAL,CAAWC,iBAAX,CAA6BF,KAA7B,EAAoC,MAAKC,KAAL,CAAWD,KAAX,CAAiBG,IAArD;AACD,K;;AAEOC,IAAAA,gB,GAAmB,UAACD,IAAD,EAAkB;AAC3C,YAAKF,KAAL,CAAWC,iBAAX,CAA6B,MAAKD,KAAL,CAAWD,KAAX,CAAiBA,KAA9C,EAAqDG,IAArD;AACD,K,mDA/FME,qB,GAAP,+BAA6BC,SAA7B,EAAoD,CAClD,IAAI,KAAKL,KAAL,CAAWM,GAAX,KAAmBD,SAAS,CAACC,GAAjC,EAAsC,CACpC,OAAO,IAAP,CACD,CACD,IAAI,CAACC,GAAG,CAACC,OAAJ,CAAYH,SA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EAAE,MAAI,CAAClC,KAAL,CAAWwB,WAR1B,GADF;;;AAYD,OAfA,CAPH,CADF;;;AA0BD,G,uBA7DwBE,eAAMC,S,EAA3BC,Y,CAGUQ,Y,GAAe,EAC3BX,SAAS,EAAE,mBAACQ,GAAD,UAAyDA,GAAG,CAACC,SAA7D,EADgB,E","sourcesContent":["import React from 'react';\n\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { DateSelect } from '../DateSelect';\nimport { Nullable } from '../../typings/utility-types';\n\nimport { themeConfig } from './config';\nimport * as CDS from './CalendarDateShape';\nimport { MonthViewModel } from './MonthViewModel';\nimport { DayCellViewModel } from './DayCellViewModel';\nimport { MonthView } from './MonthView';\nimport { DayCellView } from './DayCellView';\nimport * as CalendarScrollEvents from './CalendarScrollEvents';\n\ninterface MonthProps {\n top: number;\n month: MonthViewModel;\n maxDate?: CDS.CalendarDateShape;\n minDate?: CDS.CalendarDateShape;\n today?: CDS.CalendarDateShape;\n value?: Nullable<CDS.CalendarDateShape>;\n onDateClick?: (date: CDS.CalendarDateShape) => void;\n onMonthYearChange: (month: number, year: number) => void;\n isHoliday?: (day: CDS.CalendarDateShape & { isWeekend: boolean }) => boolean;\n}\n\nexport class Month extends React.Component<MonthProps> {\n private theme!: Theme;\n\n private monthSelect: DateSelect | null = null;\n private yearSelect: DateSelect | null = null;\n\n public shouldComponentUpdate(nextProps: MonthProps) {\n if (this.props.top !== nextProps.top) {\n return true;\n }\n if (!CDS.isEqual(nextProps.value, this.props.value)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.today, this.props.today)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.minDate, this.props.minDate)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.maxDate, this.props.maxDate)) {\n return true;\n }\n return this.props.month !== nextProps.month;\n }\n\n public componentDidMount() {\n CalendarScrollEvents.addListener(this.closeSelects);\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n const { month, maxDate, minDate, top } = this.props;\n return (\n <MonthView\n firstDayOffset={month.offset}\n height={month.getHeight(this.theme)}\n isFirstInYear={month.isFirstInYear}\n isLastInYear={month.isLastInYear}\n maxDate={maxDate}\n minDate={minDate}\n month={month.month}\n top={top}\n year={month.year}\n onMonthSelect={this.handleMonthSelect}\n onYearSelect={this.handleYearSelect}\n monthSelectRef={this.monthRef}\n yearSelectRef={this.yearRef}\n >\n {this.renderCells()}\n </MonthView>\n );\n }\n\n private renderCells() {\n return (\n <MonthDayGrid\n days={this.props.month.days}\n offset={this.props.month.offset}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n today={this.props.today}\n value={this.props.value}\n onDateClick={this.props.onDateClick}\n isHoliday={this.props.isHoliday}\n />\n );\n }\n\n private closeSelects = () => {\n if (this.monthSelect) {\n this.monthSelect.close();\n }\n if (this.yearSelect) {\n this.yearSelect.close();\n }\n };\n\n private monthRef = (monthSelect: DateSelect | null) => {\n this.monthSelect = monthSelect;\n };\n\n private yearRef = (yearSelect: DateSelect | null) => {\n this.yearSelect = yearSelect;\n };\n\n private handleMonthSelect = (month: number) => {\n this.props.onMonthYearChange(month, this.props.month.year);\n };\n\n private handleYearSelect = (year: number) => {\n this.props.onMonthYearChange(this.props.month.month, year);\n };\n}\n\ninterface MonthDayGridProps {\n days: DayCellViewModel[];\n offset: number;\n minDate?: CDS.CalendarDateShape;\n maxDate?: CDS.CalendarDateShape;\n today?: CDS.CalendarDateShape;\n value?: Nullable<CDS.CalendarDateShape>;\n onDateClick?: (x0: CDS.CalendarDateShape) => void;\n isHoliday: (day: CDS.CalendarDateShape & { isWeekend: boolean }) => boolean;\n}\n\nclass MonthDayGrid extends React.Component<MonthDayGridProps> {\n private theme!: Theme;\n\n public static defaultProps = {\n isHoliday: (day: CDS.CalendarDateShape & { isWeekend: boolean }) => day.isWeekend,\n };\n\n public shouldComponentUpdate(nextProps: MonthDayGridProps) {\n if (!CDS.isEqual(nextProps.value, this.props.value)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.today, this.props.today)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.minDate, this.props.minDate)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.maxDate, this.props.maxDate)) {\n return true;\n }\n return this.props.days !== nextProps.days;\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n return (\n <div>\n <div\n style={{\n width: this.props.offset * themeConfig(this.theme).DAY_SIZE,\n display: 'inline-block',\n }}\n />\n {this.props.days.map((day) => {\n const isWeekend = this.props.isHoliday(day);\n\n return (\n <DayCellView\n date={day}\n key={`${day.date}.${day.month}.${day.year}`}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n today={this.props.today}\n value={this.props.value}\n isWeekend={isWeekend}\n onDateClick={this.props.onDateClick}\n />\n );\n })}\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"sources":["Month.tsx"],"names":["Month","theme","monthSelect","yearSelect","closeSelects","close","monthRef","yearRef","handleMonthSelect","month","props","onMonthYearChange","year","handleYearSelect","shouldComponentUpdate","nextProps","top","CDS","isEqual","value","today","minDate","maxDate","componentDidMount","CalendarScrollEvents","addListener","render","renderMain","offset","getHeight","isFirstInYear","isLastInYear","renderCells","days","onDateClick","isHoliday","renderDay","React","Component","MonthDayGrid","width","DAY_WIDTH","display","map","day","isWeekend","date","renderItem","defaultProps"],"mappings":"wUAAA;;AAEA;;;;;AAKA;AACA;;;AAGA;AACA;AACA,sF;;;;;;;;;;;;;;;AAeaA,K;AACHC,IAAAA,K;;AAEAC,IAAAA,W,GAAiC,I;AACjCC,IAAAA,U,GAAgC,I;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2Eh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\nimport { ThemeContext } from '../../lib/theming/ThemeContext';\nimport { Theme } from '../../lib/theming/Theme';\nimport { DateSelect } from '../DateSelect';\nimport { Nullable } from '../../typings/utility-types';\n\nimport { themeConfig } from './config';\nimport * as CDS from './CalendarDateShape';\nimport { MonthViewModel } from './MonthViewModel';\nimport { DayCellViewModel } from './DayCellViewModel';\nimport { MonthView } from './MonthView';\nimport { DayCellView } from './DayCellView';\nimport * as CalendarScrollEvents from './CalendarScrollEvents';\n\ninterface MonthProps {\n top: number;\n month: MonthViewModel;\n maxDate?: CDS.CalendarDateShape;\n minDate?: CDS.CalendarDateShape;\n today?: CDS.CalendarDateShape;\n value?: Nullable<CDS.CalendarDateShape>;\n onDateClick?: (date: CDS.CalendarDateShape) => void;\n onMonthYearChange: (month: number, year: number) => void;\n isHoliday?: (day: CDS.CalendarDateShape & { isWeekend: boolean }) => boolean;\n renderDay?: (date: CDS.CalendarDateShape) => React.ReactNode;\n}\n\nexport class Month extends React.Component<MonthProps> {\n private theme!: Theme;\n\n private monthSelect: DateSelect | null = null;\n private yearSelect: DateSelect | null = null;\n\n public shouldComponentUpdate(nextProps: MonthProps) {\n if (this.props.top !== nextProps.top) {\n return true;\n }\n if (!CDS.isEqual(nextProps.value, this.props.value)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.today, this.props.today)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.minDate, this.props.minDate)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.maxDate, this.props.maxDate)) {\n return true;\n }\n return this.props.month !== nextProps.month;\n }\n\n public componentDidMount() {\n CalendarScrollEvents.addListener(this.closeSelects);\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n const { month, maxDate, minDate, top } = this.props;\n return (\n <MonthView\n firstDayOffset={month.offset}\n height={month.getHeight(this.theme)}\n isFirstInYear={month.isFirstInYear}\n isLastInYear={month.isLastInYear}\n maxDate={maxDate}\n minDate={minDate}\n month={month.month}\n top={top}\n year={month.year}\n onMonthSelect={this.handleMonthSelect}\n onYearSelect={this.handleYearSelect}\n monthSelectRef={this.monthRef}\n yearSelectRef={this.yearRef}\n >\n {this.renderCells()}\n </MonthView>\n );\n }\n\n private renderCells() {\n return (\n <MonthDayGrid\n days={this.props.month.days}\n offset={this.props.month.offset}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n today={this.props.today}\n value={this.props.value}\n onDateClick={this.props.onDateClick}\n isHoliday={this.props.isHoliday}\n renderItem={this.props.renderDay}\n />\n );\n }\n\n private closeSelects = () => {\n if (this.monthSelect) {\n this.monthSelect.close();\n }\n if (this.yearSelect) {\n this.yearSelect.close();\n }\n };\n\n private monthRef = (monthSelect: DateSelect | null) => {\n this.monthSelect = monthSelect;\n };\n\n private yearRef = (yearSelect: DateSelect | null) => {\n this.yearSelect = yearSelect;\n };\n\n private handleMonthSelect = (month: number) => {\n this.props.onMonthYearChange(month, this.props.month.year);\n };\n\n private handleYearSelect = (year: number) => {\n this.props.onMonthYearChange(this.props.month.month, year);\n };\n}\n\ninterface MonthDayGridProps {\n days: DayCellViewModel[];\n offset: number;\n minDate?: CDS.CalendarDateShape;\n maxDate?: CDS.CalendarDateShape;\n today?: CDS.CalendarDateShape;\n value?: Nullable<CDS.CalendarDateShape>;\n onDateClick?: (x0: CDS.CalendarDateShape) => void;\n isHoliday: (day: CDS.CalendarDateShape & { isWeekend: boolean }) => boolean;\n renderItem: (date: CDS.CalendarDateShape) => React.ReactNode;\n}\n\nclass MonthDayGrid extends React.Component<MonthDayGridProps> {\n private theme!: Theme;\n\n public static defaultProps = {\n isHoliday: (day: CDS.CalendarDateShape & { isWeekend: boolean }) => day.isWeekend,\n renderItem: (date: CDS.CalendarDateShape) => date.date,\n };\n\n public shouldComponentUpdate(nextProps: MonthDayGridProps) {\n if (!CDS.isEqual(nextProps.value, this.props.value)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.today, this.props.today)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.minDate, this.props.minDate)) {\n return true;\n }\n if (!CDS.isEqual(nextProps.maxDate, this.props.maxDate)) {\n return true;\n }\n return this.props.days !== nextProps.days;\n }\n\n public render() {\n return (\n <ThemeContext.Consumer>\n {(theme) => {\n this.theme = theme;\n return this.renderMain();\n }}\n </ThemeContext.Consumer>\n );\n }\n\n public renderMain() {\n return (\n <div>\n <div\n style={{\n width: this.props.offset * themeConfig(this.theme).DAY_WIDTH,\n display: 'inline-block',\n }}\n />\n {this.props.days.map((day) => {\n const isWeekend = this.props.isHoliday(day);\n\n return (\n <DayCellView\n date={day}\n key={`${day.date}.${day.month}.${day.year}`}\n minDate={this.props.minDate}\n maxDate={this.props.maxDate}\n today={this.props.today}\n value={this.props.value}\n isWeekend={isWeekend}\n onDateClick={this.props.onDateClick}\n renderItem={this.props.renderItem}\n />\n );\n })}\n </div>\n );\n }\n}\n"]}
@@ -21,7 +21,7 @@ var styles = (0, _Emotion.memoizeStyle)({
21
21
  },
22
22
 
23
23
  month: function month(t) {
24
- var width = parseInt(t.calendarCellSize) * 7;
24
+ var width = parseInt(t.calendarCellWidth) * 7;
25
25
  return (0, _Emotion.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteralLoose2.default)(["\n position: absolute;\n width: ", "px;\n "])),
26
26
 
27
27
  width);
@@ -1 +1 @@
1
- {"version":3,"sources":["MonthView.styles.ts"],"names":["styles","headerMonth","t","css","calendarMonthTitleLineHeight","calendarMonthTitlePaddingTop","calendarMonthTitlePaddingBottom","headerYear","month","width","parseInt","calendarCellSize","header","headerSticky","calendarMonthHeaderStickedBgColor","monthTitle","calendarMonthTitleBorderBottomColor","dateSelectFontWeight","calendarMonthTitleMarginX","calendarMonthTitleMarginBottom"],"mappings":"4QAAA,oD;;;AAGO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,WADiC,uBACrBC,CADqB,EACX;AACpB,eAAOC,YAAP;;AAEiBD,IAAAA,CAAC,CAACE,4BAFnB;AAGaF,IAAAA,CAAC,CAACG,4BAHf,EAGiDH,CAAC,CAACI,+BAHnD;;AAKD,GAPgC;;AASjCC,EAAAA,UATiC,sBAStBL,CATsB,EASZ;AACnB,eAAOC,YAAP;;;;AAIiBD,IAAAA,CAAC,CAACE,4BAJnB;AAKaF,IAAAA,CAAC,CAACG,4BALf,EAKiDH,CAAC,CAACI,+BALnD;;AAOD,GAjBgC;;AAmBjCE,EAAAA,KAnBiC,iBAmB3BN,CAnB2B,EAmBjB;AACd,QAAMO,KAAK,GAAGC,QAAQ,CAACR,CAAC,CAACS,gBAAH,CAAR,GAA+B,CAA7C;AACA,eAAOR,YAAP;;AAEWM,IAAAA,KAFX;;AAID,GAzBgC;;AA2BjCG,EAAAA,MA3BiC,oBA2BxB;AACP,eAAOT,YAAP;;;AAGD,GA/BgC;;AAiCjCU,EAAAA,YAjCiC,wBAiCpBX,CAjCoB,EAiCV;AACrB,eAAOC,YAAP;AACsBD,IAAAA,CAAC,CAACY,iCADxB;;;AAID,GAtCgC;;AAwCjCC,EAAAA,UAxCiC,sBAwCtBb,CAxCsB,EAwCZ;AACnB,eAAOC,YAAP;AAC6BD,IAAAA,CAAC,CAACc,mCAD/B;AAEiBd,IAAAA,CAAC,CAACe,oBAFnB;AAGcf,IAAAA,CAAC,CAACgB,yBAHhB,EAG6ChB,CAAC,CAACiB,8BAH/C;;AAKD,GA9CgC,EAAb,CAAf,C","sourcesContent":["import { css, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\n\nexport const styles = memoizeStyle({\n headerMonth(t: Theme) {\n return css`\n display: inline-block;\n line-height: ${t.calendarMonthTitleLineHeight};\n padding: ${t.calendarMonthTitlePaddingTop} 0 ${t.calendarMonthTitlePaddingBottom};\n `;\n },\n\n headerYear(t: Theme) {\n return css`\n display: inline-block;\n position: absolute;\n right: 0;\n line-height: ${t.calendarMonthTitleLineHeight};\n padding: ${t.calendarMonthTitlePaddingTop} 0 ${t.calendarMonthTitlePaddingBottom};\n `;\n },\n\n month(t: Theme) {\n const width = parseInt(t.calendarCellSize) * 7;\n return css`\n position: absolute;\n width: ${width}px;\n `;\n },\n\n header() {\n return css`\n position: relative;\n `;\n },\n\n headerSticky(t: Theme) {\n return css`\n background-color: ${t.calendarMonthHeaderStickedBgColor};\n z-index: 2;\n `;\n },\n\n monthTitle(t: Theme) {\n return css`\n border-bottom: 1px solid ${t.calendarMonthTitleBorderBottomColor};\n font-weight: ${t.dateSelectFontWeight};\n margin: 0 ${t.calendarMonthTitleMarginX} ${t.calendarMonthTitleMarginBottom};\n `;\n },\n});\n"]}
1
+ {"version":3,"sources":["MonthView.styles.ts"],"names":["styles","headerMonth","t","css","calendarMonthTitleLineHeight","calendarMonthTitlePaddingTop","calendarMonthTitlePaddingBottom","headerYear","month","width","parseInt","calendarCellWidth","header","headerSticky","calendarMonthHeaderStickedBgColor","monthTitle","calendarMonthTitleBorderBottomColor","dateSelectFontWeight","calendarMonthTitleMarginX","calendarMonthTitleMarginBottom"],"mappings":"4QAAA,oD;;;AAGO,IAAMA,MAAM,GAAG,2BAAa;AACjCC,EAAAA,WADiC,uBACrBC,CADqB,EACX;AACpB,eAAOC,YAAP;;AAEiBD,IAAAA,CAAC,CAACE,4BAFnB;AAGaF,IAAAA,CAAC,CAACG,4BAHf,EAGiDH,CAAC,CAACI,+BAHnD;;AAKD,GAPgC;;AASjCC,EAAAA,UATiC,sBAStBL,CATsB,EASZ;AACnB,eAAOC,YAAP;;;;AAIiBD,IAAAA,CAAC,CAACE,4BAJnB;AAKaF,IAAAA,CAAC,CAACG,4BALf,EAKiDH,CAAC,CAACI,+BALnD;;AAOD,GAjBgC;;AAmBjCE,EAAAA,KAnBiC,iBAmB3BN,CAnB2B,EAmBjB;AACd,QAAMO,KAAK,GAAGC,QAAQ,CAACR,CAAC,CAACS,iBAAH,CAAR,GAAgC,CAA9C;AACA,eAAOR,YAAP;;AAEWM,IAAAA,KAFX;;AAID,GAzBgC;;AA2BjCG,EAAAA,MA3BiC,oBA2BxB;AACP,eAAOT,YAAP;;;AAGD,GA/BgC;;AAiCjCU,EAAAA,YAjCiC,wBAiCpBX,CAjCoB,EAiCV;AACrB,eAAOC,YAAP;AACsBD,IAAAA,CAAC,CAACY,iCADxB;;;AAID,GAtCgC;;AAwCjCC,EAAAA,UAxCiC,sBAwCtBb,CAxCsB,EAwCZ;AACnB,eAAOC,YAAP;AAC6BD,IAAAA,CAAC,CAACc,mCAD/B;AAEiBd,IAAAA,CAAC,CAACe,oBAFnB;AAGcf,IAAAA,CAAC,CAACgB,yBAHhB,EAG6ChB,CAAC,CAACiB,8BAH/C;;AAKD,GA9CgC,EAAb,CAAf,C","sourcesContent":["import { css, memoizeStyle } from '../../lib/theming/Emotion';\nimport { Theme } from '../../lib/theming/Theme';\n\nexport const styles = memoizeStyle({\n headerMonth(t: Theme) {\n return css`\n display: inline-block;\n line-height: ${t.calendarMonthTitleLineHeight};\n padding: ${t.calendarMonthTitlePaddingTop} 0 ${t.calendarMonthTitlePaddingBottom};\n `;\n },\n\n headerYear(t: Theme) {\n return css`\n display: inline-block;\n position: absolute;\n right: 0;\n line-height: ${t.calendarMonthTitleLineHeight};\n padding: ${t.calendarMonthTitlePaddingTop} 0 ${t.calendarMonthTitlePaddingBottom};\n `;\n },\n\n month(t: Theme) {\n const width = parseInt(t.calendarCellWidth) * 7;\n return css`\n position: absolute;\n width: ${width}px;\n `;\n },\n\n header() {\n return css`\n position: relative;\n `;\n },\n\n headerSticky(t: Theme) {\n return css`\n background-color: ${t.calendarMonthHeaderStickedBgColor};\n z-index: 2;\n `;\n },\n\n monthTitle(t: Theme) {\n return css`\n border-bottom: 1px solid ${t.calendarMonthTitleBorderBottomColor};\n font-weight: ${t.dateSelectFontWeight};\n margin: 0 ${t.calendarMonthTitleMarginX} ${t.calendarMonthTitleMarginBottom};\n `;\n },\n});\n"]}
@@ -24,8 +24,8 @@ MonthViewModel = /*#__PURE__*/function () {var _proto = MonthViewModel.prototype
24
24
  _proto.
25
25
 
26
26
  getHeight = function getHeight(theme) {var _themeConfig =
27
- (0, _config.themeConfig)(theme),DAY_SIZE = _themeConfig.DAY_SIZE,MONTH_TITLE_OFFSET_HEIGHT = _themeConfig.MONTH_TITLE_OFFSET_HEIGHT,MONTH_BOTTOM_MARGIN = _themeConfig.MONTH_BOTTOM_MARGIN;
28
- return getMonthHeight(this.daysCount, this.offset, DAY_SIZE, MONTH_TITLE_OFFSET_HEIGHT, MONTH_BOTTOM_MARGIN);
27
+ (0, _config.themeConfig)(theme),DAY_HEIGHT = _themeConfig.DAY_HEIGHT,MONTH_TITLE_OFFSET_HEIGHT = _themeConfig.MONTH_TITLE_OFFSET_HEIGHT,MONTH_BOTTOM_MARGIN = _themeConfig.MONTH_BOTTOM_MARGIN;
28
+ return getMonthHeight(this.daysCount, this.offset, DAY_HEIGHT, MONTH_TITLE_OFFSET_HEIGHT, MONTH_BOTTOM_MARGIN);
29
29
  };
30
30
 
31
31
  function MonthViewModel(month, year) {this.daysCount = void 0;this.offset = void 0;this.month = void 0;this.year = void 0;this.days = void 0;this.isLastInYear = void 0;this.isFirstInYear = void 0;
@@ -1 +1 @@
1
- {"version":3,"sources":["MonthViewModel.ts"],"names":["MonthViewModel","getHeight","theme","DAY_SIZE","MONTH_TITLE_OFFSET_HEIGHT","MONTH_BOTTOM_MARGIN","getMonthHeight","daysCount","offset","month","year","days","isLastInYear","isFirstInYear","Math","ceil","floor","getMonthsDays","getMonthOffset","Array","from","length","_","i","isWeekend","DayCellViewModel","create","dayHeight","titleHeight","marginBottom","Date","getDate","day","getDay"],"mappings":"uEAAA;;;AAGA;AACA,sD;;AAEaA,c;;;;;;;;;;;;;AAaX;;;AAGA;;;AAGOC,EAAAA,S,GAAP,mBAAiBC,KAAjB,EAAuC;AACgC,6BAAYA,KAAZ,CADhC,CAC7BC,QAD6B,gBAC7BA,QAD6B,CACnBC,yBADmB,gBACnBA,yBADmB,CACQC,mBADR,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jB,CAAwBH,CAAC,GAAG,CAA5B,EAA+Bd,KAA/B,EAAsCC,IAAtC,EAA4Cc,SAA5C,CAAP;AACD,KAHW,CAAZ;AAID,G,kEA7CUxB,c,CACG0B,M,GAAS,gBAAK,UAACjB,KAAD,EAAgBC,IAAhB,UAAiD,IAAIV,cAAJ,CAAmBS,KAAnB,EAA0BC,IAA1B,CAAjD,EAAL,C;;;AA+CzB,IAAMJ,cAAc,GAAG;AACrB,UAACC,SAAD,EAAoBC,MAApB,EAAoCmB,SAApC,EAAuDC,WAAvD,EAA4EC,YAA5E;AACEf,IAAAA,IAAI,CAACC,IAAL,CAAU,CAACR,SAAS,GAAGC,MAAb,IAAuB,CAAjC,IAAsCmB,SAAtC,GAAkDC,WAAlD,GAAgEC,YADlE,GADqB,CAAvB;;AAIA,IAAMZ,aAAa,GAAG,gBAAK,UAACR,KAAD,EAAgBC,IAAhB,UAAiC,IAAIoB,IAAJ,CAASpB,IAAT,EAAeD,KAAK,GAAG,CAAvB,EAA0B,CAA1B,EAA6BsB,OAA7B,EAAjC,EAAL,CAAtB;;AAEA,IAAMb,cAAc,GAAG,gBAAK,UAACT,KAAD,EAAgBC,IAAhB,EAAiC;AAC3D,MAAMsB,GAAG,GAAG,IAAIF,IAAJ,CAASpB,IAAT,EAAeD,KAAf,EAAsB,CAAtB,EAAyBwB,MAAzB,KAAoC,CAAhD;AACA,MAAID,GAAG,KAAK,CAAC,CAAb,EAAgB;AACd,WAAO,CAAP;AACD;AACD,SAAOA,GAAP;AACD,CANsB,CAAvB","sourcesContent":["import { memo } from '../../lib/memo';\nimport { Theme } from '../../lib/theming/Theme';\n\nimport { themeConfig } from './config';\nimport { DayCellViewModel } from './DayCellViewModel';\n\nexport class MonthViewModel {\n public static create = memo((month: number, year: number): MonthViewModel => new MonthViewModel(month, year));\n\n public readonly daysCount: number;\n\n public readonly offset: number;\n\n public readonly month: number;\n\n public readonly year: number;\n\n public readonly days: DayCellViewModel[];\n\n // FIXME: shouldbe readonly\n public isLastInYear: boolean;\n\n // FIXME: shouldbe readonly\n public isFirstInYear: boolean;\n\n public getHeight(theme: Theme): number {\n const { DAY_SIZE, MONTH_TITLE_OFFSET_HEIGHT, MONTH_BOTTOM_MARGIN } = themeConfig(theme);\n return getMonthHeight(this.daysCount, this.offset, DAY_SIZE, MONTH_TITLE_OFFSET_HEIGHT, MONTH_BOTTOM_MARGIN);\n }\n\n private constructor(month: number, year: number) {\n if (month < 0) {\n year -= Math.ceil(-month / 12);\n month = 12 + (month % 12);\n }\n if (month > 11) {\n year += Math.floor(month / 12);\n month %= 12;\n }\n const daysCount = getMonthsDays(month, year);\n const offset = getMonthOffset(month, year);\n this.daysCount = daysCount;\n this.offset = offset;\n this.month = month;\n this.year = year;\n this.isLastInYear = month === 11;\n this.isFirstInYear = month === 0;\n this.days = Array.from({ length: daysCount }, (_, i) => {\n const isWeekend = (i + getMonthOffset(month, year)) % 7 >= 5;\n return DayCellViewModel.create(i + 1, month, year, isWeekend);\n });\n }\n}\n\nconst getMonthHeight = memo(\n (daysCount: number, offset: number, dayHeight: number, titleHeight: number, marginBottom: number) =>\n Math.ceil((daysCount + offset) / 7) * dayHeight + titleHeight + marginBottom,\n);\nconst getMonthsDays = memo((month: number, year: number) => new Date(year, month + 1, 0).getDate());\n\nconst getMonthOffset = memo((month: number, year: number) => {\n const day = new Date(year, month, 1).getDay() - 1;\n if (day === -1) {\n return 6;\n }\n return day;\n});\n"]}
1
+ {"version":3,"sources":["MonthViewModel.ts"],"names":["MonthViewModel","getHeight","theme","DAY_HEIGHT","MONTH_TITLE_OFFSET_HEIGHT","MONTH_BOTTOM_MARGIN","getMonthHeight","daysCount","offset","month","year","days","isLastInYear","isFirstInYear","Math","ceil","floor","getMonthsDays","getMonthOffset","Array","from","length","_","i","isWeekend","DayCellViewModel","create","dayHeight","titleHeight","marginBottom","Date","getDate","day","getDay"],"mappings":"uEAAA;;;AAGA;AACA,sD;;AAEaA,c;;;;;;;;;;;;;AAaX;;;AAGA;;;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AAJ,EAAU;AACtD,UAAMC,SAAS,GAAG,CAACD,CAAC,GAAGL,cAAc,CAACT,KAAD,EAAQC,IAAR,CAAnB,IAAoC,CAApC,IAAyC,CAA3D;AACA,aAAOe,mCAAiBC,MAAjB,CAAwBH,CAAC,GAAG,CAA5B,EAA+Bd,KAA/B,EAAsCC,IAAtC,EAA4Cc,SAA5C,CAAP;AACD,KAHW,CAAZ;AAID,G,kEA7CUxB,c,CACG0B,M,GAAS,gBAAK,UAACjB,KAAD,EAAgBC,IAAhB,UAAiD,IAAIV,cAAJ,CAAmBS,KAAnB,EAA0BC,IAA1B,CAAjD,EAAL,C;;;AA+CzB,IAAMJ,cAAc,GAAG;AACrB,UAACC,SAAD,EAAoBC,MAApB,EAAoCmB,SAApC,EAAuDC,WAAvD,EAA4EC,YAA5E;AACEf,IAAAA,IAAI,CAACC,IAAL,CAAU,CAACR,SAAS,GAAGC,MAAb,IAAuB,CAAjC,IAAsCmB,SAAtC,GAAkDC,WAAlD,GAAgEC,YADlE,GADqB,CAAvB;;AAIA,IAAMZ,aAAa,GAAG,gBAAK,UAACR,KAAD,EAAgBC,IAAhB,UAAiC,IAAIoB,IAAJ,CAASpB,IAAT,EAAeD,KAAK,GAAG,CAAvB,EAA0B,CAA1B,EAA6BsB,OAA7B,EAAjC,EAAL,CAAtB;;AAEA,IAAMb,cAAc,GAAG,gBAAK,UAACT,KAAD,EAAgBC,IAAhB,EAAiC;AAC3D,MAAMsB,GAAG,GAAG,IAAIF,IAAJ,CAASpB,IAAT,EAAeD,KAAf,EAAsB,CAAtB,EAAyBwB,MAAzB,KAAoC,CAAhD;AACA,MAAID,GAAG,KAAK,CAAC,CAAb,EAAgB;AACd,WAAO,CAAP;AACD;AACD,SAAOA,GAAP;AACD,CANsB,CAAvB","sourcesContent":["import { memo } from '../../lib/memo';\nimport { Theme } from '../../lib/theming/Theme';\n\nimport { themeConfig } from './config';\nimport { DayCellViewModel } from './DayCellViewModel';\n\nexport class MonthViewModel {\n public static create = memo((month: number, year: number): MonthViewModel => new MonthViewModel(month, year));\n\n public readonly daysCount: number;\n\n public readonly offset: number;\n\n public readonly month: number;\n\n public readonly year: number;\n\n public readonly days: DayCellViewModel[];\n\n // FIXME: shouldbe readonly\n public isLastInYear: boolean;\n\n // FIXME: shouldbe readonly\n public isFirstInYear: boolean;\n\n public getHeight(theme: Theme): number {\n const { DAY_HEIGHT, MONTH_TITLE_OFFSET_HEIGHT, MONTH_BOTTOM_MARGIN } = themeConfig(theme);\n return getMonthHeight(this.daysCount, this.offset, DAY_HEIGHT, MONTH_TITLE_OFFSET_HEIGHT, MONTH_BOTTOM_MARGIN);\n }\n\n private constructor(month: number, year: number) {\n if (month < 0) {\n year -= Math.ceil(-month / 12);\n month = 12 + (month % 12);\n }\n if (month > 11) {\n year += Math.floor(month / 12);\n month %= 12;\n }\n const daysCount = getMonthsDays(month, year);\n const offset = getMonthOffset(month, year);\n this.daysCount = daysCount;\n this.offset = offset;\n this.month = month;\n this.year = year;\n this.isLastInYear = month === 11;\n this.isFirstInYear = month === 0;\n this.days = Array.from({ length: daysCount }, (_, i) => {\n const isWeekend = (i + getMonthOffset(month, year)) % 7 >= 5;\n return DayCellViewModel.create(i + 1, month, year, isWeekend);\n });\n }\n}\n\nconst getMonthHeight = memo(\n (daysCount: number, offset: number, dayHeight: number, titleHeight: number, marginBottom: number) =>\n Math.ceil((daysCount + offset) / 7) * dayHeight + titleHeight + marginBottom,\n);\nconst getMonthsDays = memo((month: number, year: number) => new Date(year, month + 1, 0).getDate());\n\nconst getMonthOffset = memo((month: number, year: number) => {\n const day = new Date(year, month, 1).getDay() - 1;\n if (day === -1) {\n return 6;\n }\n return day;\n});\n"]}
@@ -1,6 +1,7 @@
1
1
  import { Theme } from '../../lib/theming/Theme';
2
2
  export declare const themeConfig: (t: Theme) => {
3
- DAY_SIZE: number;
3
+ DAY_WIDTH: number;
4
+ DAY_HEIGHT: number;
4
5
  MONTH_TITLE_HEIGHT: number;
5
6
  MONTH_TITLE_OFFSET_HEIGHT: number;
6
7
  WRAPPER_HEIGHT: number;