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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPZYQAumujy5kXaOKurr6zgTP2krHrFVXi2kj8seRYrlvq2GssUjReh5MiVpQbLFQNy9HsmcasqpBNVsXytWTw0ZDjA=

Calendar

import { Calendar, type CalendarEvent } from '@dxos/react-ui-calendar';
Terminal window
npm install @dxos/react-ui-calendar

A calendar shows dates for the user to pick from or to plan. Calendar draws them in two ways:

  • Calendar.Grid is a scrolling grid of weeks. Use it when the user picks a day or a range.
  • Calendar.Week is 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 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 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

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.

@version โ€• 16.8.0

@see โ€• https://react.dev/reference/react/useState

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.

@version โ€• 16.8.0

@see โ€• https://react.dev/reference/react/useState

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.

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.

@version โ€• 16.8.0

@see โ€• https://react.dev/reference/react/useRef

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.

@version โ€• 16.8.0

@see โ€• https://react.dev/reference/react/useState

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: DateConstructor
new () => 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.

@param โ€• date A numeric value equal to the day of the month.

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.

@param โ€• hours A numeric value equal to the hours value.

@param โ€• min A numeric value equal to the minutes value.

@param โ€• sec A numeric value equal to the seconds value.

@param โ€• ms A numeric value equal to the milliseconds value.

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.

@version โ€• 16.8.0

@see โ€• https://react.dev/reference/react/useState

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.

@version โ€• 16.8.0

@see โ€• https://react.dev/reference/react/useRef

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.

@param โ€• callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.

@param โ€• thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.

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.