@trackunit/react-core-contexts 1.19.14 → 1.20.0
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 +27 -1
- package/index.esm.js +29 -3
- package/package.json +7 -7
- package/src/geolocation/GeolocationProviderIrisApp.d.ts +11 -0
package/index.cjs.js
CHANGED
|
@@ -464,6 +464,32 @@ const FilterBarProviderIrisApp = ({ children }) => {
|
|
|
464
464
|
return jsxRuntime.jsx(reactCoreContextsApi.FilterBarProvider, { value: filterBarContext, children: children });
|
|
465
465
|
};
|
|
466
466
|
|
|
467
|
+
/**
|
|
468
|
+
* This is a provider for the GeolocationContext.
|
|
469
|
+
* Its for useGeolocation hook to get the current position of the user through the host
|
|
470
|
+
* such that each iframe only prompts for permission once.
|
|
471
|
+
*/
|
|
472
|
+
const GeolocationProviderIrisApp = ({ children }) => {
|
|
473
|
+
const [position, setPosition] = react.useState(null);
|
|
474
|
+
react.useEffect(() => {
|
|
475
|
+
void irisAppRuntimeCore.GeolocationRuntime.getGeolocationPosition(false).then(pos => {
|
|
476
|
+
if (pos !== null) {
|
|
477
|
+
setPosition(pos);
|
|
478
|
+
}
|
|
479
|
+
});
|
|
480
|
+
}, []);
|
|
481
|
+
const getPosition = react.useCallback(async (options) => {
|
|
482
|
+
const prompt = options?.prompt !== false;
|
|
483
|
+
const pos = await irisAppRuntimeCore.GeolocationRuntime.getGeolocationPosition(prompt);
|
|
484
|
+
if (pos !== null) {
|
|
485
|
+
setPosition(pos);
|
|
486
|
+
}
|
|
487
|
+
return pos;
|
|
488
|
+
}, []);
|
|
489
|
+
const value = react.useMemo(() => ({ position, getPosition }), [position, getPosition]);
|
|
490
|
+
return jsxRuntime.jsx(reactCoreContextsApi.GeolocationProvider, { value: value, children: children });
|
|
491
|
+
};
|
|
492
|
+
|
|
467
493
|
/**
|
|
468
494
|
* This is a provider for the Modal Dialog Context.
|
|
469
495
|
*/
|
|
@@ -717,7 +743,7 @@ const TrackunitProviders = ({ translations, children, errorHandler }) => {
|
|
|
717
743
|
i18nLibraryTranslation.registerTranslations(translations); // Register the apps translations if passed.
|
|
718
744
|
}
|
|
719
745
|
i18nLibraryTranslation.initializeTranslationsForApp(); // Initialize all registered translations
|
|
720
|
-
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(ExportDataProviderIrisApp, { children: jsxRuntime.jsx(TimeRangeProviderIrisApp, { children: jsxRuntime.jsx(WidgetConfigProviderIrisApp, { children: jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
746
|
+
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(ExportDataProviderIrisApp, { children: jsxRuntime.jsx(TimeRangeProviderIrisApp, { children: jsxRuntime.jsx(WidgetConfigProviderIrisApp, { children: jsxRuntime.jsx(GeolocationProviderIrisApp, { children: jsxRuntime.jsx(react.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
721
747
|
};
|
|
722
748
|
|
|
723
749
|
exports.ManagerApolloProvider = ManagerApolloProvider;
|
package/index.esm.js
CHANGED
|
@@ -8,8 +8,8 @@ import { print } from 'graphql';
|
|
|
8
8
|
import { createClient } from 'graphql-sse';
|
|
9
9
|
import { useState, useMemo, useEffect, useCallback, useReducer, Suspense } from 'react';
|
|
10
10
|
import { onError } from '@apollo/client/link/error';
|
|
11
|
-
import { ToastRuntime, AnalyticsRuntime, setupHostConnector, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, ExportDataRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingRuntime, ThemeCssRuntime, TimeRangeRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime, WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
|
|
12
|
-
import { ToastProvider, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, ExportDataContext, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-contexts-api';
|
|
11
|
+
import { ToastRuntime, AnalyticsRuntime, setupHostConnector, AssetSortingRuntime, ConfirmationDialogRuntime, EnvironmentRuntime, ExportDataRuntime, AssetsFilterBarRuntime, CustomersFilterBarRuntime, SitesFilterBarRuntime, GeolocationRuntime, ModalDialogRuntime, NavigationRuntime, OemBrandingRuntime, ThemeCssRuntime, TimeRangeRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime, WidgetConfigRuntime } from '@trackunit/iris-app-runtime-core';
|
|
12
|
+
import { ToastProvider, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, ExportDataContext, FilterBarProvider, GeolocationProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-contexts-api';
|
|
13
13
|
import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
|
|
14
14
|
import { Spinner } from '@trackunit/react-components';
|
|
15
15
|
import { SortOrder, AssetSortByProperty } from '@trackunit/iris-app-runtime-core-api';
|
|
@@ -462,6 +462,32 @@ const FilterBarProviderIrisApp = ({ children }) => {
|
|
|
462
462
|
return jsx(FilterBarProvider, { value: filterBarContext, children: children });
|
|
463
463
|
};
|
|
464
464
|
|
|
465
|
+
/**
|
|
466
|
+
* This is a provider for the GeolocationContext.
|
|
467
|
+
* Its for useGeolocation hook to get the current position of the user through the host
|
|
468
|
+
* such that each iframe only prompts for permission once.
|
|
469
|
+
*/
|
|
470
|
+
const GeolocationProviderIrisApp = ({ children }) => {
|
|
471
|
+
const [position, setPosition] = useState(null);
|
|
472
|
+
useEffect(() => {
|
|
473
|
+
void GeolocationRuntime.getGeolocationPosition(false).then(pos => {
|
|
474
|
+
if (pos !== null) {
|
|
475
|
+
setPosition(pos);
|
|
476
|
+
}
|
|
477
|
+
});
|
|
478
|
+
}, []);
|
|
479
|
+
const getPosition = useCallback(async (options) => {
|
|
480
|
+
const prompt = options?.prompt !== false;
|
|
481
|
+
const pos = await GeolocationRuntime.getGeolocationPosition(prompt);
|
|
482
|
+
if (pos !== null) {
|
|
483
|
+
setPosition(pos);
|
|
484
|
+
}
|
|
485
|
+
return pos;
|
|
486
|
+
}, []);
|
|
487
|
+
const value = useMemo(() => ({ position, getPosition }), [position, getPosition]);
|
|
488
|
+
return jsx(GeolocationProvider, { value: value, children: children });
|
|
489
|
+
};
|
|
490
|
+
|
|
465
491
|
/**
|
|
466
492
|
* This is a provider for the Modal Dialog Context.
|
|
467
493
|
*/
|
|
@@ -715,7 +741,7 @@ const TrackunitProviders = ({ translations, children, errorHandler }) => {
|
|
|
715
741
|
registerTranslations(translations); // Register the apps translations if passed.
|
|
716
742
|
}
|
|
717
743
|
initializeTranslationsForApp(); // Initialize all registered translations
|
|
718
|
-
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(ExportDataProviderIrisApp, { children: jsx(TimeRangeProviderIrisApp, { children: jsx(WidgetConfigProviderIrisApp, { children: jsx(Suspense, { fallback: jsx(Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
744
|
+
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(ExportDataProviderIrisApp, { children: jsx(TimeRangeProviderIrisApp, { children: jsx(WidgetConfigProviderIrisApp, { children: jsx(GeolocationProviderIrisApp, { children: jsx(Suspense, { fallback: jsx(Spinner, { centering: "centered", "data-testid": "trackunit-providers" }), children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }) }));
|
|
719
745
|
};
|
|
720
746
|
|
|
721
747
|
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
|
+
"version": "1.20.0",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"engines": {
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"@apollo/client": "3.13.8",
|
|
11
11
|
"react": "19.0.0",
|
|
12
12
|
"@trackunit/iris-app-api": "1.15.7",
|
|
13
|
-
"@trackunit/iris-app-runtime-core-api": "1.
|
|
14
|
-
"@trackunit/react-core-hooks": "1.
|
|
15
|
-
"@trackunit/i18n-library-translation": "1.
|
|
16
|
-
"@trackunit/react-components": "1.
|
|
17
|
-
"@trackunit/iris-app-runtime-core": "1.
|
|
13
|
+
"@trackunit/iris-app-runtime-core-api": "1.13.0",
|
|
14
|
+
"@trackunit/react-core-hooks": "1.13.0",
|
|
15
|
+
"@trackunit/i18n-library-translation": "1.14.0",
|
|
16
|
+
"@trackunit/react-components": "1.19.0",
|
|
17
|
+
"@trackunit/iris-app-runtime-core": "1.14.0",
|
|
18
18
|
"graphql": "^16.10.0",
|
|
19
19
|
"graphql-sse": "^2.5.4",
|
|
20
|
-
"@trackunit/react-core-contexts-api": "1.
|
|
20
|
+
"@trackunit/react-core-contexts-api": "1.14.0"
|
|
21
21
|
},
|
|
22
22
|
"module": "./index.esm.js",
|
|
23
23
|
"main": "./index.cjs.js",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
type GeolocationProviderIrisAppProps = Readonly<{
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
}>;
|
|
5
|
+
/**
|
|
6
|
+
* This is a provider for the GeolocationContext.
|
|
7
|
+
* Its for useGeolocation hook to get the current position of the user through the host
|
|
8
|
+
* such that each iframe only prompts for permission once.
|
|
9
|
+
*/
|
|
10
|
+
export declare const GeolocationProviderIrisApp: ({ children }: GeolocationProviderIrisAppProps) => ReactNode;
|
|
11
|
+
export {};
|