@uxf/datepicker 10.0.0-beta.41 → 10.0.0-beta.80

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.
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDatePickerNavigation = void 0;
4
4
  const react_1 = require("react");
5
+ const dayjs_en_1 = require("../utils/dayjs-en");
5
6
  const get_initial_months_1 = require("../utils/get-initial-months");
6
7
  const get_next_active_month_1 = require("../utils/get-next-active-month");
7
- const dayjs_en_1 = require("../utils/dayjs-en");
8
8
  function useDatePickerNavigation({ activeMonths, setActiveMonths, setFocusedDate, minBookingDate, maxBookingDate, numberOfMonths, }) {
9
9
  const goToPrevMonths = (0, react_1.useCallback)(() => {
10
10
  setActiveMonths((0, get_next_active_month_1.getNextActiveMonth)(activeMonths, numberOfMonths, -1));
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDatePicker = void 0;
4
4
  const react_1 = require("react");
5
+ const dayjs_en_1 = require("../utils/dayjs-en");
5
6
  const get_initial_months_1 = require("../utils/get-initial-months");
7
+ const is_browser_1 = require("../utils/is-browser");
6
8
  const is_date_blocked_1 = require("../utils/is-date-blocked");
7
9
  const is_date_hovered_1 = require("../utils/is-date-hovered");
8
10
  const is_in_unavailable_dates_1 = require("../utils/is-in-unavailable-dates");
9
11
  const is_start_date_1 = require("../utils/is-start-date");
10
12
  const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
11
- const is_browser_1 = require("../utils/is-browser");
12
- const dayjs_en_1 = require("../utils/dayjs-en");
13
13
  function useDatePicker({ firstDayOfWeek = 0, initialVisibleMonth, isDateBlocked: isDateBlockedProps = () => false, maxBookingDate, minBookingDate, numberOfMonths = 1, onDateChange, preventScroll, selectedDate, unavailableDates = [], }) {
14
14
  const [activeMonths, setActiveMonths] = (0, react_1.useState)(() => selectedDate
15
15
  ? (0, get_initial_months_1.getInitialMonths)(numberOfMonths, selectedDate)
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDateRangePicker = exports.END_DATE = exports.START_DATE = void 0;
4
4
  const react_1 = require("react");
5
5
  const can_select_range_1 = require("../utils/can-select-range");
6
+ const dayjs_en_1 = require("../utils/dayjs-en");
6
7
  const get_initial_months_1 = require("../utils/get-initial-months");
8
+ const is_browser_1 = require("../utils/is-browser");
7
9
  const is_date_blocked_1 = require("../utils/is-date-blocked");
8
10
  const is_date_hovered_1 = require("../utils/is-date-hovered");
9
11
  const is_date_inside_range_1 = require("../utils/is-date-inside-range");
@@ -12,8 +14,6 @@ const is_first_or_last_selected_date_1 = require("../utils/is-first-or-last-sele
12
14
  const is_in_unavailable_dates_1 = require("../utils/is-in-unavailable-dates");
13
15
  const is_start_date_1 = require("../utils/is-start-date");
14
16
  const use_date_picker_navigation_1 = require("./use-date-picker-navigation");
15
- const is_browser_1 = require("../utils/is-browser");
16
- const dayjs_en_1 = require("../utils/dayjs-en");
17
17
  exports.START_DATE = "startDate";
18
18
  exports.END_DATE = "endDate";
19
19
  function useDateRangePicker({ changeActiveMonthOnSelect = false, endDate, exactMinBookingDays = false, firstDayOfWeek = 0, focusedInput, initialVisibleMonth, isDateBlocked: isDateBlockedProps = () => false, maxBookingDate, minBookingDate, minBookingDays = 1, numberOfMonths = 2, onDatesChange, startDate, unavailableDates = [], }) {
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useDecade = exports.decadeLabelFormatFn = exports.yearLabelFormatFn = void 0;
4
4
  const react_1 = require("react");
5
- const get_years_1 = require("../utils/get-years");
6
5
  const dayjs_en_1 = require("../utils/dayjs-en");
6
+ const get_years_1 = require("../utils/get-years");
7
7
  const yearLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY");
8
8
  exports.yearLabelFormatFn = yearLabelFormatFn;
9
9
  const decadeLabelFormatFn = (start, end) => `${(0, dayjs_en_1.dayjsEn)(start).format("YYYY")} \u2013 ${(0, dayjs_en_1.dayjsEn)(end).format("YYYY")}`;
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useMonth = exports.monthLabelFormatFn = exports.weekdayLabelFormatFn = exports.dayLabelFormatFn = void 0;
4
4
  const react_1 = require("react");
5
+ const dayjs_en_1 = require("../utils/dayjs-en");
5
6
  const get_days_1 = require("../utils/get-days");
6
7
  const get_weekday_labels_1 = require("../utils/get-weekday-labels");
7
- const dayjs_en_1 = require("../utils/dayjs-en");
8
8
  const dayLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("DD");
9
9
  exports.dayLabelFormatFn = dayLabelFormatFn;
10
10
  const weekdayLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("dd"); // localization
package/hooks/use-year.js CHANGED
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useYear = exports.yearLabelFormatFn = exports.monthLabelFormatFn = void 0;
4
4
  const react_1 = require("react");
5
- const get_months_1 = require("../utils/get-months");
6
5
  const dayjs_en_1 = require("../utils/dayjs-en");
6
+ const get_months_1 = require("../utils/get-months");
7
7
  const monthLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("MMMM"); // localized
8
8
  exports.monthLabelFormatFn = monthLabelFormatFn;
9
9
  const yearLabelFormatFn = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY");
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@uxf/datepicker",
3
- "version": "10.0.0-beta.41",
3
+ "version": "10.0.0-beta.80",
4
4
  "description": "A set of React hooks to create an awesome datepicker.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
7
  "build": "tsc -P tsconfig.json",
8
- "typecheck": "tsc --noEmit --skipLibCheck",
9
- "jest": "jest --coverage=true"
8
+ "typecheck": "tsc --noEmit --skipLibCheck"
10
9
  },
11
10
  "publishConfig": {
12
11
  "access": "public"
@@ -15,25 +14,21 @@
15
14
  "type": "git",
16
15
  "url": "git+https://gitlab.com/uxf-npm/datepicker.git"
17
16
  },
18
- "devDependencies": {
19
- "@testing-library/react-hooks": "^7.0.1",
20
- "@types/react": "18.2.6",
21
- "react": "18.2.0"
22
- },
23
17
  "author": "UX Fans s.r.o.",
24
18
  "license": "ISC",
25
19
  "bugs": {
26
20
  "url": "https://gitlab.com/uxf-npm/datepicker/issues"
27
21
  },
28
22
  "homepage": "https://gitlab.com/uxf-npm/datepicker#readme",
29
- "dependencies": {
30
- "dayjs": "^1.11.5"
31
- },
32
23
  "peerDependencies": {
33
- "react": ">=17"
24
+ "react": ">=18.2.0",
25
+ "react-dom": ">=18.2.0"
34
26
  },
35
- "volta": {
36
- "node": "16.5.0",
37
- "yarn": "1.22.19"
27
+ "devDependencies": {
28
+ "@testing-library/react-hooks": "7.0.2",
29
+ "@types/react": "18.2.27",
30
+ "@types/react-dom": "18.2.12",
31
+ "react": "18.2.0",
32
+ "react-dom": "18.2.0"
38
33
  }
39
34
  }
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.canSelectRange = void 0;
4
- const get_each_1 = require("./get-each");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_each_1 = require("./get-each");
6
6
  // eslint-disable-next-line complexity
7
7
  function canSelectRange({ startDate, endDate, isDateBlocked, minBookingDays, exactMinBookingDays, minBookingDate, maxBookingDate, }) {
8
8
  const isStartDateAfterOrEqualMinDate = minBookingDate
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getCurrentYearMonthAndDate = void 0;
4
- const get_date_month_and_year_1 = require("./get-date-month-and-year");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_date_month_and_year_1 = require("./get-date-month-and-year");
6
6
  function getCurrentYearMonthAndDate() {
7
7
  return (0, get_date_month_and_year_1.getDateMonthAndYear)((0, dayjs_en_1.dayjsEn)().startOf("day").toDate());
8
8
  }
package/utils/get-days.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDays = void 0;
4
- const get_each_1 = require("./get-each");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_each_1 = require("./get-each");
6
6
  function getDays({ year, month, firstDayOfWeek = 0, dayLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("DD"), }) {
7
7
  const date = new Date(year, month);
8
8
  const lastDayOfWeek = firstDayOfWeek + 7;
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getInitialMonths = void 0;
4
+ const dayjs_en_1 = require("./dayjs-en");
4
5
  const get_current_year_month_and_date_1 = require("./get-current-year-month-and-date");
5
6
  const get_date_month_and_year_1 = require("./get-date-month-and-year");
6
- const dayjs_en_1 = require("./dayjs-en");
7
7
  function getInitialMonths(numberOfMonths, startDate) {
8
8
  const firstMonth = startDate ? (0, get_date_month_and_year_1.getDateMonthAndYear)(startDate) : (0, get_current_year_month_and_date_1.getCurrentYearMonthAndDate)();
9
9
  let prevMonthDate = firstMonth.date;
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getMonths = void 0;
4
- const get_each_1 = require("./get-each");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_each_1 = require("./get-each");
6
6
  function getMonths({ year, monthLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("MMMM"), }) {
7
7
  const date = new Date(year, 0);
8
8
  const yearStart = (0, dayjs_en_1.dayjsEn)(date).startOf("year").toDate();
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getNextActiveMonth = void 0;
4
- const get_date_month_and_year_1 = require("./get-date-month-and-year");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_date_month_and_year_1 = require("./get-date-month-and-year");
6
6
  function getNextActiveMonth(activeMonth, numberOfMonths, counter, step) {
7
7
  let prevMonth;
8
8
  if (step) {
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getWeekdayLabels = void 0;
4
- const get_each_1 = require("./get-each");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_each_1 = require("./get-each");
6
6
  function getWeekdayLabels({ firstDayOfWeek = 0, weekdayLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("dd"), }) {
7
7
  const now = new Date();
8
8
  const arr = (0, get_each_1.getEach)((0, dayjs_en_1.dayjsEn)(now).startOf("week").add(firstDayOfWeek, "day").toDate(), (0, dayjs_en_1.dayjsEn)(now).endOf("week").add(firstDayOfWeek, "day").toDate(), "day");
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const dayjs_1 = __importDefault(require("dayjs"));
7
- const get_weekday_labels_1 = require("./get-weekday-labels");
8
7
  require("dayjs/locale/cs");
8
+ const get_weekday_labels_1 = require("./get-weekday-labels");
9
9
  test("getWeekdayLabels", () => {
10
10
  expect((0, get_weekday_labels_1.getWeekdayLabels)({})).toStrictEqual(["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]);
11
11
  });
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getYears = void 0;
4
- const get_each_1 = require("./get-each");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_each_1 = require("./get-each");
6
6
  function getYears({ startYear, endYear, yearLabelFormat = (date) => (0, dayjs_en_1.dayjsEn)(date).format("YYYY"), }) {
7
7
  return (0, get_each_1.getEach)(startYear, endYear, "year").map((d) => ({
8
8
  date: d,
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateBlocked = void 0;
4
- const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const is_in_unavailable_dates_1 = require("./is-in-unavailable-dates");
6
6
  function isDateBlocked({ date, minBookingDate, maxBookingDate, isDateBlockedFn, startDate, endDate, minBookingDays = 1, unavailableDates = [], }) {
7
7
  const compareMinDate = minBookingDate
8
8
  ? new Date(minBookingDate.getFullYear(), minBookingDate.getMonth(), minBookingDate.getDate(), 0, 0, 0)
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.isDateHovered = void 0;
4
- const get_each_1 = require("./get-each");
5
4
  const dayjs_en_1 = require("./dayjs-en");
5
+ const get_each_1 = require("./get-each");
6
6
  function isDateHovered({ date, startDate, endDate, isDateBlocked, hoveredDate, minBookingDays, exactMinBookingDays, }) {
7
7
  if (
8
8
  // exact min booking days