@mhome/ui 0.1.6 → 0.1.8

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhome/ui",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "type": "module",
5
5
  "description": "mHome UI Component Library",
6
6
  "main": "dist/index.cjs.js",
@@ -105,20 +105,17 @@ const DatePicker = React.forwardRef(
105
105
 
106
106
  // Generate calendar days
107
107
  const getCalendarDays = () => {
108
- const startOfMonth = selectedDate
109
- ? selectedDate.startOf("month")
110
- : dayjs().startOf("month");
111
- const endOfMonth = selectedDate
112
- ? selectedDate.endOf("month")
113
- : dayjs().endOf("month");
114
- const startDate = startOfMonth.startOf("week");
115
- const endDate = endOfMonth.endOf("week");
108
+ const baseDate = selectedDate || dayjs();
109
+ const startOfMonth = dayjs(baseDate).startOf("month");
110
+ const endOfMonth = dayjs(baseDate).endOf("month");
111
+ const startDate = dayjs(startOfMonth).startOf("week");
112
+ const endDate = dayjs(endOfMonth).endOf("week");
116
113
  const days = [];
117
114
  let currentDate = startDate;
118
115
 
119
116
  while (currentDate.isBefore(endDate) || currentDate.isSame(endDate)) {
120
- days.push(currentDate);
121
- currentDate = currentDate.add(1, "day");
117
+ days.push(dayjs(currentDate));
118
+ currentDate = dayjs(currentDate).add(1, "day");
122
119
  }
123
120
 
124
121
  return days;
@@ -130,14 +127,14 @@ const DatePicker = React.forwardRef(
130
127
 
131
128
  const handlePrevMonth = () => {
132
129
  const newDate = selectedDate
133
- ? selectedDate.subtract(1, "month")
130
+ ? dayjs(selectedDate).subtract(1, "month")
134
131
  : dayjs().subtract(1, "month");
135
132
  setSelectedDate(newDate);
136
133
  };
137
134
 
138
135
  const handleNextMonth = () => {
139
136
  const newDate = selectedDate
140
- ? selectedDate.add(1, "month")
137
+ ? dayjs(selectedDate).add(1, "month")
141
138
  : dayjs().add(1, "month");
142
139
  setSelectedDate(newDate);
143
140
  };
@@ -248,7 +245,7 @@ const DatePicker = React.forwardRef(
248
245
  if (viewMode === "year") {
249
246
  setSelectedDate(
250
247
  selectedDate
251
- ? selectedDate.subtract(10, "year")
248
+ ? dayjs(selectedDate).subtract(10, "year")
252
249
  : dayjs().subtract(10, "year")
253
250
  );
254
251
  } else {
@@ -334,7 +331,7 @@ const DatePicker = React.forwardRef(
334
331
  type="button"
335
332
  onClick={() => {
336
333
  const newDate = selectedDate
337
- ? selectedDate.year(year)
334
+ ? dayjs(selectedDate).year(year)
338
335
  : dayjs().year(year).month(currentMonth);
339
336
  setSelectedDate(newDate);
340
337
  setShowYearPicker(false);
@@ -372,7 +369,7 @@ const DatePicker = React.forwardRef(
372
369
  if (viewMode === "year") {
373
370
  setSelectedDate(
374
371
  selectedDate
375
- ? selectedDate.add(10, "year")
372
+ ? dayjs(selectedDate).add(10, "year")
376
373
  : dayjs().add(10, "year")
377
374
  );
378
375
  } else {
@@ -481,7 +478,7 @@ const DatePicker = React.forwardRef(
481
478
  type="button"
482
479
  onClick={() => {
483
480
  const newDate = selectedDate
484
- ? selectedDate.month(monthIndex)
481
+ ? dayjs(selectedDate).month(monthIndex)
485
482
  : dayjs().month(monthIndex).year(currentYear);
486
483
  setSelectedDate(newDate);
487
484
  setViewMode("month");