@klinking/colander 3.1.0-alpha.3 → 3.1.0-alpha.4
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 +1 -1
- package/dist/formats/date.d.mts +1 -1
- package/dist/formats/date.mjs +1 -1
- package/dist/formats/object.cjs +1 -1
- package/dist/formats/object.d.cts +1 -1
- package/dist/formats/object.d.mts +1 -1
- package/dist/formats/object.mjs +1 -1
- package/dist/formats/plain-date-time.cjs +1 -1
- package/dist/formats/plain-date-time.d.cts +1 -1
- package/dist/formats/plain-date-time.d.mts +1 -1
- package/dist/formats/plain-date-time.mjs +1 -1
- package/dist/formats/plain-date.cjs +1 -1
- package/dist/formats/plain-date.d.cts +1 -1
- package/dist/formats/plain-date.d.mts +1 -1
- 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 +1 -1
- package/dist/formats/plain-month-day.d.mts +1 -1
- 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 +1 -1
- package/dist/formats/plain-year-month.d.mts +1 -1
- 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 +1 -1
- package/dist/formats/zoned-date-time.d.mts +1 -1
- package/dist/formats/zoned-date-time.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{weeks-navigation-DvryOSWF.cjs → weeks-navigation-DV538__x.cjs} +32 -28
- package/dist/{weeks-navigation-DEaASUAh.mjs → weeks-navigation-elCpdfQ3.mjs} +32 -28
- package/dist/{weeks-view-context-CNAq2Hiu.d.cts → weeks-view-context-CUCy8njs.d.cts} +2 -0
- package/dist/{weeks-view-context-CsP3PBiu.d.mts → weeks-view-context-E1NwyNgQ.d.mts} +2 -0
- package/package.json +1 -1
- package/src/calendar-provider.tsx +6 -0
- package/src/calendar-types.ts +2 -0
- package/src/day-cell.tsx +8 -1
- package/src/month-view.tsx +7 -15
- package/src/today.test.tsx +98 -0
- package/src/utils.test.ts +25 -0
- package/src/utils.ts +17 -0
- package/src/weeks-view-state.ts +8 -15
package/src/utils.ts
CHANGED
|
@@ -39,6 +39,23 @@ export function getSystemTimeZone(T: TemporalNamespace): string {
|
|
|
39
39
|
return T.Now.timeZoneId();
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* The date a view opens on: the selected date, else today in the provider's time zone.
|
|
44
|
+
*
|
|
45
|
+
* @param selected - The currently selected value, or `undefined`.
|
|
46
|
+
* @param today - Reads today's date in the provider's time zone.
|
|
47
|
+
* @param timeZone - IANA time zone.
|
|
48
|
+
* @param T - Temporal namespace.
|
|
49
|
+
*/
|
|
50
|
+
export function resolveInitialAnchor(
|
|
51
|
+
selected: DateValueObject | undefined,
|
|
52
|
+
today: () => Temporal.PlainDate,
|
|
53
|
+
timeZone: string,
|
|
54
|
+
T: TemporalNamespace,
|
|
55
|
+
): Temporal.PlainDate {
|
|
56
|
+
return selectedToZdt(selected, timeZone, T)?.toPlainDate() ?? today();
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
/**
|
|
43
60
|
* Converts any {@link DateValueObject} into a `Temporal.ZonedDateTime`.
|
|
44
61
|
*
|
package/src/weeks-view-state.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type FirstWeekSpec,
|
|
10
10
|
} from "./resolve-first-week";
|
|
11
11
|
import type { RootState } from "./types";
|
|
12
|
-
import {
|
|
12
|
+
import { resolveInitialAnchor, selectedToZdt } from "./utils";
|
|
13
13
|
import type {
|
|
14
14
|
ViewContextValue,
|
|
15
15
|
ViewStableContextValue,
|
|
@@ -46,7 +46,7 @@ export function useWeeksViewRootState(props: WeeksViewRootProps) {
|
|
|
46
46
|
const calState = useCalendarState();
|
|
47
47
|
|
|
48
48
|
const T = calStable.temporal;
|
|
49
|
-
const { weekStartDay, isDateDisabled, minValue, maxValue, timeZone } =
|
|
49
|
+
const { weekStartDay, isDateDisabled, minValue, maxValue, timeZone, today } =
|
|
50
50
|
calStable;
|
|
51
51
|
|
|
52
52
|
// --- Controlled/uncontrolled firstWeek ---
|
|
@@ -63,16 +63,9 @@ export function useWeeksViewRootState(props: WeeksViewRootProps) {
|
|
|
63
63
|
if (firstWeekProp !== undefined) return resolveSpec(firstWeekProp);
|
|
64
64
|
if (defaultFirstWeekProp !== undefined)
|
|
65
65
|
return resolveSpec(defaultFirstWeekProp);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
calState.selected,
|
|
70
|
-
timeZone,
|
|
71
|
-
T,
|
|
72
|
-
).toPlainDate();
|
|
73
|
-
return resolveSpec(plain);
|
|
74
|
-
}
|
|
75
|
-
return resolveSpec(T.Now.plainDateISO());
|
|
66
|
+
return resolveSpec(
|
|
67
|
+
resolveInitialAnchor(calState.selected, today, timeZone, T),
|
|
68
|
+
);
|
|
76
69
|
});
|
|
77
70
|
|
|
78
71
|
const resolvedFirstWeek = isControlled
|
|
@@ -145,10 +138,10 @@ export function useWeeksViewRootState(props: WeeksViewRootProps) {
|
|
|
145
138
|
const firstWeek = weeks[0];
|
|
146
139
|
const lastWeek = weeks[weeks.length - 1];
|
|
147
140
|
if (firstWeek === undefined || lastWeek === undefined) {
|
|
148
|
-
const
|
|
141
|
+
const now = today();
|
|
149
142
|
return {
|
|
150
|
-
windowStart:
|
|
151
|
-
windowEnd:
|
|
143
|
+
windowStart: now,
|
|
144
|
+
windowEnd: now,
|
|
152
145
|
weekCount: 0,
|
|
153
146
|
dayCount: 0,
|
|
154
147
|
enabledWeekCount: 0,
|