@uxf/datepicker 16.0.0 → 16.2.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.
|
@@ -4,10 +4,10 @@ exports.useDatePickerNavigation = useDatePickerNavigation;
|
|
|
4
4
|
const compiler_runtime_1 = require("react/compiler-runtime");
|
|
5
5
|
const create_date_string_1 = require("../utils/create-date-string");
|
|
6
6
|
const date_string_1 = require("../utils/date-string");
|
|
7
|
+
const get_first_active_month_1 = require("../utils/get-first-active-month");
|
|
7
8
|
const get_initial_months_1 = require("../utils/get-initial-months");
|
|
8
9
|
const get_next_active_month_1 = require("../utils/get-next-active-month");
|
|
9
10
|
function useDatePickerNavigation(t0) {
|
|
10
|
-
var _a, _b;
|
|
11
11
|
const $ = (0, compiler_runtime_1.c)(62);
|
|
12
12
|
const { activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths } = t0;
|
|
13
13
|
let t1;
|
|
@@ -142,7 +142,7 @@ function useDatePickerNavigation(t0) {
|
|
|
142
142
|
let lastYear;
|
|
143
143
|
let t8;
|
|
144
144
|
if ($[34] !== activeMonths || $[35] !== maxBookingDate || $[36] !== minBookingDate) {
|
|
145
|
-
const firstMonthStr = (0, date_string_1.toDateString)((
|
|
145
|
+
const firstMonthStr = (0, date_string_1.toDateString)((0, get_first_active_month_1.getFirstActiveMonth)(activeMonths).date);
|
|
146
146
|
const lastMonthStr = (0, date_string_1.toDateString)(activeMonths[activeMonths.length - 1].date);
|
|
147
147
|
firstYear = parseInt(firstMonthStr.slice(0, 4), 10);
|
|
148
148
|
lastYear = parseInt(lastMonthStr.slice(0, 4), 10);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uxf/datepicker",
|
|
3
|
-
"version": "16.
|
|
3
|
+
"version": "16.2.0",
|
|
4
4
|
"description": "A set of React hooks to create an awesome datepicker.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"license": "MIT",
|
|
21
21
|
"peerDependencies": {
|
|
22
22
|
"@uxf/core": "15.2.1",
|
|
23
|
-
"@uxf/core-react": "16.
|
|
23
|
+
"@uxf/core-react": "16.2.0",
|
|
24
24
|
"dayjs": "^1.11.23",
|
|
25
25
|
"next": ">=16.4.3",
|
|
26
26
|
"react": "^19.3.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/react": "19.3.0",
|
|
36
36
|
"@types/react-dom": "19.3.0",
|
|
37
37
|
"@uxf/core": "15.2.1",
|
|
38
|
-
"@uxf/core-react": "16.
|
|
38
|
+
"@uxf/core-react": "16.2.0",
|
|
39
39
|
"dayjs": "^1.11.23",
|
|
40
40
|
"react": "19.3.1",
|
|
41
41
|
"react-dom": "19.3.1"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MonthType } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* The first month a date picker shows. `activeMonths` always holds at least one month (`getInitialMonths` starts with
|
|
4
|
+
* one and navigation keeps the count), so the current month is never returned in practice: it only satisfies the
|
|
5
|
+
* type of `.at(0)`, without reading the clock in every render that calls this.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getFirstActiveMonth(activeMonths: MonthType[]): MonthType;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFirstActiveMonth = getFirstActiveMonth;
|
|
4
|
+
const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
|
|
5
|
+
/**
|
|
6
|
+
* The first month a date picker shows. `activeMonths` always holds at least one month (`getInitialMonths` starts with
|
|
7
|
+
* one and navigation keeps the count), so the current month is never returned in practice: it only satisfies the
|
|
8
|
+
* type of `.at(0)`, without reading the clock in every render that calls this.
|
|
9
|
+
*/
|
|
10
|
+
function getFirstActiveMonth(activeMonths) {
|
|
11
|
+
var _a;
|
|
12
|
+
return (_a = activeMonths.at(0)) !== null && _a !== void 0 ? _a : (0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)();
|
|
13
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const get_first_active_month_1 = require("./get-first-active-month");
|
|
4
|
+
const get_initial_months_1 = require("./get-initial-months");
|
|
5
|
+
test("returns the first active month", () => {
|
|
6
|
+
const months = (0, get_initial_months_1.getInitialMonths)(2, new Date(2021, 9, 15));
|
|
7
|
+
expect((0, get_first_active_month_1.getFirstActiveMonth)(months)).toBe(months.at(0));
|
|
8
|
+
});
|
|
9
|
+
test("falls back to the current month for an empty list", () => {
|
|
10
|
+
jest.useFakeTimers().setSystemTime(new Date(2024, 1, 10, 12));
|
|
11
|
+
expect((0, get_first_active_month_1.getFirstActiveMonth)([])).toMatchObject({ year: 2024, month: 1 });
|
|
12
|
+
jest.useRealTimers();
|
|
13
|
+
});
|