@super-calendar/dom 2.17.0 → 2.19.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/README.md +42 -2
- package/dist/index.d.mts +58 -16
- package/dist/index.d.ts +58 -16
- package/dist/index.js +435 -150
- package/dist/index.mjs +437 -152
- package/package.json +2 -2
- package/src/Agenda.tsx +20 -3
- package/src/Calendar.tsx +106 -30
- package/src/MonthList.tsx +1 -1
- package/src/MonthView.tsx +243 -46
- package/src/ResourceTimeline.tsx +11 -7
- package/src/TimeGrid.tsx +363 -153
- package/src/YearView.tsx +21 -5
package/src/YearView.tsx
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { format, startOfDay, type Locale } from "date-fns";
|
|
2
|
-
import
|
|
3
|
-
|
|
2
|
+
import {
|
|
3
|
+
type CSSProperties,
|
|
4
|
+
type PointerEvent as ReactPointerEvent,
|
|
5
|
+
type ReactElement,
|
|
6
|
+
useEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from "react";
|
|
4
11
|
import {
|
|
5
12
|
bandRounding,
|
|
6
13
|
buildMonthWeeks,
|
|
@@ -11,6 +18,7 @@ import {
|
|
|
11
18
|
monthCreateRange,
|
|
12
19
|
daySelectionState,
|
|
13
20
|
getIsToday,
|
|
21
|
+
nowInTimeZone,
|
|
14
22
|
filterHiddenDays,
|
|
15
23
|
getWeekDays,
|
|
16
24
|
getYearMonths,
|
|
@@ -20,8 +28,6 @@ import {
|
|
|
20
28
|
rangeBandKind,
|
|
21
29
|
type WeekStartsOn,
|
|
22
30
|
weekdayFormatToken,
|
|
23
|
-
} from "@super-calendar/core";
|
|
24
|
-
import {
|
|
25
31
|
type CalendarLabels,
|
|
26
32
|
dayAccessibilityLabel,
|
|
27
33
|
resolveCalendarLabels,
|
|
@@ -59,6 +65,13 @@ export interface YearViewProps<T = unknown>
|
|
|
59
65
|
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
60
66
|
hiddenDays?: number[];
|
|
61
67
|
locale?: Locale;
|
|
68
|
+
/**
|
|
69
|
+
* The instant whose calendar day is highlighted as today. Defaults to the
|
|
70
|
+
* device clock, and is read in `timeZone` when one is set.
|
|
71
|
+
*/
|
|
72
|
+
now?: Date;
|
|
73
|
+
/** Highlight today as it is in this IANA time zone (default: the device's). */
|
|
74
|
+
timeZone?: string;
|
|
62
75
|
/** Translations for the screen-reader words; omitted keys use English. */
|
|
63
76
|
labels?: Partial<CalendarLabels>;
|
|
64
77
|
/** Highlight this date instead of the real "today". */
|
|
@@ -111,6 +124,8 @@ export function YearView<T = unknown>({
|
|
|
111
124
|
weekStartsOn = 0,
|
|
112
125
|
hiddenDays,
|
|
113
126
|
locale,
|
|
127
|
+
now,
|
|
128
|
+
timeZone,
|
|
114
129
|
labels: labelsProp,
|
|
115
130
|
activeDate,
|
|
116
131
|
selectedRange,
|
|
@@ -179,6 +194,7 @@ export function YearView<T = unknown>({
|
|
|
179
194
|
return () => window.removeEventListener("pointerup", finish);
|
|
180
195
|
}, [isCreating, onCreateEvent]);
|
|
181
196
|
|
|
197
|
+
const today = nowInTimeZone(now, timeZone);
|
|
182
198
|
const months = useMemo(() => getYearMonths(date), [date]);
|
|
183
199
|
const weekdayLabels = useMemo(
|
|
184
200
|
() =>
|
|
@@ -294,7 +310,7 @@ export function YearView<T = unknown>({
|
|
|
294
310
|
/>
|
|
295
311
|
);
|
|
296
312
|
}
|
|
297
|
-
const isToday = getIsToday(day);
|
|
313
|
+
const isToday = getIsToday(day, today);
|
|
298
314
|
const isHighlighted = activeDate
|
|
299
315
|
? isSameCalendarDay(day, activeDate)
|
|
300
316
|
: isToday;
|