Skip to content

Commit cbc18ac

Browse files
committed
build
1 parent a001f7b commit cbc18ac

File tree

5 files changed

+646
-524
lines changed

5 files changed

+646
-524
lines changed

packages/hooks/lib/index.cjs.js

Lines changed: 103 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -611,8 +611,8 @@ function q(t, e) {
611611
r = C(n, e).getTime() - N(n, e).getTime()
612612
return Math.round(r / 6048e5) + 1
613613
}
614-
var B = /^(1[0-2]|0?\d)/,
615-
O = /^(3[0-1]|[0-2]?\d)/,
614+
var O = /^(1[0-2]|0?\d)/,
615+
B = /^(3[0-1]|[0-2]?\d)/,
616616
H = /^(36[0-6]|3[0-5]\d|[0-2]?\d?\d)/,
617617
L = /^(5[0-3]|[0-4]?\d)/,
618618
W = /^(2[0-3]|[0-1]?\d)/,
@@ -914,7 +914,7 @@ var mt = {
914914
}
915915
switch (e) {
916916
case 'M':
917-
return at(B, t, a)
917+
return at(O, t, a)
918918
case 'MM':
919919
return ut(2, t, a)
920920
case 'Mo':
@@ -951,7 +951,7 @@ var mt = {
951951
}
952952
switch (e) {
953953
case 'L':
954-
return at(B, t, a)
954+
return at(O, t, a)
955955
case 'LL':
956956
return ut(2, t, a)
957957
case 'Lo':
@@ -1043,7 +1043,7 @@ var mt = {
10431043
parse: function (t, e, n, r) {
10441044
switch (e) {
10451045
case 'd':
1046-
return at(O, t)
1046+
return at(B, t)
10471047
case 'do':
10481048
return n.ordinalNumber(t, {unit: 'date'})
10491049
default:
@@ -1676,8 +1676,8 @@ var Ct = function (t, e) {
16761676
return xt(Math.floor(r * Math.pow(10, n - 3)), e.length)
16771677
}
16781678
var qt = 'midnight',
1679-
Bt = 'noon',
1680-
Ot = 'morning',
1679+
Ot = 'noon',
1680+
Bt = 'morning',
16811681
Ht = 'afternoon',
16821682
Lt = 'evening',
16831683
Wt = 'night',
@@ -1909,7 +1909,7 @@ var qt = 'midnight',
19091909
b: function (t, e, n) {
19101910
var r,
19111911
a = t.getUTCHours()
1912-
switch (((r = 12 === a ? Bt : 0 === a ? qt : a / 12 >= 1 ? 'pm' : 'am'), e)) {
1912+
switch (((r = 12 === a ? Ot : 0 === a ? qt : a / 12 >= 1 ? 'pm' : 'am'), e)) {
19131913
case 'b':
19141914
case 'bb':
19151915
case 'bbb':
@@ -1924,7 +1924,7 @@ var qt = 'midnight',
19241924
B: function (t, e, n) {
19251925
var r,
19261926
a = t.getUTCHours()
1927-
switch (((r = a >= 17 ? Lt : a >= 12 ? Ht : a >= 4 ? Ot : Wt), e)) {
1927+
switch (((r = a >= 17 ? Lt : a >= 12 ? Ht : a >= 4 ? Bt : Wt), e)) {
19281928
case 'B':
19291929
case 'BB':
19301930
case 'BBB':
@@ -2438,17 +2438,17 @@ function Te(t) {
24382438
if (N) {
24392439
var q = N.incompatibleTokens
24402440
if (Array.isArray(q)) {
2441-
for (var B = void 0, O = 0; O < E.length; O++) {
2442-
var H = E[O].token
2441+
for (var O = void 0, B = 0; B < E.length; B++) {
2442+
var H = E[B].token
24432443
if (-1 !== q.indexOf(H) || H === Y) {
2444-
B = E[O]
2444+
O = E[B]
24452445
break
24462446
}
24472447
}
2448-
if (B)
2448+
if (O)
24492449
throw new RangeError(
24502450
"The format string mustn't contain `"
2451-
.concat(B.fullToken, '` and `')
2451+
.concat(O.fullToken, '` and `')
24522452
.concat(P, '` at the same time'),
24532453
)
24542454
} else if ('*' === N.incompatibleTokens && E.length)
@@ -2534,59 +2534,103 @@ function Te(t) {
25342534
: v,
25352535
b = e.unavailableDates,
25362536
p = void 0 === b ? [] : b,
2537-
D = t.useState(function () {
2537+
D = e.changeActiveMonthOnSelect,
2538+
T = void 0 === D || D,
2539+
k = t.useState(function () {
25382540
return pe(m, n || s || null)
25392541
}),
2540-
T = D[0],
2541-
k = D[1],
2542-
x = t.useState(null),
2543-
C = x[0],
2544-
M = x[1],
2545-
U = t.useState(n),
2546-
S = U[0],
2547-
E = U[1]
2542+
x = k[0],
2543+
C = k[1],
2544+
M = t.useState(null),
2545+
U = M[0],
2546+
S = M[1],
2547+
E = t.useState(n),
2548+
P = E[0],
2549+
Y = E[1]
25482550
t.useEffect(function () {
25492551
return (
25502552
'undefined' != typeof window &&
25512553
window.addEventListener &&
2552-
window.addEventListener('keydown', q),
2554+
window.addEventListener('keydown', B),
25532555
function () {
2554-
window.removeEventListener && window.removeEventListener('keydown', q)
2556+
window.removeEventListener && window.removeEventListener('keydown', B)
25552557
}
25562558
)
25572559
})
2558-
var P = function (t) {
2560+
var N = function (t) {
25592561
return fe(p, t) || y(t)
25602562
},
2561-
Y = function (t) {
2562-
E(t), (!S || (S && !de(t, S))) && k(pe(m, t))
2563+
q = function (t) {
2564+
Y(t), (!P || (P && !de(t, P))) && C(pe(m, t))
25632565
},
2564-
N = function (t) {
2566+
O = function (t) {
25652567
return ve({
25662568
date: t,
25672569
minBookingDate: i,
25682570
maxBookingDate: o,
25692571
startDate: n,
25702572
endDate: r,
25712573
minBookingDays: f,
2572-
isDateBlockedFn: P,
2574+
isDateBlockedFn: N,
25732575
})
25742576
}
2575-
function q(t) {
2577+
function B(t) {
25762578
if (
25772579
('ArrowRight' === t.key ||
25782580
'ArrowLeft' === t.key ||
25792581
'ArrowDown' === t.key ||
25802582
'ArrowUp' === t.key) &&
2581-
!S
2583+
!P
25822584
) {
2583-
var e = T[0]
2584-
Y(e.date), k(pe(m, e.date))
2585+
var e = x[0]
2586+
q(e.date), C(pe(m, e.date))
25852587
}
25862588
}
2589+
var H = t.useCallback(
2590+
function () {
2591+
C(De(x, m, -1)), Y(null)
2592+
},
2593+
[x, m],
2594+
),
2595+
L = t.useCallback(
2596+
function () {
2597+
C(De(x, m, -1, 1)), Y(null)
2598+
},
2599+
[x, m],
2600+
),
2601+
W = t.useCallback(
2602+
function () {
2603+
C(De(x, m, 1)), Y(null)
2604+
},
2605+
[x, m],
2606+
),
2607+
F = t.useCallback(
2608+
function () {
2609+
C(De(x, m, 1, 1)), Y(null)
2610+
},
2611+
[x, m],
2612+
),
2613+
Q = t.useCallback(
2614+
function (t) {
2615+
C(pe(m, t)), Y(null)
2616+
},
2617+
[m],
2618+
),
2619+
R = t.useCallback(
2620+
function (t) {
2621+
void 0 === t && (t = 1), C(De(x, m, -(12 * t - m + 1))), Y(null)
2622+
},
2623+
[x, m],
2624+
),
2625+
I = t.useCallback(
2626+
function (t) {
2627+
void 0 === t && (t = 1), C(De(x, m, 12 * t - m + 1)), Y(null)
2628+
},
2629+
[x, m],
2630+
)
25872631
return {
25882632
firstDayOfWeek: g,
2589-
activeMonths: T,
2633+
activeMonths: x,
25902634
isDateSelected: function (t) {
25912635
return he(t, n, r)
25922636
},
@@ -2613,12 +2657,12 @@ function Te(t) {
26132657
})
26142658
})({
26152659
date: t,
2616-
hoveredDate: C,
2660+
hoveredDate: U,
26172661
startDate: n,
26182662
endDate: r,
26192663
minBookingDays: f,
26202664
exactMinBookingDays: d,
2621-
isDateBlocked: P,
2665+
isDateBlocked: N,
26222666
})
26232667
},
26242668
isFirstOrLastSelectedDate: function (t) {
@@ -2630,20 +2674,20 @@ function Te(t) {
26302674
isEndDate: function (t) {
26312675
return ge(t, r)
26322676
},
2633-
isDateBlocked: N,
2677+
isDateBlocked: O,
26342678
numberOfMonths: m,
26352679
isDateFocused: function (t) {
2636-
return !!S && de(t, S)
2680+
return !!P && de(t, P)
26372681
},
2638-
focusedDate: S,
2639-
hoveredDate: C,
2682+
focusedDate: P,
2683+
hoveredDate: U,
26402684
onResetDates: function () {
26412685
u({startDate: null, endDate: null, focusedInput: 'startDate'})
26422686
},
26432687
onDateHover: function (t) {
26442688
if (t) {
26452689
if (t) {
2646-
var e = !N(t) || (n && de(t, n)),
2690+
var e = !O(t) || (n && de(t, n)),
26472691
a = !i || !oe(t, Jt(i, -1)),
26482692
u = !o || !ue(t, o),
26492693
s = Jt(t, f - 1),
@@ -2653,9 +2697,9 @@ function Te(t) {
26532697
m = n && !r && !d && a && u,
26542698
w = !(f > 1 && n) || se(t, {start: n, end: Jt(n, f - 2)}),
26552699
g = n && de(t, n) && w
2656-
e && (h || m || g) ? M(t) : null !== C && M(null)
2700+
e && (h || m || g) ? S(t) : null !== U && S(null)
26572701
}
2658-
} else M(null)
2702+
} else S(null)
26592703
},
26602704
onDateSelect: function (t) {
26612705
;('endDate' === a || 'startDate' === a) &&
@@ -2666,53 +2710,39 @@ function Te(t) {
26662710
exactMinBookingDays: d,
26672711
minBookingDate: i,
26682712
maxBookingDate: o,
2669-
isDateBlocked: P,
2713+
isDateBlocked: N,
26702714
startDate: t,
26712715
endDate: null,
26722716
})
26732717
? u({startDate: t, endDate: Jt(t, f - 1), focusedInput: null})
26742718
: (('endDate' === a && n && oe(t, n)) || ('startDate' === a && r && ue(t, r))) &&
26752719
!d &&
2676-
Te({minBookingDays: f, isDateBlocked: P, startDate: t, endDate: null})
2720+
Te({minBookingDays: f, isDateBlocked: N, startDate: t, endDate: null})
26772721
? u({endDate: null, startDate: t, focusedInput: 'endDate'})
26782722
: 'startDate' === a &&
26792723
!d &&
2680-
Te({minBookingDays: f, isDateBlocked: P, endDate: r, startDate: t})
2724+
Te({minBookingDays: f, isDateBlocked: N, endDate: r, startDate: t})
26812725
? u({endDate: r, startDate: t, focusedInput: 'endDate'})
26822726
: 'startDate' === a &&
26832727
!d &&
2684-
Te({minBookingDays: f, isDateBlocked: P, endDate: null, startDate: t})
2728+
Te({minBookingDays: f, isDateBlocked: N, endDate: null, startDate: t})
26852729
? u({endDate: null, startDate: t, focusedInput: 'endDate'})
26862730
: 'endDate' === a &&
26872731
n &&
26882732
!oe(t, n) &&
26892733
!d &&
2690-
Te({minBookingDays: f, isDateBlocked: P, startDate: n, endDate: t}) &&
2734+
Te({minBookingDays: f, isDateBlocked: N, startDate: n, endDate: t}) &&
26912735
u({startDate: n, endDate: t, focusedInput: null}),
2692-
'endDate' === a || (S && (!S || de(t, S))) || k(pe(m, t))
2693-
},
2694-
onDateFocus: Y,
2695-
goToPreviousMonths: function () {
2696-
k(De(T, m, -1)), E(null)
2697-
},
2698-
goToPreviousMonthsByOneMonth: function () {
2699-
k(De(T, m, -1, 1)), E(null)
2700-
},
2701-
goToNextMonths: function () {
2702-
k(De(T, m, 1)), E(null)
2703-
},
2704-
goToNextMonthsByOneMonth: function () {
2705-
k(De(T, m, 1, 1)), E(null)
2706-
},
2707-
goToDate: function (t) {
2708-
k(pe(m, t)), E(null)
2709-
},
2710-
goToPreviousYear: function (t) {
2711-
void 0 === t && (t = 1), k(De(T, m, -(12 * t - m + 1))), E(null)
2712-
},
2713-
goToNextYear: function (t) {
2714-
void 0 === t && (t = 1), k(De(T, m, 12 * t - m + 1)), E(null)
2715-
},
2736+
'endDate' !== a && (!P || (P && !de(t, P))) && T && C(pe(m, t))
2737+
},
2738+
onDateFocus: q,
2739+
goToPreviousMonths: H,
2740+
goToPreviousMonthsByOneMonth: L,
2741+
goToNextMonths: W,
2742+
goToNextMonthsByOneMonth: F,
2743+
goToDate: Q,
2744+
goToPreviousYear: R,
2745+
goToNextYear: I,
27162746
}
27172747
}),
27182748
(exports.useDay = function (e) {

0 commit comments

Comments
 (0)