/** * @license * Copyright 2023 Aglyn LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import { ContextType } from 'react'; import { type InjectedContextConsumerProps } from '../hocs/create-hoc-with-context-consumer'; export type QueueId = string; export type Queues = QueueId[]; export type TupledDequeue = [QueueId, DequeueLoading]; export type QueueResponse = ConditionalNonDist; export interface LoadingHelper { enqueue(asTuple?: T): QueueResponse; dequeue(queueId?: QueueId): void; dequeueAll(): void; check(queueId?: QueueId): boolean; } export type EnqueueLoading = LoadingHelper['enqueue']; export type DequeueLoading = LoadingHelper['dequeue']; export type DequeueAllLoading = LoadingHelper['dequeueAll']; export type CheckLoading = LoadingHelper['check']; export type EnqueueResponse = { (): LoadingManager; readonly queueId: QueueId; }; export declare class LoaderItem { readonly id: QueueId; private readonly manager; loading(): boolean; constructor(id: QueueId, manager: LoadingManager); dequeue(): this; } export declare class LoadingManager { queues: Map; get loading(): boolean; constructor(); check: (id: QueueId) => boolean; static createQueueId(): string; enqueue(): LoaderItem; dequeue(id: QueueId): this; } export declare const LoadingContext: import("react").Context<{ loading: boolean; queueLoading: EnqueueLoading; dequeueLoading: DequeueLoading; dequeueAllLoading: DequeueAllLoading; checkLoading: CheckLoading; }>; export type LoadingContextType = ContextType; export declare const LoadingConsumer: import("react").Consumer<{ loading: boolean; queueLoading: EnqueueLoading; dequeueLoading: DequeueLoading; dequeueAllLoading: DequeueAllLoading; checkLoading: CheckLoading; }>; export declare const useLoading: () => { loading: boolean; queueLoading: EnqueueLoading; dequeueLoading: DequeueLoading; dequeueAllLoading: DequeueAllLoading; checkLoading: CheckLoading; }; export interface LoadingProviderProps { children?: JSX.Children; } export declare function LoadingProviderComponent(props: LoadingProviderProps): import("react").JSX.Element; declare const WithN = "_contextLoading"; type WithN = typeof WithN; export type LoadingConsumer = typeof LoadingConsumer; export type WithInjectedLoadingContextProps = InjectedContextConsumerProps; /** * App loading context HOC prop injector */ export declare const withInjectedLoadingContext: import("../..").WithContextConsumer<{ loading: boolean; queueLoading: EnqueueLoading; dequeueLoading: DequeueLoading; dequeueAllLoading: DequeueAllLoading; checkLoading: CheckLoading; }, "_contextLoading">; export {};