@klinking/colander 2.0.3 → 3.0.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.
- package/dist/formats/date.cjs +1 -1
- package/dist/formats/date.d.cts +2 -2
- package/dist/formats/date.d.mts +2 -2
- package/dist/formats/date.mjs +1 -1
- package/dist/formats/object.cjs +1 -1
- package/dist/formats/object.d.cts +2 -2
- package/dist/formats/object.d.mts +2 -2
- package/dist/formats/object.mjs +1 -1
- package/dist/formats/plain-date-time.cjs +1 -1
- package/dist/formats/plain-date-time.d.cts +2 -2
- package/dist/formats/plain-date-time.d.mts +2 -2
- package/dist/formats/plain-date-time.mjs +1 -1
- package/dist/formats/plain-date.cjs +1 -1
- package/dist/formats/plain-date.d.cts +2 -2
- package/dist/formats/plain-date.d.mts +2 -2
- package/dist/formats/plain-date.mjs +1 -1
- package/dist/formats/plain-month-day.cjs +1 -1
- package/dist/formats/plain-month-day.d.cts +2 -2
- package/dist/formats/plain-month-day.d.mts +2 -2
- package/dist/formats/plain-month-day.mjs +1 -1
- package/dist/formats/plain-year-month.cjs +1 -1
- package/dist/formats/plain-year-month.d.cts +2 -2
- package/dist/formats/plain-year-month.d.mts +2 -2
- package/dist/formats/plain-year-month.mjs +1 -1
- package/dist/formats/zoned-date-time.cjs +1 -1
- package/dist/formats/zoned-date-time.d.cts +2 -2
- package/dist/formats/zoned-date-time.d.mts +2 -2
- package/dist/formats/zoned-date-time.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11 -2
- package/dist/index.d.mts +11 -2
- package/dist/index.mjs +1 -1
- package/dist/{weeks-navigation-Xve4O55H.mjs → weeks-navigation-Bg0nZLgh.mjs} +43 -41
- package/dist/{weeks-navigation-epiyL4IP.cjs → weeks-navigation-CJzhxbgj.cjs} +43 -41
- package/dist/{index-BWNknC9t.d.mts → weeks-view-context-CNAq2Hiu.d.cts} +77 -22
- package/dist/{index-DV_WxL3K.d.cts → weeks-view-context-CsP3PBiu.d.mts} +77 -22
- package/package.json +1 -1
- package/src/formats/date.ts +4 -1
- package/src/formats/object.ts +4 -1
- package/src/formats/plain-date-time.ts +4 -1
- package/src/formats/plain-date.ts +4 -1
- package/src/formats/plain-month-day.ts +4 -1
- package/src/formats/plain-year-month.ts +4 -1
- package/src/formats/zoned-date-time.ts +4 -1
- package/src/grid.tsx +1 -1
- package/src/index.ts +4 -1
- package/src/month-view-types.ts +11 -6
- package/src/month-view.test.tsx +44 -2
- package/src/month-view.tsx +6 -6
- package/src/navigation.tsx +13 -1
- package/src/{overflow.test.ts → out-of-range.test.ts} +16 -12
- package/src/{overflow.ts → out-of-range.ts} +56 -10
- package/src/weeks-navigation.tsx +8 -7
- package/src/weeks-view-state.ts +33 -26
- package/src/weeks-view-types.ts +15 -4
- package/src/weeks-view.tsx +3 -3
|
@@ -1299,11 +1299,11 @@ function useViewContext() {
|
|
|
1299
1299
|
//#endregion
|
|
1300
1300
|
//#region src/month-view.tsx
|
|
1301
1301
|
function MonthViewRoot(props) {
|
|
1302
|
-
const { numberOfMonths: numberOfMonthsProp, fixedWeeks: fixedWeeksProp, outsideDays: outsideDaysProp,
|
|
1302
|
+
const { numberOfMonths: numberOfMonthsProp, fixedWeeks: fixedWeeksProp, outsideDays: outsideDaysProp, outOfRangeBehavior: outOfRangeBehaviorProp, month: monthProp, defaultMonth: defaultMonthProp, onMonthChange, children } = props;
|
|
1303
1303
|
const numberOfMonths = Math.max(1, Math.min(numberOfMonthsProp ?? 1, 12));
|
|
1304
1304
|
const fixedWeeks = fixedWeeksProp ?? false;
|
|
1305
1305
|
const outsideDays = outsideDaysProp ?? "enabled";
|
|
1306
|
-
const
|
|
1306
|
+
const outOfRangeBehavior = outOfRangeBehaviorProp ?? "unbounded";
|
|
1307
1307
|
const calStable = useCalendarStable();
|
|
1308
1308
|
const calState = useCalendarState();
|
|
1309
1309
|
const T = calStable.temporal;
|
|
@@ -1576,7 +1576,7 @@ function MonthViewRoot(props) {
|
|
|
1576
1576
|
numberOfMonths,
|
|
1577
1577
|
fixedWeeks,
|
|
1578
1578
|
outsideDays,
|
|
1579
|
-
|
|
1579
|
+
outOfRangeBehavior,
|
|
1580
1580
|
goNextMonth,
|
|
1581
1581
|
goPrevMonth,
|
|
1582
1582
|
setGridLabelId,
|
|
@@ -1585,7 +1585,7 @@ function MonthViewRoot(props) {
|
|
|
1585
1585
|
numberOfMonths,
|
|
1586
1586
|
fixedWeeks,
|
|
1587
1587
|
outsideDays,
|
|
1588
|
-
|
|
1588
|
+
outOfRangeBehavior,
|
|
1589
1589
|
goNextMonth,
|
|
1590
1590
|
goPrevMonth,
|
|
1591
1591
|
setGridLabelId
|
|
@@ -1629,14 +1629,14 @@ function MonthViewRoot(props) {
|
|
|
1629
1629
|
});
|
|
1630
1630
|
}
|
|
1631
1631
|
function MonthView(props) {
|
|
1632
|
-
const { numberOfMonths, fixedWeeks, outsideDays,
|
|
1632
|
+
const { numberOfMonths, fixedWeeks, outsideDays, outOfRangeBehavior, month, defaultMonth, onMonthChange, children, ...calendarProps } = props;
|
|
1633
1633
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarProvider, {
|
|
1634
1634
|
...calendarProps,
|
|
1635
1635
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MonthViewRoot, {
|
|
1636
1636
|
numberOfMonths,
|
|
1637
1637
|
fixedWeeks,
|
|
1638
1638
|
outsideDays,
|
|
1639
|
-
|
|
1639
|
+
outOfRangeBehavior,
|
|
1640
1640
|
month,
|
|
1641
1641
|
defaultMonth,
|
|
1642
1642
|
onMonthChange,
|
|
@@ -2877,7 +2877,7 @@ function WeeksViewGridFn(props, ref) {
|
|
|
2877
2877
|
numberOfMonths: 1,
|
|
2878
2878
|
fixedWeeks: false,
|
|
2879
2879
|
outsideDays: "enabled",
|
|
2880
|
-
|
|
2880
|
+
outOfRangeBehavior: "unbounded",
|
|
2881
2881
|
goNextMonth: () => {},
|
|
2882
2882
|
goPrevMonth: () => {},
|
|
2883
2883
|
setGridLabelId: () => {},
|
|
@@ -3167,7 +3167,7 @@ function useNavButton(direction) {
|
|
|
3167
3167
|
const { disabled: globalDisabled, minValue, maxValue, temporal: T } = useCalendarStable();
|
|
3168
3168
|
const monthViewStable = useMonthViewStable();
|
|
3169
3169
|
const monthViewState = useMonthViewState();
|
|
3170
|
-
const { goNextMonth: goToNextMonth, goPrevMonth: goToPrevMonth, numberOfMonths } = monthViewStable;
|
|
3170
|
+
const { goNextMonth: goToNextMonth, goPrevMonth: goToPrevMonth, numberOfMonths, outOfRangeBehavior } = monthViewStable;
|
|
3171
3171
|
const { currentMonth: currentDateTime, allMonths, rootState } = monthViewState;
|
|
3172
3172
|
const refMonth = direction === "next" ? allMonths[numberOfMonths - 1] ?? currentDateTime : currentDateTime;
|
|
3173
3173
|
const destMonth = direction === "prev" ? refMonth.month === 1 ? 12 : refMonth.month - 1 : refMonth.month === 12 ? 1 : refMonth.month + 1;
|
|
@@ -3175,11 +3175,13 @@ function useNavButton(direction) {
|
|
|
3175
3175
|
const boundValue = direction === "prev" ? minValue : maxValue;
|
|
3176
3176
|
const isDisabled = (0, react.useMemo)(() => {
|
|
3177
3177
|
if (globalDisabled) return true;
|
|
3178
|
+
if (outOfRangeBehavior === "unbounded") return false;
|
|
3178
3179
|
if (!boundValue) return false;
|
|
3179
3180
|
if (direction === "prev") return destYear < boundValue.year || destYear === boundValue.year && destMonth < boundValue.month;
|
|
3180
3181
|
return destYear > boundValue.year || destYear === boundValue.year && destMonth > boundValue.month;
|
|
3181
3182
|
}, [
|
|
3182
3183
|
globalDisabled,
|
|
3184
|
+
outOfRangeBehavior,
|
|
3183
3185
|
destYear,
|
|
3184
3186
|
destMonth,
|
|
3185
3187
|
boundValue,
|
|
@@ -3626,7 +3628,7 @@ function computeWeeksInWindow(firstWeek, weekCount, weekStartDay, _T) {
|
|
|
3626
3628
|
return weeks;
|
|
3627
3629
|
}
|
|
3628
3630
|
//#endregion
|
|
3629
|
-
//#region src/
|
|
3631
|
+
//#region src/out-of-range.ts
|
|
3630
3632
|
/** Returns true if any day in the 7-day span starting at weekStart falls within [min, max]. */
|
|
3631
3633
|
function weekHasValidDay(weekStart, min, max, T) {
|
|
3632
3634
|
const weekEnd = weekStart.add({ days: 6 });
|
|
@@ -3673,10 +3675,10 @@ function shrinkWindow(firstWeek, weekCount, min, max, T) {
|
|
|
3673
3675
|
};
|
|
3674
3676
|
}
|
|
3675
3677
|
/**
|
|
3676
|
-
* Given a target firstWeek and weekCount, apply
|
|
3678
|
+
* Given a target firstWeek and weekCount, apply the out-of-range behavior and return
|
|
3677
3679
|
* the adjusted { firstWeek, weekCount }.
|
|
3678
3680
|
*/
|
|
3679
|
-
function
|
|
3681
|
+
function applyOutOfRange({ targetFirstWeek, weekCount, behavior, min, max, weekStartDay, T }) {
|
|
3680
3682
|
if (!min || !max || behavior === "unbounded") return {
|
|
3681
3683
|
firstWeek: targetFirstWeek,
|
|
3682
3684
|
weekCount
|
|
@@ -3719,7 +3721,7 @@ function canShift({ currentFirstWeek, weekCount, direction, shiftBy, behavior, m
|
|
|
3719
3721
|
return false;
|
|
3720
3722
|
}
|
|
3721
3723
|
if (behavior === "snap" || behavior === "snap-shrink") {
|
|
3722
|
-
const applied =
|
|
3724
|
+
const applied = applyOutOfRange({
|
|
3723
3725
|
targetFirstWeek,
|
|
3724
3726
|
weekCount,
|
|
3725
3727
|
behavior,
|
|
@@ -3831,9 +3833,9 @@ function resolveFirstWeek(currentFirstWeek, weekCount, target, options) {
|
|
|
3831
3833
|
* Reads calendar-level context and manages weeks-specific state.
|
|
3832
3834
|
*/
|
|
3833
3835
|
function useWeeksViewRootState(props) {
|
|
3834
|
-
const { weekCount, firstWeek: firstWeekProp, defaultFirstWeek: defaultFirstWeekProp, onFirstWeekChange, scrollBy: scrollByProp,
|
|
3836
|
+
const { weekCount, firstWeek: firstWeekProp, defaultFirstWeek: defaultFirstWeekProp, onFirstWeekChange, scrollBy: scrollByProp, outOfRangeBehavior: outOfRangeBehaviorProp, onWindowChange } = props;
|
|
3835
3837
|
const scrollBy = scrollByProp ?? "row";
|
|
3836
|
-
const
|
|
3838
|
+
const outOfRangeBehavior = outOfRangeBehaviorProp ?? "unbounded";
|
|
3837
3839
|
const calStable = useCalendarStable();
|
|
3838
3840
|
const calState = useCalendarState();
|
|
3839
3841
|
const T = calStable.temporal;
|
|
@@ -3853,10 +3855,10 @@ function useWeeksViewRootState(props) {
|
|
|
3853
3855
|
weekStartDay,
|
|
3854
3856
|
T
|
|
3855
3857
|
]);
|
|
3856
|
-
const
|
|
3858
|
+
const outOfRangeResult = (0, react.useMemo)(() => applyOutOfRange({
|
|
3857
3859
|
targetFirstWeek: resolvedFirstWeek,
|
|
3858
3860
|
weekCount,
|
|
3859
|
-
behavior:
|
|
3861
|
+
behavior: outOfRangeBehavior,
|
|
3860
3862
|
...minValue !== void 0 && { min: minValue },
|
|
3861
3863
|
...maxValue !== void 0 && { max: maxValue },
|
|
3862
3864
|
weekStartDay,
|
|
@@ -3864,19 +3866,19 @@ function useWeeksViewRootState(props) {
|
|
|
3864
3866
|
}), [
|
|
3865
3867
|
resolvedFirstWeek,
|
|
3866
3868
|
weekCount,
|
|
3867
|
-
|
|
3869
|
+
outOfRangeBehavior,
|
|
3868
3870
|
minValue,
|
|
3869
3871
|
maxValue,
|
|
3870
3872
|
weekStartDay,
|
|
3871
3873
|
T
|
|
3872
3874
|
]);
|
|
3873
3875
|
const adjustedWeeks = (0, react.useMemo)(() => {
|
|
3874
|
-
const sameFirst = T.PlainDate.compare(
|
|
3875
|
-
const sameCount =
|
|
3876
|
+
const sameFirst = T.PlainDate.compare(outOfRangeResult.firstWeek, resolvedFirstWeek) === 0;
|
|
3877
|
+
const sameCount = outOfRangeResult.weekCount === weekCount;
|
|
3876
3878
|
if (sameFirst && sameCount) return rawWeeks;
|
|
3877
|
-
return computeWeeksInWindow(
|
|
3879
|
+
return computeWeeksInWindow(outOfRangeResult.firstWeek, outOfRangeResult.weekCount, weekStartDay, T);
|
|
3878
3880
|
}, [
|
|
3879
|
-
|
|
3881
|
+
outOfRangeResult,
|
|
3880
3882
|
resolvedFirstWeek,
|
|
3881
3883
|
weekCount,
|
|
3882
3884
|
rawWeeks,
|
|
@@ -4049,10 +4051,10 @@ function useWeeksViewRootState(props) {
|
|
|
4049
4051
|
}, [isControlled, onFirstWeekChange]);
|
|
4050
4052
|
const goNext = (0, react.useCallback)((shiftBy) => {
|
|
4051
4053
|
const shift = shiftBy ?? weekCount;
|
|
4052
|
-
updateFirstWeek(
|
|
4054
|
+
updateFirstWeek(applyOutOfRange({
|
|
4053
4055
|
targetFirstWeek: resolvedFirstWeek.add({ weeks: shift }),
|
|
4054
4056
|
weekCount,
|
|
4055
|
-
behavior:
|
|
4057
|
+
behavior: outOfRangeBehavior,
|
|
4056
4058
|
...minValue !== void 0 && { min: minValue },
|
|
4057
4059
|
...maxValue !== void 0 && { max: maxValue },
|
|
4058
4060
|
weekStartDay,
|
|
@@ -4061,7 +4063,7 @@ function useWeeksViewRootState(props) {
|
|
|
4061
4063
|
}, [
|
|
4062
4064
|
resolvedFirstWeek,
|
|
4063
4065
|
weekCount,
|
|
4064
|
-
|
|
4066
|
+
outOfRangeBehavior,
|
|
4065
4067
|
minValue,
|
|
4066
4068
|
maxValue,
|
|
4067
4069
|
weekStartDay,
|
|
@@ -4070,10 +4072,10 @@ function useWeeksViewRootState(props) {
|
|
|
4070
4072
|
]);
|
|
4071
4073
|
const goPrev = (0, react.useCallback)((shiftBy) => {
|
|
4072
4074
|
const shift = shiftBy ?? weekCount;
|
|
4073
|
-
updateFirstWeek(
|
|
4075
|
+
updateFirstWeek(applyOutOfRange({
|
|
4074
4076
|
targetFirstWeek: resolvedFirstWeek.subtract({ weeks: shift }),
|
|
4075
4077
|
weekCount,
|
|
4076
|
-
behavior:
|
|
4078
|
+
behavior: outOfRangeBehavior,
|
|
4077
4079
|
...minValue !== void 0 && { min: minValue },
|
|
4078
4080
|
...maxValue !== void 0 && { max: maxValue },
|
|
4079
4081
|
weekStartDay,
|
|
@@ -4082,7 +4084,7 @@ function useWeeksViewRootState(props) {
|
|
|
4082
4084
|
}, [
|
|
4083
4085
|
resolvedFirstWeek,
|
|
4084
4086
|
weekCount,
|
|
4085
|
-
|
|
4087
|
+
outOfRangeBehavior,
|
|
4086
4088
|
minValue,
|
|
4087
4089
|
maxValue,
|
|
4088
4090
|
weekStartDay,
|
|
@@ -4090,10 +4092,10 @@ function useWeeksViewRootState(props) {
|
|
|
4090
4092
|
updateFirstWeek
|
|
4091
4093
|
]);
|
|
4092
4094
|
const scrollToWeek = (0, react.useCallback)((target, options) => {
|
|
4093
|
-
updateFirstWeek(
|
|
4095
|
+
updateFirstWeek(applyOutOfRange({
|
|
4094
4096
|
targetFirstWeek: resolveFirstWeek(resolvedFirstWeek, weekCount, resolveSpec(target), options),
|
|
4095
4097
|
weekCount,
|
|
4096
|
-
behavior:
|
|
4098
|
+
behavior: outOfRangeBehavior,
|
|
4097
4099
|
...minValue !== void 0 && { min: minValue },
|
|
4098
4100
|
...maxValue !== void 0 && { max: maxValue },
|
|
4099
4101
|
weekStartDay,
|
|
@@ -4103,7 +4105,7 @@ function useWeeksViewRootState(props) {
|
|
|
4103
4105
|
resolvedFirstWeek,
|
|
4104
4106
|
weekCount,
|
|
4105
4107
|
resolveSpec,
|
|
4106
|
-
|
|
4108
|
+
outOfRangeBehavior,
|
|
4107
4109
|
minValue,
|
|
4108
4110
|
maxValue,
|
|
4109
4111
|
weekStartDay,
|
|
@@ -4123,7 +4125,7 @@ function useWeeksViewRootState(props) {
|
|
|
4123
4125
|
const stableCtx = (0, react.useMemo)(() => ({
|
|
4124
4126
|
weekCount,
|
|
4125
4127
|
scrollBy,
|
|
4126
|
-
|
|
4128
|
+
outOfRangeBehavior,
|
|
4127
4129
|
goNext,
|
|
4128
4130
|
goPrev,
|
|
4129
4131
|
scrollToWeek,
|
|
@@ -4132,7 +4134,7 @@ function useWeeksViewRootState(props) {
|
|
|
4132
4134
|
}), [
|
|
4133
4135
|
weekCount,
|
|
4134
4136
|
scrollBy,
|
|
4135
|
-
|
|
4137
|
+
outOfRangeBehavior,
|
|
4136
4138
|
goNext,
|
|
4137
4139
|
goPrev,
|
|
4138
4140
|
scrollToWeek,
|
|
@@ -4194,7 +4196,7 @@ function WeeksViewRootFn(props, ref) {
|
|
|
4194
4196
|
numberOfMonths: 1,
|
|
4195
4197
|
fixedWeeks: false,
|
|
4196
4198
|
outsideDays: "enabled",
|
|
4197
|
-
|
|
4199
|
+
outOfRangeBehavior: "unbounded",
|
|
4198
4200
|
goNextMonth: () => {},
|
|
4199
4201
|
goPrevMonth: () => {},
|
|
4200
4202
|
setGridLabelId: () => {},
|
|
@@ -4234,7 +4236,7 @@ function WeeksViewRootFn(props, ref) {
|
|
|
4234
4236
|
}
|
|
4235
4237
|
const WeeksViewRoot = (0, react.forwardRef)(WeeksViewRootFn);
|
|
4236
4238
|
function WeeksViewFn(props, ref) {
|
|
4237
|
-
const { weekCount, firstWeek, defaultFirstWeek, onFirstWeekChange, scrollBy,
|
|
4239
|
+
const { weekCount, firstWeek, defaultFirstWeek, onFirstWeekChange, scrollBy, outOfRangeBehavior, onWindowChange, children, ...calendarProps } = props;
|
|
4238
4240
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CalendarProvider, {
|
|
4239
4241
|
...calendarProps,
|
|
4240
4242
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(WeeksViewRoot, {
|
|
@@ -4244,7 +4246,7 @@ function WeeksViewFn(props, ref) {
|
|
|
4244
4246
|
defaultFirstWeek,
|
|
4245
4247
|
onFirstWeekChange,
|
|
4246
4248
|
scrollBy,
|
|
4247
|
-
|
|
4249
|
+
outOfRangeBehavior,
|
|
4248
4250
|
onWindowChange,
|
|
4249
4251
|
children
|
|
4250
4252
|
})
|
|
@@ -4265,7 +4267,7 @@ const weekCountStateAttributesMapping = {
|
|
|
4265
4267
|
};
|
|
4266
4268
|
function useWeeksNavButton(direction, shiftByProp) {
|
|
4267
4269
|
const { disabled: globalDisabled, minValue, maxValue, temporal: T, weekStartDay } = useCalendarStable();
|
|
4268
|
-
const { weekCount,
|
|
4270
|
+
const { weekCount, outOfRangeBehavior, goNext, goPrev } = useWeeksViewStable();
|
|
4269
4271
|
const { windowInfo } = useWeeksViewState();
|
|
4270
4272
|
const { rootState } = useMonthViewState();
|
|
4271
4273
|
const currentFirstWeek = windowInfo.windowStart;
|
|
@@ -4276,7 +4278,7 @@ function useWeeksNavButton(direction, shiftByProp) {
|
|
|
4276
4278
|
weekCount,
|
|
4277
4279
|
direction: direction === "next" ? 1 : -1,
|
|
4278
4280
|
...shiftByProp !== void 0 && { shiftBy: shiftByProp },
|
|
4279
|
-
behavior:
|
|
4281
|
+
behavior: outOfRangeBehavior,
|
|
4280
4282
|
...minValue !== void 0 && { min: minValue },
|
|
4281
4283
|
...maxValue !== void 0 && { max: maxValue },
|
|
4282
4284
|
weekStartDay,
|
|
@@ -4288,7 +4290,7 @@ function useWeeksNavButton(direction, shiftByProp) {
|
|
|
4288
4290
|
weekCount,
|
|
4289
4291
|
direction,
|
|
4290
4292
|
shiftByProp,
|
|
4291
|
-
|
|
4293
|
+
outOfRangeBehavior,
|
|
4292
4294
|
minValue,
|
|
4293
4295
|
maxValue,
|
|
4294
4296
|
weekStartDay,
|
|
@@ -4328,7 +4330,7 @@ function PrevWeeksButtonFn(props, ref) {
|
|
|
4328
4330
|
}
|
|
4329
4331
|
/**
|
|
4330
4332
|
* Button that navigates to the previous week(s). Automatically disabled when
|
|
4331
|
-
* no more weeks are available based on `
|
|
4333
|
+
* no more weeks are available based on `outOfRangeBehavior` and `min`.
|
|
4332
4334
|
* Exposes `data-direction="prev"`.
|
|
4333
4335
|
*/
|
|
4334
4336
|
const PrevWeeksButton = (0, react.forwardRef)(PrevWeeksButtonFn);
|
|
@@ -4346,7 +4348,7 @@ function NextWeeksButtonFn(props, ref) {
|
|
|
4346
4348
|
}
|
|
4347
4349
|
/**
|
|
4348
4350
|
* Button that navigates to the next week(s). Automatically disabled when
|
|
4349
|
-
* no more weeks are available based on `
|
|
4351
|
+
* no more weeks are available based on `outOfRangeBehavior` and `max`.
|
|
4350
4352
|
* Exposes `data-direction="next"`.
|
|
4351
4353
|
*/
|
|
4352
4354
|
const NextWeeksButton = (0, react.forwardRef)(NextWeeksButtonFn);
|
|
@@ -4370,7 +4372,7 @@ function WeekCountFn(props, ref) {
|
|
|
4370
4372
|
}
|
|
4371
4373
|
/**
|
|
4372
4374
|
* Renders the current visible week count as a number. Useful with shrink
|
|
4373
|
-
*
|
|
4375
|
+
* out-of-range modes where the actual count may be less than the `weekCount` prop.
|
|
4374
4376
|
*/
|
|
4375
4377
|
const WeekCount = (0, react.forwardRef)(WeekCountFn);
|
|
4376
4378
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as _$react from "react";
|
|
2
|
-
import React$1 from "react";
|
|
3
1
|
import * as _$react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
2
|
import { useRender } from "@base-ui/react/use-render";
|
|
3
|
+
import * as _$react from "react";
|
|
4
|
+
import React$1 from "react";
|
|
5
5
|
|
|
6
6
|
//#region ../node_modules/.pnpm/@js-temporal+polyfill@0.5.1/node_modules/@js-temporal/polyfill/index.d.ts
|
|
7
7
|
declare namespace Temporal {
|
|
@@ -1544,16 +1544,55 @@ interface CalendarStateContextValue {
|
|
|
1544
1544
|
baseRootState: BaseRootState;
|
|
1545
1545
|
}
|
|
1546
1546
|
//#endregion
|
|
1547
|
-
//#region src/
|
|
1547
|
+
//#region src/out-of-range.d.ts
|
|
1548
1548
|
/**
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1549
|
+
* Controls how a {@link WeeksView} window behaves when navigation would move it
|
|
1550
|
+
* past the `min`/`max` bounds.
|
|
1551
|
+
*
|
|
1552
|
+
* `min`/`max` always restrict which **days are selectable**. `outOfRangeBehavior`
|
|
1553
|
+
* is a separate concern: it decides whether the **visible window** may scroll
|
|
1554
|
+
* beyond those bounds, and how the edge is handled.
|
|
1555
|
+
*
|
|
1556
|
+
* - `"unbounded"` — Navigation is never restricted by `min`/`max`; any range of
|
|
1557
|
+
* weeks can be viewed. Out-of-range days simply render disabled. (Default.)
|
|
1558
|
+
* - `"stop"` — Navigation halts at the boundary: the Prev/Next button is
|
|
1559
|
+
* disabled once the next step would show a window containing no in-range day.
|
|
1560
|
+
* - `"stop-shrink"` — Like `"stop"`, but near the edge the window **shrinks** to
|
|
1561
|
+
* fewer week rows instead of showing rows that are entirely out of range.
|
|
1562
|
+
* - `"snap"` — A jump that would overshoot **snaps** the window so its edge
|
|
1563
|
+
* aligns to the last/first in-range week, rather than stopping or overshooting.
|
|
1564
|
+
* - `"snap-shrink"` — Snap to the boundary, then **shrink** the window to just
|
|
1565
|
+
* the in-range weeks.
|
|
1566
|
+
*
|
|
1567
|
+
* `"snap"` and `"snap-shrink"` are identical **unless the selectable range spans
|
|
1568
|
+
* fewer weeks than `weekCount`** — i.e. the window is taller than the range.
|
|
1569
|
+
* Snapping can only pin *one* edge to a bound; if the range is narrower than the
|
|
1570
|
+
* window, the opposite edge still overhangs into out-of-range weeks. `"snap"`
|
|
1571
|
+
* keeps the full `weekCount` (padding the overhang with all-disabled week rows),
|
|
1572
|
+
* while `"snap-shrink"` trims those rows so only the in-range weeks show.
|
|
1573
|
+
*
|
|
1574
|
+
* Example with `weekCount: 6` and a `min`/`max` that span just 2 weeks: `"snap"`
|
|
1575
|
+
* shows 6 rows (4 of them fully disabled), `"snap-shrink"` shows 2 rows. When
|
|
1576
|
+
* the range is ≥ `weekCount` weeks wide, the snapped window already fits, so the
|
|
1577
|
+
* two behave the same.
|
|
1551
1578
|
*/
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1579
|
+
type OutOfRangeBehavior = "unbounded" | "stop" | "stop-shrink" | "snap" | "snap-shrink";
|
|
1580
|
+
/**
|
|
1581
|
+
* Controls how {@link MonthView} navigation behaves when it would move the
|
|
1582
|
+
* visible month(s) past the `min`/`max` bounds.
|
|
1583
|
+
*
|
|
1584
|
+
* `min`/`max` always restrict which **days are selectable**. This decides
|
|
1585
|
+
* whether you can still **view** months outside them.
|
|
1586
|
+
*
|
|
1587
|
+
* - `"unbounded"` — Prev/Next are never disabled by `min`/`max`; you can page to
|
|
1588
|
+
* any month. Out-of-range days render disabled. (Default.)
|
|
1589
|
+
* - `"stop"` — Prev/Next become disabled once the destination month crosses the
|
|
1590
|
+
* boundary.
|
|
1591
|
+
*
|
|
1592
|
+
* MonthView renders fixed month grids, so the `"…-shrink"`/`"snap…"` modes that
|
|
1593
|
+
* {@link OutOfRangeBehavior} offers for WeeksView's flexible window don't apply.
|
|
1594
|
+
*/
|
|
1595
|
+
type MonthOutOfRangeBehavior = "unbounded" | "stop";
|
|
1557
1596
|
//#endregion
|
|
1558
1597
|
//#region src/month-view-types.d.ts
|
|
1559
1598
|
/** Props accepted by `MonthView.Root`. */
|
|
@@ -1575,12 +1614,17 @@ interface MonthViewRootProps {
|
|
|
1575
1614
|
*/
|
|
1576
1615
|
outsideDays?: OutsideDays | undefined;
|
|
1577
1616
|
/**
|
|
1578
|
-
* How month navigation behaves at `min`/`max` bounds.
|
|
1579
|
-
*
|
|
1580
|
-
*
|
|
1617
|
+
* How month navigation behaves at the `min`/`max` bounds. `min`/`max` always
|
|
1618
|
+
* restrict which **days are selectable**; this controls whether you can still
|
|
1619
|
+
* **view** months outside them. See {@link MonthOutOfRangeBehavior}.
|
|
1620
|
+
*
|
|
1621
|
+
* - `"unbounded"` — Prev/Next are never disabled by `min`/`max`; you can page
|
|
1622
|
+
* to any month, with out-of-range days rendered disabled.
|
|
1623
|
+
* - `"stop"` — Prev/Next disable once the destination month crosses the bound.
|
|
1624
|
+
*
|
|
1581
1625
|
* @default "unbounded"
|
|
1582
1626
|
*/
|
|
1583
|
-
|
|
1627
|
+
outOfRangeBehavior?: MonthOutOfRangeBehavior | undefined;
|
|
1584
1628
|
/**
|
|
1585
1629
|
* The controlled visible month. When provided, the component is controlled.
|
|
1586
1630
|
*
|
|
@@ -1610,7 +1654,7 @@ interface MonthViewStableContextValue {
|
|
|
1610
1654
|
/** How outside-month days are displayed. */
|
|
1611
1655
|
outsideDays: OutsideDays;
|
|
1612
1656
|
/** How month navigation behaves at bounds. */
|
|
1613
|
-
|
|
1657
|
+
outOfRangeBehavior: MonthOutOfRangeBehavior;
|
|
1614
1658
|
/** Navigate to the next month(s). */
|
|
1615
1659
|
goNextMonth: () => void;
|
|
1616
1660
|
/** Navigate to the previous month(s). */
|
|
@@ -1828,10 +1872,21 @@ interface WeeksViewRootProps {
|
|
|
1828
1872
|
*/
|
|
1829
1873
|
scrollBy?: "row" | "page" | undefined;
|
|
1830
1874
|
/**
|
|
1831
|
-
* How
|
|
1875
|
+
* How the visible window behaves at the `min`/`max` bounds. `min`/`max`
|
|
1876
|
+
* always restrict which **days are selectable**; this controls whether the
|
|
1877
|
+
* window may scroll beyond them, and how the edge is handled. See
|
|
1878
|
+
* {@link OutOfRangeBehavior}.
|
|
1879
|
+
*
|
|
1880
|
+
* - `"unbounded"` — navigation is never restricted by `min`/`max`.
|
|
1881
|
+
* - `"stop"` — navigation halts once the next step has no in-range day.
|
|
1882
|
+
* - `"stop-shrink"` — like `"stop"`, but the window shrinks at the edge.
|
|
1883
|
+
* - `"snap"` — overshooting jumps snap the window edge to the last/first
|
|
1884
|
+
* in-range week.
|
|
1885
|
+
* - `"snap-shrink"` — snap to the boundary, shrinking if still out of range.
|
|
1886
|
+
*
|
|
1832
1887
|
* @default "unbounded"
|
|
1833
1888
|
*/
|
|
1834
|
-
|
|
1889
|
+
outOfRangeBehavior?: OutOfRangeBehavior | undefined;
|
|
1835
1890
|
/** Called when the visible window changes. */
|
|
1836
1891
|
onWindowChange?: ((info: WindowInfo) => void) | undefined;
|
|
1837
1892
|
/** React children. */
|
|
@@ -1866,7 +1921,7 @@ interface WeeksViewStableContextValue {
|
|
|
1866
1921
|
/** How much to scroll per navigation step. */
|
|
1867
1922
|
scrollBy: "row" | "page";
|
|
1868
1923
|
/** How navigation behaves at bounds. */
|
|
1869
|
-
|
|
1924
|
+
outOfRangeBehavior: OutOfRangeBehavior;
|
|
1870
1925
|
/** Navigate to the next week(s). Optionally override the shift amount (in weeks). */
|
|
1871
1926
|
goNext: (shiftBy?: number) => void;
|
|
1872
1927
|
/** Navigate to the previous week(s). Optionally override the shift amount (in weeks). */
|
|
@@ -1935,19 +1990,19 @@ type WeekCountState = {
|
|
|
1935
1990
|
type WeekCountProps = useRender.ComponentProps<"span", WeekCountState>;
|
|
1936
1991
|
/**
|
|
1937
1992
|
* Button that navigates to the previous week(s). Automatically disabled when
|
|
1938
|
-
* no more weeks are available based on `
|
|
1993
|
+
* no more weeks are available based on `outOfRangeBehavior` and `min`.
|
|
1939
1994
|
* Exposes `data-direction="prev"`.
|
|
1940
1995
|
*/
|
|
1941
1996
|
declare const PrevWeeksButton: React$1.ForwardRefExoticComponent<Omit<PrevWeeksButtonProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1942
1997
|
/**
|
|
1943
1998
|
* Button that navigates to the next week(s). Automatically disabled when
|
|
1944
|
-
* no more weeks are available based on `
|
|
1999
|
+
* no more weeks are available based on `outOfRangeBehavior` and `max`.
|
|
1945
2000
|
* Exposes `data-direction="next"`.
|
|
1946
2001
|
*/
|
|
1947
2002
|
declare const NextWeeksButton: React$1.ForwardRefExoticComponent<Omit<NextWeeksButtonProps, "ref"> & React$1.RefAttributes<HTMLButtonElement>>;
|
|
1948
2003
|
/**
|
|
1949
2004
|
* Renders the current visible week count as a number. Useful with shrink
|
|
1950
|
-
*
|
|
2005
|
+
* out-of-range modes where the actual count may be less than the `weekCount` prop.
|
|
1951
2006
|
*/
|
|
1952
2007
|
declare const WeekCount: React$1.ForwardRefExoticComponent<Omit<WeekCountProps, "ref"> & React$1.RefAttributes<HTMLSpanElement>>;
|
|
1953
2008
|
//#endregion
|
|
@@ -2043,4 +2098,4 @@ declare function useWeeksViewStable(): WeeksViewStableContextValue;
|
|
|
2043
2098
|
/** Returns the WeeksView state context (volatile grid data). */
|
|
2044
2099
|
declare function useWeeksViewState(): WeeksViewStateContextValue;
|
|
2045
2100
|
//#endregion
|
|
2046
|
-
export { GridBody as $,
|
|
2101
|
+
export { GridBody as $, TimeStringState as $t, VisibleMonth as A, GridHeaderProps as At, resolveFirstWeekSpec as B, PlainDateObject as Bt, WeekCountState as C, DayCellTemplateState as Ct, WeeksViewProps as D, GridBodyState as Dt, WeeksView as E, GridBodyProps as Et, WeekDescriptor as F, MonthYearStringProps as Ft, RangePreview as G, RangePreviewState as Gt, WeekNumberHeader as H, RangeEndDragHandleProps as Ht, computeWeeksInWindow as I, MonthYearStringState as It, MonthYearString as J, RangeStartDragHandleProps as Jt, RangeSelected as K, RangeSelectedProps as Kt, FirstWeekSpec as L, NavButtonState as Lt, WeeksViewStableContextValue as M, GridProps as Mt, WeeksViewStateContextValue as N, GridState as Nt, WeeksViewRoot as O, GridHeaderCellProps as Ot, WindowInfo as P, MonthData as Pt, Grid as Q, TimeStringProps as Qt, ScrollToWeekSnap as R, NextMonthButtonProps as Rt, WeekCountProps as S, DayCellTemplateProps as St, WeeksNavButtonState as T, DragHandleState as Tt, RangeEndDragHandle as U, RangeMode as Ut, WeekNumberCell as V, PrevMonthButtonProps as Vt, RangeStartDragHandle as W, RangePreviewProps as Wt, PrevMonthButton as X, RootState as Xt, NextMonthButton as Y, RawValueForFormat as Yt, TimeString as Z, TemporalNamespace as Zt, NextWeeksButton as _, DateStringProps as _t, useMonthViewStable as a, WeekNumberHeaderProps as an, MonthView as at, PrevWeeksButtonProps as b, DayButtonProps as bt, useCalendarState as c, WeekTemplateProps as cn, MonthViewRootProps as ct, MonthSeparatorCell as d, GridContext as dn, MonthOutOfRangeBehavior as dt, ValueChangeMeta as en, WeekTemplate as et, MonthSeparatorMonth as f, WeekDataContext as fn, OutOfRangeBehavior as ft, MonthSeparatorYear as g, DateRange as gt, MonthSeparatorWeekCount as h, CalendarStateContextValue as ht, useViewContext as i, WeekNumberCellState as in, GridHeaderCell as it, WeeksViewRootProps as j, GridHeaderState as jt, WeeksViewRootHandle as k, GridHeaderCellState as kt, computePreviewRange as l, WeekTemplateState as ln, MonthViewStableContextValue as lt, MonthSeparatorState as m, CalendarStableContextValue as mt, useWeeksViewState as n, ValueFormat as nn, DayCellTemplate as nt, useMonthViewState as o, WeekNumberHeaderState as on, MonthViewProps as ot, MonthSeparatorRow as p, CalendarProviderProps as pt, DateString as q, RangeSelectedState as qt, ViewContextValue as r, WeekNumberCellProps as rn, GridHeader as rt, useCalendarStable as s, WeekStartDay as sn, MonthViewRoot as st, useWeeksViewStable as t, ValueForFormat as tn, DayButton as tt, MonthSeparator as u, DayCellDataContext as un, MonthViewStateContextValue as ut, NextWeeksButtonProps as v, DateStringState as vt, WeeksNavButtonOwnProps as w, DragHandleOwnProps as wt, WeekCount as x, DayButtonState as xt, PrevWeeksButton as y, DateValueObject as yt, resolveFirstWeek as z, OutsideDays as zt };
|