@trackunit/react-core-hooks 0.2.223-alpha-2936c016d71.0 → 0.2.225

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
@@ -1,14 +1,11 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  var React = require('react');
6
4
  var jsxRuntime = require('react/jsx-runtime');
7
5
  var irisAppRuntimeCore = require('@trackunit/iris-app-runtime-core');
8
6
  var sharedUtils = require('@trackunit/shared-utils');
9
7
 
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
8
+ function _interopNamespaceDefault(e) {
12
9
  var n = Object.create(null);
13
10
  if (e) {
14
11
  Object.keys(e).forEach(function (k) {
@@ -21,11 +18,11 @@ function _interopNamespace(e) {
21
18
  }
22
19
  });
23
20
  }
24
- n["default"] = e;
21
+ n.default = e;
25
22
  return Object.freeze(n);
26
23
  }
27
24
 
28
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
25
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
29
26
 
30
27
  const AnalyticsContext = React.createContext(null);
31
28
  const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
@@ -34,7 +31,7 @@ const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
34
31
  *
35
32
  * @example
36
33
  * import { useAnalytics, useEnvironment } from "@trackunit/react-core-hooks";
37
- * const { logPageView, logEvent } = useAnalytics(AllEvents);
34
+ * const { logPageView, logEvent } = useAnalytics(SharedEvents);
38
35
  *
39
36
  * // log page view event
