Calendar
import { Calendar, type CalendarEvent } from '@dxos/react-ui-calendar';npm install @dxos/react-ui-calendarA calendar shows dates for the user to pick from or to plan. Calendar draws them in two ways:
Calendar.Gridis a scrolling grid of weeks. Use it when the user picks a day or a range.Calendar.Weekis a week of hours with events in it. Use it when the user plans a week.
Both sit inside Calendar.Root, which holds the date the calendar shows.
Add the packageโs strings from @dxos/react-ui-calendar/translations to the resourceExtensions of Theme.Provider.
| Part | What it is |
|---|---|
Calendar.Root |
The root, which holds the date in view and the first day of the week (weekStartsOn) |
Calendar.Toolbar |
The row that names the month in view and jumps back to today |
Calendar.Grid |
Weeks of days that scroll. rows sets how many show |
Calendar.Week |
A week of hours, with each event in its dayโs column. Overlapping events share the column |
Calendar.Grid
Section titled โCalendar.GridโCalendar.Grid shows weeks of days that scroll, and reports the day or the range the user picks.
| Prop | Type | Effect |
|---|---|---|
rows |
number |
Sets how many weeks show |
dates |
DateMarker[] |
Marks days, each with a border for its tag |
initialDate |
Date |
Sets the day scrolled into view. Today by default |
scrollMargin |
number |
Sets how many weeks stay above a day scrolled into view. 2 by default |
onSelect |
({ date }) => void |
The user picked a day, with a click or an arrow key |
onSelectRange |
({ range }) => void |
The user picked a range, with a drag or Shift and an arrow key |
Calendar.Week
Section titled โCalendar.WeekโCalendar.Week draws a week of hours, with each event in its dayโs column. An event is an id, a title, a start
and an end.
Calendar.Week reports gestures and holds no events of its own, so you apply each change to your state.
| Prop | Type | Effect |
|---|---|---|
date |
Date |
Sets the week to show, from any day in it. Today by default |
events |
CalendarEvent[] |
Sets the events to draw |
onEventCreate |
({ start, end }) => void |
The user dragged out an empty slot |
onEventUpdate |
({ id, start, end }) => void |
The user moved an event or dragged its edge |
Pick a day
Section titled โPick a dayโCalendar.Grid scrolls through the weeks, and Calendar.Toolbar names the month in view. The user clicks a day to
pick it, or drags across days to pick a range. onSelect reports the day, and onSelectRange reports the range.
Example (Showing six weeks under a toolbar)
import { function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState } from 'react';import { const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar } from '@dxos/react-ui-calendar';import * as import Typography
Typography from '@dxos/react-ui/Typography';
/** A date picker: the grid scrolls through weeks, and the toolbar names the month in view. */export const const MonthPicker: () => React.JSX.Element
A date picker: the grid scrolls through weeks, and the toolbar names the month in view.
MonthPicker = () => { const [const picked: string
picked, const setPicked: React.Dispatch<React.SetStateAction<string>>
setPicked] = useState<string>(initialState: string | (() => string)): [string, React.Dispatch<React.SetStateAction<string>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState('Click a day, or drag across days.');
return ( <const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined;} & React.RefAttributes<CalendarController>>
Root> <const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Toolbar /> <const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Grid rows?: number | undefined
rows={6} onSelect?: ((event: { date: Date;}) => void) | undefined
Fired when a user selects a single date (click or arrow key).
onSelect={({ date: Date
date }) => const setPicked: (value: React.SetStateAction<string>) => void
setPicked(date: Date
date.Date.toDateString(): string
Returns a date as a string value.
toDateString())} onSelectRange?: ((event: { range: Range;}) => void) | undefined
Fired when a user commits a multi-day range, either by a drag gesture or
by shift+arrow extension. The range is normalized: from <= to, both at
start-of-day. Not fired for single-day selections (use
onSelect
).
onSelectRange={({ range: Range
range }) => const setPicked: (value: React.SetStateAction<string>) => void
setPicked( `${range: Range
range.from: Date
from.Date.toDateString(): string
Returns a date as a string value.
toDateString()} to ${range: Range
range.to: Date
to.Date.toDateString(): string
Returns a date as a string value.
toDateString()}`, ) } /> <import Typography
Typography.const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLParagraphElement>>export Text
Text whose first line is centred in a block, so it lines up with a Block or control beside it however many lines
it wraps to. Renders a <p>; asChild puts the metrics on a heading or other text element instead.
Text tone?: Typography.TextTone | undefined
Emphasis below the default (DESIGN.md "Text emphasis"): description for secondary content, subdued for
interface text.
tone='muted'>{const picked: string
picked}</import Typography
Typography.const Text: React.ForwardRefExoticComponent<Omit<Typography.TextProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLParagraphElement>>export Text
Text whose first line is centred in a block, so it lines up with a Block or control beside it however many lines
it wraps to. Renders a <p>; asChild puts the metrics on a heading or other text element instead.
Text> </const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined;} & React.RefAttributes<CalendarController>>
Root> );};
rows sets the grid to six weeks. The two handlers put the day or the range into picked, which the line under the
grid shows.
Plan a week
Section titled โPlan a weekโIn Calendar.Week, the user drags an empty slot to add an event, drags an event to move it, or drags its edge to
resize it. The week calls onEventCreate or onEventUpdate, and you change the events you hold.
Example (Keeping a week of events in state)
import { function useRef<T>(initialValue: T): React.RefObject<T> (+2 overloads)
useRef returns a mutable ref object whose .current property is initialized to the passed argument
(initialValue). The returned object will persist for the full lifetime of the component.
Note that useRef() is useful for more than the ref attribute. Itโs handy for keeping any mutable
value around similar to how youโd use instance fields in classes.
useRef, function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState } from 'react';import { const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar, type type CalendarEvent = { id: string; title?: string; start: Date; end: Date;}
An event rendered on the week's time grid. Times are interpreted in local time.
CalendarEvent } from '@dxos/react-ui-calendar';import * as import Panel
Panel from '@dxos/react-ui/Panel';
/** An event at `hour` on the day `day` days after this week's Monday. */const const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at = (day: number
day: number, hour: number
hour: number, minutes: number
minutes = 0) => { const const date: Date
date = new var Date: DateConstructornew () => Date (+3 overloads)
Date(); // `getDay` counts from Sunday; step back to Monday, then forward to the day. const date: Date
date.Date.setDate(date: number): number
Sets the numeric day-of-the-month value of the Date object using local time.
setDate(const date: Date
date.Date.getDate(): number
Gets the day-of-the-month, using local time.
getDate() - ((const date: Date
date.Date.getDay(): number
Gets the day of the week, using local time.
getDay() + 6) % 7) + day: number
day); const date: Date
date.Date.setHours(hours: number, min?: number, sec?: number, ms?: number): number
Sets the hour value in the Date object using local time.
setHours(hour: number
hour, minutes: number
minutes, 0, 0); return const date: Date
date;};
const const WEEK: CalendarEvent[]
WEEK: type CalendarEvent = { id: string; title?: string; start: Date; end: Date;}
An event rendered on the week's time grid. Times are interpreted in local time.
CalendarEvent[] = [ { id: string
id: '1', title?: string | undefined
title: 'Standup', start: Date
start: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(0, 9), end: Date
end: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(0, 9, 30) }, { id: string
id: '2', title?: string | undefined
title: 'Design review', start: Date
start: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(1, 10), end: Date
end: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(1, 11, 30) }, { id: string
id: '3', title?: string | undefined
title: 'Lunch', start: Date
start: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(2, 12), end: Date
end: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(2, 13) }, { id: string
id: '4', title?: string | undefined
title: 'Planning', start: Date
start: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(3, 14), end: Date
end: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(3, 15, 30) }, { id: string
id: '5', title?: string | undefined
title: 'Demo', start: Date
start: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(4, 11), end: Date
end: const at: (day: number, hour: number, minutes?: number) => Date
An event at hour on the day day days after this week's Monday.
at(4, 12) },];
/** A week of events: drag an empty slot to add one, drag an event to move it, or drag its edge to resize it. */export const const WeekPlanner: () => React.JSX.Element
A week of events: drag an empty slot to add one, drag an event to move it, or drag its edge to resize it.
WeekPlanner = () => { const [const events: CalendarEvent[]
events, const setEvents: React.Dispatch<React.SetStateAction<CalendarEvent[]>>
setEvents] = useState<CalendarEvent[]>(initialState: CalendarEvent[] | (() => CalendarEvent[])): [CalendarEvent[], React.Dispatch<React.SetStateAction<CalendarEvent[]>>] (+1 overload)
Returns a stateful value, and a function to update it.
useState(const WEEK: CalendarEvent[]
WEEK); const const nextId: React.RefObject<number>
nextId = useRef<number>(initialValue: number): React.RefObject<number> (+2 overloads)
useRef returns a mutable ref object whose .current property is initialized to the passed argument
(initialValue). The returned object will persist for the full lifetime of the component.
Note that useRef() is useful for more than the ref attribute. Itโs handy for keeping any mutable
value around similar to how youโd use instance fields in classes.
useRef(const WEEK: CalendarEvent[]
WEEK.Array<CalendarEvent>.length: number
Gets or sets the length of the array. This is a number one higher than the highest index in the array.
length + 1);
return ( <const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined;} & React.RefAttributes<CalendarController>>
Root> <import Panel
Panel.const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
The plank host: fills its parent, sets data-size and a level for its subtree, and is the pane's
query container, so its header, body and footer collapse at the same pane width.
Root> <import Panel
Panel.const Header: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Header
The top row on the bar aspect, which steps off whatever level hosts the panel; it sizes to its content, so it takes
no space when empty and one block when it holds a Toolbar.Root.
Header> <const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Toolbar /> </import Panel
Panel.const Header: React.ForwardRefExoticComponent<Omit<{ asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Header
The top row on the bar aspect, which steps off whatever level hosts the panel; it sizes to its content, so it takes
no space when empty and one block when it holds a Toolbar.Root.
Header> <const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>
Week events?: CalendarEvent[] | undefined
events={const events: CalendarEvent[]
events} onEventCreate?: ((event: { start: Date; end: Date;}) => void) | undefined
Fired when the user drags out a new time slot on an empty part of a day column.
onEventCreate={({ start: Date
start, end: Date
end }) => const setEvents: (value: React.SetStateAction<CalendarEvent[]>) => void
setEvents((current: CalendarEvent[]
current) => [ ...current: CalendarEvent[]
current, { id: string
id: var String: StringConstructor(value?: any) => string
Allows manipulation and formatting of text strings and determination and location of substrings within strings.
String(const nextId: React.RefObject<number>
nextId.React.RefObject<number>.current: number
The current value of the ref.
current++), title?: string | undefined
title: 'New event', start: Date
start, end: Date
end }, ]) } onEventUpdate?: ((event: { id: string; start: Date; end: Date;}) => void) | undefined
Fired when an event is moved (duration preserved) or resized (one edge changed).
onEventUpdate={({ id: string
id, start: Date
start, end: Date
end }) => const setEvents: (value: React.SetStateAction<CalendarEvent[]>) => void
setEvents((current: CalendarEvent[]
current) => current: CalendarEvent[]
current.Array<CalendarEvent>.map<CalendarEvent>(callbackfn: (value: CalendarEvent, index: number, array: CalendarEvent[]) => CalendarEvent, thisArg?: any): CalendarEvent[]
Calls a defined callback function on each element of an array, and returns an array that contains the results.
map((event: CalendarEvent
event) => event: CalendarEvent
event.id: string
id === id: string
id ? { ...event: CalendarEvent
event, start: Date
start, end: Date
end } : event: CalendarEvent
event, ), ) } /> </import Panel
Panel.const Root: React.ForwardRefExoticComponent<Omit<Panel.RootProps & { asChild?: boolean;}, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue;} & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>export Root
The plank host: fills its parent, sets data-size and a level for its subtree, and is the pane's
query container, so its header, body and footer collapse at the same pane width.
Root> </const Calendar: { Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined; } & React.RefAttributes<CalendarController>>; Toolbar: React.ForwardRefExoticComponent<Omit<CalendarToolbarProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Grid: React.ForwardRefExoticComponent<Omit<CalendarGridProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>; Week: React.ForwardRefExoticComponent<Omit<CalendarWeekProps, "className"> & { classNames?: import("@dxos/ui-types").ClassNameValue; } & Pick<React.HTMLAttributes<Element>, "children" | "role" | "style"> & React.RefAttributes<HTMLDivElement>>;}
Calendar.type Root: React.ForwardRefExoticComponent<Partial<Pick<CalendarContextValue, "weekStartsOn">> & { children?: React.ReactNode | undefined;} & React.RefAttributes<CalendarController>>
Root> );};
onEventCreate appends an event with the start and end of the slot the user dragged out. onEventUpdate
replaces the start and end of the event with the same id.