willba-component-library 0.2.64 → 0.2.65
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/lib/index.esm.js +59 -7
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +59 -7
- package/lib/index.js.map +1 -1
- package/lib/index.umd.js +59 -7
- package/lib/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/components/FilterCalendar/FilterCalendar.stories.tsx +50 -50
- package/src/components/FilterCalendar/FilterCalendar.tsx +3 -3
- package/src/components/FilterCalendar/hooks/useFilterCalendar.ts +18 -3
- package/src/core/components/calendar/Calendar.tsx +0 -6
package/lib/index.esm.js
CHANGED
|
@@ -3590,6 +3590,53 @@ function min(dirtyDatesArray) {
|
|
|
3590
3590
|
return result || new Date(NaN);
|
|
3591
3591
|
}
|
|
3592
3592
|
|
|
3593
|
+
/**
|
|
3594
|
+
* @name compareAsc
|
|
3595
|
+
* @category Common Helpers
|
|
3596
|
+
* @summary Compare the two dates and return -1, 0 or 1.
|
|
3597
|
+
*
|
|
3598
|
+
* @description
|
|
3599
|
+
* Compare the two dates and return 1 if the first date is after the second,
|
|
3600
|
+
* -1 if the first date is before the second or 0 if dates are equal.
|
|
3601
|
+
*
|
|
3602
|
+
* @param {Date|Number} dateLeft - the first date to compare
|
|
3603
|
+
* @param {Date|Number} dateRight - the second date to compare
|
|
3604
|
+
* @returns {Number} the result of the comparison
|
|
3605
|
+
* @throws {TypeError} 2 arguments required
|
|
3606
|
+
*
|
|
3607
|
+
* @example
|
|
3608
|
+
* // Compare 11 February 1987 and 10 July 1989:
|
|
3609
|
+
* const result = compareAsc(new Date(1987, 1, 11), new Date(1989, 6, 10))
|
|
3610
|
+
* //=> -1
|
|
3611
|
+
*
|
|
3612
|
+
* @example
|
|
3613
|
+
* // Sort the array of dates:
|
|
3614
|
+
* const result = [
|
|
3615
|
+
* new Date(1995, 6, 2),
|
|
3616
|
+
* new Date(1987, 1, 11),
|
|
3617
|
+
* new Date(1989, 6, 10)
|
|
3618
|
+
* ].sort(compareAsc)
|
|
3619
|
+
* //=> [
|
|
3620
|
+
* // Wed Feb 11 1987 00:00:00,
|
|
3621
|
+
* // Mon Jul 10 1989 00:00:00,
|
|
3622
|
+
* // Sun Jul 02 1995 00:00:00
|
|
3623
|
+
* // ]
|
|
3624
|
+
*/
|
|
3625
|
+
function compareAsc(dirtyDateLeft, dirtyDateRight) {
|
|
3626
|
+
requiredArgs(2, arguments);
|
|
3627
|
+
var dateLeft = toDate(dirtyDateLeft);
|
|
3628
|
+
var dateRight = toDate(dirtyDateRight);
|
|
3629
|
+
var diff = dateLeft.getTime() - dateRight.getTime();
|
|
3630
|
+
if (diff < 0) {
|
|
3631
|
+
return -1;
|
|
3632
|
+
} else if (diff > 0) {
|
|
3633
|
+
return 1;
|
|
3634
|
+
// Return 0 if diff is 0; return NaN if diff is NaN
|
|
3635
|
+
} else {
|
|
3636
|
+
return diff;
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
|
|
3593
3640
|
/**
|
|
3594
3641
|
* @name isSameDay
|
|
3595
3642
|
* @category Day Helpers
|
|
@@ -11508,7 +11555,6 @@ var Calendar = forwardRef(function (_a, ref) {
|
|
|
11508
11555
|
var today = startOfDay(new Date());
|
|
11509
11556
|
var selectedStartDate = calendarRange === null || calendarRange === void 0 ? void 0 : calendarRange.from;
|
|
11510
11557
|
var rangeContextStartDate = rangeContext === null || rangeContext === void 0 ? void 0 : rangeContext.from;
|
|
11511
|
-
console.log({ disableCalendarDates: disableCalendarDates });
|
|
11512
11558
|
// Handle initial disable dates including overlapping availableDates.lastCheckOut and disabledDates.start
|
|
11513
11559
|
var _d = useUpdateDisabledDates({
|
|
11514
11560
|
disableCalendarDates: disableCalendarDates,
|
|
@@ -11516,7 +11562,6 @@ var Calendar = forwardRef(function (_a, ref) {
|
|
|
11516
11562
|
updateCalendarMonthNavigation: updateCalendarMonthNavigation,
|
|
11517
11563
|
updateCalendarDefaultMonth: updateCalendarDefaultMonth,
|
|
11518
11564
|
}), newDisableCalendarDates = _d.newDisableCalendarDates, overlappingDate = _d.overlappingDate, lastPossibleCheckout = _d.lastPossibleCheckout;
|
|
11519
|
-
console.log({ newDisableCalendarDates: newDisableCalendarDates });
|
|
11520
11565
|
// Handle disable dates by page
|
|
11521
11566
|
var disabledDatesByPage$1 = disabledDatesByPage({
|
|
11522
11567
|
today: today,
|
|
@@ -11546,7 +11591,6 @@ var Calendar = forwardRef(function (_a, ref) {
|
|
|
11546
11591
|
});
|
|
11547
11592
|
setUpdatedForSubmit && setUpdatedForSubmit(true);
|
|
11548
11593
|
};
|
|
11549
|
-
console.log({ disabledDates: disabledDates });
|
|
11550
11594
|
// Handle disabled dates for range context
|
|
11551
11595
|
var _e = handleRangeContextDisabledDates({
|
|
11552
11596
|
rangeContext: rangeContext,
|
|
@@ -12007,8 +12051,17 @@ var useFilterCalendar = function (_a) {
|
|
|
12007
12051
|
// Lifecycle
|
|
12008
12052
|
// Handle update component with new data
|
|
12009
12053
|
useEffect(function () {
|
|
12010
|
-
|
|
12011
|
-
|
|
12054
|
+
console.log('1', outerDisableCalendarDates);
|
|
12055
|
+
if (outerDisableCalendarDates === null || outerDisableCalendarDates === void 0 ? void 0 : outerDisableCalendarDates.availableDates) {
|
|
12056
|
+
setDisableCalendarDates({
|
|
12057
|
+
availableDates: __spreadArray$1([], __read(outerDisableCalendarDates.availableDates.sort(function (a, b) {
|
|
12058
|
+
return compareAsc(a.checkIn, b.checkIn);
|
|
12059
|
+
})), false),
|
|
12060
|
+
disabledDates: outerDisableCalendarDates.disabledDates
|
|
12061
|
+
? __spreadArray$1([], __read(outerDisableCalendarDates.disabledDates.sort(function (a, b) {
|
|
12062
|
+
return compareAsc(a.from, b.from);
|
|
12063
|
+
})), false) : [],
|
|
12064
|
+
});
|
|
12012
12065
|
}
|
|
12013
12066
|
}, [outerDisableCalendarDates]);
|
|
12014
12067
|
// Handle Range Context initial selections
|
|
@@ -12105,7 +12158,7 @@ function FilterCalendar(_a) {
|
|
|
12105
12158
|
useUpdateTranslations({ language: language });
|
|
12106
12159
|
var t = useTranslation().t;
|
|
12107
12160
|
var isMobile = reactResponsiveExports.useMediaQuery({ maxWidth: 690 });
|
|
12108
|
-
console.log('
|
|
12161
|
+
console.log('2', { outerDisableCalendarDates: outerDisableCalendarDates });
|
|
12109
12162
|
var _b = useFilterCalendar({
|
|
12110
12163
|
onSubmit: onSubmit,
|
|
12111
12164
|
setToggleCalendar: setToggleCalendar,
|
|
@@ -12114,7 +12167,6 @@ function FilterCalendar(_a) {
|
|
|
12114
12167
|
outerRangeContext: outerRangeContext,
|
|
12115
12168
|
outerDisableCalendarDates: outerDisableCalendarDates,
|
|
12116
12169
|
}), setCalendarRange = _b.setCalendarRange, handleClearDates = _b.handleClearDates, calendarRange = _b.calendarRange, disabledDates = _b.disabledDates, setDisabledDates = _b.setDisabledDates, updateCalendarMonthNavigation = _b.updateCalendarMonthNavigation, updateCalendarDefaultMonth = _b.updateCalendarDefaultMonth, setUpdateCalendarMonthNavigation = _b.setUpdateCalendarMonthNavigation, calendarHasError = _b.calendarHasError, setCalendarHasError = _b.setCalendarHasError, setUpdatedForSubmit = _b.setUpdatedForSubmit, rangeContext = _b.rangeContext, disableCalendarDates = _b.disableCalendarDates;
|
|
12117
|
-
console.log('1', { disableCalendarDates: disableCalendarDates });
|
|
12118
12170
|
// Display component after fully loaded
|
|
12119
12171
|
useAwaitRender();
|
|
12120
12172
|
// Handle close filter section
|