@super-calendar/native 2.6.0 → 2.8.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.
@@ -14,9 +14,11 @@ import { createSlots, type SlotStyleProps } from "../utils/slots";
14
14
  import {
15
15
  buildMonthWeeks,
16
16
  getIsToday,
17
+ filterHiddenDays,
17
18
  getWeekDays,
18
19
  getYearMonths,
19
20
  groupEventsByDay,
21
+ isBackgroundEvent,
20
22
  isSameCalendarDay,
21
23
  weekdayFormatToken,
22
24
  } from "@super-calendar/core";
@@ -43,6 +45,8 @@ export type YearViewProps<T = unknown> = SlotStyleProps<YearViewSlot> & {
43
45
  /** Days holding at least one event get a dot. Omit for a plain year. */
44
46
  events?: CalendarEvent<T>[];
45
47
  weekStartsOn: WeekStartsOn;
48
+ /** Weekdays (0=Sunday…6=Saturday) hidden from the grid, e.g. `[0, 6]` for weekends off. */
49
+ hiddenDays?: number[];
46
50
  locale?: Locale;
47
51
  /** Highlight this date instead of the real "today". */
48
52
  activeDate?: Date;
@@ -65,6 +69,7 @@ function YearViewInner<T>({
65
69
  date,
66
70
  events,
67
71
  weekStartsOn,
72
+ hiddenDays,
68
73
  locale,
69
74
  activeDate,
70
75
  minMonthWidth = 150,
@@ -87,14 +92,19 @@ function YearViewInner<T>({
87
92
  // Weekday initials for one shared header per mini month.
88
93
  const weekdayLabels = useMemo(
89
94
  () =>
90
- getWeekDays(date, weekStartsOn).map((d) =>
95
+ filterHiddenDays(getWeekDays(date, weekStartsOn), hiddenDays).map((d) =>
91
96
  format(d, weekdayFormatToken("narrow"), { locale }),
92
97
  ),
93
- [date, weekStartsOn, locale],
98
+ [date, weekStartsOn, locale, hiddenDays],
94
99
  );
95
100
  // Days that hold at least one event, keyed like `groupEventsByDay`.
96
101
  const eventDays = useMemo(
97
- () => new Set(events && events.length > 0 ? groupEventsByDay(events).keys() : []),
102
+ () =>
103
+ new Set(
104
+ events && events.length > 0
105
+ ? groupEventsByDay(events.filter((e) => !isBackgroundEvent(e))).keys()
106
+ : [],
107
+ ),
98
108
  [events],
99
109
  );
100
110
 
@@ -102,7 +112,7 @@ function YearViewInner<T>({
102
112
  <ScrollView onLayout={handleLayout} showsVerticalScrollIndicator>
103
113
  <View {...slot("grid", { base: styles.grid })}>
104
114
  {months.map((month) => {
105
- const weeks = buildMonthWeeks(month, weekStartsOn);
115
+ const weeks = buildMonthWeeks(month, weekStartsOn, { hiddenDays });
106
116
  const title = format(month, "MMMM", { locale });
107
117
  const monthLabel = format(month, "MMMM yyyy", { locale });
108
118
  const titleText = (
package/src/index.tsx CHANGED
@@ -55,6 +55,7 @@ export {
55
55
  } from "./theme";
56
56
  export type {
57
57
  BusinessHours,
58
+ BusinessHoursBand,
58
59
  CalendarEvent,
59
60
  CalendarMode,
60
61
  EventAccessibilityLabelContext,
@@ -80,13 +81,18 @@ export {
80
81
  isWithinDateRange,
81
82
  nextDateRange,
82
83
  useDateRange,
84
+ useEventSource,
85
+ useNow,
83
86
  } from "@super-calendar/core";
84
87
  export {
85
88
  buildMonthGrid,
89
+ layoutMonthWeek,
90
+ type MonthEventSegment,
86
91
  type MonthGrid,
87
92
  type MonthGridDay,
88
93
  type MonthGridWeek,
89
94
  type MonthGridWeekday,
95
+ type MonthWeekEvents,
90
96
  type UseMonthGridOptions,
91
97
  useMonthGrid,
92
98
  weekdayFormatToken,
@@ -108,4 +114,10 @@ export {
108
114
  isSameCalendarDay,
109
115
  minutesIntoDay,
110
116
  } from "@super-calendar/core";
111
- export { layoutDayEvents, isAllDayEvent, type PositionedEvent } from "@super-calendar/core";
117
+ export {
118
+ layoutDayEvents,
119
+ isAllDayEvent,
120
+ isBackgroundEvent,
121
+ backgroundBandsForDay,
122
+ type PositionedEvent,
123
+ } from "@super-calendar/core";
package/src/types.ts CHANGED
@@ -12,6 +12,7 @@ import type { CalendarEvent, CalendarMode } from "@super-calendar/core";
12
12
  // importing them from "../types".
13
13
  export type {
14
14
  BusinessHours,
15
+ BusinessHoursBand,
15
16
  CalendarEvent,
16
17
  CalendarMode,
17
18
  EventAccessibilityLabelContext,