@lumx/react 3.13.2-alpha.0 → 3.13.3-alpha.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.
package/package.json CHANGED
@@ -6,8 +6,8 @@
6
6
  "url": "https://github.com/lumapps/design-system/issues"
7
7
  },
8
8
  "dependencies": {
9
- "@lumx/core": "^3.13.2-alpha.0",
10
- "@lumx/icons": "^3.13.2-alpha.0",
9
+ "@lumx/core": "^3.13.3-alpha.0",
10
+ "@lumx/icons": "^3.13.3-alpha.0",
11
11
  "@popperjs/core": "^2.5.4",
12
12
  "body-scroll-lock": "^3.1.5",
13
13
  "classnames": "^2.3.2",
@@ -110,5 +110,5 @@
110
110
  "build:storybook": "storybook build"
111
111
  },
112
112
  "sideEffects": false,
113
- "version": "3.13.2-alpha.0"
113
+ "version": "3.13.3-alpha.0"
114
114
  }
@@ -49,7 +49,28 @@ export const DefaultValue = {
49
49
  value: new Date('2019-02-28'),
50
50
  },
51
51
  };
52
+ /**
53
+ * With default value selected and restricted range
54
+ */
55
+ export const Restricted = {
56
+ args: {
57
+ ...LabelPlaceholderAndHelper.args,
58
+ value: new Date(new Date().setDate(10)),
59
+ minDate: new Date(new Date().setDate(4)),
60
+ maxDate: new Date(new Date().setDate(24)),
61
+ },
62
+ };
52
63
 
64
+ /**
65
+ * With default value selected and restricted range
66
+ */
67
+ export const RestrictedEmpty = {
68
+ args: {
69
+ ...LabelPlaceholderAndHelper.args,
70
+ minDate: new Date(new Date().setDate(4)),
71
+ maxDate: new Date(new Date().setDate(24)),
72
+ },
73
+ };
53
74
  /**
54
75
  * With default month
55
76
  */
@@ -89,11 +89,11 @@ describe(getMonthCalendar.name, () => {
89
89
  },
90
90
  {
91
91
  '0': { date: new Date('2017-02-05'), isOutOfRange: true },
92
- '1': { date: new Date('2017-02-06'), isOutOfRange: true },
92
+ '1': { date: new Date('2017-02-06') },
93
93
  '2': { date: new Date('2017-02-07') },
94
94
  '3': { date: new Date('2017-02-08') },
95
95
  '4': { date: new Date('2017-02-09') },
96
- '5': { date: new Date('2017-02-10'), isOutOfRange: true },
96
+ '5': { date: new Date('2017-02-10') },
97
97
  '6': { date: new Date('2017-02-11'), isOutOfRange: true },
98
98
  },
99
99
  {
@@ -25,21 +25,30 @@ export const getMonthCalendar = (
25
25
  rangeMaxDate?: Date,
26
26
  ): MonthCalendar => {
27
27
  const month = referenceDate.getMonth();
28
- const iterDate = new Date(referenceDate.getTime());
28
+ const iterDate = new Date(referenceDate);
29
29
  iterDate.setDate(1);
30
30
 
31
+ const minDate = rangeMinDate && new Date(rangeMinDate);
32
+ const maxDate = rangeMaxDate && new Date(rangeMaxDate);
33
+ // Reset time to compare dates only.
34
+ iterDate.setUTCHours(0, 0, 0, 0);
35
+ minDate?.setUTCHours(0, 0, 0, 0);
36
+ maxDate?.setUTCHours(0, 0, 0, 0);
37
+
31
38
  const weekDays = getWeekDays(locale);
32
39
  const lastDayOfWeek = last(weekDays) as WeekDayInfo;
33
40
 
34
41
  const weeks: Array<AnnotatedWeek> = [];
35
42
  let week: AnnotatedWeek = {};
36
43
  let rowCount = 0;
44
+
37
45
  while (rowCount < MONTH_ROW_COUNT) {
38
46
  const weekDayNumber = iterDate.getDay();
39
47
  const day: AnnotatedDay = { date: new Date(iterDate.getTime()) };
40
48
 
41
49
  // If a range is specified, check if the day is out of range.
42
- if ((rangeMinDate && iterDate <= rangeMinDate) || (rangeMaxDate && iterDate >= rangeMaxDate)) {
50
+ // min and max date are included within the valid range.
51
+ if ((minDate && iterDate < minDate) || (maxDate && iterDate > maxDate)) {
43
52
  day.isOutOfRange = true;
44
53
  }
45
54