@trackunit/react-core-contexts 1.3.89 → 1.3.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js
CHANGED
|
@@ -483,6 +483,34 @@ const ThemeCssProviderIrisApp = ({ children }) => {
|
|
|
483
483
|
return jsxRuntime.jsx(jsxRuntime.Fragment, { children: children });
|
|
484
484
|
};
|
|
485
485
|
|
|
486
|
+
/**
|
|
487
|
+
* This is a provider for the FilterBarContext.
|
|
488
|
+
*/
|
|
489
|
+
const TimeRangeProviderIrisApp = ({ children }) => {
|
|
490
|
+
const [timeRangeContext, setTimeRangeContext] = React.useState();
|
|
491
|
+
React.useEffect(() => {
|
|
492
|
+
irisAppRuntimeCore.TimeRangeRuntime.getTimeRange()
|
|
493
|
+
.catch(() => null)
|
|
494
|
+
.then(timeRange => {
|
|
495
|
+
setTimeRangeContext(prev => ({
|
|
496
|
+
timeRange: timeRange,
|
|
497
|
+
}));
|
|
498
|
+
});
|
|
499
|
+
}, []);
|
|
500
|
+
const methods = React.useMemo(() => ({
|
|
501
|
+
onTimeRangeChanged: (timeRange) => {
|
|
502
|
+
setTimeRangeContext(prev => ({
|
|
503
|
+
timeRange: timeRange || null,
|
|
504
|
+
}));
|
|
505
|
+
},
|
|
506
|
+
}), []);
|
|
507
|
+
useSubscribeToHostChanges(methods);
|
|
508
|
+
if (!timeRangeContext) {
|
|
509
|
+
return null;
|
|
510
|
+
}
|
|
511
|
+
return jsxRuntime.jsx(reactCoreHooks.TimeRangeProvider, { value: timeRangeContext, children: children });
|
|
512
|
+
};
|
|
513
|
+
|
|
486
514
|
/**
|
|
487
515
|
* This is a provider for the ToastContext.
|
|
488
516
|
*/
|
|
@@ -609,7 +637,7 @@ const TrackunitProviders = ({ translations, children, errorHandler }) => {
|
|
|
609
637
|
i18nLibraryTranslation.registerTranslations(translations); // Register the apps translations if passed.
|
|
610
638
|
}
|
|
611
639
|
i18nLibraryTranslation.initializeTranslationsForApp(); // Initialize all registered translations
|
|
612
|
-
return (jsxRuntime.jsx(EnvironmentProviderIrisApp, { children: jsxRuntime.jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsxRuntime.jsx(ThemeCssProviderIrisApp, { children: jsxRuntime.jsx(TokenProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserPreferenceProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserProviderIrisApp, { children: jsxRuntime.jsx(UserSubscriptionProviderIrisApp, { children: jsxRuntime.jsx(AnalyticsProviderIrisApp, { children: jsxRuntime.jsx(OemBrandingContextProviderIrisApp, { children: jsxRuntime.jsx(AssetSortingProviderIrisApp, { children: jsxRuntime.jsx(ManagerApolloProvider, { children: jsxRuntime.jsx(NavigationProviderIrisApp, { children: jsxRuntime.jsx(ToastProviderIrisApp, { children: jsxRuntime.jsx(ModalDialogContextProviderIrisApp, { children: jsxRuntime.jsx(ConfirmationDialogProviderIrisApp, { children: jsxRuntime.jsx(FilterBarProviderIrisApp, { children: jsxRuntime.jsx(
|
|
640
|
+
return (jsxRuntime.jsx(EnvironmentProviderIrisApp, { children: jsxRuntime.jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsxRuntime.jsx(ThemeCssProviderIrisApp, { children: jsxRuntime.jsx(TokenProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserPreferenceProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserProviderIrisApp, { children: jsxRuntime.jsx(UserSubscriptionProviderIrisApp, { children: jsxRuntime.jsx(AnalyticsProviderIrisApp, { children: jsxRuntime.jsx(OemBrandingContextProviderIrisApp, { children: jsxRuntime.jsx(AssetSortingProviderIrisApp, { children: jsxRuntime.jsx(ManagerApolloProvider, { children: jsxRuntime.jsx(NavigationProviderIrisApp, { children: jsxRuntime.jsx(ToastProviderIrisApp, { children: jsxRuntime.jsx(ModalDialogContextProviderIrisApp, { children: jsxRuntime.jsx(ConfirmationDialogProviderIrisApp, { children: jsxRuntime.jsx(FilterBarProviderIrisApp, { children: jsxRuntime.jsx(TimeRangeProviderIrisApp, { children: jsxRuntime.jsx(React.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", dataTestId: "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
613
641
|
};
|
|
614
642
|
|
|
615
643
|
exports.ManagerApolloProvider = ManagerApolloProvider;
|
package/index.esm.js
CHANGED
|
@@ -3,13 +3,13 @@ import { ApolloProvider, createHttpLink, ApolloClient, InMemoryCache, from, spli
|
|
|
3
3
|
import { setContext } from '@apollo/client/link/context';
|
|
4
4
|
import { onError } from '@apollo/client/link/error';
|
|
5
5
|
import { removeTypenameFromVariables } from '@apollo/client/link/remove-typename';
|
|
6
|
-
import { useEnvironment, useToken, useErrorHandler, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, ToastProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider } from '@trackunit/react-core-hooks';
|
|
6
|
+
import { useEnvironment, useToken, useErrorHandler, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, ToastProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider } from '@trackunit/react-core-hooks';
|
|
7
7
|
import * as React from 'react';
|
|
8
|
-
import { useState, useMemo, useEffect } from 'react';
|
|
8
|
+
import { useState, useMemo, useEffect, Suspense } from 'react';
|
|
9
9
|
import '@js-temporal/polyfill';
|
|
10
10
|
import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
|
|
11
11
|
import { Spinner } from '@trackunit/react-components';
|
|
12
|
-
import { AnalyticsContextRuntime, setupHostConnector, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, FilterBarRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingContextRuntime, ThemeCssRuntime, ToastRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime } from '@trackunit/iris-app-runtime-core';
|
|
12
|
+
import { AnalyticsContextRuntime, setupHostConnector, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, FilterBarRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingContextRuntime, ThemeCssRuntime, TimeRangeRuntime, ToastRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime } from '@trackunit/iris-app-runtime-core';
|
|
13
13
|
|
|
14
14
|
const createApolloClient = ({ graphqlManagerUrl, graphqlPublicUrl, graphqlInternalUrl, graphqlReportUrl, isDev, tracingHeaders, firstToken, errorHandler, }) => {
|
|
15
15
|
let token;
|
|
@@ -463,6 +463,34 @@ const ThemeCssProviderIrisApp = ({ children }) => {
|
|
|
463
463
|
return jsx(Fragment, { children: children });
|
|
464
464
|
};
|
|
465
465
|
|
|
466
|
+
/**
|
|
467
|
+
* This is a provider for the FilterBarContext.
|
|
468
|
+
*/
|
|
469
|
+
const TimeRangeProviderIrisApp = ({ children }) => {
|
|
470
|
+
const [timeRangeContext, setTimeRangeContext] = useState();
|
|
471
|
+
useEffect(() => {
|
|
472
|
+
TimeRangeRuntime.getTimeRange()
|
|
473
|
+
.catch(() => null)
|
|
474
|
+
.then(timeRange => {
|
|
475
|
+
setTimeRangeContext(prev => ({
|
|
476
|
+
timeRange: timeRange,
|
|
477
|
+
}));
|
|
478
|
+
});
|
|
479
|
+
}, []);
|
|
480
|
+
const methods = useMemo(() => ({
|
|
481
|
+
onTimeRangeChanged: (timeRange) => {
|
|
482
|
+
setTimeRangeContext(prev => ({
|
|
483
|
+
timeRange: timeRange || null,
|
|
484
|
+
}));
|
|
485
|
+
},
|
|
486
|
+
}), []);
|
|
487
|
+
useSubscribeToHostChanges(methods);
|
|
488
|
+
if (!timeRangeContext) {
|
|
489
|
+
return null;
|
|
490
|
+
}
|
|
491
|
+
return jsx(TimeRangeProvider, { value: timeRangeContext, children: children });
|
|
492
|
+
};
|
|
493
|
+
|
|
466
494
|
/**
|
|
467
495
|
* This is a provider for the ToastContext.
|
|
468
496
|
*/
|
|
@@ -589,7 +617,7 @@ const TrackunitProviders = ({ translations, children, errorHandler }) => {
|
|
|
589
617
|
registerTranslations(translations); // Register the apps translations if passed.
|
|
590
618
|
}
|
|
591
619
|
initializeTranslationsForApp(); // Initialize all registered translations
|
|
592
|
-
return (jsx(EnvironmentProviderIrisApp, { children: jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsx(ThemeCssProviderIrisApp, { children: jsx(TokenProviderIrisApp, { children: jsx(CurrentUserPreferenceProviderIrisApp, { children: jsx(CurrentUserProviderIrisApp, { children: jsx(UserSubscriptionProviderIrisApp, { children: jsx(AnalyticsProviderIrisApp, { children: jsx(OemBrandingContextProviderIrisApp, { children: jsx(AssetSortingProviderIrisApp, { children: jsx(ManagerApolloProvider, { children: jsx(NavigationProviderIrisApp, { children: jsx(ToastProviderIrisApp, { children: jsx(ModalDialogContextProviderIrisApp, { children: jsx(ConfirmationDialogProviderIrisApp, { children: jsx(FilterBarProviderIrisApp, { children: jsx(
|
|
620
|
+
return (jsx(EnvironmentProviderIrisApp, { children: jsx(ErrorHandlingProviderIrisApp, { errorHandler: errorHandler, children: jsx(ThemeCssProviderIrisApp, { children: jsx(TokenProviderIrisApp, { children: jsx(CurrentUserPreferenceProviderIrisApp, { children: jsx(CurrentUserProviderIrisApp, { children: jsx(UserSubscriptionProviderIrisApp, { children: jsx(AnalyticsProviderIrisApp, { children: jsx(OemBrandingContextProviderIrisApp, { children: jsx(AssetSortingProviderIrisApp, { children: jsx(ManagerApolloProvider, { children: jsx(NavigationProviderIrisApp, { children: jsx(ToastProviderIrisApp, { children: jsx(ModalDialogContextProviderIrisApp, { children: jsx(ConfirmationDialogProviderIrisApp, { children: jsx(FilterBarProviderIrisApp, { children: jsx(TimeRangeProviderIrisApp, { children: jsx(Suspense, { fallback: jsx(Spinner, { centering: "centered", dataTestId: "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
593
621
|
};
|
|
594
622
|
|
|
595
623
|
export { ManagerApolloProvider, ToastProviderIrisApp, TrackunitProviders };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-core-contexts",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.94",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
"react": "19.0.0",
|
|
12
12
|
"@js-temporal/polyfill": "^0.4.4",
|
|
13
13
|
"jest-fetch-mock": "^3.0.3",
|
|
14
|
-
"@trackunit/iris-app-api": "1.3.
|
|
15
|
-
"@trackunit/react-core-contexts-api": "1.4.
|
|
16
|
-
"@trackunit/react-core-hooks": "1.3.
|
|
17
|
-
"@trackunit/i18n-library-translation": "1.3.
|
|
18
|
-
"@trackunit/react-components": "1.4.
|
|
19
|
-
"@trackunit/iris-app-runtime-core": "1.4.
|
|
14
|
+
"@trackunit/iris-app-api": "1.3.71",
|
|
15
|
+
"@trackunit/react-core-contexts-api": "1.4.71",
|
|
16
|
+
"@trackunit/react-core-hooks": "1.3.73",
|
|
17
|
+
"@trackunit/i18n-library-translation": "1.3.75",
|
|
18
|
+
"@trackunit/react-components": "1.4.84",
|
|
19
|
+
"@trackunit/iris-app-runtime-core": "1.4.72"
|
|
20
20
|
},
|
|
21
21
|
"module": "./index.esm.js",
|
|
22
22
|
"main": "./index.cjs.js",
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import { TranslationResource } from "@trackunit/i18n-library-translation";
|
|
3
3
|
import { ErrorHandlingContextValue } from "@trackunit/react-core-contexts-api";
|
|
4
|
-
import
|
|
4
|
+
import { ReactNode } from "react";
|
|
5
5
|
export interface TrackunitProvidersProps {
|
|
6
6
|
/** A translation resource for the App extensions to be registered before initialization */
|
|
7
7
|
translations?: TranslationResource<string>;
|
|
8
8
|
errorHandler?: ErrorHandlingContextValue;
|
|
9
|
-
children:
|
|
9
|
+
children: ReactNode;
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* This is a provider for the TrackunitDataProviders.
|