40
37
  * useEffect(() => {
@@ -45,7 +42,7 @@ const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
45
42
  * logEvent("Login", { loginPage: "New Manager" });
46
43
  * @see {@link IAnalyticsContext}
47
44
  */
48
- const useAnalytics = (type) => {
45
+ const useAnalytics = (events) => {
49
46
  const context = React.useContext(AnalyticsContext);
50
47
  if (!context) {
51
48
  throw new Error("useAnalytics must be used within an AnalyticsProvider");
@@ -98,7 +95,7 @@ const ConfirmationDialogContext = React__namespace.createContext(null);
98
95
  /**
99
96
  * This is a provider for the ConfirmationDialogContext.
100
97
  */
101
- const ConfirmationDialogProvider = (props) => (jsxRuntime.jsx(ConfirmationDialogContext.Provider, Object.assign({}, props)));
98
+ const ConfirmationDialogProvider = (props) => (jsxRuntime.jsx(ConfirmationDialogContext.Provider, { ...props }));
102
99
  /**
103
100
  * This is a hook to use the ConfirmationDialogContext.
104
101
  */
@@ -115,7 +112,7 @@ const EnvironmentContext = React.createContext(null);
115
112
  * This is a provider for the EnvironmentContext.
116
113
  */
117
114
  const EnvironmentContextProvider = (props) => {
118
- return jsxRuntime.jsx(EnvironmentContext.Provider, Object.assign({}, props));
115
+ return jsxRuntime.jsx(EnvironmentContext.Provider, { ...props });
119
116
  };
120
117
  /**
121
118
  * This is a hook to use the EnvironmentContext.
@@ -158,54 +155,24 @@ const useErrorHandler = () => {
158
155
  return context;
159
156
  };
160
157
 
161
- /******************************************************************************
162
- Copyright (c) Microsoft Corporation.
163
-
164
- Permission to use, copy, modify, and/or distribute this software for any
165
- purpose with or without fee is hereby granted.
166
-
167
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
168
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
169
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
170
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
171
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
172
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
173
- PERFORMANCE OF THIS SOFTWARE.
174
- ***************************************************************************** */
175
-
176
- function __awaiter(thisArg, _arguments, P, generator) {
177
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
178
- return new (P || (P = Promise))(function (resolve, reject) {
179
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
180
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
181
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
182
- step((generator = generator.apply(thisArg, _arguments || [])).next());
183
- });
184
- }
185
-
186
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
187
- var e = new Error(message);
188
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
189
- };
190
-
191
158
  /**
192
159
  * Fetch any url as a blob and return a blob url.
193
160
  * This is used to get and display logos and images related to Iris Apps.
194
161
  */
195
- const fetchAssetBlobUrl = (fullUrl, headers) => __awaiter(void 0, void 0, void 0, function* () {
162
+ const fetchAssetBlobUrl = async (fullUrl, headers) => {
196
163
  try {
197
- const result = yield fetch(fullUrl, {
164
+ const result = await fetch(fullUrl, {
198
165
  method: "GET",
199
166
  headers,
200
167
  });
201
- const blob = yield result.blob();
168
+ const blob = await result.blob();
202
169
  const assetUrl = URL.createObjectURL(blob);
203
170
  return assetUrl;
204
171
  }
205
172
  catch (e) {
206
173
  return null;
207
174
  }
208
- });
175
+ };
209
176
 
210
177
  const FilterBarContext = React__namespace.createContext(null);
211
178
  /**
@@ -232,7 +199,7 @@ const useFilterBarContext = () => {
232
199
  /**
233
200
  * This is a provider for the FilterBarContext.
234
201
  */
235
- const FilterBarProvider = (props) => jsxRuntime.jsx(FilterBarContext.Provider, Object.assign({}, props));
202
+ const FilterBarProvider = (props) => jsxRuntime.jsx(FilterBarContext.Provider, { ...props });
236
203
 
237
204
  const TokenContext = React__namespace.createContext(null);
238
205
  /**
@@ -255,7 +222,7 @@ const useToken = () => {
255
222
  * This is a provider for the TokenContext.
256
223
  */
257
224
  const TokenProvider = (props) => {
258
- return jsxRuntime.jsx(TokenContext.Provider, Object.assign({}, props));
225
+ return jsxRuntime.jsx(TokenContext.Provider, { ...props });
259
226
  };
260
227
 
261
228
  const base64ToBlob = (base64, contentType = "") => {
@@ -342,7 +309,12 @@ const useIrisAppImage = () => {
342
309
  const { featureBranchQueryParam } = useFeatureBranchQueryString();
343
310
  const { token } = useToken();
344
311
  // Add Auth headers to all fetch requests
345
- const headers = React.useMemo(() => (Object.assign(Object.assign({}, tracingHeaders), { "commit-number": `${tracingHeaders["commit-number"]}`, "Content-Type": "application/json", Authorization: `Bearer ${token}` })), [token, tracingHeaders]);
312
+ const headers = React.useMemo(() => ({
313
+ ...tracingHeaders,
314
+ "commit-number": `${tracingHeaders["commit-number"]}`,
315
+ "Content-Type": "application/json",
316
+ Authorization: `Bearer ${token}`,
317
+ }), [token, tracingHeaders]);
346
318
  /**
347
319
  * Returns the URL to the Iris App SDK server for the given Iris App ID and version.
348
320
  * If the APP is served from localhost or a Feature Branch, the URL will be part of the App Entry.
@@ -357,14 +329,14 @@ const useIrisAppImage = () => {
357
329
  * If the APP is served from localhost or a Feature Branch, the URLs will be part of the App Entry.
358
330
  * If the url does not exist in the App Entry, use the getIrisAppUrl function to get the URL.
359
331
  */
360
- const getAppImage = React.useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ irisAppUrl, logoPath }) {
332
+ const getAppImage = React.useCallback(async ({ irisAppUrl, logoPath }) => {
361
333
  if (!logoPath) {
362
334
  return null;
363
335
  }
364
336
  const logoFetchUrl = `${irisAppUrl}${IRIS_APP_ASSET_PATH}${logoPath}${featureBranchQueryParam}`;
365
- const logoImageUrl = yield fetchAssetBlobUrl(logoFetchUrl, headers);
337
+ const logoImageUrl = await fetchAssetBlobUrl(logoFetchUrl, headers);
366
338
  return logoImageUrl;
367
- }), [featureBranchQueryParam, headers]);
339
+ }, [featureBranchQueryParam, headers]);
368
340
  return {
369
341
  getAppUrl,
370
342
  getAppImage,
@@ -394,14 +366,14 @@ const useOemBrandingContext = () => {
394
366
  * This is a provider for the IOemBrandingContext.
395
367
  */
396
368
  const OemBrandingContextProvider = (props) => {
397
- return jsxRuntime.jsx(OemBrandingContext.Provider, Object.assign({}, props));
369
+ return jsxRuntime.jsx(OemBrandingContext.Provider, { ...props });
398
370
  };
399
371
 
400
372
  const ModalDialogContext = React__namespace.createContext(null);
401
373
  /**
402
374
  * This is a provider for the ModalDialogContext.
403
375
  */
404
- const ModalDialogContextProvider = (props) => (jsxRuntime.jsx(ModalDialogContext.Provider, Object.assign({}, props)));
376
+ const ModalDialogContextProvider = (props) => (jsxRuntime.jsx(ModalDialogContext.Provider, { ...props }));
405
377
  /**
406
378
  * This is a hook to use the useModalDialogContext.
407
379
  */
@@ -418,7 +390,7 @@ const NavigationContext = React.createContext(null);
418
390
  * This is a provider for the NavigationContext.
419
391
  */
420
392
  const NavigationContextProvider = (props) => {
421
- return jsxRuntime.jsx(NavigationContext.Provider, Object.assign({}, props));
393
+ return jsxRuntime.jsx(NavigationContext.Provider, { ...props });
422
394
  };
423
395
  /**
424
396
  * This is a hook to use the NavigationContext.
@@ -457,13 +429,11 @@ const useHasAccessTo = (options) => {
457
429
  }
458
430
  const [hasAccess, setHasAccess] = React.useState();
459
431
  React.useEffect(() => {
460
- function checkAccess() {
461
- return __awaiter(this, void 0, void 0, function* () {
462
- if (options.assetId) {
463
- const doHaveAccess = yield (context === null || context === void 0 ? void 0 : context.hasAccessTo(options));
464
- setHasAccess(() => doHaveAccess);
465
- }
466
- });
432
+ async function checkAccess() {
433
+ if (options.assetId) {
434
+ const doHaveAccess = await (context === null || context === void 0 ? void 0 : context.hasAccessTo(options));
435
+ setHasAccess(() => doHaveAccess);
436
+ }
467
437
  }
468
438
  checkAccess();
469
439
  }, [context, options]);
@@ -491,10 +461,10 @@ const useAssetRuntime = () => {
491
461
  const [loading, setLoading] = React.useState(true);
492
462
  const [error, setError] = React.useState();
493
463
  React.useEffect(() => {
494
- const getAssetInfo = () => __awaiter(void 0, void 0, void 0, function* () {
464
+ const getAssetInfo = async () => {
495
465
  setLoading(true);
496
466
  try {
497
- const updatedAssetInfo = yield irisAppRuntimeCore.AssetRuntime.getAssetInfo();
467
+ const updatedAssetInfo = await irisAppRuntimeCore.AssetRuntime.getAssetInfo();
498
468
  setLoading(false);
499
469
  setAssetInfo(updatedAssetInfo);
500
470
  }
@@ -502,7 +472,7 @@ const useAssetRuntime = () => {
502
472
  setLoading(false);
503
473
  setError(new Error("Failed to get asset info"));
504
474
  }
505
- });
475
+ };
506
476
  getAssetInfo();
507
477
  }, []);
508
478
  return { assetInfo, loading, error };
@@ -530,10 +500,10 @@ const useCustomerRuntime = () => {
530
500
  const [loading, setLoading] = React.useState(true);
531
501
  const [error, setError] = React.useState();
532
502
  React.useEffect(() => {
533
- const getCustomerInfo = () => __awaiter(void 0, void 0, void 0, function* () {
503
+ const getCustomerInfo = async () => {
534
504
  setLoading(true);
535
505
  try {
536
- const updatedCustomerInfo = yield irisAppRuntimeCore.CustomerRuntime.getCustomerInfo();
506
+ const updatedCustomerInfo = await irisAppRuntimeCore.CustomerRuntime.getCustomerInfo();
537
507
  setLoading(false);
538
508
  setCustomerInfo(updatedCustomerInfo);
539
509
  }
@@ -541,7 +511,7 @@ const useCustomerRuntime = () => {
541
511
  setLoading(false);
542
512
  setError(new Error("Failed to get customer info"));
543
513
  }
544
- });
514
+ };
545
515
  getCustomerInfo();
546
516
  }, []);
547
517
  return { customerInfo, loading, error };
@@ -569,10 +539,10 @@ const useEventRuntime = () => {
569
539
  const [loading, setLoading] = React.useState(true);
570
540
  const [error, setError] = React.useState();
571
541
  React.useEffect(() => {
572
- const getEventInfo = () => __awaiter(void 0, void 0, void 0, function* () {
542
+ const getEventInfo = async () => {
573
543
  setLoading(true);
574
544
  try {
575
- const updatedEventInfo = yield irisAppRuntimeCore.EventRuntime.getEventInfo();
545
+ const updatedEventInfo = await irisAppRuntimeCore.EventRuntime.getEventInfo();
576
546
  setLoading(false);
577
547
  setEventInfo(updatedEventInfo);
578
548
  }
@@ -580,7 +550,7 @@ const useEventRuntime = () => {
580
550
  setLoading(false);
581
551
  setError(new Error("Failed to get event info"));
582
552
  }
583
- });
553
+ };
584
554
  getEventInfo();
585
555
  }, []);
586
556
  return { eventInfo, loading, error };
@@ -607,10 +577,10 @@ const useIrisAppName = () => {
607
577
  const [loading, setLoading] = React.useState(true);
608
578
  const [error, setError] = React.useState();
609
579
  React.useEffect(() => {
610
- const getAppName = () => __awaiter(void 0, void 0, void 0, function* () {
580
+ const getAppName = async () => {
611
581
  setLoading(true);
612
582
  try {
613
- const updatedAppName = yield irisAppRuntimeCore.ParamsRuntime.getAppName();
583
+ const updatedAppName = await irisAppRuntimeCore.ParamsRuntime.getAppName();
614
584
  setLoading(false);
615
585
  setAppName(updatedAppName);
616
586
  }
@@ -618,7 +588,7 @@ const useIrisAppName = () => {
618
588
  setLoading(false);
619
589
  setError(new Error("Failed to get iris app name"));
620
590
  }
621
- });
591
+ };
622
592
  getAppName();
623
593
  }, []);
624
594
  return { appName, loading, error };
@@ -644,11 +614,11 @@ const useIrisAppId = () => {
644
614
  const [loading, setLoading] = React.useState(true);
645
615
  const [error, setError] = React.useState();
646
616
  React.useEffect(() => {
647
- const getAppName = () => __awaiter(void 0, void 0, void 0, function* () {
617
+ const getAppName = async () => {
648
618
  setLoading(true);
649
619
  try {
650
- const updatedAppName = yield irisAppRuntimeCore.ParamsRuntime.getAppName();
651
- const updatedOrgName = yield irisAppRuntimeCore.ParamsRuntime.getOrgName();
620
+ const updatedAppName = await irisAppRuntimeCore.ParamsRuntime.getAppName();
621
+ const updatedOrgName = await irisAppRuntimeCore.ParamsRuntime.getOrgName();
652
622
  setLoading(false);
653
623
  setIrisAppId(`${updatedOrgName}/${updatedAppName}`);
654
624
  }
@@ -656,7 +626,7 @@ const useIrisAppId = () => {
656
626
  setLoading(false);
657
627
  setError(new Error("Failed to get iris app name"));
658
628
  }
659
- });
629
+ };
660
630
  getAppName();
661
631
  }, []);
662
632
  return { irisAppId, loading, error };
@@ -684,10 +654,10 @@ const useSiteRuntime = () => {
684
654
  const [loading, setLoading] = React.useState(true);
685
655
  const [error, setError] = React.useState();
686
656
  React.useEffect(() => {
687
- const getSiteInfo = () => __awaiter(void 0, void 0, void 0, function* () {
657
+ const getSiteInfo = async () => {
688
658
  setLoading(true);
689
659
  try {
690
- const updatedSiteInfo = yield irisAppRuntimeCore.SiteRuntime.getSiteInfo();
660
+ const updatedSiteInfo = await irisAppRuntimeCore.SiteRuntime.getSiteInfo();
691
661
  setLoading(false);
692
662
  setSiteInfo(updatedSiteInfo);
693
663
  }
@@ -695,7 +665,7 @@ const useSiteRuntime = () => {
695
665
  setLoading(false);
696
666
  setError(new Error("Failed to get site info"));
697
667
  }
698
- });
668
+ };
699
669
  getSiteInfo();
700
670
  }, []);
701
671
  return { siteInfo, loading, error };
@@ -706,7 +676,7 @@ const UserSubscriptionContext = React__namespace.createContext(null);
706
676
  * This is a provider for the UserSubscriptionContext.
707
677
  */
708
678
  const UserSubscriptionProvider = (props) => {
709
- return jsxRuntime.jsx(UserSubscriptionContext.Provider, Object.assign({}, props));
679
+ return jsxRuntime.jsx(UserSubscriptionContext.Provider, { ...props });
710
680
  };
711
681
  /**
712
682
  * This is a hook to use the UserSubscriptionContext.
@@ -731,7 +701,7 @@ const ToastContext = React__namespace.createContext(null);
731
701
  /**
732
702
  * This is a provider for the ToastContext.
733
703
  */
734
- const ToastProvider = (props) => jsxRuntime.jsx(ToastContext.Provider, Object.assign({}, props));
704
+ const ToastProvider = (props) => jsxRuntime.jsx(ToastContext.Provider, { ...props });
735
705
  /**
736
706
  * This is a hook to use the ToastContext.
737
707
  *
@@ -782,7 +752,7 @@ const CurrentUserPreferenceContext = React.createContext(null);
782
752
  *
783
753
  */
784
754
  const CurrentUserPreferenceProvider = (props) => {
785
- return jsxRuntime.jsx(CurrentUserPreferenceContext.Provider, Object.assign({}, props));
755
+ return jsxRuntime.jsx(CurrentUserPreferenceContext.Provider, { ...props });
786
756
  };
787
757
  /**
788
758
  * This is a hook providing the Current User language.
@@ -864,7 +834,7 @@ const CurrentUserContext = React.createContext(null);
864
834
  * This is a provider for the CurrentUserContext.
865
835
  */
866
836
  const CurrentUserProvider = (props) => {
867
- return jsxRuntime.jsx(CurrentUserContext.Provider, Object.assign({}, props));
837
+ return jsxRuntime.jsx(CurrentUserContext.Provider, { ...props });
868
838
  };
869
839
  /**
870
840
  * This is a hook providing the CurrentUserContext.
package/index.esm.js CHANGED
@@ -11,7 +11,7 @@ const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
11
11
  *
12
12
  * @example
13
13
  * import { useAnalytics, useEnvironment } from "@trackunit/react-core-hooks";
14
- * const { logPageView, logEvent } = useAnalytics(AllEvents);
14
+ * const { logPageView, logEvent } = useAnalytics(SharedEvents);
15
15
  *
16
16
  * // log page view event
17
17
  * useEffect(() => {
@@ -22,7 +22,7 @@ const AnalyticsContextProvider = AnalyticsContext.Provider; // easy import
22
22
  * logEvent("Login", { loginPage: "New Manager" });
23
23
  * @see {@link IAnalyticsContext}
24
24
  */
25
- const useAnalytics = (type) => {
25
+ const useAnalytics = (events) => {
26
26
  const context = useContext(AnalyticsContext);
27
27
  if (!context) {
28
28
  throw new Error("useAnalytics must be used within an AnalyticsProvider");
@@ -75,7 +75,7 @@ const ConfirmationDialogContext = React.createContext(null);
75
75
  /**
76
76
  * This is a provider for the ConfirmationDialogContext.
77
77
  */
78
- const ConfirmationDialogProvider = (props) => (jsx(ConfirmationDialogContext.Provider, Object.assign({}, props)));
78
+ const ConfirmationDialogProvider = (props) => (jsx(ConfirmationDialogContext.Provider, { ...props }));
79
79
  /**
80
80
  * This is a hook to use the ConfirmationDialogContext.
81
81
  */
@@ -92,7 +92,7 @@ const EnvironmentContext = createContext(null);
92
92
  * This is a provider for the EnvironmentContext.
93
93
  */
94
94
  const EnvironmentContextProvider = (props) => {
95
- return jsx(EnvironmentContext.Provider, Object.assign({}, props));
95
+ return jsx(EnvironmentContext.Provider, { ...props });
96
96
  };
97
97
  /**
98
98
  * This is a hook to use the EnvironmentContext.
@@ -135,54 +135,24 @@ const useErrorHandler = () => {
135
135
  return context;
136
136
  };
137
137
 
138
- /******************************************************************************
139
- Copyright (c) Microsoft Corporation.
140
-
141
- Permission to use, copy, modify, and/or distribute this software for any
142
- purpose with or without fee is hereby granted.
143
-
144
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
145
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
146
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
147
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
148
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
149
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
150
- PERFORMANCE OF THIS SOFTWARE.
151
- ***************************************************************************** */
152
-
153
- function __awaiter(thisArg, _arguments, P, generator) {
154
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
155
- return new (P || (P = Promise))(function (resolve, reject) {
156
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
157
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
158
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
159
- step((generator = generator.apply(thisArg, _arguments || [])).next());
160
- });
161
- }
162
-
163
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
164
- var e = new Error(message);
165
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
166
- };
167
-
168
138
  /**
169
139
  * Fetch any url as a blob and return a blob url.
170
140
  * This is used to get and display logos and images related to Iris Apps.
171
141
  */
172
- const fetchAssetBlobUrl = (fullUrl, headers) => __awaiter(void 0, void 0, void 0, function* () {
142
+ const fetchAssetBlobUrl = async (fullUrl, headers) => {
173
143
  try {
174
- const result = yield fetch(fullUrl, {
144
+ const result = await fetch(fullUrl, {
175
145
  method: "GET",
176
146
  headers,
177
147
  });
178
- const blob = yield result.blob();
148
+ const blob = await result.blob();
179
149
  const assetUrl = URL.createObjectURL(blob);
180
150
  return assetUrl;
181
151
  }
182
152
  catch (e) {
183
153
  return null;
184
154
  }
185
- });
155
+ };
186
156
 
187
157
  const FilterBarContext = React.createContext(null);
188
158
  /**
@@ -209,7 +179,7 @@ const useFilterBarContext = () => {
209
179
  /**
210
180
  * This is a provider for the FilterBarContext.
211
181
  */
212
- const FilterBarProvider = (props) => jsx(FilterBarContext.Provider, Object.assign({}, props));
182
+ const FilterBarProvider = (props) => jsx(FilterBarContext.Provider, { ...props });
213
183
 
214
184
  const TokenContext = React.createContext(null);
215
185
  /**
@@ -232,7 +202,7 @@ const useToken = () => {
232
202
  * This is a provider for the TokenContext.
233
203
  */
234
204
  const TokenProvider = (props) => {
235
- return jsx(TokenContext.Provider, Object.assign({}, props));
205
+ return jsx(TokenContext.Provider, { ...props });
236
206
  };
237
207
 
238
208
  const base64ToBlob = (base64, contentType = "") => {
@@ -319,7 +289,12 @@ const useIrisAppImage = () => {
319
289
  const { featureBranchQueryParam } = useFeatureBranchQueryString();
320
290
  const { token } = useToken();
321
291
  // Add Auth headers to all fetch requests
322
- const headers = useMemo(() => (Object.assign(Object.assign({}, tracingHeaders), { "commit-number": `${tracingHeaders["commit-number"]}`, "Content-Type": "application/json", Authorization: `Bearer ${token}` })), [token, tracingHeaders]);
292
+ const headers = useMemo(() => ({
293
+ ...tracingHeaders,
294
+ "commit-number": `${tracingHeaders["commit-number"]}`,
295
+ "Content-Type": "application/json",
296
+ Authorization: `Bearer ${token}`,
297
+ }), [token, tracingHeaders]);
323
298
  /**
324
299
  * Returns the URL to the Iris App SDK server for the given Iris App ID and version.
325
300
  * If the APP is served from localhost or a Feature Branch, the URL will be part of the App Entry.
@@ -334,14 +309,14 @@ const useIrisAppImage = () => {
334
309
  * If the APP is served from localhost or a Feature Branch, the URLs will be part of the App Entry.
335
310
  * If the url does not exist in the App Entry, use the getIrisAppUrl function to get the URL.
336
311
  */
337
- const getAppImage = useCallback((_a) => __awaiter(void 0, [_a], void 0, function* ({ irisAppUrl, logoPath }) {
312
+ const getAppImage = useCallback(async ({ irisAppUrl, logoPath }) => {
338
313
  if (!logoPath) {
339
314
  return null;
340
315
  }
341
316
  const logoFetchUrl = `${irisAppUrl}${IRIS_APP_ASSET_PATH}${logoPath}${featureBranchQueryParam}`;
342
- const logoImageUrl = yield fetchAssetBlobUrl(logoFetchUrl, headers);
317
+ const logoImageUrl = await fetchAssetBlobUrl(logoFetchUrl, headers);
343
318
  return logoImageUrl;
344
- }), [featureBranchQueryParam, headers]);
319
+ }, [featureBranchQueryParam, headers]);
345
320
  return {
346
321
  getAppUrl,
347
322
  getAppImage,
@@ -371,14 +346,14 @@ const useOemBrandingContext = () => {
371
346
  * This is a provider for the IOemBrandingContext.
372
347
  */
373
348
  const OemBrandingContextProvider = (props) => {
374
- return jsx(OemBrandingContext.Provider, Object.assign({}, props));
349
+ return jsx(OemBrandingContext.Provider, { ...props });
375
350
  };
376
351
 
377
352
  const ModalDialogContext = React.createContext(null);
378
353
  /**
379
354
  * This is a provider for the ModalDialogContext.
380
355
  */
381
- const ModalDialogContextProvider = (props) => (jsx(ModalDialogContext.Provider, Object.assign({}, props)));
356
+ const ModalDialogContextProvider = (props) => (jsx(ModalDialogContext.Provider, { ...props }));
382
357
  /**
383
358
  * This is a hook to use the useModalDialogContext.
384
359
  */
@@ -395,7 +370,7 @@ const NavigationContext = createContext(null);
395
370
  * This is a provider for the NavigationContext.
396
371
  */
397
372
  const NavigationContextProvider = (props) => {
398
- return jsx(NavigationContext.Provider, Object.assign({}, props));
373
+ return jsx(NavigationContext.Provider, { ...props });
399
374
  };
400
375
  /**
401
376
  * This is a hook to use the NavigationContext.
@@ -434,13 +409,11 @@ const useHasAccessTo = (options) => {
434
409
  }
435
410
  const [hasAccess, setHasAccess] = useState();
436
411
  useEffect(() => {
437
- function checkAccess() {
438
- return __awaiter(this, void 0, void 0, function* () {
439
- if (options.assetId) {
440
- const doHaveAccess = yield (context === null || context === void 0 ? void 0 : context.hasAccessTo(options));
441
- setHasAccess(() => doHaveAccess);
442
- }
443
- });
412
+ async function checkAccess() {
413
+ if (options.assetId) {
414
+ const doHaveAccess = await (context === null || context === void 0 ? void 0 : context.hasAccessTo(options));
415
+ setHasAccess(() => doHaveAccess);
416
+ }
444
417
  }
445
418
  checkAccess();
446
419
  }, [context, options]);
@@ -468,10 +441,10 @@ const useAssetRuntime = () => {
468
441
  const [loading, setLoading] = useState(true);
469
442
  const [error, setError] = useState();
470
443
  useEffect(() => {
471
- const getAssetInfo = () => __awaiter(void 0, void 0, void 0, function* () {
444
+ const getAssetInfo = async () => {
472
445
  setLoading(true);
473
446
  try {
474
- const updatedAssetInfo = yield AssetRuntime.getAssetInfo();
447
+ const updatedAssetInfo = await AssetRuntime.getAssetInfo();
475
448
  setLoading(false);
476
449
  setAssetInfo(updatedAssetInfo);
477
450
  }
@@ -479,7 +452,7 @@ const useAssetRuntime = () => {
479
452
  setLoading(false);
480
453
  setError(new Error("Failed to get asset info"));
481
454
  }
482
- });
455
+ };
483
456
  getAssetInfo();
484
457
  }, []);
485
458
  return { assetInfo, loading, error };
@@ -507,10 +480,10 @@ const useCustomerRuntime = () => {
507
480
  const [loading, setLoading] = useState(true);
508
481
  const [error, setError] = useState();
509
482
  useEffect(() => {
510
- const getCustomerInfo = () => __awaiter(void 0, void 0, void 0, function* () {
483
+ const getCustomerInfo = async () => {
511
484
  setLoading(true);
512
485
  try {
513
- const updatedCustomerInfo = yield CustomerRuntime.getCustomerInfo();
486
+ const updatedCustomerInfo = await CustomerRuntime.getCustomerInfo();
514
487
  setLoading(false);
515
488
  setCustomerInfo(updatedCustomerInfo);
516
489
  }
@@ -518,7 +491,7 @@ const useCustomerRuntime = () => {
518
491
  setLoading(false);
519
492
  setError(new Error("Failed to get customer info"));
520
493
  }
521
- });
494
+ };
522
495
  getCustomerInfo();
523
496
  }, []);
524
497
  return { customerInfo, loading, error };
@@ -546,10 +519,10 @@ const useEventRuntime = () => {
546
519
  const [loading, setLoading] = useState(true);
547
520
  const [error, setError] = useState();
548
521
  useEffect(() => {
549
- const getEventInfo = () => __awaiter(void 0, void 0, void 0, function* () {
522
+ const getEventInfo = async () => {
550
523
  setLoading(true);
551
524
  try {
552
- const updatedEventInfo = yield EventRuntime.getEventInfo();
525
+ const updatedEventInfo = await EventRuntime.getEventInfo();
553
526
  setLoading(false);
554
527
  setEventInfo(updatedEventInfo);
555
528
  }
@@ -557,7 +530,7 @@ const useEventRuntime = () => {
557
530
  setLoading(false);
558
531
  setError(new Error("Failed to get event info"));
559
532
  }
560
- });
533
+ };
561
534
  getEventInfo();
562
535
  }, []);
563
536
  return { eventInfo, loading, error };
@@ -584,10 +557,10 @@ const useIrisAppName = () => {
584
557
  const [loading, setLoading] = useState(true);
585
558
  const [error, setError] = useState();
586
559
  useEffect(() => {
587
- const getAppName = () => __awaiter(void 0, void 0, void 0, function* () {
560
+ const getAppName = async () => {
588
561
  setLoading(true);
589
562
  try {
590
- const updatedAppName = yield ParamsRuntime.getAppName();
563
+ const updatedAppName = await ParamsRuntime.getAppName();
591
564
  setLoading(false);
592
565
  setAppName(updatedAppName);
593
566
  }
@@ -595,7 +568,7 @@ const useIrisAppName = () => {
595
568
  setLoading(false);
596
569
  setError(new Error("Failed to get iris app name"));
597
570
  }
598
- });
571
+ };
599
572
  getAppName();
600
573
  }, []);
601
574
  return { appName, loading, error };
@@ -621,11 +594,11 @@ const useIrisAppId = () => {
621
594
  const [loading, setLoading] = useState(true);
622
595
  const [error, setError] = useState();
623
596
  useEffect(() => {
624
- const getAppName = () => __awaiter(void 0, void 0, void 0, function* () {
597
+ const getAppName = async () => {
625
598
  setLoading(true);
626
599
  try {
627
- const updatedAppName = yield ParamsRuntime.getAppName();
628
- const updatedOrgName = yield ParamsRuntime.getOrgName();
600
+ const updatedAppName = await ParamsRuntime.getAppName();
601
+ const updatedOrgName = await ParamsRuntime.getOrgName();
629
602
  setLoading(false);
630
603
  setIrisAppId(`${updatedOrgName}/${updatedAppName}`);
631
604
  }
@@ -633,7 +606,7 @@ const useIrisAppId = () => {
633
606
  setLoading(false);
634
607
  setError(new Error("Failed to get iris app name"));
635
608
  }
636
- });
609
+ };
637
610
  getAppName();
638
611
  }, []);
639
612
  return { irisAppId, loading, error };
@@ -661,10 +634,10 @@ const useSiteRuntime = () => {
661
634
  const [loading, setLoading] = useState(true);
662
635
  const [error, setError] = useState();
663
636
  useEffect(() => {
664
- const getSiteInfo = () => __awaiter(void 0, void 0, void 0, function* () {
637
+ const getSiteInfo = async () => {
665
638
  setLoading(true);
666
639
  try {
667
- const updatedSiteInfo = yield SiteRuntime.getSiteInfo();
640
+ const updatedSiteInfo = await SiteRuntime.getSiteInfo();
668
641
  setLoading(false);
669
642
  setSiteInfo(updatedSiteInfo);
670
643
  }
@@ -672,7 +645,7 @@ const useSiteRuntime = () => {
672
645
  setLoading(false);
673
646
  setError(new Error("Failed to get site info"));
674
647
  }
675
- });
648
+ };
676
649
  getSiteInfo();
677
650
  }, []);
678
651
  return { siteInfo, loading, error };
@@ -683,7 +656,7 @@ const UserSubscriptionContext = React.createContext(null);
683
656
  * This is a provider for the UserSubscriptionContext.
684
657
  */
685
658
  const UserSubscriptionProvider = (props) => {
686
- return jsx(UserSubscriptionContext.Provider, Object.assign({}, props));
659
+ return jsx(UserSubscriptionContext.Provider, { ...props });
687
660
  };
688
661
  /**
689
662
  * This is a hook to use the UserSubscriptionContext.
@@ -708,7 +681,7 @@ const ToastContext = React.createContext(null);
708
681
  /**
709
682
  * This is a provider for the ToastContext.
710
683
  */
711
- const ToastProvider = (props) => jsx(ToastContext.Provider, Object.assign({}, props));
684
+ const ToastProvider = (props) => jsx(ToastContext.Provider, { ...props });
712
685
  /**
713
686
  * This is a hook to use the ToastContext.
714
687
  *
@@ -759,7 +732,7 @@ const CurrentUserPreferenceContext = createContext(null);
759
732
  *
760
733
  */
761
734
  const CurrentUserPreferenceProvider = (props) => {
762
- return jsx(CurrentUserPreferenceContext.Provider, Object.assign({}, props));
735
+ return jsx(CurrentUserPreferenceContext.Provider, { ...props });
763
736
  };
764
737
  /**
765
738
  * This is a hook providing the Current User language.
@@ -841,7 +814,7 @@ const CurrentUserContext = createContext(null);
841
814
  * This is a provider for the CurrentUserContext.
842
815
  */
843
816
  const CurrentUserProvider = (props) => {
844
- return jsx(CurrentUserContext.Provider, Object.assign({}, props));
817
+ return jsx(CurrentUserContext.Provider, { ...props });
845
818
  };
846
819
  /**
847
820
  * This is a hook providing the CurrentUserContext.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trackunit/react-core-hooks",
3
- "version": "0.2.223-alpha-2936c016d71.0",
3
+ "version": "0.2.225",
4
4
  "repository": "https://github.com/Trackunit/manager",
5
5
  "license": "SEE LICENSE IN LICENSE.txt",
6
6
  "engines": {
@@ -8,11 +8,12 @@
8
8
  },
9
9
  "dependencies": {
10
10
  "@trackunit/react-core-contexts-api": "*",
11
- "react": "^18.2.0",
11
+ "react": "18.3.1",
12
12
  "@trackunit/iris-app-runtime-core": "*",
13
13
  "jest-fetch-mock": "^3.0.3",
14
14
  "@trackunit/shared-utils": "*"
15
15
  },
16
16
  "module": "./index.esm.js",
17
- "main": "./index.cjs.js"
18
- }
17
+ "main": "./index.cjs.js",
18
+ "types": "./index.esm.d.ts"
19
+ }
@@ -1,5 +1,4 @@
1
- /// <reference types="react" />
2
- import { BaseEvent, Event, IAnalyticsContext } from "@trackunit/react-core-contexts-api";
1
+ import { BaseEvent, Event, IAnalyticsContext, UnspecifiedEvent } from "@trackunit/react-core-contexts-api";
3
2
  export declare const AnalyticsContext: import("react").Context<IAnalyticsContext<Record<string, never>> | null>;
4
3
  export declare const AnalyticsContextProvider: import("react").Provider<IAnalyticsContext<Record<string, never>> | null>;
5
4
  /**
@@ -7,7 +6,7 @@ export declare const AnalyticsContextProvider: import("react").Provider<IAnalyti
7
6
  *
8
7
  * @example
9
8
  * import { useAnalytics, useEnvironment } from "@trackunit/react-core-hooks";
10
- * const { logPageView, logEvent } = useAnalytics(AllEvents);
9
+ * const { logPageView, logEvent } = useAnalytics(SharedEvents);
11
10
  *
12
11
  * // log page view event
13
12
  * useEffect(() => {
@@ -18,4 +17,4 @@ export declare const AnalyticsContextProvider: import("react").Provider<IAnalyti
18
17
  * logEvent("Login", { loginPage: "New Manager" });
19
18
  * @see {@link IAnalyticsContext}
20
19
  */
21
- export declare const useAnalytics: <T extends Record<string, Event<BaseEvent | import("@trackunit/react-core-contexts-api").AdditionalProperties>> = never>(type?: T) => IAnalyticsContext<T>;
20
+ export declare const useAnalytics: <TEvents extends Record<string, Event<BaseEvent | UnspecifiedEvent>> = never>(events: TEvents) => IAnalyticsContext<TEvents>;
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { AssetSortingContextValue } from "@trackunit/react-core-contexts-api";
3
2
  /**
4
3
  * This is a provider for the AssetSortingContext.
@@ -7,7 +7,7 @@ export interface ConfirmationDialogContextProviderProps {
7
7
  /**
8
8
  * This is a provider for the ConfirmationDialogContext.
9
9
  */
10
- export declare const ConfirmationDialogProvider: (props: ConfirmationDialogContextProviderProps) => JSX.Element;
10
+ export declare const ConfirmationDialogProvider: (props: ConfirmationDialogContextProviderProps) => import("react/jsx-runtime").JSX.Element;
11
11
  /**
12
12
  * This is a hook to use the ConfirmationDialogContext.
13
13
  */
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IEnvironmentContext } from "@trackunit/react-core-contexts-api";
3
2
  interface IProps {
4
3
  value: IEnvironmentContext;
@@ -7,7 +6,7 @@ interface IProps {
7
6
  /**
8
7
  * This is a provider for the EnvironmentContext.
9
8
  */
10
- export declare const EnvironmentContextProvider: (props: IProps) => JSX.Element;
9
+ export declare const EnvironmentContextProvider: (props: IProps) => import("react/jsx-runtime").JSX.Element;
11
10
  /**
12
11
  * This is a hook to use the EnvironmentContext.
13
12
  *
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { ErrorHandlingContextValue } from "@trackunit/react-core-contexts-api";
3
2
  export declare const ErrorHandlingContext: import("react").Context<ErrorHandlingContextValue | null>;
4
3
  export declare const ErrorHandlingContextProvider: import("react").Provider<ErrorHandlingContextValue | null>;
@@ -22,5 +22,5 @@ interface IProps {
22
22
  /**
23
23
  * This is a provider for the FilterBarContext.
24
24
  */
25
- export declare const FilterBarProvider: (props: IProps) => JSX.Element;
25
+ export declare const FilterBarProvider: (props: IProps) => import("react/jsx-runtime").JSX.Element;
26
26
  export {};
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { IOemBrandingContext } from "@trackunit/react-core-contexts-api";
3
2
  /**
4
3
  * This is a hook to use the IOemBrandingContext.
@@ -19,5 +18,5 @@ interface IProps {
19
18
  /**
20
19
  * This is a provider for the IOemBrandingContext.
21
20
  */
22
- export declare const OemBrandingContextProvider: (props: IProps) => JSX.Element;
21
+ export declare const OemBrandingContextProvider: (props: IProps) => import("react/jsx-runtime").JSX.Element;
23
22
  export {};
@@ -7,7 +7,7 @@ export interface ModalDialogProviderProps {
7
7
  /**
8
8
  * This is a provider for the ModalDialogContext.
9
9
  */
10
- export declare const ModalDialogContextProvider: (props: ModalDialogProviderProps) => JSX.Element;
10
+ export declare const ModalDialogContextProvider: (props: ModalDialogProviderProps) => import("react/jsx-runtime").JSX.Element;
11
11
  /**
12
12
  * This is a hook to use the useModalDialogContext.
13
13
  */
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import { HasAccessToOptions, INavigationContext } from "@trackunit/react-core-contexts-api";
3
2
  interface IProps {
4
3
  value: INavigationContext;
@@ -7,7 +6,7 @@ interface IProps {
7
6
  /**
8
7
  * This is a provider for the NavigationContext.
9
8
  */
10
- export declare const NavigationContextProvider: (props: IProps) => JSX.Element;
9
+ export declare const NavigationContextProvider: (props: IProps) => import("react/jsx-runtime").JSX.Element;
11
10
  /**
12
11
  * This is a hook to use the NavigationContext.
13
12
  *
@@ -7,7 +7,7 @@ interface IProps {
7
7
  /**
8
8
  * This is a provider for the UserSubscriptionContext.
9
9
  */
10
- export declare const UserSubscriptionProvider: (props: IProps) => JSX.Element;
10
+ export declare const UserSubscriptionProvider: (props: IProps) => import("react/jsx-runtime").JSX.Element;
11
11
  /**
12
12
  * This is a hook to use the UserSubscriptionContext.
13
13
  *
@@ -7,7 +7,7 @@ export interface ToastContextProviderProps {
7
7
  /**
8
8
  * This is a provider for the ToastContext.
9
9
  */
10
- export declare const ToastProvider: (props: ToastContextProviderProps) => JSX.Element;
10
+ export declare const ToastProvider: (props: ToastContextProviderProps) => import("react/jsx-runtime").JSX.Element;
11
11
  /**
12
12
  * This is a hook to use the ToastContext.
13
13
  *
@@ -17,5 +17,5 @@ interface IProps {
17
17
  /**
18
18
  * This is a provider for the TokenContext.
19
19
  */
20
- export declare const TokenProvider: (props: IProps) => JSX.Element;
20
+ export declare const TokenProvider: (props: IProps) => import("react/jsx-runtime").JSX.Element;
21
21
  export {};
@@ -7,7 +7,7 @@ interface Props {
7
7
  /**
8
8
  *
9
9
  */
10
- export declare const CurrentUserPreferenceProvider: (props: Props) => JSX.Element;
10
+ export declare const CurrentUserPreferenceProvider: (props: Props) => import("react/jsx-runtime").JSX.Element;
11
11
  /**
12
12
  * This is a hook providing the Current User language.
13
13
  *
@@ -7,7 +7,7 @@ interface Props {
7
7
  /**
8
8
  * This is a provider for the CurrentUserContext.
9
9
  */
10
- export declare const CurrentUserProvider: (props: Props) => JSX.Element;
10
+ export declare const CurrentUserProvider: (props: Props) => import("react/jsx-runtime").JSX.Element;
11
11
  /**
12
12
  * This is a hook providing the CurrentUserContext.
13
13
  *