2023-09-14 01:34:48 +08:00
|
|
|
import React, { createContext, useState } from 'react';
|
2023-11-29 02:31:28 +08:00
|
|
|
import { ExtensibleArea } from '/imports/ui/components/plugins-engine/extensible-areas/types';
|
2024-01-30 01:04:04 +08:00
|
|
|
import { PluginsContextType, UserListGraphqlVariables } from './types';
|
2023-08-16 06:31:11 +08:00
|
|
|
|
|
|
|
export const PluginsContext = createContext<PluginsContextType>({} as PluginsContextType);
|
|
|
|
|
2023-09-14 01:34:48 +08:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
|
|
export const PluginsContextProvider = ({ children, ...props }: any) => {
|
2023-11-29 02:31:28 +08:00
|
|
|
const [pluginsExtensibleAreasAggregatedState, setPluginsExtensibleAreasAggregatedState] = useState<ExtensibleArea>(
|
|
|
|
{} as ExtensibleArea,
|
2023-09-14 01:34:48 +08:00
|
|
|
);
|
|
|
|
const [userListGraphqlVariables, setUserListGraphqlVariables] = useState<UserListGraphqlVariables>(
|
|
|
|
{} as UserListGraphqlVariables,
|
|
|
|
);
|
2024-01-17 01:02:12 +08:00
|
|
|
const [domElementManipulationMessageIds, setDomElementManipulationMessageIds] = useState<string[]>([]);
|
2023-09-14 01:34:48 +08:00
|
|
|
|
2023-08-16 06:31:11 +08:00
|
|
|
return (
|
2023-09-14 01:34:48 +08:00
|
|
|
<PluginsContext.Provider
|
|
|
|
value={{
|
2023-09-05 20:49:55 +08:00
|
|
|
...props,
|
2023-11-29 02:31:28 +08:00
|
|
|
setPluginsExtensibleAreasAggregatedState,
|
|
|
|
pluginsExtensibleAreasAggregatedState,
|
2023-09-05 20:49:55 +08:00
|
|
|
userListGraphqlVariables,
|
|
|
|
setUserListGraphqlVariables,
|
2024-01-17 01:02:12 +08:00
|
|
|
domElementManipulationMessageIds,
|
|
|
|
setDomElementManipulationMessageIds,
|
2023-09-14 01:34:48 +08:00
|
|
|
}}
|
2023-08-16 06:31:11 +08:00
|
|
|
>
|
2023-09-14 01:34:48 +08:00
|
|
|
{children}
|
2023-08-16 06:31:11 +08:00
|
|
|
</PluginsContext.Provider>
|
|
|
|
);
|
|
|
|
};
|