@copart/ops-tool-kit 1.13.0-beta.14 → 1.13.0-beta.15

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.
@@ -6,7 +6,7 @@ var React = require('react');
6
6
  var ReactDOM = require('react-dom');
7
7
  var frontEndUtils = require('@copart/front-end-utils');
8
8
  var coreComponents = require('@copart/core-components');
9
- var reactRouterDom = require('react-router-dom');
9
+ var ReactRouterDOM = require('react-router-dom');
10
10
 
11
11
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
12
 
@@ -46,9 +46,10 @@ function _mergeNamespaces(n, m) {
46
46
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
47
47
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
48
48
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
49
+ var ReactRouterDOM__namespace = /*#__PURE__*/_interopNamespace(ReactRouterDOM);
49
50
 
50
51
  const name$1 = "@copart/ops-tool-kit";
51
- const version$3 = "1.13.0-beta.14";
52
+ const version$3 = "1.13.0-beta.15";
52
53
  const main$1 = "dist/ops-tool-kit.js";
53
54
  const style = "dist/ops-tool-kit.css";
54
55
  const files = [
@@ -109,7 +110,7 @@ const devDependencies$1 = {
109
110
  const peerDependencies = {
110
111
  "@copart/core-components": "2.3.0-alpha.filters.6",
111
112
  react: "*",
112
- "react-router-dom": "^5.0.0"
113
+ "react-router-dom": "^5.0.0 || ^6.0.0"
113
114
  };
114
115
  const dependencies$1 = {
115
116
  "@reacting/purist": "0.1.0",
@@ -69725,13 +69726,68 @@ function serializeNavItems(items) {
69725
69726
  });
69726
69727
  }
69727
69728
 
69729
+ /**
69730
+ * True when the host app uses react-router-dom v6+ (`useNavigate` present, `useHistory` removed).
69731
+ */
69732
+ var IS_REACT_ROUTER_V6 = typeof ReactRouterDOM__namespace.useNavigate === 'function' && typeof ReactRouterDOM__namespace.useHistory !== 'function';
69733
+ function normalizeNavigateTarget(to) {
69734
+ if (typeof to === 'string') return normalizeIframePath(to);
69735
+ return to;
69736
+ }
69737
+ function useRouterNavigationV5() {
69738
+ var history = ReactRouterDOM__namespace.useHistory();
69739
+ var location = ReactRouterDOM__namespace.useLocation();
69740
+ var navigate = React.useCallback(function (to, options) {
69741
+ if (typeof to === 'number') {
69742
+ history.go(to);
69743
+ return;
69744
+ }
69745
+ var target = normalizeNavigateTarget(to);
69746
+ if ((options === null || options === void 0 ? void 0 : options.state) != null) history.push(target, options.state);else if (options !== null && options !== void 0 && options.replace) history.replace(target);else history.push(target);
69747
+ }, [history]);
69748
+ return {
69749
+ navigate: navigate,
69750
+ location: location
69751
+ };
69752
+ }
69753
+ function useRouterNavigationV6() {
69754
+ var navigateFn = ReactRouterDOM__namespace.useNavigate();
69755
+ var location = ReactRouterDOM__namespace.useLocation();
69756
+ var navigate = React.useCallback(function (to, options) {
69757
+ if (typeof to === 'number') {
69758
+ navigateFn(to);
69759
+ return;
69760
+ }
69761
+ var target = normalizeNavigateTarget(to);
69762
+ if ((options === null || options === void 0 ? void 0 : options.state) != null || options !== null && options !== void 0 && options.replace) {
69763
+ navigateFn(target, {
69764
+ state: options === null || options === void 0 ? void 0 : options.state,
69765
+ replace: options === null || options === void 0 ? void 0 : options.replace
69766
+ });
69767
+ } else {
69768
+ navigateFn(target);
69769
+ }
69770
+ }, [navigateFn]);
69771
+ return {
69772
+ navigate: navigate,
69773
+ location: location
69774
+ };
69775
+ }
69776
+
69777
+ /**
69778
+ * Router-agnostic navigation for iframe shell components.
69779
+ * Uses `useHistory` on react-router-dom v5 and `useNavigate` on v6.
69780
+ */
69781
+ var useRouterNavigation = IS_REACT_ROUTER_V6 ? useRouterNavigationV6 : useRouterNavigationV5;
69782
+
69728
69783
  function IframeRouteSync(_ref) {
69729
69784
  var _ref$updateUriIsPath = _ref.updateUriIsPath,
69730
69785
  updateUriIsPath = _ref$updateUriIsPath === void 0 ? false : _ref$updateUriIsPath,
69731
69786
  _ref$suppressEcho = _ref.suppressEcho,
69732
69787
  suppressEcho = _ref$suppressEcho === void 0 ? true : _ref$suppressEcho;
69733
- var history = reactRouterDom.useHistory();
69734
- var location = reactRouterDom.useLocation();
69788
+ var _useRouterNavigation = useRouterNavigation(),
69789
+ navigate = _useRouterNavigation.navigate,
69790
+ location = _useRouterNavigation.location;
69735
69791
  var initialRef = React.useRef(true);
69736
69792
  var suppressUpdateUriRef = React.useRef(false);
69737
69793
  React.useEffect(function () {
@@ -69739,11 +69795,11 @@ function IframeRouteSync(_ref) {
69739
69795
  if (data.eventType === 'LOAD_URI' && data.eventProps) {
69740
69796
  var path = normalizeIframePath(data.eventProps.uri);
69741
69797
  if (suppressEcho) suppressUpdateUriRef.current = true;
69742
- history.push(path);
69798
+ navigate(path);
69743
69799
  }
69744
69800
  });
69745
69801
  return remove;
69746
- }, [history, suppressEcho]);
69802
+ }, [navigate, suppressEcho]);
69747
69803
  React.useEffect(function () {
69748
69804
  if (initialRef.current) {
69749
69805
  initialRef.current = false;
@@ -69883,11 +69939,10 @@ function IframeAppRootInner(_ref) {
69883
69939
  navCountsOnError = _ref.navCountsOnError,
69884
69940
  updateUriIsPath = _ref.updateUriIsPath,
69885
69941
  suppressRouteSyncEcho = _ref.suppressRouteSyncEcho;
69886
- var history = reactRouterDom.useHistory();
69942
+ var _useRouterNavigation = useRouterNavigation(),
69943
+ navigate = _useRouterNavigation.navigate;
69887
69944
  return /*#__PURE__*/React__default["default"].createElement(CrumbProvider, {
69888
- navigate: function navigate(path) {
69889
- return history.push(path);
69890
- }
69945
+ navigate: navigate
69891
69946
  }, /*#__PURE__*/React__default["default"].createElement(AppEnvSender, {
69892
69947
  toolkitEnv: toolkitEnv,
69893
69948
  mihelpAgentProps: mihelpAgentProps
@@ -69923,7 +69978,7 @@ function IframeAppRoot(_ref2) {
69923
69978
  _ref2$suppressRouteSy = _ref2.suppressRouteSyncEcho,
69924
69979
  suppressRouteSyncEcho = _ref2$suppressRouteSy === void 0 ? true : _ref2$suppressRouteSy;
69925
69980
  var initialPath = normalizeIframePath(initialUri);
69926
- return /*#__PURE__*/React__default["default"].createElement(reactRouterDom.MemoryRouter, {
69981
+ return /*#__PURE__*/React__default["default"].createElement(ReactRouterDOM.MemoryRouter, {
69927
69982
  initialEntries: [initialPath],
69928
69983
  initialIndex: 0
69929
69984
  }, /*#__PURE__*/React__default["default"].createElement(IframeAppRootInner, {
@@ -81779,6 +81834,7 @@ exports.AutoRefresh = AutoRefresh;
81779
81834
  exports.CallLogger = CallLogger;
81780
81835
  exports.ContextualHelp = ContextualHelp;
81781
81836
  exports.Crumb = Crumb$1;
81837
+ exports.IS_REACT_ROUTER_V6 = IS_REACT_ROUTER_V6;
81782
81838
  exports.IframeAppRoot = IframeAppRoot;
81783
81839
  exports.IframeRouteSync = IframeRouteSync;
81784
81840
  exports.NavConfigSender = NavConfigSender;
@@ -81793,4 +81849,5 @@ exports.registerEarlyLoadUriListener = registerEarlyLoadUriListener;
81793
81849
  exports.resolveCountStatus = resolveCountStatus;
81794
81850
  exports.serializeNavItems = serializeNavItems;
81795
81851
  exports.storage = storage$2;
81852
+ exports.useRouterNavigation = useRouterNavigation;
81796
81853
  //# sourceMappingURL=ops-tool-kit.js.map