@trackunit/react-core-contexts 0.4.259 → 0.4.261

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
@@ -30970,6 +30970,34 @@ const CurrentUserProviderIrisApp = ({ children }) => {
30970
30970
  return jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, { value: currentuserContext, children: children });
30971
30971
  };
30972
30972
 
30973
+ /**
30974
+ * This is a provider for the CurrentUserContext.
30975
+ */
30976
+ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
30977
+ const [language, setLanguage] = React.useState(null);
30978
+ const [systemOfMeasurement, setSystemOfMeasurement] = React.useState(null);
30979
+ const [timeZonePreference, setTimeZonePreference] = React.useState(null);
30980
+ React.useEffect(() => {
30981
+ irisAppRuntimeCore.CurrentUserPreferenceRuntime.getCurrentUserLanguage()
30982
+ .catch(() => null)
30983
+ .then(setLanguage);
30984
+ }, [setLanguage]);
30985
+ React.useEffect(() => {
30986
+ irisAppRuntimeCore.CurrentUserPreferenceRuntime.getCurrentUserSystemOfMeasurement()
30987
+ .catch(() => null)
30988
+ .then(setSystemOfMeasurement);
30989
+ }, []);
30990
+ React.useEffect(() => {
30991
+ irisAppRuntimeCore.CurrentUserPreferenceRuntime.getCurrentUserTimeZonePreference()
30992
+ .catch(() => null)
30993
+ .then(setTimeZonePreference);
30994
+ }, []);
30995
+ if (!language) {
30996
+ return null;
30997
+ }
30998
+ return (jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: { language, systemOfMeasurement, timeZonePreference }, children: children }));
30999
+ };
31000
+
30973
31001
  /**
30974
31002
  * This is a provider for the UserSubscriptionContext.
30975
31003
  */
@@ -30994,7 +31022,7 @@ const TrackunitProviders = ({ translations, children }) => {
30994
31022
  i18nLibraryTranslation.registerTranslations(translations); // Register the apps translations if passed.
30995
31023
  }
30996
31024
  i18nLibraryTranslation.initializeTranslationsForApp(); // Initialize all registered translations
