@super-calendar/native 2.10.0 → 2.11.1
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 +1 -1
- package/dist/{DefaultMonthEvent--9Jg6w-x.d.ts → DefaultMonthEvent-B9KzVzFa.d.mts} +11 -5
- package/dist/{DefaultMonthEvent-BlnKHaq2.d.mts → DefaultMonthEvent-DlIIWDzr.d.ts} +11 -5
- package/dist/{MonthList-CjKhzOJX.mjs → MonthList-B-UE37ZG.mjs} +166 -139
- package/dist/{MonthList-DNT1LJkk.js → MonthList-sGAZxQZ_.js} +176 -137
- package/dist/index.d.mts +67 -21
- package/dist/index.d.ts +67 -21
- package/dist/index.js +1121 -772
- package/dist/index.mjs +1117 -774
- package/dist/picker.d.mts +1 -1
- package/dist/picker.d.ts +1 -1
- package/dist/picker.js +1 -1
- package/dist/picker.mjs +1 -1
- package/package.json +3 -3
- package/src/components/Agenda.tsx +5 -1
- package/src/components/AllDayLane.tsx +36 -53
- package/src/components/Calendar.tsx +196 -149
- package/src/components/DefaultEvent.tsx +3 -0
- package/src/components/DefaultMonthEvent.tsx +3 -0
- package/src/components/MonthList.tsx +6 -0
- package/src/components/MonthPager.tsx +6 -0
- package/src/components/MonthView.tsx +195 -172
- package/src/components/MultiDayMovePreview.tsx +1 -3
- package/src/components/ResourceTimeline.tsx +18 -7
- package/src/components/TimeGrid.tsx +1409 -903
- package/src/components/YearView.tsx +22 -5
- package/src/index.tsx +1 -0
- package/src/utils/labels.ts +13 -0
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Text,
|
|
10
10
|
type TextStyle,
|
|
11
11
|
View,
|
|
12
|
+
type ScrollViewProps,
|
|
12
13
|
} from "react-native";
|
|
13
14
|
import { Gesture, GestureDetector, type PanGesture } from "react-native-gesture-handler";
|
|
14
15
|
import { useCalendarTheme } from "../theme";
|
|
@@ -32,6 +33,11 @@ import {
|
|
|
32
33
|
rangeBandKind,
|
|
33
34
|
weekdayFormatToken,
|
|
34
35
|
} from "@super-calendar/core";
|
|
36
|
+
import {
|
|
37
|
+
type CalendarLabels,
|
|
38
|
+
dayAccessibilityLabel,
|
|
39
|
+
resolveCalendarLabels,
|
|
40
|
+
} from "@super-calendar/core";
|
|
35
41
|
|
|
36
42
|
const isWeb = Platform.OS === "web";
|
|
37
43
|
// Hold before a year-grid drag takes over, so a tap still opens the day.
|
|
@@ -66,6 +72,8 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
|
|
|
66
72
|
/** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
|
|
67
73
|
hiddenDays?: number[];
|
|
68
74
|
locale?: Locale;
|
|
75
|
+
/** Translations for the screen-reader words; omitted keys use English. */
|
|
76
|
+
labels?: Partial<CalendarLabels>;
|
|
69
77
|
/** Highlight this date instead of the real "today". */
|
|
70
78
|
activeDate?: Date;
|
|
71
79
|
/** A selected span: endpoints get a filled badge, the days between get the range band. */
|
|
@@ -103,6 +111,8 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
|
|
|
103
111
|
* the last, exclusive). A plain tap still fires `onPressDay`, not this.
|
|
104
112
|
*/
|
|
105
113
|
onCreateEvent?: (start: Date, end: Date) => void;
|
|
114
|
+
/** Pull-to-refresh control, mounted on the year's scroll view. */
|
|
115
|
+
refreshControl?: ScrollViewProps["refreshControl"];
|
|
106
116
|
};
|
|
107
117
|
|
|
108
118
|
// Seed before the first layout pass so the grid renders immediately (and in
|
|
@@ -115,6 +125,7 @@ function YearViewInner<T>({
|
|
|
115
125
|
weekStartsOn,
|
|
116
126
|
hiddenDays,
|
|
117
127
|
locale,
|
|
128
|
+
labels: labelsProp,
|
|
118
129
|
activeDate,
|
|
119
130
|
selectedRange,
|
|
120
131
|
selectedDates,
|
|
@@ -126,10 +137,12 @@ function YearViewInner<T>({
|
|
|
126
137
|
onPressMonth,
|
|
127
138
|
onSelectDrag,
|
|
128
139
|
onCreateEvent,
|
|
140
|
+
refreshControl,
|
|
129
141
|
classNames,
|
|
130
142
|
styles: styleOverrides,
|
|
131
143
|
}: YearViewProps<T>): ReactElement {
|
|
132
144
|
const theme = useCalendarTheme();
|
|
145
|
+
const labels = useMemo(() => resolveCalendarLabels(labelsProp), [labelsProp]);
|
|
133
146
|
const slot = createSlots<YearViewSlot>({ classNames, styles: styleOverrides });
|
|
134
147
|
|
|
135
148
|
const [columns, setColumns] = useState(FALLBACK_COLUMNS);
|
|
@@ -244,6 +257,7 @@ function YearViewInner<T>({
|
|
|
244
257
|
// under the finger. On the web a press arms it immediately, so freezing
|
|
245
258
|
// there would cost every touch scroll; the browser arbitrates instead.
|
|
246
259
|
scrollEnabled={isWeb || sweep == null}
|
|
260
|
+
refreshControl={refreshControl}
|
|
247
261
|
>
|
|
248
262
|
<View {...slot("grid", { base: styles.grid })}>
|
|
249
263
|
{months.map((month, monthIndex) => {
|
|
@@ -335,11 +349,14 @@ function YearViewInner<T>({
|
|
|
335
349
|
sweep != null &&
|
|
336
350
|
dayTime >= Math.min(sweep.anchor, sweep.hover) &&
|
|
337
351
|
dayTime <= Math.max(sweep.anchor, sweep.hover);
|
|
338
|
-
const label =
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
state.
|
|
342
|
-
|
|
352
|
+
const label = dayAccessibilityLabel({
|
|
353
|
+
dateLabel: format(day, "EEEE, d LLLL yyyy", { locale }),
|
|
354
|
+
isToday,
|
|
355
|
+
isSelected: state.isSelected,
|
|
356
|
+
isDisabled: state.isDisabled,
|
|
357
|
+
hasEvents,
|
|
358
|
+
labels,
|
|
359
|
+
});
|
|
343
360
|
// Today wins over a selection, matching the month grid.
|
|
344
361
|
const badge = dayBadgeKind(state, isHighlighted);
|
|
345
362
|
const daySlot = slot("day", { base: styles.day });
|
package/src/index.tsx
CHANGED
|
@@ -98,6 +98,7 @@ export {
|
|
|
98
98
|
weekdayFormatToken,
|
|
99
99
|
} from "@super-calendar/core";
|
|
100
100
|
export { expandRecurringEvents } from "@super-calendar/core";
|
|
101
|
+
export { type CalendarLabels, defaultCalendarLabels } from "@super-calendar/core";
|
|
101
102
|
export {
|
|
102
103
|
type ICalEvent,
|
|
103
104
|
parseICalendar,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type CalendarLabels, defaultCalendarLabels } from "@super-calendar/core";
|
|
2
|
+
import { type Context, createContext, useContext } from "react";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The resolved `labels` of the nearest view, so the built-in event renderers
|
|
6
|
+
* can localize their screen-reader text without a prop on `RenderEventArgs`.
|
|
7
|
+
*/
|
|
8
|
+
export const CalendarLabelsContext: Context<CalendarLabels> =
|
|
9
|
+
createContext<CalendarLabels>(defaultCalendarLabels);
|
|
10
|
+
|
|
11
|
+
export function useCalendarLabels(): CalendarLabels {
|
|
12
|
+
return useContext(CalendarLabelsContext);
|
|
13
|
+
}
|