@pushwoosh/dumb-components 2.12.1 → 2.12.2

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.
@@ -11,6 +11,16 @@ function makeBaseline(a, count) {
11
11
  length: count
12
12
  }, (_, i) => addPeriod(a, 'month', i));
13
13
  }
14
+ const YEARS_BACK = 100;
15
+ const YEARS_AHEAD = 10;
16
+ function makeYearOptions(panelYear, minDay, maxDay) {
17
+ const currentYear = new Date().getFullYear();
18
+ const from = Math.min(minDay?.year ?? currentYear - YEARS_BACK, panelYear);
19
+ const to = Math.max(maxDay?.year ?? currentYear + YEARS_AHEAD, panelYear);
20
+ return Array.from({
21
+ length: to - from + 1
22
+ }, (_, i) => from + i);
23
+ }
14
24
  function delayCallback(fn) {
15
25
  return setTimeout(() => {
16
26
  requestAnimationFrame(fn);
@@ -78,10 +88,6 @@ export const CalendarMonthSlider = ({
78
88
  setAnchor(newAnchor);
79
89
  setPanels(makeBaseline(newAnchor, visibleCount));
80
90
  };
81
- const currentYear = new Date().getFullYear();
82
- const yearOptions = Array.from({
83
- length: 11
84
- }, (_, i) => currentYear - 5 + i);
85
91
  const viewportWidth = `${visibleCount * monthWidth + gap * (visibleCount - 1)}px`;
86
92
  return _jsxs(Root, {
87
93
  style: {
@@ -114,7 +120,7 @@ export const CalendarMonthSlider = ({
114
120
  }), _jsx(StyledSelect, {
115
121
  value: p.year,
116
122
  onChange: e => handleYearChange(e, i, p),
117
- children: yearOptions.map(year => _jsx("option", {
123
+ children: makeYearOptions(p.year, monthProps.disableOnAndBefore, monthProps.disableOnAndAfter).map(year => _jsx("option", {
118
124
  value: year,
119
125
  children: year
120
126
  }, year))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pushwoosh/dumb-components",
3
- "version": "2.12.1",
3
+ "version": "2.12.2",
4
4
  "description": "React components to build Pushwoosh products",
5
5
  "main": "index.js",
6
6
  "module": "index.js",