import * as React from 'react'; import { draftService } from '../apps'; import { PriorityFn } from '../apps/draft-service'; /** The value returned from `useDrafts()` hook */ export type DraftsContextValue = { /** `true` if drafts are currently loading for the first time. */ isLoading: boolean; /** The incomplete submissions that were saved for later */ drafts: draftService.LocalFormSubmissionDraft[]; /** `true` drafts are syncing with other devices */ isSyncing: boolean; /** * The date when the sync process last completed successfully, will be `null` * until it has completed the first time. */ lastSyncTime: Date | null; /** A function to trigger syncing of the drafts */ syncDrafts: ({ abortSignal, priorityFn, }: { abortSignal: AbortSignal | undefined; priorityFn: PriorityFn | undefined; }) => Promise; /** An Error object if syncing drafts fails */ syncError: Error | null; /** A function to clear Error object from syncing drafts */ clearSyncError: () => void; /** A function to remove a draft */ deleteDraft: (formSubmissionDraftId: string) => Promise; }; /** * React Component that provides the context for the `useDrafts()` hook to be * used by components further down your component tree. **It should only be * included in your component tree once and ideally at the root of the * application.** * * #### Example * * ```jsx * import * as React from 'react' * import { DraftsContextProvider, useDrafts } from '@oneblink/apps-react' * * function Component() { * const draftsContext = useDrafts() * // use drafts here * } * * function App() { * return ( * * * * ) * } * * const root = document.getElementById('root') * if (root) { * ReactDOM.render(, root) * } * ``` * * @param props * @returns * @group Components */ export declare function DraftsContextProvider({ /** The identifier for the forms app associated with the user's drafts */ formsAppId, /** * `true` if drafts are enabled, otherwise `false`. Can be used for account * tier validation. */ isDraftsEnabled, /** Your application components */ children, }: { formsAppId: number; isDraftsEnabled: boolean; children: React.ReactNode; }): import("react/jsx-runtime").JSX.Element; /** * React hook to get the context value for Drafts. Will throw an Error if used * outside of the `` component. * * @returns * @group Hooks */ export default function useDrafts(): DraftsContextValue;