@trackunit/react-core-contexts-test 0.1.117 → 0.1.119

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.cjs2.js CHANGED
@@ -1,247 +1,57 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
- var React = require('react');
5
- var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
6
4
  var testUtils = require('react-dom/test-utils');
5
+ var React = require('react');
7
6
  var ReactDOM = require('react-dom');
8
7
  var ReactDOMClient = require('react-dom/client');
9
8
  var require$$0 = require('util');
10
9
  var reactCoreHooks = require('@trackunit/react-core-hooks');
11
10
  var reactRouterDom = require('react-router-dom');
11
+ var reactCoreContextsApi = require('@trackunit/react-core-contexts-api');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
15
15
  function _interopNamespace(e) {
16
- if (e && e.__esModule) return e;
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
25
27
  });
26
- }
27
- });
28
- }
29
- n["default"] = e;
30
- return Object.freeze(n);
28
+ }
29
+ n["default"] = e;
30
+ return Object.freeze(n);
31
31
  }
32
32
 
33
33
  function _mergeNamespaces(n, m) {
34
- m.forEach(function (e) {
35
- e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
36
- if (k !== 'default' && !(k in n)) {
37
- var d = Object.getOwnPropertyDescriptor(e, k);
38
- Object.defineProperty(n, k, d.get ? d : {
39
- enumerable: true,
40
- get: function () { return e[k]; }
34
+ m.forEach(function (e) {
35
+ e && typeof e !== 'string' && !Array.isArray(e) && Object.keys(e).forEach(function (k) {
36
+ if (k !== 'default' && !(k in n)) {
37
+ var d = Object.getOwnPropertyDescriptor(e, k);
38
+ Object.defineProperty(n, k, d.get ? d : {
39
+ enumerable: true,
40
+ get: function () { return e[k]; }
41
+ });
42
+ }
41
43
  });
42
- }
43
44
  });
44
- });
45
- return Object.freeze(n);
45
+ return Object.freeze(n);
46
46
  }
47
47
 
48
- var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
49
- var React__namespace = /*#__PURE__*/_interopNamespace(React);
50
48
  var testUtils__namespace = /*#__PURE__*/_interopNamespace(testUtils);
49
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
50
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
51
51
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
52
52
  var ReactDOMClient__namespace = /*#__PURE__*/_interopNamespace(ReactDOMClient);
53
53
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
54
54
 
55
- /**
56
- * Logs props that have changed.
57
- * Use this for debugging which props force a component to re-render.
58
- * This is a hook version of the class component lifecycle method `componentDidUpdate`.
59
- * ALWAYS wrap in your own object.
60
- *
61
- * @param id optional id to use for logging or it will guess the id from the stack trace
62
- * @param propsToWatch all the props to watch for changes
63
- * @example
64
- * const propsToWatch = { foo: props.foo, bar: props.bar };
65
- * useDebugger({ id: "MyComponent", propsToWatch });
66
- */
67
- const useDebugger = ({ id, propsToWatch, }) => {
68
- const prevPropsRef = React.useRef(propsToWatch);
69
- const uniqueId = React.useMemo(() => {
70
- var _a;
71
- return id || ((_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n")[2].trim()) || "unknown-id";
72
- }, [id]);
73
- React.useEffect(() => {
74
- const changedProps = Object.entries(propsToWatch || {}).reduce((result, [key, value]) => {
75
- if (prevPropsRef.current && prevPropsRef.current[key] !== value) {
76
- result[key + ""] = [prevPropsRef.current[key], value];
77
- }
78
- return result;
79
- }, {});
80
- if (Object.keys(changedProps).length > 0) {
81
- // eslint-disable-next-line no-console
82
- Object.keys(changedProps).forEach(changedProp => {
83
- // eslint-disable-next-line no-console
84
- console.log(`${uniqueId} changed property: ${changedProp}`);
85
- // JSON stringify is used to avoid console.table from logging the object reference
86
- const result = JSON.parse(JSON.stringify(changedProps[changedProp]));
87
- const result0 = result[0];
88
- const result1 = result[1];
89
- result0 &&
90
- Object.keys(result0).forEach(prop => {
91
- result0[prop] = JSON.stringify(result0[prop]);
92
- });
93
- result1 &&
94
- Object.keys(result1).forEach(prop => {
95
- result1[prop] = JSON.stringify(result1[prop]);
96
- });
97
- // eslint-disable-next-line no-console
98
- console.table([result0, result1]);
99
- });
100
- // eslint-disable-next-line no-console
101
- console.dir(changedProps);
102
- }
103
- prevPropsRef.current = propsToWatch;
104
- }, [propsToWatch, uniqueId]);
105
- };
106
- /**
107
- * Debugger component for debugging state changes and re-renders.
108
- *
109
- * This component will log when it is mounted, re-renders or unmounted.
110
- * It will also log when any of its props change.
111
- *
112
- * @param id optional id to use for logging
113
- * @param stop if true, will stop execution and open debugger
114
- * @param logPropsChanges optional object with props to watch for changes
115
- * @param children the children to render
116
- */
117
- const Debugger = ({ id, logPropsChanges, stop, children, }) => {
118
- var _a, _b, _c, _d, _e, _f;
119
- const uniqueId = id ||
120
- (
121
- // @ts-ignore
122
- (_e = (_d = (_c = (_b = (_a = React__default["default"]["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]) === null || _a === void 0 ? void 0 : _a.ReactCurrentOwner) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c._debugOwner) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.name) ||
123
- ((_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2].trim()) ||
124
- "unknown-id";
125
- useDebugger({ id: uniqueId, propsToWatch: logPropsChanges || {} });
126
- // eslint-disable-next-line no-console
127
- console.log(`${uniqueId} Debugger is rendering`);
128
- React.useEffect(() => {
129
- // eslint-disable-next-line no-console
130
- console.log(`${uniqueId} Debugger is mounting`);
131
- return () => {
132
- // eslint-disable-next-line no-console
133
- console.log(`${uniqueId} Debugger is unmounting`);
134
- };
135
- // eslint-disable-next-line react-hooks/exhaustive-deps
136
- }, []);
137
- if (stop === true) {
138
- // eslint-disable-next-line no-debugger
139
- debugger;
140
- }
141
- return jsxRuntime.jsx("div", { className: "Debugger", children: children });
142
- };
143
-
144
- /**
145
- * Do nothing
146
- */
147
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
148
- const doNothing = () => {
149
- /* Do nothing */
150
- };
151
-
152
- const mockAnalyticsContext = {
153
- logEvent: doNothing,
154
- logError: doNothing,
155
- logPageView: doNothing,
156
- setUserProperty: doNothing,
157
- };
158
-
159
- const mockAssetSortingContext = {
160
- setSortBy: doNothing,
161
- sortingState: {
162
- sortBy: reactCoreContextsApi.AssetSortByProperty.Criticality,
163
- order: reactCoreContextsApi.SortOrder.Desc,
164
- },
165
- };
166
-
167
- /**
168
- * Mocks the current user context
169
- *
170
- * @returns {ICurrentUserContext} - Returns the mocked current user context
171
- */
172
- const mockCurrentUserContext = {
173
- userName: "",
174
- userRole: "",
175
- customerId: 12345,
176
- userId: 154312,
177
- tasUserId: "751ea227-f199-4d00-925f-a608312c5e45",
178
- email: "",
179
- name: "",
180
- accountId: "",
181
- assumedUser: null,
182
- jobTitle: "",
183
- isAuthenticated: true,
184
- isVerified: true,
185
- isTrackunitUser: false,
186
- isAssuming: false,
187
- isAccountOwner: true,
188
- subscriptionPackage: "EXPAND_FLEET_OWNER",
189
- };
190
-
191
- const mockEnvironmentContext = {
192
- auth: {
193
- url: "",
194
- clientId: "",
195
- issuer: "",
196
- },
197
- managerClassicUrl: "https://sso.trackunit.com",
198
- googleMapsApiKey: "",
199
- amplitudeApiKey: "",
200
- amplitudeApiEndpoint: "",
201
- graphqlPublicUrl: "",
202
- graphqlManagerUrl: "",
203
- graphqlManagerImageUploadUrl: "",
204
- graphqlReportUrl: "",
205
- buildVersion: "",
206
- commitNumber: 0,
207
- buildDate: "",
208
- irisAppSdkServerUrl: "",
209
- publicUrl: "",
210
- isDev: true,
211
- environment: "",
212
- sentryDsn: "",
213
- sessionId: "",
214
- tracingHeaders: {
215
- "X-TrackunitAppVersion": "",
216
- "session-id": "",
217
- },
218
- trackunitRestApiUrl: "",
219
- hubspotRequestAppAccessFormId: "",
220
- };
221
-
222
- const mockOemBrandingContext = {
223
- getAllBrandingDetails: doNothing,
224
- getOemBranding: doNothing,
225
- getOemImage: doNothing,
226
- };
227
-
228
- const mockToastContext = {
229
- addToast: doNothing,
230
- setIsManifestError: doNothing,
231
- };
232
-
233
- /**
234
- * This is a mock for the UserSubscriptionContext.
235
- *
236
- * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
237
- */
238
- const mockUserSubscriptionContext = {
239
- numberOfDaysWithAccessToHistoricalData: 30,
240
- numberOfDaysWithAccessToHistoricalInsights: 30,
241
- features: [],
242
- packageType: "EXPAND_FLEET_OWNER",
243
- };
244
-
245
55
  /******************************************************************************
246
56
  Copyright (c) Microsoft Corporation.
247
57
 
@@ -2664,11 +2474,11 @@ var _default$2i = format;
2664
2474
  default_1 = build.default = _default$2i;
2665
2475
 
2666
2476
  var index = /*#__PURE__*/_mergeNamespaces({
2667
- __proto__: null,
2668
- get DEFAULT_OPTIONS () { return DEFAULT_OPTIONS_1; },
2669
- format: format_1,
2670
- get plugins () { return plugins_1; },
2671
- get default () { return default_1; }
2477
+ __proto__: null,
2478
+ get DEFAULT_OPTIONS () { return DEFAULT_OPTIONS_1; },
2479
+ format: format_1,
2480
+ get plugins () { return plugins_1; },
2481
+ get default () { return default_1; }
2672
2482
  }, [build]);
2673
2483
 
2674
2484
  /**
@@ -16063,85 +15873,85 @@ const screen = typeof document !== 'undefined' && document.body // eslint-disabl
16063
15873
  }, initialValue);
16064
15874
 
16065
15875
  var dom_esm = /*#__PURE__*/Object.freeze({
16066
- __proto__: null,
16067
- prettyFormat: index,
16068
- buildQueries: buildQueries,
16069
- configure: configure,
16070
- createEvent: createEvent,
16071
- findAllByAltText: findAllByAltText,
16072
- findAllByDisplayValue: findAllByDisplayValue,
16073
- findAllByLabelText: findAllByLabelText,
16074
- findAllByPlaceholderText: findAllByPlaceholderText,
16075
- findAllByRole: findAllByRole,
16076
- findAllByTestId: findAllByTestId,
16077
- findAllByText: findAllByText,
16078
- findAllByTitle: findAllByTitle,
16079
- findByAltText: findByAltText,
16080
- findByDisplayValue: findByDisplayValue,
16081
- findByLabelText: findByLabelText,
16082
- findByPlaceholderText: findByPlaceholderText,
16083
- findByRole: findByRole,
16084
- findByTestId: findByTestId,
16085
- findByText: findByText,
16086
- findByTitle: findByTitle,
16087
- fireEvent: fireEvent,
16088
- getAllByAltText: getAllByAltText,
16089
- getAllByDisplayValue: getAllByDisplayValue,
16090
- getAllByLabelText: getAllByLabelTextWithSuggestions,
16091
- getAllByPlaceholderText: getAllByPlaceholderText,
16092
- getAllByRole: getAllByRole,
16093
- getAllByTestId: getAllByTestId,
16094
- getAllByText: getAllByText,
16095
- getAllByTitle: getAllByTitle,
16096
- getByAltText: getByAltText,
16097
- getByDisplayValue: getByDisplayValue,
16098
- getByLabelText: getByLabelTextWithSuggestions,
16099
- getByPlaceholderText: getByPlaceholderText,
16100
- getByRole: getByRole,
16101
- getByTestId: getByTestId,
16102
- getByText: getByText,
16103
- getByTitle: getByTitle,
16104
- getConfig: getConfig,
16105
- getDefaultNormalizer: getDefaultNormalizer,
16106
- getElementError: getElementError,
16107
- getMultipleElementsFoundError: getMultipleElementsFoundError,
16108
- getNodeText: getNodeText,
16109
- getQueriesForElement: getQueriesForElement,
16110
- getRoles: getRoles,
16111
- getSuggestedQuery: getSuggestedQuery,
16112
- isInaccessible: isInaccessible,
16113
- logDOM: logDOM,
16114
- logRoles: logRoles,
16115
- makeFindQuery: makeFindQuery,
16116
- makeGetAllQuery: makeGetAllQuery,
16117
- makeSingleQuery: makeSingleQuery,
16118
- prettyDOM: prettyDOM,
16119
- queries: queries,
16120
- queryAllByAltText: queryAllByAltTextWithSuggestions,
16121
- queryAllByAttribute: queryAllByAttribute,
16122
- queryAllByDisplayValue: queryAllByDisplayValueWithSuggestions,
16123
- queryAllByLabelText: queryAllByLabelTextWithSuggestions,
16124
- queryAllByPlaceholderText: queryAllByPlaceholderTextWithSuggestions,
16125
- queryAllByRole: queryAllByRoleWithSuggestions,
16126
- queryAllByTestId: queryAllByTestIdWithSuggestions,
16127
- queryAllByText: queryAllByTextWithSuggestions,
16128
- queryAllByTitle: queryAllByTitleWithSuggestions,
16129
- queryByAltText: queryByAltText,
16130
- queryByAttribute: queryByAttribute,
16131
- queryByDisplayValue: queryByDisplayValue,
16132
- queryByLabelText: queryByLabelText,
16133
- queryByPlaceholderText: queryByPlaceholderText,
16134
- queryByRole: queryByRole,
16135
- queryByTestId: queryByTestId,
16136
- queryByText: queryByText,
16137
- queryByTitle: queryByTitle,
16138
- queryHelpers: queryHelpers,
16139
- screen: screen,
16140
- waitFor: waitForWrapper,
16141
- waitForElementToBeRemoved: waitForElementToBeRemoved,
16142
- within: getQueriesForElement,
16143
- wrapAllByQueryWithSuggestion: wrapAllByQueryWithSuggestion,
16144
- wrapSingleQueryWithSuggestion: wrapSingleQueryWithSuggestion
15876
+ __proto__: null,
15877
+ prettyFormat: index,
15878
+ buildQueries: buildQueries,
15879
+ configure: configure,
15880
+ createEvent: createEvent,
15881
+ findAllByAltText: findAllByAltText,
15882
+ findAllByDisplayValue: findAllByDisplayValue,
15883
+ findAllByLabelText: findAllByLabelText,
15884
+ findAllByPlaceholderText: findAllByPlaceholderText,
15885
+ findAllByRole: findAllByRole,
15886
+ findAllByTestId: findAllByTestId,
15887
+ findAllByText: findAllByText,
15888
+ findAllByTitle: findAllByTitle,
15889
+ findByAltText: findByAltText,
15890
+ findByDisplayValue: findByDisplayValue,
15891
+ findByLabelText: findByLabelText,
15892
+ findByPlaceholderText: findByPlaceholderText,
15893
+ findByRole: findByRole,
15894
+ findByTestId: findByTestId,
15895
+ findByText: findByText,
15896
+ findByTitle: findByTitle,
15897
+ fireEvent: fireEvent,
15898
+ getAllByAltText: getAllByAltText,
15899
+ getAllByDisplayValue: getAllByDisplayValue,
15900
+ getAllByLabelText: getAllByLabelTextWithSuggestions,
15901
+ getAllByPlaceholderText: getAllByPlaceholderText,
15902
+ getAllByRole: getAllByRole,
15903
+ getAllByTestId: getAllByTestId,
15904
+ getAllByText: getAllByText,
15905
+ getAllByTitle: getAllByTitle,
15906
+ getByAltText: getByAltText,
15907
+ getByDisplayValue: getByDisplayValue,
15908
+ getByLabelText: getByLabelTextWithSuggestions,
15909
+ getByPlaceholderText: getByPlaceholderText,
15910
+ getByRole: getByRole,
15911
+ getByTestId: getByTestId,
15912
+ getByText: getByText,
15913
+ getByTitle: getByTitle,
15914
+ getConfig: getConfig,
15915
+ getDefaultNormalizer: getDefaultNormalizer,
15916
+ getElementError: getElementError,
15917
+ getMultipleElementsFoundError: getMultipleElementsFoundError,
15918
+ getNodeText: getNodeText,
15919
+ getQueriesForElement: getQueriesForElement,
15920
+ getRoles: getRoles,
15921
+ getSuggestedQuery: getSuggestedQuery,
15922
+ isInaccessible: isInaccessible,
15923
+ logDOM: logDOM,
15924
+ logRoles: logRoles,
15925
+ makeFindQuery: makeFindQuery,
15926
+ makeGetAllQuery: makeGetAllQuery,
15927
+ makeSingleQuery: makeSingleQuery,
15928
+ prettyDOM: prettyDOM,
15929
+ queries: queries,
15930
+ queryAllByAltText: queryAllByAltTextWithSuggestions,
15931
+ queryAllByAttribute: queryAllByAttribute,
15932
+ queryAllByDisplayValue: queryAllByDisplayValueWithSuggestions,
15933
+ queryAllByLabelText: queryAllByLabelTextWithSuggestions,
15934
+ queryAllByPlaceholderText: queryAllByPlaceholderTextWithSuggestions,
15935
+ queryAllByRole: queryAllByRoleWithSuggestions,
15936
+ queryAllByTestId: queryAllByTestIdWithSuggestions,
15937
+ queryAllByText: queryAllByTextWithSuggestions,
15938
+ queryAllByTitle: queryAllByTitleWithSuggestions,
15939
+ queryByAltText: queryByAltText,
15940
+ queryByAttribute: queryByAttribute,
15941
+ queryByDisplayValue: queryByDisplayValue,
15942
+ queryByLabelText: queryByLabelText,
15943
+ queryByPlaceholderText: queryByPlaceholderText,
15944
+ queryByRole: queryByRole,
15945
+ queryByTestId: queryByTestId,
15946
+ queryByText: queryByText,
15947
+ queryByTitle: queryByTitle,
15948
+ queryHelpers: queryHelpers,
15949
+ screen: screen,
15950
+ waitFor: waitForWrapper,
15951
+ waitForElementToBeRemoved: waitForElementToBeRemoved,
15952
+ within: getQueriesForElement,
15953
+ wrapAllByQueryWithSuggestion: wrapAllByQueryWithSuggestion,
15954
+ wrapSingleQueryWithSuggestion: wrapSingleQueryWithSuggestion
16145
15955
  });
16146
15956
 
16147
15957
  const domAct = testUtils__namespace.act;
@@ -43479,6 +43289,53 @@ function ApolloMockedProviderWithError(props) {
43479
43289
  return (jsxRuntime.jsx(MockedProvider, Object.assign({}, otherProps, { link: link, defaultOptions: Object.assign(Object.assign({}, defaultOptions), { watchQuery: { fetchPolicy: "no-cache" } }) })));
43480
43290
  }
43481
43291
 
43292
+ /**
43293
+ * Do nothing
43294
+ */
43295
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
43296
+ const doNothing = () => {
43297
+ /* Do nothing */
43298
+ };
43299
+
43300
+ const mockAnalyticsContext = {
43301
+ logEvent: doNothing,
43302
+ logError: doNothing,
43303
+ logPageView: doNothing,
43304
+ setUserProperty: doNothing,
43305
+ };
43306
+
43307
+ const mockAssetSortingContext = {
43308
+ setSortBy: doNothing,
43309
+ sortingState: {
43310
+ sortBy: reactCoreContextsApi.AssetSortByProperty.Criticality,
43311
+ order: reactCoreContextsApi.SortOrder.Desc,
43312
+ },
43313
+ };
43314
+
43315
+ /**
43316
+ * Mocks the current user context
43317
+ *
43318
+ * @returns {ICurrentUserContext} - Returns the mocked current user context
43319
+ */
43320
+ const mockCurrentUserContext = {
43321
+ userName: "",
43322
+ userRole: "",
43323
+ customerId: 12345,
43324
+ userId: 154312,
43325
+ tasUserId: "751ea227-f199-4d00-925f-a608312c5e45",
43326
+ email: "",
43327
+ name: "",
43328
+ accountId: "",
43329
+ assumedUser: null,
43330
+ jobTitle: "",
43331
+ isAuthenticated: true,
43332
+ isVerified: true,
43333
+ isTrackunitUser: false,
43334
+ isAssuming: false,
43335
+ isAccountOwner: true,
43336
+ subscriptionPackage: "EXPAND_FLEET_OWNER",
43337
+ };
43338
+
43482
43339
  /**
43483
43340
  * Mocks the current user context
43484
43341
  *
@@ -43493,6 +43350,60 @@ const mockCurrentUserPreferenceContext = {
43493
43350
  setSystemOfMeasurement: doNothing,
43494
43351
  };
43495
43352
 
43353
+ const mockEnvironmentContext = {
43354
+ auth: {
43355
+ url: "",
43356
+ clientId: "",
43357
+ issuer: "",
43358
+ },
43359
+ managerClassicUrl: "https://sso.trackunit.com",
43360
+ googleMapsApiKey: "",
43361
+ amplitudeApiKey: "",
43362
+ amplitudeApiEndpoint: "",
43363
+ graphqlPublicUrl: "",
43364
+ graphqlManagerUrl: "",
43365
+ graphqlManagerImageUploadUrl: "",
43366
+ graphqlReportUrl: "",
43367
+ buildVersion: "",
43368
+ commitNumber: 0,
43369
+ buildDate: "",
43370
+ irisAppSdkServerUrl: "",
43371
+ publicUrl: "",
43372
+ isDev: true,
43373
+ environment: "",
43374
+ sentryDsn: "",
43375
+ sessionId: "",
43376
+ tracingHeaders: {
43377
+ "X-TrackunitAppVersion": "",
43378
+ "session-id": "",
43379
+ },
43380
+ trackunitRestApiUrl: "",
43381
+ hubspotRequestAppAccessFormId: "",
43382
+ };
43383
+
43384
+ const mockOemBrandingContext = {
43385
+ getAllBrandingDetails: doNothing,
43386
+ getOemBranding: doNothing,
43387
+ getOemImage: doNothing,
43388
+ };
43389
+
43390
+ const mockToastContext = {
43391
+ addToast: doNothing,
43392
+ setIsManifestError: doNothing,
43393
+ };
43394
+
43395
+ /**
43396
+ * This is a mock for the UserSubscriptionContext.
43397
+ *
43398
+ * @returns { IUserSubscriptionContext }- mock for the UserSubscriptionContext
43399
+ */
43400
+ const mockUserSubscriptionContext = {
43401
+ numberOfDaysWithAccessToHistoricalData: 30,
43402
+ numberOfDaysWithAccessToHistoricalInsights: 30,
43403
+ features: [],
43404
+ packageType: "EXPAND_FLEET_OWNER",
43405
+ };
43406
+
43496
43407
  /**
43497
43408
  * Flushes all promises in the queue.
43498
43409
  * This is useful when testing async code.
@@ -43986,6 +43897,95 @@ class TrackunitProvidersMockBuilder {
43986
43897
  */
43987
43898
  const trackunitProviders = () => new TrackunitProvidersMockBuilder();
43988
43899
 
43900
+ /**
43901
+ * Logs props that have changed.
43902
+ * Use this for debugging which props force a component to re-render.
43903
+ * This is a hook version of the class component lifecycle method `componentDidUpdate`.
43904
+ * ALWAYS wrap in your own object.
43905
+ *
43906
+ * @param id optional id to use for logging or it will guess the id from the stack trace
43907
+ * @param propsToWatch all the props to watch for changes
43908
+ * @example
43909
+ * const propsToWatch = { foo: props.foo, bar: props.bar };
43910
+ * useDebugger({ id: "MyComponent", propsToWatch });
43911
+ */
43912
+ const useDebugger = ({ id, propsToWatch, }) => {
43913
+ const prevPropsRef = React.useRef(propsToWatch);
43914
+ const uniqueId = React.useMemo(() => {
43915
+ var _a;
43916
+ return id || ((_a = new Error().stack) === null || _a === void 0 ? void 0 : _a.split("\n")[2].trim()) || "unknown-id";
43917
+ }, [id]);
43918
+ React.useEffect(() => {
43919
+ const changedProps = Object.entries(propsToWatch || {}).reduce((result, [key, value]) => {
43920
+ if (prevPropsRef.current && prevPropsRef.current[key] !== value) {
43921
+ result[key + ""] = [prevPropsRef.current[key], value];
43922
+ }
43923
+ return result;
43924
+ }, {});
43925
+ if (Object.keys(changedProps).length > 0) {
43926
+ // eslint-disable-next-line no-console
43927
+ Object.keys(changedProps).forEach(changedProp => {
43928
+ // eslint-disable-next-line no-console
43929
+ console.log(`${uniqueId} changed property: ${changedProp}`);
43930
+ // JSON stringify is used to avoid console.table from logging the object reference
43931
+ const result = JSON.parse(JSON.stringify(changedProps[changedProp]));
43932
+ const result0 = result[0];
43933
+ const result1 = result[1];
43934
+ result0 &&
43935
+ Object.keys(result0).forEach(prop => {
43936
+ result0[prop] = JSON.stringify(result0[prop]);
43937
+ });
43938
+ result1 &&
43939
+ Object.keys(result1).forEach(prop => {
43940
+ result1[prop] = JSON.stringify(result1[prop]);
43941
+ });
43942
+ // eslint-disable-next-line no-console
43943
+ console.table([result0, result1]);
43944
+ });
43945
+ // eslint-disable-next-line no-console
43946
+ console.dir(changedProps);
43947
+ }
43948
+ prevPropsRef.current = propsToWatch;
43949
+ }, [propsToWatch, uniqueId]);
43950
+ };
43951
+ /**
43952
+ * Debugger component for debugging state changes and re-renders.
43953
+ *
43954
+ * This component will log when it is mounted, re-renders or unmounted.
43955
+ * It will also log when any of its props change.
43956
+ *
43957
+ * @param id optional id to use for logging
43958
+ * @param stop if true, will stop execution and open debugger
43959
+ * @param logPropsChanges optional object with props to watch for changes
43960
+ * @param children the children to render
43961
+ */
43962
+ const Debugger = ({ id, logPropsChanges, stop, children, }) => {
43963
+ var _a, _b, _c, _d, _e, _f;
43964
+ const uniqueId = id ||
43965
+ (
43966
+ // @ts-ignore
43967
+ (_e = (_d = (_c = (_b = (_a = React__default["default"]["__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED"]) === null || _a === void 0 ? void 0 : _a.ReactCurrentOwner) === null || _b === void 0 ? void 0 : _b.current) === null || _c === void 0 ? void 0 : _c._debugOwner) === null || _d === void 0 ? void 0 : _d.type) === null || _e === void 0 ? void 0 : _e.name) ||
43968
+ ((_f = new Error().stack) === null || _f === void 0 ? void 0 : _f.split("\n")[2].trim()) ||
43969
+ "unknown-id";
43970
+ useDebugger({ id: uniqueId, propsToWatch: logPropsChanges || {} });
43971
+ // eslint-disable-next-line no-console
43972
+ console.log(`${uniqueId} Debugger is rendering`);
43973
+ React.useEffect(() => {
43974
+ // eslint-disable-next-line no-console
43975
+ console.log(`${uniqueId} Debugger is mounting`);
43976
+ return () => {
43977
+ // eslint-disable-next-line no-console
43978
+ console.log(`${uniqueId} Debugger is unmounting`);
43979
+ };
43980
+ // eslint-disable-next-line react-hooks/exhaustive-deps
43981
+ }, []);
43982
+ if (stop === true) {
43983
+ // eslint-disable-next-line no-debugger
43984
+ debugger;
43985
+ }
43986
+ return jsxRuntime.jsx("div", { className: "Debugger", children: children });
43987
+ };
43988
+
43989
43989
  /**
43990
43990
  *
43991
43991
  * @param document Document that represents the specific GQL query / mutation schema.
package/index.esm.js CHANGED
@@ -1,10 +1,10 @@
1
1
  export { D as Debugger, T as TrackunitProvidersMockBuilder, l as doNothing, f as flushPromises, o as flushPromisesInAct, m as mockAnalyticsContext, b as mockAssetSortingContext, e as mockCurrentUserContext, h as mockEnvironmentContext, i as mockOemBrandingContext, j as mockToastContext, k as mockUserSubscriptionContext, q as queryFor, n as queryForHook, t as trackunitProviders, u as useDebugger, v as validateIrisApp } from './index.esm2.js';
2
2
  import 'react/jsx-runtime';
3
- import 'react';
4
- import '@trackunit/react-core-contexts-api';
5
3
  import 'react-dom/test-utils';
4
+ import 'react';
6
5
  import 'react-dom';
7
6
  import 'react-dom/client';
8
7
  import 'util';
9
8
  import '@trackunit/react-core-hooks';
10
9
  import 'react-router-dom';
10
+ import '@trackunit/react-core-contexts-api';