API: primitives (@fragiola/calendar-react)
ResizeHandle
A handle that resizes its event from its start or its end with resize(), inside a segment or a timed event, placed at the edge by you.
ResizeHandle resizes the event it is in, from one edge, with the resize() feature from
@fragiola/calendar-react/resize. Put it inside a Calendar.Segment (a day-grid event: its days)
or a Calendar.TimeEvent (a timed event: its times). It renders a div with data-edge; where it
sits on the event, its size and its cursor are yours.
Behaviour
- A press and drag on it moves the edge: by days in a day grid, by
snapDurationsteps in a time grid; the event's other edge stays. A resize to nothing (end <= start) is refused, as are the edges the edit rules forbid (durationEditable, orstartEditablefor the start edge). - The drag previews through
DragPreviewand runs oneevent.resizeon release (thedropengine event,onEventDrop, withkind: "resize"). - It is
aria-hidden: from the keyboard, Shift + arrows resize a grabbed event (Shift + Up/Down in a time grid, Shift + Left/Right in a day grid). - Without
resize()in the model's features it renders nothing and warns once.
Usage
import { Calendar, type TimeSegment } from "@fragiola/calendar-react";
import { ResizeHandle } from "@fragiola/calendar-react/resize";
export function ResizableEvent(props: { segment: TimeSegment }) {
return (
<Calendar.TimeEvent segment={props.segment} className="event">
<ResizeHandle edge="start" className="handle handle-top" />
<span className="event-title">{props.segment.eventId}</span>
<ResizeHandle edge="end" className="handle handle-bottom" />
</Calendar.TimeEvent>
);
}.handle {
position: absolute;
inset-inline: 0;
block-size: 6px;
cursor: ns-resize;
}
.handle-top {
inset-block-start: 0;
}
.handle-bottom {
inset-block-end: 0;
}See Resizing events.
Attributes
| attribute | value |
|---|---|
data-calendar-part | data-calendar-part="resize-handle" |
data-edge | start or end |
data-occurrence-id | its event's occurrence |
aria-hidden | true |
Props
In Vue: the same props (in kebab-case in a template), and slots in place of children; see
Vue primitives.
In Angular: a directive on your element, the props as its inputs, templates in place of
children; see Angular primitives.
ResizeHandleProps takes the common props and any div
attribute, and:
| prop | type | description |
|---|---|---|
edge | "start" or "end" | the edge it moves: the event's start or its end |
children | ReactNode | what it shows (a grip) |
State
ResizeHandleState:
| field | type | description |
|---|---|---|
edge | "start" or "end" | the edge it moves |