import type { SchedulerEventId } from '@mui/x-scheduler-internals/models'; import type { SchedulerChangeEventDetails } from '@mui/x-scheduler-internals/internals'; export type SchedulerDependencyId = string | number; /** * 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; export type SchedulerDependencyEventRejectionReason = 'recurringEvent' | 'unknownEvent'; 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. * @default [] */ dependencies?: readonly SchedulerDependency[]; /** * Event handler called when the dependencies change. */ onDependenciesChange?: (value: SchedulerDependency[], eventDetails: SchedulerChangeEventDetails) => void; }