{"version":3,"file":"calendar.types.mjs","names":[],"sources":["../../../../package/common/calendar/calendar.types.ts"],"sourcesContent":["import type { CSSProperties, ReactNode, Ref } from 'react';\nimport type { SlotClassNames, SlotStyles, HtmlProps } from '../types/slots.types';\nimport type { ColorValue } from '../themeProvider/color.types';\nimport type { Weekday } from '../utils/weekStart';\n\nexport enum CalendarView {\n  Month = 'month',\n  Week = 'week',\n  Day = 'day',\n  Agenda = 'agenda',\n}\n\n/** A day of the week, as `Date#getDay()` counts: 0 is Sunday, 1 is Monday. */\nexport type CalendarWeekday = Weekday;\n\n/** First day of the week, as `Date#getDay()` counts: 0 is Sunday, 1 is Monday. */\nexport type CalendarWeekStart = CalendarWeekday;\n\nexport interface CalendarEvent {\n  /** Unique among `events`: each occurrence of a recurring series needs an id of its own. */\n  id: string | number;\n  title: string;\n  /** Local time. */\n  start: Date;\n  /** Local time, exclusive. An all-day event on the 26th ends at midnight on the 27th. */\n  end: Date;\n  /** Shown in the all-day row instead of the time grid. Timed events of 24 hours or more are too. */\n  allDay?: boolean;\n  /** A `ThemeColor` or any CSS colour. Falls back to `--primary-color`. */\n  color?: ColorValue;\n  /** Can be clicked but not moved or resized. */\n  readOnly?: boolean;\n}\n\n/** A span of local time. `end` is exclusive. */\nexport interface CalendarRange {\n  start: Date;\n  end: Date;\n}\n\nexport interface CalendarEventChange<E extends CalendarEvent = CalendarEvent> {\n  event: E;\n  start: Date;\n  end: Date;\n}\n\nexport interface CalendarSlot {\n  start: Date;\n  end: Date;\n  allDay: boolean;\n}\n\n/** Where `renderEvent` draws an event. */\nexport interface CalendarEventContext {\n  /**\n   * The event has one line: an event under 45 minutes in the week and day views, an all-day bar,\n   * or a row of the month view. The day and agenda lists have room for more.\n   */\n  singleLine: boolean;\n}\n\nexport type CalendarSlots = 'root' | 'header' | 'dayHeader' | 'cell' | 'event';\n\n/** Text Calendar renders of its own, for translating it. Dates and times come from `locale`. */\nexport interface CalendarLabels {\n  /** Previous period button (default `Previous`). */\n  previous?: string;\n  /** Next period button (default `Next`). */\n  next?: string;\n  /** Jump to today (default `Today`). */\n  today?: string;\n  /** Name of the view switcher, read out by screen readers (default `Calendar view`). */\n  viewSwitcher?: string;\n  month?: string;\n  week?: string;\n  day?: string;\n  agenda?: string;\n  /** All-day row and all-day events (default `All day`). */\n  allDay?: string;\n  /** Overflow button in a month cell (default `+3 more`). */\n  more?: (count: number) => string;\n  /** Appended to a day's name for screen readers (default `3 events`). */\n  eventCount?: (count: number) => string;\n  /** A day or period without events (default `No events`). */\n  noEvents?: string;\n  /** Create button in the header and in a day's event list, shown when `onSlotCreate` is set (default `New event`). */\n  newEvent?: string;\n  /** A week number, shown with `showWeekNumbers` (default `Week 40`). */\n  weekNumber?: (week: number) => string;\n}\n\nexport interface CalendarProps<E extends CalendarEvent = CalendarEvent> extends HtmlProps<HTMLDivElement> {\n  /** The events to show. Only the ones inside the range `onRangeChange` reports are needed. */\n  events: E[];\n  /** Controlled: the selected day, `'YYYY-MM-DD'`, whose period is shown. Omit for uncontrolled. */\n  date?: string;\n  /** Day shown initially when uncontrolled, `'YYYY-MM-DD'` (default today). */\n  defaultDate?: string;\n  /** Called with the new day, `'YYYY-MM-DD'`: the value a DatePicker holds. */\n  onDateChange?: (day: string) => void;\n  /** Controlled view. Omit for uncontrolled. */\n  view?: CalendarView;\n  /** View shown initially when uncontrolled (default the first of `views`). */\n  defaultView?: CalendarView;\n  onViewChange?: (view: CalendarView) => void;\n  /** Views offered in the switcher, in order. The switcher is hidden when there is only one (default all four). */\n  views?: CalendarView[];\n  /** BCP 47 tag for dates, times and the week start (default the app's `locale`, else the browser's). */\n  locale?: string;\n  /** Overrides the locale's first day of the week. */\n  weekStartsOn?: CalendarWeekStart;\n  /** Minutes that creating, moving and resizing snap to (default `15`). */\n  slotMinutes?: number;\n  /** Days of the week left out of every view: `[0, 6]` hides the weekend. */\n  hiddenDays?: CalendarWeekday[];\n  /**\n   * Hour the week and day views open at, such as `6` for 06:00 (default an hour before now while\n   * today is shown, otherwise the start of `workingHours`, or 07:00).\n   */\n  scrollToHour?: number;\n  /**\n   * Working time in the week and day views, `[8, 17]` for 08:00 to 17:00: the hours outside it are\n   * shaded. `[22, 6]` runs overnight. Its start is also the hour those views open at when today is\n   * not shown and `scrollToHour` is not set.\n   */\n  workingHours?: readonly [start: number, end: number];\n  /** Shows ISO 8601 week numbers: on each row of the month view, and in the corner of the week and day views. */\n  showWeekNumbers?: boolean;\n  /**\n   * Called on mount and whenever the shown period changes, with the period and one either side of\n   * it, so the neighbours are already filled while swiping. Fetch events and expand recurring\n   * series for this range.\n   */\n  onRangeChange?: (range: CalendarRange) => void;\n  /** An event was clicked or tapped. `anchor` is its element, for positioning a popover. */\n  onEventClick?: (event: E, anchor: HTMLElement) => void;\n  /**\n   * An event was moved or resized. Setting it is what makes events draggable. Update `events`\n   * in the same render, or return a promise: the event then stays where it was dropped until the\n   * promise settles, and is drawn from `events` again after that, back in place if it rejected.\n   */\n  onEventChange?: (change: CalendarEventChange<E>) => void | Promise<unknown>;\n  /**\n   * Empty time was clicked or dragged over, or the header's New event button pressed. Setting it is\n   * what enables creating: a click creates an hour, or an all-day slot in the month view and the\n   * all-day row. `anchor` marks the slot on screen, for a popover's `anchor`: the first day's cell\n   * in the month view, the first day's header for the all-day row, an invisible box over the slot\n   * in the time grid, and the button itself from the header.\n   */\n  onSlotCreate?: (slot: CalendarSlot, anchor: HTMLElement) => void;\n  /**\n   * Content of an event, in place of its title. Must not contain interactive elements. Keep to the\n   * title where `context.singleLine` is set: further lines have no room there.\n   */\n  renderEvent?: (event: E, context: CalendarEventContext) => ReactNode;\n  /** A class for one event's element, next to `classNames.event`: a tentative, cancelled or selected event. */\n  eventClassName?: (event: E) => string | undefined;\n  /** The root element. */\n  ref?: Ref<HTMLDivElement>;\n\n  className?: string;\n  style?: CSSProperties;\n  classNames?: SlotClassNames<CalendarSlots>;\n  styles?: SlotStyles<CalendarSlots>;\n  /** Overrides the text Calendar renders of its own. Merged per key. */\n  labels?: CalendarLabels;\n}\n\n/**\n * The props `ConfigProvider` can set for every Calendar. The rest depend on the event type, and\n * `locale` is the provider's own.\n */\nexport type CalendarDefaults = Pick<\n  CalendarProps,\n  | 'labels'\n  | 'weekStartsOn'\n  | 'slotMinutes'\n  | 'views'\n  | 'hiddenDays'\n  | 'scrollToHour'\n  | 'workingHours'\n  | 'showWeekNumbers'\n>;\n"],"mappings":"aAKA,IAAY,EAAL,SAAA,EAAA,OACL,GAAA,MAAA,QACA,EAAA,KAAA,OACA,EAAA,IAAA,MACA,EAAA,OAAA,UACF,EAAA,CAAA,CAAA"}