@lazerlen/legend-calendar 1.4.1 → 1.6.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/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import * as react from 'react';
2
- import { ReactNode } from 'react';
3
- import { TextProps, ViewStyle, TextStyle, PressableProps, ColorSchemeName } from 'react-native';
4
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { TextProps, ViewStyle, TextStyle, PressableProps, ColorSchemeName } from 'react-native';
3
+ import { ReactNode } from 'react';
5
4
  import { LegendListProps } from '@legendapp/list/react-native';
6
5
 
7
6
  type CalendarTextProps = Omit<TextProps, "onPress" | "onLongPress" | "onPressIn" | "onPressOut">;
@@ -158,7 +157,7 @@ interface CalendarItemDayProps {
158
157
  * `CalendarItemDayWithContainer`, since it also includes the spacing between
159
158
  * each day.
160
159
  */
161
- declare const CalendarItemDay: react.NamedExoticComponent<CalendarItemDayProps>;
160
+ declare const CalendarItemDay: ({ onPress, children, theme, height, metadata, textProps, CalendarPressableComponent, }: CalendarItemDayProps) => react_jsx_runtime.JSX.Element;
162
161
  interface CalendarItemDayContainerTheme {
163
162
  /** An empty view that acts as a spacer between each day. The spacing is
164
163
  * controlled by the `daySpacing` prop. */
@@ -189,7 +188,7 @@ interface CalendarItemDayContainerProps {
189
188
  /** The metadata for the day, extracted from the calendar's state. */
190
189
  metadata?: CalendarDayMetadata;
191
190
  }
192
- declare const CalendarItemDayContainer: react.NamedExoticComponent<CalendarItemDayContainerProps>;
191
+ declare const CalendarItemDayContainer: ({ children, isStartOfWeek, shouldShowActiveDayFiller, theme, daySpacing, dayHeight, metadata, }: CalendarItemDayContainerProps) => react_jsx_runtime.JSX.Element;
193
192
  interface CalendarItemDayWithContainerProps extends Omit<CalendarItemDayProps, "height">, Pick<CalendarItemDayContainerProps, "daySpacing" | "dayHeight"> {
194
193
  containerTheme?: CalendarItemDayContainerTheme;
195
194
  /**
@@ -205,7 +204,7 @@ interface CalendarItemDayWithContainerProps extends Omit<CalendarItemDayProps, "
205
204
  */
206
205
  calendarInstanceId?: string;
207
206
  }
208
- declare const CalendarItemDayWithContainer: react.NamedExoticComponent<CalendarItemDayWithContainerProps>;
207
+ declare const CalendarItemDayWithContainer: ({ children, metadata: baseMetadata, onPress, theme, dayHeight, daySpacing, containerTheme, calendarInstanceId, CalendarPressableComponent, }: CalendarItemDayWithContainerProps) => react_jsx_runtime.JSX.Element;
209
208
 
210
209
  interface CalendarItemEmptyProps {
211
210
  /** The height of the cell. Should be the same as `CalendarItemDay`. */
@@ -215,7 +214,7 @@ interface CalendarItemEmptyProps {
215
214
  container?: ViewStyle;
216
215
  };
217
216
  }
218
- declare const CalendarItemEmpty: react.NamedExoticComponent<CalendarItemEmptyProps>;
217
+ declare const CalendarItemEmpty: (props: CalendarItemEmptyProps) => react_jsx_runtime.JSX.Element;
219
218
 
220
219
  interface CalendarItemWeekNameTheme {
221
220
  container?: ViewStyle;
@@ -232,7 +231,7 @@ interface CalendarItemWeekNameProps {
232
231
  /** Optional TextProps to spread to the <Text> component. */
233
232
  textProps?: Omit<CalendarTextProps, "children">;
234
233
  }
235
- declare const CalendarItemWeekName: react.NamedExoticComponent<CalendarItemWeekNameProps>;
234
+ declare const CalendarItemWeekName: ({ children, height, theme, textProps, }: CalendarItemWeekNameProps) => react_jsx_runtime.JSX.Element;
236
235
 
237
236
  interface CalendarRowMonthTheme {
238
237
  container?: ViewStyle;
@@ -248,7 +247,7 @@ interface CalendarRowMonthProps {
248
247
  /** The theme of the month row, useful for customizing the component. */
249
248
  theme?: CalendarRowMonthTheme;
250
249
  }
251
- declare const CalendarRowMonth: react.NamedExoticComponent<CalendarRowMonthProps>;
250
+ declare const CalendarRowMonth: ({ children, height, theme, }: CalendarRowMonthProps) => react_jsx_runtime.JSX.Element;
252
251
 
253
252
  /**
254
253
  * Minimal theme for the Legend Calendar component.
@@ -334,7 +333,7 @@ interface CalendarRowWeekProps {
334
333
  interface CalendarRowWeekTheme {
335
334
  container?: ViewStyle;
336
335
  }
337
- declare const CalendarRowWeek: react.NamedExoticComponent<CalendarRowWeekProps>;
336
+ declare const CalendarRowWeek: ({ children, spacing, theme, }: CalendarRowWeekProps) => react_jsx_runtime.JSX.Element;
338
337
 
339
338
  type PressableLike = React.ComponentType<Pick<PressableProps, "children" | "style" | "disabled"> & {
340
339
  onPress: () => void;
@@ -410,7 +409,7 @@ interface CalendarProps extends UseCalendarParams {
410
409
  /** Optional component to replace the default <Pressable> component. */
411
410
  CalendarPressableComponent?: PressableLike;
412
411
  }
413
- declare const Calendar$1: react.NamedExoticComponent<CalendarProps>;
412
+ declare const Calendar$1: (props: CalendarProps) => react_jsx_runtime.JSX.Element;
414
413
 
415
414
  interface CalendarMonth {
416
415
  id: string;
@@ -480,6 +479,29 @@ declare const getHeightForMonth: ({ calendarRowVerticalSpacing: vSpacing, calend
480
479
  * `Calendar` props to simplify building custom `Calendar` components.
481
480
  */
482
481
  type CalendarMonthEnhanced = CalendarMonth & {
482
+ /**
483
+ * The calendar configuration props for this item. Available when using a
484
+ * custom `renderItem` for backwards compatibility.
485
+ *
486
+ * @deprecated Prefer reading calendar config from context via
487
+ * `useCalendarListConfig()` instead of spreading `item.calendarProps`.
488
+ * This avoids creating a new data array each render and lets LegendList
489
+ * skip unnecessary item re-renders.
490
+ *
491
+ * **Before (slower):**
492
+ * ```tsx
493
+ * renderItem={({ item }) => (
494
+ * <MyCalendar calendarMonthId={item.id} {...item.calendarProps} />
495
+ * )}
496
+ * ```
497
+ *
498
+ * **After (faster):**
499
+ * ```tsx
500
+ * // Inside your custom calendar component:
501
+ * const listConfig = useCalendarListConfig();
502
+ * // Merge: { ...listConfig, ...props }
503
+ * ```
504
+ */
483
505
  calendarProps: Omit<CalendarProps, "calendarMonthId">;
484
506
  };
485
507
  interface CalendarListProps extends Omit<CalendarProps, "calendarMonthId">, Omit<LegendListProps<CalendarMonthEnhanced>, "renderItem" | "data" | "children"> {
@@ -540,6 +562,12 @@ interface CalendarListProps extends Omit<CalendarProps, "calendarMonthId">, Omit
540
562
  * - calendarAdditionalHeight
541
563
  * - calendarRowVerticalSpacing
542
564
  * - calendarSpacing
565
+ *
566
+ * **Performance tip**: Using `item.calendarProps` is provided for
567
+ * backwards compatibility but creates a new data array each render.
568
+ * For better performance, have your custom component call
569
+ * `useCalendarListConfig()` to read the shared config from context
570
+ * and only use `item.id` as `calendarMonthId`.
543
571
  */
544
572
  renderItem?: LegendListProps<CalendarMonthEnhanced>["renderItem"];
545
573
  }
@@ -555,7 +583,7 @@ interface CalendarListRef {
555
583
  scrollToDate: (date: Date, animated: boolean, params?: ImperativeScrollParams) => void;
556
584
  scrollToOffset: (offset: number, animated: boolean) => void;
557
585
  }
558
- declare function CalendarList({ ref, ...props }: CalendarListProps & {
586
+ declare function CalendarList(props: CalendarListProps & {
559
587
  ref?: React.Ref<CalendarListRef>;
560
588
  }): react_jsx_runtime.JSX.Element;
561
589
 
@@ -583,6 +611,23 @@ interface VStackProps {
583
611
  }
584
612
  declare function VStack({ children, spacing, alignItems, justifyContent, grow, }: VStackProps): react_jsx_runtime.JSX.Element;
585
613
 
614
+ /**
615
+ * The calendar configuration props shared across all items in a
616
+ * `CalendarList`. When `Calendar` is rendered inside `CalendarList`, it reads
617
+ * these values from context instead of receiving them through the list item's
618
+ * data, which keeps the `data` array identity stable and allows LegendList to
619
+ * skip unnecessary re-renders.
620
+ *
621
+ * When `Calendar` is used standalone (outside a list), the context is `null`
622
+ * and all props are passed directly.
623
+ */
624
+ type CalendarListConfig = Omit<CalendarProps, "calendarMonthId">;
625
+ /**
626
+ * Returns the shared calendar configuration from the nearest
627
+ * `CalendarListConfigProvider`, or `null` when used outside a `CalendarList`.
628
+ */
629
+ declare const useCalendarListConfig: () => CalendarListConfig | null;
630
+
586
631
  /**
587
632
  * This file houses the public API for the legend-calendar package.
588
633
  */
@@ -704,4 +749,4 @@ declare const useDateRange: (initialDateRange?: CalendarActiveDateRange) => {
704
749
  isDateRangeValid: boolean;
705
750
  };
706
751
 
707
- export { Calendar, type CalendarActiveDateRange, type CalendarDayMetadata, type CalendarItemDayContainerProps, type CalendarItemDayProps, type CalendarItemDayWithContainerProps, type CalendarItemEmptyProps, type CalendarItemWeekNameProps, type CalendarListProps, type CalendarListRef, type CalendarMonth, type CalendarMonthEnhanced, type CalendarOnDayPress, type CalendarProps, type CalendarRowMonthProps, type CalendarRowWeekProps, type CalendarTextProps, type CalendarTheme, type HStackProps, type UseCalendarListParams, type UseCalendarParams, type VStackProps, activeDateRangesStore, buildCalendar, fromDateId, getHeightForMonth, toDateId, useCalendar, useCalendarList, useDateRange, useOptimizedDayMetadata };
752
+ export { Calendar, type CalendarActiveDateRange, type CalendarDayMetadata, type CalendarItemDayContainerProps, type CalendarItemDayProps, type CalendarItemDayWithContainerProps, type CalendarItemEmptyProps, type CalendarItemWeekNameProps, type CalendarListConfig, type CalendarListProps, type CalendarListRef, type CalendarMonth, type CalendarMonthEnhanced, type CalendarOnDayPress, type CalendarProps, type CalendarRowMonthProps, type CalendarRowWeekProps, type CalendarTextProps, type CalendarTheme, type HStackProps, type UseCalendarListParams, type UseCalendarParams, type VStackProps, activeDateRangesStore, buildCalendar, fromDateId, getHeightForMonth, toDateId, useCalendar, useCalendarList, useCalendarListConfig, useDateRange, useOptimizedDayMetadata };