import type { SchedulerEventId, SchedulerEventSide, SchedulerResourceId } from '@mui/x-scheduler-internals/models'; import type { SchedulerChangeEventDetails } from '@mui/x-scheduler-internals/internals'; export type SchedulerDependencyId = string | number; declare module '@mui/x-scheduler-internals/models' { interface SchedulerSelectionTypeLookup { dependency: SchedulerDependencyId; } } /** * The other PDM types (`StartToStart`, `FinishToFinish`, `StartToFinish`) will widen this union when implemented. */ export type SchedulerDependencyType = 'FinishToStart'; /** * A dependency between two events, referencing them by id. * For `"FinishToStart"`, `source` is the predecessor and `target` the successor. */ export interface SchedulerDependency { /** * The unique identifier of the dependency. */ id: SchedulerDependencyId; /** * The id of the event at the source end of the dependency. */ source: SchedulerEventId; /** * The id of the event at the target end of the dependency. */ target: SchedulerEventId; /** * The type of the dependency. */ type: SchedulerDependencyType; } /** * Properties to create a dependency with `addDependency()`. * The id is generated by the store. */ export type SchedulerDependencyCreationProperties = Omit; /** * State of the pending create-dependency drag gesture, from a terminal to a target event. */ export interface SchedulerDependencyCreation { /** * The id of the event the gesture started from (the predecessor). */ sourceEventId: SchedulerEventId; /** * The key of the occurrence the gesture started from. * Anchors the provisional arrow on the row appearance the user grabbed. */ sourceOccurrenceKey: string; /** * The resource of the row appearance the gesture started from. The occurrence key * alone does not identify an appearance: an event assigned to several resources * repeats the same occurrence (and key) on each of its rows. */ sourceResourceId: SchedulerResourceId; /** * The edge of the source event the gesture started from. */ sourceSide: SchedulerEventSide; /** * The id of the event currently hovered as a valid drop target, if any. */ targetEventId: SchedulerEventId | null; /** * The key of the hovered occurrence, so the provisional arrow snaps to the row * appearance under the pointer. */ targetOccurrenceKey: string | null; /** * The resource of the hovered row appearance, qualifying `targetOccurrenceKey` the * same way `sourceResourceId` qualifies the source. */ targetResourceId: SchedulerResourceId | null; } export type SchedulerDependencyEventRejectionReason = 'recurringEvent' | 'unknownEvent' | 'readOnlyEvent'; export type SchedulerDependencyRejectionReason = SchedulerDependencyEventRejectionReason | 'duplicateDependency'; export type SchedulerAddDependencyResult = { status: 'added'; id: SchedulerDependencyId; } | { status: 'rejected'; reason: SchedulerDependencyEventRejectionReason; eventId: SchedulerEventId; } | { status: 'rejected'; reason: 'duplicateDependency'; dependencyId: SchedulerDependencyId; }; /** * State slice holding the dependencies collection. */ export interface SchedulerDependenciesState { /** * The dependencies as provided to `props.dependencies`. */ dependencyModelList: readonly SchedulerDependency[]; /** * A lookup to get a dependency from its id. */ dependencyModelLookup: Map; } /** * Parameters to control the dependencies collection. */ export interface SchedulerDependenciesParameters { /** * The dependencies between events. Providing a value — even an empty array — * enables the dependencies feature (terminals, arrows, selection); omitting it * disables the feature entirely. */ dependencies?: readonly SchedulerDependency[]; /** * Event handler called when the dependencies change. */ onDependenciesChange?: (value: SchedulerDependency[], eventDetails: SchedulerChangeEventDetails) => void; }