Fragiola

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 snapDuration steps 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, or startEditable for the start edge).
  • The drag previews through DragPreview and runs one event.resize on release (the drop engine event, onEventDrop, with kind: "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

attributevalue
data-calendar-partdata-calendar-part="resize-handle"
data-edgestart or end
data-occurrence-idits event's occurrence
aria-hiddentrue

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:

proptypedescription
edge"start" or "end"the edge it moves: the event's start or its end
childrenReactNodewhat it shows (a grip)

State

ResizeHandleState:

fieldtypedescription
edge"start" or "end"the edge it moves