import type { Data, Variables, VariablesOf } from '@apollo-elements/core/types'; import type { ApolloError, DocumentNode } from '@apollo/client/core'; import type { ApolloMutationElement } from './apollo-mutation.js'; export declare type MutationEventType = ('mutation-completed' | 'mutation-error' | 'will-mutate' | 'will-navigate'); export interface MutationEventDetail> { data?: Data | null; error?: Error | ApolloError | null; variables?: Variables | null; element: ApolloMutationElement; mutation: DocumentNode | null; } export declare class MutationEvent> extends CustomEvent> { type: MutationEventType; detail: MutationEventDetail; constructor(type: MutationEventType, init: CustomEventInit); } /** * Fired when the element is about to mutate. * Useful for setting variables or cancelling the mutation by calling `preventDefault` * Prevent default to prevent mutation. Detail is `{ element: this }` * @typeParam Data Element's Data type * @typeParam Variables Element's Variables type */ export declare class WillMutateEvent> extends MutationEvent { static type: "will-mutate"; type: 'will-mutate'; constructor(element: ApolloMutationElement); } /** * Fired when a mutation completes. * `detail` is the mutation data. * @typeParam Data Element's Data type * @typeParam Variables Element's Variables type */ export declare class MutationCompletedEvent> extends MutationEvent { static type: "mutation-completed"; type: 'mutation-completed'; constructor(element: ApolloMutationElement); } /** * Fired before an with a link trigger mutates. * Cancel the event with `event.preventDefault()` to prevent navigation. * @typeParam Data Element's Data type * @typeParam Variables Element's Variables type */ export declare class WillNavigateEvent> extends MutationEvent { static type: "will-navigate"; type: 'will-navigate'; constructor(element: ApolloMutationElement); } /** * Fired when the mutation rejects. * @typeParam Data Element's Data type * @typeParam Variables Element's Variables type */ export declare class MutationErrorEvent> extends MutationEvent { static type: "mutation-error"; type: 'mutation-error'; constructor(element: ApolloMutationElement); } declare global { interface HTMLElementEventMap { 'will-mutate': WillMutateEvent; 'will-navigate': WillNavigateEvent; 'mutation-completed': MutationCompletedEvent; 'mutation-error': MutationErrorEvent; } }