30997
- return (jsxRuntime.jsx(EnvironmentProviderIrisApp, { children: jsxRuntime.jsx(TokenProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserProviderIrisApp, { children: jsxRuntime.jsx(UserSubscriptionProviderIrisApp, { children: jsxRuntime.jsx(AnalyticsProviderIrisApp, { children: jsxRuntime.jsx(GlobalSelectionProviderIrisApp, { children: jsxRuntime.jsx(OemBrandingContextProviderIrisApp, { children: jsxRuntime.jsx(AssetSortingProviderIrisApp, { children: jsxRuntime.jsx(ManagerApolloProvider, { children: jsxRuntime.jsx(ToastProviderIrisApp, { children: jsxRuntime.jsx(FilterBarProviderIrisApp, { children: jsxRuntime.jsx(React__namespace.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered" }), children: jsxRuntime.jsx(TrackunitRouterIrisApp, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }));
31025
+ return (jsxRuntime.jsx(EnvironmentProviderIrisApp, { children: jsxRuntime.jsx(TokenProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserPreferenceProviderIrisApp, { children: jsxRuntime.jsx(CurrentUserProviderIrisApp, { children: jsxRuntime.jsx(UserSubscriptionProviderIrisApp, { children: jsxRuntime.jsx(AnalyticsProviderIrisApp, { children: jsxRuntime.jsx(GlobalSelectionProviderIrisApp, { children: jsxRuntime.jsx(OemBrandingContextProviderIrisApp, { children: jsxRuntime.jsx(AssetSortingProviderIrisApp, { children: jsxRuntime.jsx(ManagerApolloProvider, { children: jsxRuntime.jsx(ToastProviderIrisApp, { children: jsxRuntime.jsx(FilterBarProviderIrisApp, { children: jsxRuntime.jsx(React__namespace.Suspense, { fallback: jsxRuntime.jsx(reactComponents.Spinner, { centering: "centered" }), children: jsxRuntime.jsx(TrackunitRouterIrisApp, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }));
30998
31026
  };
30999
31027
 
31000
31028
  exports.ManagerApolloProvider = ManagerApolloProvider;
package/index.esm.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import { jsx, Fragment } from 'react/jsx-runtime';
2
2
  import { Source, visit as visit$1, BREAK, Kind, print, isSelectionNode, parse } from 'graphql';
3
- import { useEnvironment, useCurrentUser, useToken, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, EnvironmentContextProvider, FilterBarProvider, GlobalSelectionProvider, OemBrandingContextProvider, TokenProvider, useURLSynchronization, CurrentUserProvider, UserSubscriptionProvider } from '@trackunit/react-core-hooks';
3
+ import { useEnvironment, useCurrentUser, useToken, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, EnvironmentContextProvider, FilterBarProvider, GlobalSelectionProvider, OemBrandingContextProvider, TokenProvider, useURLSynchronization, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider } from '@trackunit/react-core-hooks';
4
4
  import * as React from 'react';
5
5
  import { useMemo, useEffect, useState } from 'react';
6
- import { ToastRuntime, AnalyticsContextRuntime, setupHostConnector, AssetSortingRuntime, EnvironmentRuntime, FilterBarRuntime, GlobalSelectionRuntime, OemBrandingContextRuntime, TokenRuntime, CurrentUserRuntime, UserSubscriptionRuntime } from '@trackunit/iris-app-runtime-core';
6
+ import { ToastRuntime, AnalyticsContextRuntime, setupHostConnector, AssetSortingRuntime, EnvironmentRuntime, FilterBarRuntime, GlobalSelectionRuntime, OemBrandingContextRuntime, TokenRuntime, CurrentUserRuntime, CurrentUserPreferenceRuntime, UserSubscriptionRuntime } from '@trackunit/iris-app-runtime-core';
7
7
  import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
8
8
  import { Spinner } from '@trackunit/react-components';
9
9
  import { BrowserRouter } from 'react-router-dom';
@@ -30947,6 +30947,34 @@ const CurrentUserProviderIrisApp = ({ children }) => {
30947
30947
  return jsx(CurrentUserProvider, { value: currentuserContext, children: children });
30948
30948
  };
30949
30949
 
30950
+ /**
30951
+ * This is a provider for the CurrentUserContext.
30952
+ */
30953
+ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
30954
+ const [language, setLanguage] = useState(null);
30955
+ const [systemOfMeasurement, setSystemOfMeasurement] = useState(null);
30956
+ const [timeZonePreference, setTimeZonePreference] = useState(null);
30957
+ useEffect(() => {
30958
+ CurrentUserPreferenceRuntime.getCurrentUserLanguage()
30959
+ .catch(() => null)
30960
+ .then(setLanguage);
30961
+ }, [setLanguage]);
30962
+ useEffect(() => {
30963
+ CurrentUserPreferenceRuntime.getCurrentUserSystemOfMeasurement()
30964
+ .catch(() => null)
30965
+ .then(setSystemOfMeasurement);
30966
+ }, []);
30967
+ useEffect(() => {
30968
+ CurrentUserPreferenceRuntime.getCurrentUserTimeZonePreference()
30969
+ .catch(() => null)
30970
+ .then(setTimeZonePreference);
30971
+ }, []);
30972
+ if (!language) {
30973
+ return null;
30974
+ }
30975
+ return (jsx(CurrentUserPreferenceProvider, { value: { language, systemOfMeasurement, timeZonePreference }, children: children }));
30976
+ };
30977
+
30950
30978
  /**
30951
30979
  * This is a provider for the UserSubscriptionContext.
30952
30980
  */
@@ -30971,7 +30999,7 @@ const TrackunitProviders = ({ translations, children }) => {
30971
30999
  registerTranslations(translations); // Register the apps translations if passed.
30972
31000
  }
30973
31001
  initializeTranslationsForApp(); // Initialize all registered translations
30974
- return (jsx(EnvironmentProviderIrisApp, { children: jsx(TokenProviderIrisApp, { children: jsx(CurrentUserProviderIrisApp, { children: jsx(UserSubscriptionProviderIrisApp, { children: jsx(AnalyticsProviderIrisApp, { children: jsx(GlobalSelectionProviderIrisApp, { children: jsx(OemBrandingContextProviderIrisApp, { children: jsx(AssetSortingProviderIrisApp, { children: jsx(ManagerApolloProvider, { children: jsx(ToastProviderIrisApp, { children: jsx(FilterBarProviderIrisApp, { children: jsx(React.Suspense, { fallback: jsx(Spinner, { centering: "centered" }), children: jsx(TrackunitRouterIrisApp, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }));
31002
+ return (jsx(EnvironmentProviderIrisApp, { children: jsx(TokenProviderIrisApp, { children: jsx(CurrentUserPreferenceProviderIrisApp, { children: jsx(CurrentUserProviderIrisApp, { children: jsx(UserSubscriptionProviderIrisApp, { children: jsx(AnalyticsProviderIrisApp, { children: jsx(GlobalSelectionProviderIrisApp, { children: jsx(OemBrandingContextProviderIrisApp, { children: jsx(AssetSortingProviderIrisApp, { children: jsx(ManagerApolloProvider, { children: jsx(ToastProviderIrisApp, { children: jsx(FilterBarProviderIrisApp, { children: jsx(React.Suspense, { fallback: jsx(Spinner, { centering: "centered" }), children: jsx(TrackunitRouterIrisApp, { children: children }) }) }) }) }) }) }) }) }) }) }) }) }) }));
30975
31003
  };
30976
31004
 
30977
31005
  export { ManagerApolloProvider, ToastProviderIrisApp, TrackunitProviders };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "0.4.259",
3
+ "version": "0.4.261",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -12,11 +12,11 @@
12
12
  "@js-temporal/polyfill": "0.4.3",
13
13
  "@sentry/browser": "7.57.0",
14
14
  "@trackunit/i18n-library-translation": "0.0.79",
15
- "@trackunit/iris-app-runtime-core": "0.3.77",
15
+ "@trackunit/iris-app-runtime-core": "0.3.79",
16
16
  "@trackunit/react-components": "0.1.161",
17
- "@trackunit/react-core-contexts-api": "0.2.58",
18
- "@trackunit/react-core-contexts-test": "0.1.109",
19
- "@trackunit/react-core-hooks": "0.2.95",
17
+ "@trackunit/react-core-contexts-api": "0.2.59",
18
+ "@trackunit/react-core-contexts-test": "0.1.111",
19
+ "@trackunit/react-core-hooks": "0.2.97",
20
20
  "apollo-upload-client": "17.0.0",
21
21
  "react": "18.2.0",
22
22
  "react-router-dom": "6.11.2"
@@ -0,0 +1,11 @@
1
+ import { IUserPreferencesContext } from "@trackunit/react-core-contexts-api";
2
+ import { ReactNode } from "react";
3
+ export type UserPreferencesContextIrisApp = Pick<IUserPreferencesContext, "language" | "timeZonePreference" | "timeZonePreference">;
4
+ interface IProps {
5
+ children: ReactNode;
6
+ }
7
+ /**
8
+ * This is a provider for the CurrentUserContext.
9
+ */
10
+ export declare const CurrentUserPreferenceProviderIrisApp: ({ children }: IProps) => JSX.Element | null;
11
+ export {};