@trackunit/react-core-contexts 1.9.149 → 1.9.155

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
@@ -11,6 +11,7 @@ var graphql = require('graphql');
11
11
  var graphqlSse = require('graphql-sse');
12
12
  var react = require('react');
13
13
  var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
14
+ var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
14
15
  require('@js-temporal/polyfill');
15
16
  var i18nLibraryTranslation = require('@trackunit/i18n-library-translation');
16
17
  var reactComponents = require('@trackunit/react-components');
@@ -236,8 +237,30 @@ const ManagerApolloProvider = ({ children }) => {
236
237
  * This is a provider for the ToastContext.
237
238
  */
238
239
  const ToastProviderIrisApp = ({ children }) => {
239
- const value = react.useMemo(() => ({ addToast: irisAppRuntimeCore.ToastRuntime.addToast, removeToast: irisAppRuntimeCore.ToastRuntime.removeToast }), []);
240
- return jsxRuntime.jsx(reactCoreHooks.ToastProvider, { value: value, children: children });
240
+ const value = react.useMemo(() => ({
241
+ addToast: async (toast) => {
242
+ const response = await irisAppRuntimeCore.ToastRuntime.addToast({
243
+ ...toast,
244
+ primaryAction: toast.primaryAction?.label,
245
+ secondaryAction: toast.secondaryAction?.label,
246
+ link: toast.link?.label,
247
+ });
248
+ switch (response) {
249
+ case "primaryAction":
250
+ toast.primaryAction?.onClick?.();
251
+ break;
252
+ case "secondaryAction":
253
+ toast.secondaryAction?.onClick?.();
254
+ break;
255
+ case "link":
256
+ toast.link?.onClick?.();
257
+ break;
258
+ }
259
+ return response;
260
+ },
261
+ removeToast: irisAppRuntimeCore.ToastRuntime.removeToast,
262
+ }), []);
263
+ return jsxRuntime.jsx(reactCoreContextsApi.ToastProvider, { value: value, children: children });
241
264
  };
242
265
 
243
266
  /**
@@ -258,7 +281,7 @@ const AnalyticsProviderIrisApp = ({ children }) => {
258
281
  void irisAppRuntimeCore.AnalyticsRuntime().setUserProperty(name, value);
259
282
  },
260
283
  }), []);
261
- return jsxRuntime.jsx(reactCoreHooks.AnalyticsContextProvider, { value: contextValue, children: children });
284
+ return jsxRuntime.jsx(reactCoreContextsApi.AnalyticsContextProvider, { value: contextValue, children: children });
262
285
  };
263
286
 
264
287
  /**
@@ -299,7 +322,7 @@ const AssetSortingProviderIrisApp = ({ children }) => {
299
322
  if (!assetSortingState) {
300
323
  return null;
301
324
  }
302
- return jsxRuntime.jsx(reactCoreHooks.AssetSortingProvider, { value: contextValue, children: children });
325
+ return jsxRuntime.jsx(reactCoreContextsApi.AssetSortingProvider, { value: contextValue, children: children });
303
326
  };
304
327
 
305
328
  /**
@@ -307,7 +330,7 @@ const AssetSortingProviderIrisApp = ({ children }) => {
307
330
  */
308
331
  const ConfirmationDialogProviderIrisApp = ({ children }) => {
309
332
  const value = react.useMemo(() => ({ confirm: irisAppRuntimeCore.ConfirmationDialogRuntime.confirm }), []);
310
- return jsxRuntime.jsx(reactCoreHooks.ConfirmationDialogProvider, { value: value, children: children });
333
+ return jsxRuntime.jsx(reactCoreContextsApi.ConfirmationDialogProvider, { value: value, children: children });
311
334
  };
312
335
 
313
336
  /**
@@ -331,7 +354,7 @@ const EnvironmentProviderIrisApp = ({ children }) => {
331
354
  if (!environment) {
332
355
  return null;
333
356
  }
334
- return jsxRuntime.jsx(reactCoreHooks.EnvironmentContextProvider, { value: environment, children: children });
357
+ return jsxRuntime.jsx(reactCoreContextsApi.EnvironmentContextProvider, { value: environment, children: children });
335
358
  };
336
359
 
337
360
  /**
@@ -350,7 +373,7 @@ const ErrorHandlingProviderIrisApp = ({ children, errorHandler }) => {
350
373
  // do nothing
351
374
  },
352
375
  }), []);
353
- return (jsxRuntime.jsx(reactCoreHooks.ErrorHandlingContextProvider, { value: errorHandler || defaultContextValue, children: children }));
376
+ return (jsxRuntime.jsx(reactCoreContextsApi.ErrorHandlingContextProvider, { value: errorHandler || defaultContextValue, children: children }));
354
377
  };
355
378
 
356
379
  /**
@@ -365,7 +388,7 @@ const ExportDataProviderIrisApp = ({ children }) => {
365
388
  exportData,
366
389
  };
367
390
  }, [exportData]);
368
- return jsxRuntime.jsx(reactCoreHooks.ExportDataContext, { value: value, children: children });
391
+ return jsxRuntime.jsx(reactCoreContextsApi.ExportDataContext, { value: value, children: children });
369
392
  };
370
393
 
371
394
  /**
@@ -413,7 +436,7 @@ const FilterBarProviderIrisApp = ({ children }) => {
413
436
  sitesFilterBarValues: sitesFilterBarValues ?? null,
414
437
  isLoading,
415
438
  }), [assetsFilterBarValues, customersFilterBarValues, sitesFilterBarValues, isLoading]);
416
- return jsxRuntime.jsx(reactCoreHooks.FilterBarProvider, { value: filterBarContext, children: children });
439
+ return jsxRuntime.jsx(reactCoreContextsApi.FilterBarProvider, { value: filterBarContext, children: children });
417
440
  };
418
441
 
419
442
  /**
@@ -421,7 +444,7 @@ const FilterBarProviderIrisApp = ({ children }) => {
421
444
  */
422
445
  const ModalDialogContextProviderIrisApp = ({ children }) => {
423
446
  const value = react.useMemo(() => ({ openModal: irisAppRuntimeCore.ModalDialogRuntime.openModal, closeModal: irisAppRuntimeCore.ModalDialogRuntime.closeModal }), []);
424
- return jsxRuntime.jsx(reactCoreHooks.ModalDialogContextProvider, { value: value, children: children });
447
+ return jsxRuntime.jsx(reactCoreContextsApi.ModalDialogContextProvider, { value: value, children: children });
425
448
  };
426
449
 
427
450
  /**
@@ -431,14 +454,14 @@ const NavigationProviderIrisApp = ({ children }) => {
431
454
  const environment = react.useMemo(() => {
432
455
  return irisAppRuntimeCore.NavigationRuntime;
433
456
  }, []);
434
- return jsxRuntime.jsx(reactCoreHooks.NavigationContextProvider, { value: environment, children: children });
457
+ return jsxRuntime.jsx(reactCoreContextsApi.NavigationContextProvider, { value: environment, children: children });
435
458
  };
436
459
 
437
460
  /**
438
461
  * This is a provider for the OemBrandingContext.
439
462
  */
440
463
  const OemBrandingContextProviderIrisApp = ({ children }) => {
441
- return jsxRuntime.jsx(reactCoreHooks.OemBrandingContextProvider, { value: irisAppRuntimeCore.OemBrandingRuntime, children: children });
464
+ return jsxRuntime.jsx(reactCoreContextsApi.OemBrandingContextProvider, { value: irisAppRuntimeCore.OemBrandingRuntime, children: children });
442
465
  };
443
466
 
444
467
  /**
@@ -484,7 +507,7 @@ const TimeRangeProviderIrisApp = ({ children }) => {
484
507
  if (!timeRangeContext) {
485
508
  return null;
486
509
  }
487
- return jsxRuntime.jsx(reactCoreHooks.TimeRangeProvider, { value: timeRangeContext, children: children });
510
+ return jsxRuntime.jsx(reactCoreContextsApi.TimeRangeProvider, { value: timeRangeContext, children: children });
488
511
  };
489
512
 
490
513
  /**
@@ -514,7 +537,7 @@ const TokenProviderIrisApp = ({ children }) => {
514
537
  if (!tokenContext) {
515
538
  return null;
516
539
  }
517
- return jsxRuntime.jsx(reactCoreHooks.TokenProvider, { value: tokenContext, children: children });
540
+ return jsxRuntime.jsx(reactCoreContextsApi.TokenProvider, { value: tokenContext, children: children });
518
541
  };
519
542
 
520
543
  /**
@@ -540,7 +563,7 @@ const CurrentUserProviderIrisApp = ({ children }) => {
540
563
  if (!currentuserContext) {
541
564
  return null;
542
565
  }
543
- return jsxRuntime.jsx(reactCoreHooks.CurrentUserProvider, { value: currentuserContext, children: children });
566
+ return jsxRuntime.jsx(reactCoreContextsApi.CurrentUserProvider, { value: currentuserContext, children: children });
544
567
  };
545
568
 
546
569
  /**
@@ -578,7 +601,7 @@ const CurrentUserPreferenceProviderIrisApp = ({ children }) => {
578
601
  if (!language) {
579
602
  return null;
580
603
  }
581
- return (jsxRuntime.jsx(reactCoreHooks.CurrentUserPreferenceProvider, { value: { language, systemOfMeasurement, timeZonePreference }, children: children }));
604
+ return (jsxRuntime.jsx(reactCoreContextsApi.CurrentUserPreferenceProvider, { value: { language, systemOfMeasurement, timeZonePreference }, children: children }));
582
605
  };
583
606
 
584
607
  /**
@@ -594,7 +617,7 @@ const UserSubscriptionProviderIrisApp = ({ children }) => {
594
617
  if (!subscription) {
595
618
  return null;
596
619
  }
597
- return jsxRuntime.jsx(reactCoreHooks.UserSubscriptionProvider, { value: subscription, children: children });
620
+ return jsxRuntime.jsx(reactCoreContextsApi.UserSubscriptionProvider, { value: subscription, children: children });
598
621
  };
599
622
 
600
623
  /**
@@ -620,7 +643,7 @@ const WidgetConfigProviderIrisApp = ({ children }) => {
620
643
  setLoadingState: irisAppRuntimeCore.WidgetConfigRuntime.setLoadingState,
621
644
  pollInterval,
622
645
  }), [pollInterval]);
623
- return jsxRuntime.jsx(reactCoreHooks.WidgetConfigProvider, { value: widgetConfigContextValue, children: children });
646
+ return jsxRuntime.jsx(reactCoreContextsApi.WidgetConfigProvider, { value: widgetConfigContextValue, children: children });
624
647
  };
625
648
 
626
649
  /**
package/index.esm.js CHANGED
@@ -4,11 +4,12 @@ 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
6
  import { getMainDefinition, Observable } from '@apollo/client/utilities';
7
- import { useEnvironment, useToken, useErrorHandler, ToastProvider, AnalyticsContextProvider, AssetSortingProvider, ConfirmationDialogProvider, EnvironmentContextProvider, ErrorHandlingContextProvider, ExportDataContext, FilterBarProvider, ModalDialogContextProvider, NavigationContextProvider, OemBrandingContextProvider, TimeRangeProvider, TokenProvider, CurrentUserProvider, CurrentUserPreferenceProvider, UserSubscriptionProvider, WidgetConfigProvider } from '@trackunit/react-core-hooks';
7
+ import { useEnvironment, useToken, useErrorHandler } from '@trackunit/react-core-hooks';
8
8
  import { print } from 'graphql';
9
9
  import { createClient } from 'graphql-sse';
10
10
  import { useState, useMemo, useEffect, useCallback, Suspense } from 'react';
11
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';
12
13
  import '@js-temporal/polyfill';
13
14
  import { registerTranslations, initializeTranslationsForApp } from '@trackunit/i18n-library-translation';
14
15
  import { Spinner } from '@trackunit/react-components';
@@ -234,7 +235,29 @@ const ManagerApolloProvider = ({ children }) => {
234
235
  * This is a provider for the ToastContext.
235
236
  */
236
237
  const ToastProviderIrisApp = ({ children }) => {
237
- const value = useMemo(() => ({ addToast: ToastRuntime.addToast, removeToast: ToastRuntime.removeToast }), []);
238
+ const value = useMemo(() => ({
239
+ addToast: async (toast) => {
240
+ const response = await ToastRuntime.addToast({
241
+ ...toast,
242
+ primaryAction: toast.primaryAction?.label,
243
+ secondaryAction: toast.secondaryAction?.label,
244
+ link: toast.link?.label,
245
+ });
246
+ switch (response) {
247
+ case "primaryAction":
248
+ toast.primaryAction?.onClick?.();
249
+ break;
250
+ case "secondaryAction":
251
+ toast.secondaryAction?.onClick?.();
252
+ break;
253
+ case "link":
254
+ toast.link?.onClick?.();
255
+ break;
256
+ }
257
+ return response;
258
+ },
259
+ removeToast: ToastRuntime.removeToast,
260
+ }), []);
238
261
  return jsx(ToastProvider, { value: value, children: children });
239
262
  };
240
263
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-contexts",
3
- "version": "1.9.149",
3
+ "version": "1.9.155",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -9,15 +9,16 @@
9
9
  "dependencies": {
10
10
  "@apollo/client": "3.13.8",
11
11
  "react": "19.0.0",
12
- "@trackunit/iris-app-api": "1.10.0",
13
- "@trackunit/iris-app-runtime-core-api": "1.7.117",
14
- "@trackunit/react-core-hooks": "1.7.121",
15
- "@trackunit/i18n-library-translation": "1.7.128",
16
- "@trackunit/react-components": "1.10.83",
17
- "@trackunit/iris-app-runtime-core": "1.8.117",
12
+ "@trackunit/iris-app-api": "1.10.6",
13
+ "@trackunit/iris-app-runtime-core-api": "1.7.123",
14
+ "@trackunit/react-core-hooks": "1.7.127",
15
+ "@trackunit/i18n-library-translation": "1.7.134",
16
+ "@trackunit/react-components": "1.10.89",
17
+ "@trackunit/iris-app-runtime-core": "1.8.123",
18
18
  "graphql": "^16.10.0",
19
19
  "graphql-sse": "^2.5.4",
20
- "@js-temporal/polyfill": "^0.5.1"
20
+ "@js-temporal/polyfill": "^0.5.1",
21
+ "@trackunit/react-core-contexts-api": "1.8.82"
21
22
  },
22
23
  "module": "./index.esm.js",
23
24
  "main": "./index.cjs.js",