@copart/ops-tool-kit 1.12.1-alpha.33 → 1.12.1-alpha.35

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.
@@ -32,7 +32,7 @@ var React__namespace = /*#__PURE__*/_interopNamespace(React);
32
32
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
33
33
 
34
34
  const name$r = "@copart/ops-tool-kit";
35
- const version$7 = "1.12.1-alpha.33";
35
+ const version$7 = "1.12.1-alpha.35";
36
36
  const main$1 = "dist/ops-tool-kit.js";
37
37
  const style = "dist/ops-tool-kit.css";
38
38
  const files = [
@@ -35899,51 +35899,55 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
35899
35899
  _useState18 = _slicedToArray(_useState17, 2),
35900
35900
  currentContext = _useState18[0],
35901
35901
  setCurrentContext = _useState18[1];
35902
- var _useState19 = React.useState({}),
35902
+ var _useState19 = React.useState(null),
35903
35903
  _useState20 = _slicedToArray(_useState19, 2),
35904
- feedbacks = _useState20[0],
35905
- setFeedbacks = _useState20[1];
35906
- var _useState21 = React.useState({
35904
+ lastSentFromApp = _useState20[0],
35905
+ setLastSentFromApp = _useState20[1];
35906
+ var _useState21 = React.useState({}),
35907
+ _useState22 = _slicedToArray(_useState21, 2),
35908
+ feedbacks = _useState22[0],
35909
+ setFeedbacks = _useState22[1];
35910
+ var _useState23 = React.useState({
35907
35911
  x: 0,
35908
35912
  y: 0
35909
35913
  }),
35910
- _useState22 = _slicedToArray(_useState21, 2),
35911
- position = _useState22[0],
35912
- setPosition = _useState22[1];
35913
- var _useState23 = React.useState({
35914
+ _useState24 = _slicedToArray(_useState23, 2),
35915
+ position = _useState24[0],
35916
+ setPosition = _useState24[1];
35917
+ var _useState25 = React.useState({
35914
35918
  x: 50,
35915
35919
  y: -68
35916
35920
  }),
35917
- _useState24 = _slicedToArray(_useState23, 2),
35918
- chatPosition = _useState24[0],
35919
- setChatPosition = _useState24[1];
35920
- var _useState25 = React.useState(false),
35921
35921
  _useState26 = _slicedToArray(_useState25, 2),
35922
- isDragging = _useState26[0],
35923
- setIsDragging = _useState26[1];
35924
- var _useState27 = React.useState({
35922
+ chatPosition = _useState26[0],
35923
+ setChatPosition = _useState26[1];
35924
+ var _useState27 = React.useState(false),
35925
+ _useState28 = _slicedToArray(_useState27, 2),
35926
+ isDragging = _useState28[0],
35927
+ setIsDragging = _useState28[1];
35928
+ var _useState29 = React.useState({
35925
35929
  x: 0,
35926
35930
  y: 0
35927
35931
  }),
35928
- _useState28 = _slicedToArray(_useState27, 2),
35929
- offset = _useState28[0],
35930
- setOffset = _useState28[1];
35931
- var _useState29 = React.useState(false),
35932
35932
  _useState30 = _slicedToArray(_useState29, 2),
35933
- dragged = _useState30[0],
35934
- setDragged = _useState30[1];
35935
- var _useState31 = React.useState(500),
35933
+ offset = _useState30[0],
35934
+ setOffset = _useState30[1];
35935
+ var _useState31 = React.useState(false),
35936
35936
  _useState32 = _slicedToArray(_useState31, 2),
35937
- chatWindowWidth = _useState32[0],
35938
- setChatWindowWidth = _useState32[1];
35939
- var _useState33 = React.useState(0),
35937
+ dragged = _useState32[0],
35938
+ setDragged = _useState32[1];
35939
+ var _useState33 = React.useState(500),
35940
35940
  _useState34 = _slicedToArray(_useState33, 2),
35941
- windowInnerWidthForMobile = _useState34[0],
35942
- setWindowInnerWidthForMobile = _useState34[1];
35943
- var _useState35 = React.useState(600),
35941
+ chatWindowWidth = _useState34[0],
35942
+ setChatWindowWidth = _useState34[1];
35943
+ var _useState35 = React.useState(0),
35944
35944
  _useState36 = _slicedToArray(_useState35, 2),
35945
- chatWindowHeight = _useState36[0],
35946
- setchatWindowHeight = _useState36[1]; //update this if changed in css
35945
+ windowInnerWidthForMobile = _useState36[0],
35946
+ setWindowInnerWidthForMobile = _useState36[1];
35947
+ var _useState37 = React.useState(600),
35948
+ _useState38 = _slicedToArray(_useState37, 2),
35949
+ chatWindowHeight = _useState38[0],
35950
+ setchatWindowHeight = _useState38[1]; //update this if changed in css
35947
35951
 
35948
35952
  var chatIconSize = 60; //update this if changed in css
35949
35953
 
@@ -36159,8 +36163,10 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36159
36163
  var conversationsToBeSaved = !isEmpty$2(conversationsFromSession) ? conversationsFromSession : [];
36160
36164
  setConversations(conversationsToBeSaved);
36161
36165
  var feedbacksFromSession = storage$1.getLocalItem('mihelpAgentFeedbacks');
36166
+ var lastSentApp = storage$1.getLocalItem('mihelpAgentLastSentApp');
36162
36167
  var feedbacksToBeSaved = !isEmpty$2(feedbacksFromSession) ? feedbacksFromSession : {};
36163
36168
  setFeedbacks(feedbacksToBeSaved);
36169
+ setLastSentFromApp(lastSentApp);
36164
36170
  if (conversationsToBeSaved.length) {
36165
36171
  saveCurrentContext(conversationsToBeSaved);
36166
36172
  } else {
@@ -36194,6 +36200,9 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36194
36200
  var feedbacksToBeSaved = !isEmpty$2(feedbacksFromSession) ? feedbacksFromSession : {};
36195
36201
  setFeedbacks(feedbacksToBeSaved);
36196
36202
  }
36203
+ if (event.key === 'mihelpAgentLastSentApp') {
36204
+ setLastSentFromApp(event.newValue);
36205
+ }
36197
36206
  };
36198
36207
  window.addEventListener('storage', handleStorageChange);
36199
36208
  return function () {
@@ -36222,7 +36231,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36222
36231
  };
36223
36232
  var send = /*#__PURE__*/function () {
36224
36233
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(messages) {
36225
- var _window$toolkitEnv, _window$toolkitEnv2, _window$toolkitEnv3, _storage$getLocalItem, _storage$getLocalItem2, _response$data, _response$data2, newMessages, isCoreApp, appTiles, appName, appData, appAuthName, messagesWithOutId, payload, endpoint, response, newConversations;
36234
+ var _window$toolkitEnv, _window$toolkitEnv2, _window$toolkitEnv3, _storage$getLocalItem, _storage$getLocalItem2, _response$data, _response$data2, newMessages, isCoreApp, appTiles, appName, appData, appAuthName, currentAppName, messagesWithOutId, payload, endpoint, response, newConversations;
36226
36235
  return _regeneratorRuntime().wrap(function _callee$(_context) {
36227
36236
  while (1) switch (_context.prev = _context.next) {
36228
36237
  case 0:
@@ -36230,6 +36239,18 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36230
36239
  setMessageError(false);
36231
36240
  _context.prev = 2;
36232
36241
  newMessages = _toConsumableArray(messages);
36242
+ isCoreApp = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
36243
+ appTiles = storage$1.getLocalItem('opsportal-core:config').tiles || [];
36244
+ appName = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
36245
+ appData = appTiles.find(function (tile) {
36246
+ if (tile.appName) {
36247
+ return tile.appName === appName;
36248
+ } else {
36249
+ return tile.path === "/".concat(appName);
36250
+ }
36251
+ });
36252
+ appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv3 = window.toolkitEnv) !== null && _window$toolkitEnv3 !== void 0 && _window$toolkitEnv3.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
36253
+ currentAppName = isCoreApp ? 'g2Home' : appAuthName;
36233
36254
  if (systemPrompt && typeof systemPrompt === 'string') {
36234
36255
  if (!currentContext) {
36235
36256
  if (!newMessages.find(function (m) {
@@ -36243,7 +36264,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36243
36264
  if (!isEmpty$2(storage$1.appContext)) {
36244
36265
  setCurrentContext(storage$1.appContext);
36245
36266
  }
36246
- } else if (!equals$1(currentContext, storage$1.appContext)) {
36267
+ } else if (!equals$1(currentContext, storage$1.appContext) || lastSentFromApp !== currentAppName) {
36247
36268
  setCurrentContext(storage$1.appContext);
36248
36269
  newMessages.splice(newMessages.length - 1, 0, {
36249
36270
  role: 'system',
@@ -36251,17 +36272,6 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36251
36272
  });
36252
36273
  }
36253
36274
  }
36254
- isCoreApp = (_window$toolkitEnv = window.toolkitEnv) !== null && _window$toolkitEnv !== void 0 && _window$toolkitEnv.IS_CORE_APP ? window.toolkitEnv.IS_CORE_APP : process.env.IS_CORE_APP;
36255
- appTiles = storage$1.getLocalItem('opsportal-core:config').tiles || [];
36256
- appName = (_window$toolkitEnv2 = window.toolkitEnv) !== null && _window$toolkitEnv2 !== void 0 && _window$toolkitEnv2.APP_NAME ? window.toolkitEnv.APP_NAME : process.env.APP_NAME;
36257
- appData = appTiles.find(function (tile) {
36258
- if (tile.appName) {
36259
- return tile.appName === appName;
36260
- } else {
36261
- return tile.path === "/".concat(appName);
36262
- }
36263
- });
36264
- appAuthName = appData ? appData.appAuthName : (_window$toolkitEnv3 = window.toolkitEnv) !== null && _window$toolkitEnv3 !== void 0 && _window$toolkitEnv3.APP_AUTH_NAME ? window.toolkitEnv.APP_AUTH_NAME : process.env.APP_AUTH_NAME;
36265
36275
  messagesWithOutId = newMessages.map(function (m) {
36266
36276
  return {
36267
36277
  role: m === null || m === void 0 ? void 0 : m.role,
@@ -36272,18 +36282,19 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36272
36282
  messages: messagesWithOutId,
36273
36283
  // collection,
36274
36284
  last_n: contextMessagesCount,
36275
- app_name: isCoreApp ? 'g2Home' : appAuthName,
36285
+ app_name: currentAppName,
36276
36286
  k: contextChunks
36277
36287
  };
36278
36288
  endpoint = (_storage$getLocalItem = storage$1.getLocalItem('opsportal-core:config')) === null || _storage$getLocalItem === void 0 ? void 0 : (_storage$getLocalItem2 = _storage$getLocalItem.endpoints) === null || _storage$getLocalItem2 === void 0 ? void 0 : _storage$getLocalItem2.mihelpChat;
36279
- _context.next = 15;
36289
+ _context.next = 16;
36280
36290
  return fetcher.post(endpoint, payload, {
36281
36291
  headers: {
36282
36292
  'Content-Type': 'application/json'
36283
36293
  }
36284
36294
  });
36285
- case 15:
36295
+ case 16:
36286
36296
  response = _context.sent;
36297
+ setLastSentFromApp(currentAppName);
36287
36298
  setIsLoading(false);
36288
36299
  newConversations = [].concat(_toConsumableArray(newMessages), [{
36289
36300
  role: 'assistant',
@@ -36293,28 +36304,29 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36293
36304
  }]);
36294
36305
  setConversations(newConversations);
36295
36306
  storage$1.setLocalItem('mihelpAgentConversations', newConversations);
36296
- _context.next = 34;
36307
+ storage$1.setLocalItem('mihelpAgentLastSentApp', currentAppName);
36308
+ _context.next = 37;
36297
36309
  break;
36298
- case 22:
36299
- _context.prev = 22;
36310
+ case 25:
36311
+ _context.prev = 25;
36300
36312
  _context.t0 = _context["catch"](2);
36301
36313
  if (!(retryCount.current < 3)) {
36302
- _context.next = 30;
36314
+ _context.next = 33;
36303
36315
  break;
36304
36316
  }
36305
36317
  retryCount.current++;
36306
36318
  send(messages);
36307
36319
  return _context.abrupt("return");
36308
- case 30:
36320
+ case 33:
36309
36321
  retryCount.current = 0;
36310
36322
  setMessageError(true);
36311
36323
  setIsLoading(false);
36312
36324
  console.log(_context.t0);
36313
- case 34:
36325
+ case 37:
36314
36326
  case "end":
36315
36327
  return _context.stop();
36316
36328
  }
36317
- }, _callee, null, [[2, 22]]);
36329
+ }, _callee, null, [[2, 25]]);
36318
36330
  }));
36319
36331
  return function send(_x) {
36320
36332
  return _ref2.apply(this, arguments);
@@ -36372,6 +36384,7 @@ var MiHelpAgent = function MiHelpAgent(_ref) {
36372
36384
  setConversations([]);
36373
36385
  storage$1.setLocalItem('mihelpAgentConversations', []);
36374
36386
  storage$1.setLocalItem('mihelpAgentFeedbacks', {});
36387
+ storage$1.setLocalItem('mihelpAgentLastSentApp', '');
36375
36388
  setMessageError(false);
36376
36389
  setCurrentContext(null);
36377
36390
  };
@@ -47260,7 +47273,8 @@ var NavigationBar = function NavigationBar(_ref2) {
47260
47273
  allowMultipleNavItemsOpen = _ref2.allowMultipleNavItemsOpen,
47261
47274
  setShowNavigationCounts = _ref2.setShowNavigationCounts,
47262
47275
  countsRef = _ref2.countsRef,
47263
- countAutoReloadDisabled = _ref2.countAutoReloadDisabled;
47276
+ countAutoReloadDisabled = _ref2.countAutoReloadDisabled,
47277
+ onNavSectionToggle = _ref2.onNavSectionToggle;
47264
47278
  // const withCounts = getCounts && typeof getCounts === 'function'
47265
47279
  var navigateFunction = navigateTo || (history === null || history === void 0 ? void 0 : history.push) || defaultRedirect;
47266
47280
  var _useState = React.useState(null),
@@ -47338,7 +47352,8 @@ var NavigationBar = function NavigationBar(_ref2) {
47338
47352
  setWithCounts: setWithCounts,
47339
47353
  withCounts: withCounts,
47340
47354
  countsRef: countsRef,
47341
- countAutoReloadDisabled: countAutoReloadDisabled
47355
+ countAutoReloadDisabled: countAutoReloadDisabled,
47356
+ onNavSectionToggle: onNavSectionToggle
47342
47357
  }) : null, isConfigValid === false ? /*#__PURE__*/React__default["default"].createElement("div", null, "Please check your navigation config") : null);
47343
47358
  };
47344
47359
  var NavigationMenu = function NavigationMenu(_ref3) {
@@ -47355,7 +47370,8 @@ var NavigationMenu = function NavigationMenu(_ref3) {
47355
47370
  setWithCounts = _ref3.setWithCounts,
47356
47371
  withCounts = _ref3.withCounts,
47357
47372
  countsRef = _ref3.countsRef,
47358
- countAutoReloadDisabled = _ref3.countAutoReloadDisabled;
47373
+ countAutoReloadDisabled = _ref3.countAutoReloadDisabled,
47374
+ onNavSectionToggle = _ref3.onNavSectionToggle;
47359
47375
  var redirectUrl = window.location.pathname;
47360
47376
  var _useState13 = React.useState(null),
47361
47377
  _useState14 = _slicedToArray(_useState13, 2),
@@ -47422,6 +47438,7 @@ var NavigationMenu = function NavigationMenu(_ref3) {
47422
47438
  withCounts: withCounts,
47423
47439
  countsRef: countsRef,
47424
47440
  countAutoReloadDisabled: countAutoReloadDisabled,
47441
+ onNavSectionToggle: onNavSectionToggle,
47425
47442
  counts: counts,
47426
47443
  setCounts: setCounts,
47427
47444
  countLoadAttemptsRef: countLoadAttemptsRef
@@ -47443,6 +47460,7 @@ var NavigationMenuLevel1 = function NavigationMenuLevel1(_ref4) {
47443
47460
  withCounts = _ref4.withCounts,
47444
47461
  countsRef = _ref4.countsRef,
47445
47462
  countAutoReloadDisabled = _ref4.countAutoReloadDisabled,
47463
+ onNavSectionToggle = _ref4.onNavSectionToggle,
47446
47464
  counts = _ref4.counts,
47447
47465
  setCounts = _ref4.setCounts,
47448
47466
  countLoadAttemptsRef = _ref4.countLoadAttemptsRef;
@@ -47479,6 +47497,7 @@ var NavigationMenuLevel1 = function NavigationMenuLevel1(_ref4) {
47479
47497
  withCounts: withCounts,
47480
47498
  countsRef: countsRef,
47481
47499
  countAutoReloadDisabled: countAutoReloadDisabled,
47500
+ onNavSectionToggle: onNavSectionToggle,
47482
47501
  counts: counts,
47483
47502
  setCounts: setCounts,
47484
47503
  countLoadAttemptsRef: countLoadAttemptsRef
@@ -47499,6 +47518,8 @@ var NavigationMenuLevel2 = function NavigationMenuLevel2(_ref5) {
47499
47518
  withCounts = _ref5.withCounts,
47500
47519
  countsRef = _ref5.countsRef,
47501
47520
  countAutoReloadDisabled = _ref5.countAutoReloadDisabled,
47521
+ _ref5$onNavSectionTog = _ref5.onNavSectionToggle,
47522
+ onNavSectionToggle = _ref5$onNavSectionTog === void 0 ? function () {} : _ref5$onNavSectionTog,
47502
47523
  counts = _ref5.counts,
47503
47524
  setCounts = _ref5.setCounts,
47504
47525
  countLoadAttemptsRef = _ref5.countLoadAttemptsRef;
@@ -47549,12 +47570,14 @@ var NavigationMenuLevel2 = function NavigationMenuLevel2(_ref5) {
47549
47570
  setActiveSubmenu(function (menuItems) {
47550
47571
  return allowMultipleNavItemsOpen ? [].concat(_toConsumableArray(menuItems), [navItem.fullRoute]) : [navItem.fullRoute];
47551
47572
  });
47573
+ onNavSectionToggle(navItem.route, true);
47552
47574
  } else {
47553
47575
  setActiveSubmenu(function (menuItems) {
47554
47576
  return _toConsumableArray(menuItems).filter(function (item) {
47555
47577
  return item !== navItem.fullRoute;
47556
47578
  });
47557
47579
  });
47580
+ onNavSectionToggle(navItem.route, false);
47558
47581
  }
47559
47582
  // setActiveSubmenu(isMenuExpanded ? null : navItem.fullRoute)
47560
47583
  if (!isMenuExpanded && showCounts && !countAutoReloadDisabled) {
@@ -47828,7 +47851,8 @@ var AppFrame = function AppFrame(props) {
47828
47851
  allowMultipleNavItemsOpen: props.allowMultipleNavItemsOpen,
47829
47852
  setShowNavigationCounts: setShowNavigationCounts,
47830
47853
  countsRef: props.countsRef,
47831
- countAutoReloadDisabled: props.countAutoReloadDisabled
47854
+ countAutoReloadDisabled: props.countAutoReloadDisabled,
47855
+ onNavSectionToggle: props.onNavSectionToggle
47832
47856
  }) : null, /*#__PURE__*/React__default["default"].createElement("div", {
47833
47857
  style: {
47834
47858
  marginLeft: props.showNavigation ? navigationWidth : '0px',