@bigbinary/neeto-commons-frontend 4.13.92 → 4.13.93

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.
@@ -5,10 +5,12 @@ var objectWithoutProperties = require('../../objectWithoutProperties-wSsbHFcG.js
5
5
  var ErrorPage = require('@bigbinary/neeto-molecules/ErrorPage');
6
6
  var ramda = require('ramda');
7
7
  var reactRouterDom = require('react-router-dom');
8
+ var reactUtils_PrivateRoute_utils = require('./utils.js');
8
9
  var jsxRuntime = require('react/jsx-runtime');
9
10
  require('../../typeof-D4ZZ_FlZ.js');
11
+ require('./constants.js');
10
12
 
11
- var _excluded = ["condition", "redirectRoute", "errorPage", "permissions"];
13
+ var _excluded = ["condition", "redirectRoute", "errorPage", "permissions", "homeUrl"];
12
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { defineProperty._defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
16
  var PrivateRoute = function PrivateRoute(_ref) {
@@ -20,29 +22,31 @@ var PrivateRoute = function PrivateRoute(_ref) {
20
22
  errorPage = _ref$errorPage === void 0 ? undefined : _ref$errorPage,
21
23
  _ref$permissions = _ref.permissions,
22
24
  permissions = _ref$permissions === void 0 ? undefined : _ref$permissions,
25
+ _ref$homeUrl = _ref.homeUrl,
26
+ homeUrl = _ref$homeUrl === void 0 ? undefined : _ref$homeUrl,
23
27
  props = objectWithoutProperties._objectWithoutProperties(_ref, _excluded);
28
+ var renderErrorPage = function renderErrorPage(errorPage, homeUrl, path) {
29
+ return errorPage || /*#__PURE__*/jsxRuntime.jsx(ErrorPage, {
30
+ homeUrl: homeUrl || reactUtils_PrivateRoute_utils.getHomeUrl(path),
31
+ status: 403
32
+ });
33
+ };
24
34
  if (condition) {
25
35
  if (permissions) {
26
36
  return globalProps.permissions.some(ramda.includes(ramda.__, permissions)) ? /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, _objectSpread({}, props)) : /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, _objectSpread(_objectSpread({}, props), {}, {
27
37
  component: function component() {
28
- return errorPage || /*#__PURE__*/jsxRuntime.jsx(ErrorPage, {
29
- status: 403
30
- });
38
+ return renderErrorPage(errorPage, homeUrl, props.path);
31
39
  }
32
40
  }));
33
41
  }
34
42
  return /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Route, _objectSpread({}, props));
35
43
  }
36
- if (redirectRoute) {
37
- return /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Redirect, {
38
- to: {
39
- pathname: redirectRoute
40
- }
41
- });
42
- }
43
- return errorPage || /*#__PURE__*/jsxRuntime.jsx(ErrorPage, {
44
- status: 403
44
+ if (redirectRoute) return /*#__PURE__*/jsxRuntime.jsx(reactRouterDom.Redirect, {
45
+ to: {
46
+ pathname: redirectRoute
47
+ }
45
48
  });
49
+ return renderErrorPage(errorPage, homeUrl, props.path);
46
50
  };
47
51
 
48
52
  module.exports = PrivateRoute;
@@ -1 +1 @@
1
- {"version":3,"file":"PrivateRoute.js","sources":["../../../../src/react-utils/PrivateRoute/PrivateRoute.jsx"],"sourcesContent":["import ErrorPage from \"neetomolecules/ErrorPage\";\nimport { __, includes } from \"ramda\";\nimport { Redirect, Route } from \"react-router-dom\";\n\nconst PrivateRoute = ({\n condition = globalProps.authenticated,\n redirectRoute = undefined,\n errorPage = undefined,\n permissions = undefined,\n ...props\n}) => {\n if (condition) {\n if (permissions) {\n return globalProps.permissions.some(includes(__, permissions)) ? (\n <Route {...props} />\n ) : (\n <Route\n {...props}\n component={() => errorPage || <ErrorPage status={403} />}\n />\n );\n }\n\n return <Route {...props} />;\n }\n\n if (redirectRoute) {\n return <Redirect to={{ pathname: redirectRoute }} />;\n }\n\n return errorPage || <ErrorPage status={403} />;\n};\n\nexport default PrivateRoute;\n"],"names":["PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","props","_objectWithoutProperties","_excluded","some","includes","__","_jsx","Route","_objectSpread","component","ErrorPage","status","Redirect","to","pathname"],"mappings":";;;;;;;;;;;;;AAIA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAMZ;AAAA,EAAA,IAAAC,cAAA,GAAAD,IAAA,CALJE,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAGE,WAAW,CAACC,aAAa,GAAAH,cAAA;IAAAI,kBAAA,GAAAL,IAAA,CACrCM,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAGE,MAAAA,GAAAA,SAAS,GAAAF,kBAAA;IAAAG,cAAA,GAAAR,IAAA,CACzBS,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAGD,MAAAA,GAAAA,SAAS,GAAAC,cAAA;IAAAE,gBAAA,GAAAV,IAAA,CACrBW,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAGH,MAAAA,GAAAA,SAAS,GAAAG,gBAAA;AACpBE,IAAAA,KAAK,GAAAC,gDAAA,CAAAb,IAAA,EAAAc,SAAA,CAAA;AAER,EAAA,IAAIZ,SAAS,EAAE;AACb,IAAA,IAAIS,WAAW,EAAE;AACf,MAAA,OAAOR,WAAW,CAACQ,WAAW,CAACI,IAAI,CAACC,cAAQ,CAACC,QAAE,EAAEN,WAAW,CAAC,CAAC,gBAC5DO,cAAA,CAACC,oBAAK,EAAAC,aAAA,CAAA,EAAA,EAAKR,KAAK,CAAG,CAAC,gBAEpBM,cAAA,CAACC,oBAAK,EAAAC,aAAA,CAAAA,aAAA,KACAR,KAAK,CAAA,EAAA,EAAA,EAAA;QACTS,SAAS,EAAE,SAAXA,SAASA,GAAA;AAAA,UAAA,OAAQZ,SAAS,iBAAIS,cAAA,CAACI,SAAS,EAAA;AAACC,YAAAA,MAAM,EAAE;AAAI,WAAE,CAAC;AAAA;AAAC,OAAA,CAC1D,CACF;AACH;IAEA,oBAAOL,cAAA,CAACC,oBAAK,EAAAC,aAAA,CAAKR,EAAAA,EAAAA,KAAK,CAAG,CAAC;AAC7B;AAEA,EAAA,IAAIN,aAAa,EAAE;IACjB,oBAAOY,cAAA,CAACM,uBAAQ,EAAA;AAACC,MAAAA,EAAE,EAAE;AAAEC,QAAAA,QAAQ,EAAEpB;AAAc;AAAE,KAAE,CAAC;AACtD;AAEA,EAAA,OAAOG,SAAS,iBAAIS,cAAA,CAACI,SAAS,EAAA;AAACC,IAAAA,MAAM,EAAE;AAAI,GAAE,CAAC;AAChD;;;;"}
1
+ {"version":3,"file":"PrivateRoute.js","sources":["../../../../src/react-utils/PrivateRoute/PrivateRoute.jsx"],"sourcesContent":["import ErrorPage from \"neetomolecules/ErrorPage\";\nimport { __, includes } from \"ramda\";\nimport { Redirect, Route } from \"react-router-dom\";\n\nimport { getHomeUrl } from \"./utils\";\n\nconst PrivateRoute = ({\n condition = globalProps.authenticated,\n redirectRoute = undefined,\n errorPage = undefined,\n permissions = undefined,\n homeUrl = undefined,\n ...props\n}) => {\n const renderErrorPage = (errorPage, homeUrl, path) =>\n errorPage || (\n <ErrorPage homeUrl={homeUrl || getHomeUrl(path)} status={403} />\n );\n\n if (condition) {\n if (permissions) {\n return globalProps.permissions.some(includes(__, permissions)) ? (\n <Route {...props} />\n ) : (\n <Route\n {...props}\n component={() => renderErrorPage(errorPage, homeUrl, props.path)}\n />\n );\n }\n\n return <Route {...props} />;\n }\n\n if (redirectRoute) return <Redirect to={{ pathname: redirectRoute }} />;\n\n return renderErrorPage(errorPage, homeUrl, props.path);\n};\n\nexport default PrivateRoute;\n"],"names":["PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","_ref$homeUrl","homeUrl","props","_objectWithoutProperties","_excluded","renderErrorPage","path","_jsx","ErrorPage","getHomeUrl","status","some","includes","__","Route","_objectSpread","component","Redirect","to","pathname"],"mappings":";;;;;;;;;;;;;;;AAMA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAOZ;AAAA,EAAA,IAAAC,cAAA,GAAAD,IAAA,CANJE,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAGE,WAAW,CAACC,aAAa,GAAAH,cAAA;IAAAI,kBAAA,GAAAL,IAAA,CACrCM,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAGE,MAAAA,GAAAA,SAAS,GAAAF,kBAAA;IAAAG,cAAA,GAAAR,IAAA,CACzBS,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAGD,MAAAA,GAAAA,SAAS,GAAAC,cAAA;IAAAE,gBAAA,GAAAV,IAAA,CACrBW,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAGH,MAAAA,GAAAA,SAAS,GAAAG,gBAAA;IAAAE,YAAA,GAAAZ,IAAA,CACvBa,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAGL,MAAAA,GAAAA,SAAS,GAAAK,YAAA;AAChBE,IAAAA,KAAK,GAAAC,gDAAA,CAAAf,IAAA,EAAAgB,SAAA,CAAA;EAER,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIR,SAAS,EAAEI,OAAO,EAAEK,IAAI,EAAA;AAAA,IAAA,OAC/CT,SAAS,iBACPU,cAAA,CAACC,SAAS,EAAA;AAACP,MAAAA,OAAO,EAAEA,OAAO,IAAIQ,wCAAU,CAACH,IAAI,CAAE;AAACI,MAAAA,MAAM,EAAE;AAAI,KAAE,CAChE;AAAA,GAAA;AAEH,EAAA,IAAIpB,SAAS,EAAE;AACb,IAAA,IAAIS,WAAW,EAAE;AACf,MAAA,OAAOR,WAAW,CAACQ,WAAW,CAACY,IAAI,CAACC,cAAQ,CAACC,QAAE,EAAEd,WAAW,CAAC,CAAC,gBAC5DQ,cAAA,CAACO,oBAAK,EAAAC,aAAA,CAAA,EAAA,EAAKb,KAAK,CAAG,CAAC,gBAEpBK,cAAA,CAACO,oBAAK,EAAAC,aAAA,CAAAA,aAAA,KACAb,KAAK,CAAA,EAAA,EAAA,EAAA;QACTc,SAAS,EAAE,SAAXA,SAASA,GAAA;UAAA,OAAQX,eAAe,CAACR,SAAS,EAAEI,OAAO,EAAEC,KAAK,CAACI,IAAI,CAAC;AAAA;AAAC,OAAA,CAClE,CACF;AACH;IAEA,oBAAOC,cAAA,CAACO,oBAAK,EAAAC,aAAA,CAAKb,EAAAA,EAAAA,KAAK,CAAG,CAAC;AAC7B;AAEA,EAAA,IAAIR,aAAa,EAAE,oBAAOa,cAAA,CAACU,uBAAQ,EAAA;AAACC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,QAAQ,EAAEzB;AAAc;AAAE,GAAE,CAAC;EAEvE,OAAOW,eAAe,CAACR,SAAS,EAAEI,OAAO,EAAEC,KAAK,CAACI,IAAI,CAAC;AACxD;;;;"}
@@ -0,0 +1,8 @@
1
+ 'use strict';
2
+
3
+ var HOME_PATH = "/";
4
+ var ADMIN_PATH = "/admin";
5
+
6
+ exports.ADMIN_PATH = ADMIN_PATH;
7
+ exports.HOME_PATH = HOME_PATH;
8
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../../src/react-utils/PrivateRoute/constants.js"],"sourcesContent":["export const HOME_PATH = \"/\";\nexport const ADMIN_PATH = \"/admin\";\n"],"names":["HOME_PATH","ADMIN_PATH"],"mappings":";;AAAO,IAAMA,SAAS,GAAG;AAClB,IAAMC,UAAU,GAAG;;;;;"}
@@ -7,6 +7,8 @@ require('../../objectWithoutProperties-wSsbHFcG.js');
7
7
  require('@bigbinary/neeto-molecules/ErrorPage');
8
8
  require('ramda');
9
9
  require('react-router-dom');
10
+ require('./utils.js');
11
+ require('./constants.js');
10
12
  require('react/jsx-runtime');
11
13
 
12
14
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ var reactUtils_PrivateRoute_constants = require('./constants.js');
4
+
5
+ var getHomeUrl = function getHomeUrl(path) {
6
+ if (!path) return reactUtils_PrivateRoute_constants.HOME_PATH;
7
+ if (Array.isArray(path)) {
8
+ return path.some(function (p) {
9
+ return p === null || p === void 0 ? void 0 : p.includes(reactUtils_PrivateRoute_constants.ADMIN_PATH);
10
+ }) ? reactUtils_PrivateRoute_constants.ADMIN_PATH : reactUtils_PrivateRoute_constants.HOME_PATH;
11
+ }
12
+ return path.includes(reactUtils_PrivateRoute_constants.ADMIN_PATH) ? reactUtils_PrivateRoute_constants.ADMIN_PATH : reactUtils_PrivateRoute_constants.HOME_PATH;
13
+ };
14
+
15
+ exports.getHomeUrl = getHomeUrl;
16
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../../src/react-utils/PrivateRoute/utils.js"],"sourcesContent":["import { ADMIN_PATH, HOME_PATH } from \"./constants\";\n\nexport const getHomeUrl = path => {\n if (!path) return HOME_PATH;\n\n if (Array.isArray(path)) {\n return path.some(p => p?.includes(ADMIN_PATH)) ? ADMIN_PATH : HOME_PATH;\n }\n\n return path.includes(ADMIN_PATH) ? ADMIN_PATH : HOME_PATH;\n};\n"],"names":["getHomeUrl","path","HOME_PATH","Array","isArray","some","p","includes","ADMIN_PATH"],"mappings":";;;;IAEaA,UAAU,GAAG,SAAbA,UAAUA,CAAGC,IAAI,EAAI;AAChC,EAAA,IAAI,CAACA,IAAI,EAAE,OAAOC,2CAAS;AAE3B,EAAA,IAAIC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,EAAE;AACvB,IAAA,OAAOA,IAAI,CAACI,IAAI,CAAC,UAAAC,CAAC,EAAA;MAAA,OAAIA,CAAC,aAADA,CAAC,KAAA,MAAA,GAAA,MAAA,GAADA,CAAC,CAAEC,QAAQ,CAACC,4CAAU,CAAC;KAAC,CAAA,GAAGA,4CAAU,GAAGN,2CAAS;AACzE;EAEA,OAAOD,IAAI,CAACM,QAAQ,CAACC,4CAAU,CAAC,GAAGA,4CAAU,GAAGN,2CAAS;AAC3D;;;;"}
@@ -49,6 +49,8 @@ require('./HoneybadgerErrorBoundary/utils.js');
49
49
  require('../objectWithoutProperties-wSsbHFcG.js');
50
50
  require('@bigbinary/neeto-molecules/ErrorPage');
51
51
  require('react-router-dom');
52
+ require('./PrivateRoute/utils.js');
53
+ require('./PrivateRoute/constants.js');
52
54
  require('react-helmet');
53
55
  require('../slicedToArray-BcL7fKuL.js');
54
56
  require('../unsupportedIterableToArray-BoHMiKNA.js');
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -3,10 +3,12 @@ import { _ as _objectWithoutProperties } from '../../objectWithoutProperties-DN7
3
3
  import ErrorPage from '@bigbinary/neeto-molecules/ErrorPage';
4
4
  import { includes, __ } from 'ramda';
5
5
  import { Route, Redirect } from 'react-router-dom';
6
+ import { getHomeUrl } from './utils.js';
6
7
  import { jsx } from 'react/jsx-runtime';
7
8
  import '../../typeof-D-UKOauR.js';
9
+ import './constants.js';
8
10
 
9
- var _excluded = ["condition", "redirectRoute", "errorPage", "permissions"];
11
+ var _excluded = ["condition", "redirectRoute", "errorPage", "permissions", "homeUrl"];
10
12
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
13
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
14
  var PrivateRoute = function PrivateRoute(_ref) {
@@ -18,29 +20,31 @@ var PrivateRoute = function PrivateRoute(_ref) {
18
20
  errorPage = _ref$errorPage === void 0 ? undefined : _ref$errorPage,
19
21
  _ref$permissions = _ref.permissions,
20
22
  permissions = _ref$permissions === void 0 ? undefined : _ref$permissions,
23
+ _ref$homeUrl = _ref.homeUrl,
24
+ homeUrl = _ref$homeUrl === void 0 ? undefined : _ref$homeUrl,
21
25
  props = _objectWithoutProperties(_ref, _excluded);
26
+ var renderErrorPage = function renderErrorPage(errorPage, homeUrl, path) {
27
+ return errorPage || /*#__PURE__*/jsx(ErrorPage, {
28
+ homeUrl: homeUrl || getHomeUrl(path),
29
+ status: 403
30
+ });
31
+ };
22
32
  if (condition) {
23
33
  if (permissions) {
24
34
  return globalProps.permissions.some(includes(__, permissions)) ? /*#__PURE__*/jsx(Route, _objectSpread({}, props)) : /*#__PURE__*/jsx(Route, _objectSpread(_objectSpread({}, props), {}, {
25
35
  component: function component() {
26
- return errorPage || /*#__PURE__*/jsx(ErrorPage, {
27
- status: 403
28
- });
36
+ return renderErrorPage(errorPage, homeUrl, props.path);
29
37
  }
30
38
  }));
31
39
  }
32
40
  return /*#__PURE__*/jsx(Route, _objectSpread({}, props));
33
41
  }
34
- if (redirectRoute) {
35
- return /*#__PURE__*/jsx(Redirect, {
36
- to: {
37
- pathname: redirectRoute
38
- }
39
- });
40
- }
41
- return errorPage || /*#__PURE__*/jsx(ErrorPage, {
42
- status: 403
42
+ if (redirectRoute) return /*#__PURE__*/jsx(Redirect, {
43
+ to: {
44
+ pathname: redirectRoute
45
+ }
43
46
  });
47
+ return renderErrorPage(errorPage, homeUrl, props.path);
44
48
  };
45
49
 
46
50
  export { PrivateRoute as default };
@@ -1 +1 @@
1
- {"version":3,"file":"PrivateRoute.js","sources":["../../../src/react-utils/PrivateRoute/PrivateRoute.jsx"],"sourcesContent":["import ErrorPage from \"neetomolecules/ErrorPage\";\nimport { __, includes } from \"ramda\";\nimport { Redirect, Route } from \"react-router-dom\";\n\nconst PrivateRoute = ({\n condition = globalProps.authenticated,\n redirectRoute = undefined,\n errorPage = undefined,\n permissions = undefined,\n ...props\n}) => {\n if (condition) {\n if (permissions) {\n return globalProps.permissions.some(includes(__, permissions)) ? (\n <Route {...props} />\n ) : (\n <Route\n {...props}\n component={() => errorPage || <ErrorPage status={403} />}\n />\n );\n }\n\n return <Route {...props} />;\n }\n\n if (redirectRoute) {\n return <Redirect to={{ pathname: redirectRoute }} />;\n }\n\n return errorPage || <ErrorPage status={403} />;\n};\n\nexport default PrivateRoute;\n"],"names":["PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","props","_objectWithoutProperties","_excluded","some","includes","__","_jsx","Route","_objectSpread","component","ErrorPage","status","Redirect","to","pathname"],"mappings":";;;;;;;;;;;AAIA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAMZ;AAAA,EAAA,IAAAC,cAAA,GAAAD,IAAA,CALJE,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAGE,WAAW,CAACC,aAAa,GAAAH,cAAA;IAAAI,kBAAA,GAAAL,IAAA,CACrCM,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAGE,MAAAA,GAAAA,SAAS,GAAAF,kBAAA;IAAAG,cAAA,GAAAR,IAAA,CACzBS,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAGD,MAAAA,GAAAA,SAAS,GAAAC,cAAA;IAAAE,gBAAA,GAAAV,IAAA,CACrBW,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAGH,MAAAA,GAAAA,SAAS,GAAAG,gBAAA;AACpBE,IAAAA,KAAK,GAAAC,wBAAA,CAAAb,IAAA,EAAAc,SAAA,CAAA;AAER,EAAA,IAAIZ,SAAS,EAAE;AACb,IAAA,IAAIS,WAAW,EAAE;AACf,MAAA,OAAOR,WAAW,CAACQ,WAAW,CAACI,IAAI,CAACC,QAAQ,CAACC,EAAE,EAAEN,WAAW,CAAC,CAAC,gBAC5DO,GAAA,CAACC,KAAK,EAAAC,aAAA,CAAA,EAAA,EAAKR,KAAK,CAAG,CAAC,gBAEpBM,GAAA,CAACC,KAAK,EAAAC,aAAA,CAAAA,aAAA,KACAR,KAAK,CAAA,EAAA,EAAA,EAAA;QACTS,SAAS,EAAE,SAAXA,SAASA,GAAA;AAAA,UAAA,OAAQZ,SAAS,iBAAIS,GAAA,CAACI,SAAS,EAAA;AAACC,YAAAA,MAAM,EAAE;AAAI,WAAE,CAAC;AAAA;AAAC,OAAA,CAC1D,CACF;AACH;IAEA,oBAAOL,GAAA,CAACC,KAAK,EAAAC,aAAA,CAAKR,EAAAA,EAAAA,KAAK,CAAG,CAAC;AAC7B;AAEA,EAAA,IAAIN,aAAa,EAAE;IACjB,oBAAOY,GAAA,CAACM,QAAQ,EAAA;AAACC,MAAAA,EAAE,EAAE;AAAEC,QAAAA,QAAQ,EAAEpB;AAAc;AAAE,KAAE,CAAC;AACtD;AAEA,EAAA,OAAOG,SAAS,iBAAIS,GAAA,CAACI,SAAS,EAAA;AAACC,IAAAA,MAAM,EAAE;AAAI,GAAE,CAAC;AAChD;;;;"}
1
+ {"version":3,"file":"PrivateRoute.js","sources":["../../../src/react-utils/PrivateRoute/PrivateRoute.jsx"],"sourcesContent":["import ErrorPage from \"neetomolecules/ErrorPage\";\nimport { __, includes } from \"ramda\";\nimport { Redirect, Route } from \"react-router-dom\";\n\nimport { getHomeUrl } from \"./utils\";\n\nconst PrivateRoute = ({\n condition = globalProps.authenticated,\n redirectRoute = undefined,\n errorPage = undefined,\n permissions = undefined,\n homeUrl = undefined,\n ...props\n}) => {\n const renderErrorPage = (errorPage, homeUrl, path) =>\n errorPage || (\n <ErrorPage homeUrl={homeUrl || getHomeUrl(path)} status={403} />\n );\n\n if (condition) {\n if (permissions) {\n return globalProps.permissions.some(includes(__, permissions)) ? (\n <Route {...props} />\n ) : (\n <Route\n {...props}\n component={() => renderErrorPage(errorPage, homeUrl, props.path)}\n />\n );\n }\n\n return <Route {...props} />;\n }\n\n if (redirectRoute) return <Redirect to={{ pathname: redirectRoute }} />;\n\n return renderErrorPage(errorPage, homeUrl, props.path);\n};\n\nexport default PrivateRoute;\n"],"names":["PrivateRoute","_ref","_ref$condition","condition","globalProps","authenticated","_ref$redirectRoute","redirectRoute","undefined","_ref$errorPage","errorPage","_ref$permissions","permissions","_ref$homeUrl","homeUrl","props","_objectWithoutProperties","_excluded","renderErrorPage","path","_jsx","ErrorPage","getHomeUrl","status","some","includes","__","Route","_objectSpread","component","Redirect","to","pathname"],"mappings":";;;;;;;;;;;;;AAMA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAOZ;AAAA,EAAA,IAAAC,cAAA,GAAAD,IAAA,CANJE,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAA,MAAA,GAAGE,WAAW,CAACC,aAAa,GAAAH,cAAA;IAAAI,kBAAA,GAAAL,IAAA,CACrCM,aAAa;AAAbA,IAAAA,aAAa,GAAAD,kBAAA,KAAGE,MAAAA,GAAAA,SAAS,GAAAF,kBAAA;IAAAG,cAAA,GAAAR,IAAA,CACzBS,SAAS;AAATA,IAAAA,SAAS,GAAAD,cAAA,KAAGD,MAAAA,GAAAA,SAAS,GAAAC,cAAA;IAAAE,gBAAA,GAAAV,IAAA,CACrBW,WAAW;AAAXA,IAAAA,WAAW,GAAAD,gBAAA,KAAGH,MAAAA,GAAAA,SAAS,GAAAG,gBAAA;IAAAE,YAAA,GAAAZ,IAAA,CACvBa,OAAO;AAAPA,IAAAA,OAAO,GAAAD,YAAA,KAAGL,MAAAA,GAAAA,SAAS,GAAAK,YAAA;AAChBE,IAAAA,KAAK,GAAAC,wBAAA,CAAAf,IAAA,EAAAgB,SAAA,CAAA;EAER,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,CAAIR,SAAS,EAAEI,OAAO,EAAEK,IAAI,EAAA;AAAA,IAAA,OAC/CT,SAAS,iBACPU,GAAA,CAACC,SAAS,EAAA;AAACP,MAAAA,OAAO,EAAEA,OAAO,IAAIQ,UAAU,CAACH,IAAI,CAAE;AAACI,MAAAA,MAAM,EAAE;AAAI,KAAE,CAChE;AAAA,GAAA;AAEH,EAAA,IAAIpB,SAAS,EAAE;AACb,IAAA,IAAIS,WAAW,EAAE;AACf,MAAA,OAAOR,WAAW,CAACQ,WAAW,CAACY,IAAI,CAACC,QAAQ,CAACC,EAAE,EAAEd,WAAW,CAAC,CAAC,gBAC5DQ,GAAA,CAACO,KAAK,EAAAC,aAAA,CAAA,EAAA,EAAKb,KAAK,CAAG,CAAC,gBAEpBK,GAAA,CAACO,KAAK,EAAAC,aAAA,CAAAA,aAAA,KACAb,KAAK,CAAA,EAAA,EAAA,EAAA;QACTc,SAAS,EAAE,SAAXA,SAASA,GAAA;UAAA,OAAQX,eAAe,CAACR,SAAS,EAAEI,OAAO,EAAEC,KAAK,CAACI,IAAI,CAAC;AAAA;AAAC,OAAA,CAClE,CACF;AACH;IAEA,oBAAOC,GAAA,CAACO,KAAK,EAAAC,aAAA,CAAKb,EAAAA,EAAAA,KAAK,CAAG,CAAC;AAC7B;AAEA,EAAA,IAAIR,aAAa,EAAE,oBAAOa,GAAA,CAACU,QAAQ,EAAA;AAACC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,QAAQ,EAAEzB;AAAc;AAAE,GAAE,CAAC;EAEvE,OAAOW,eAAe,CAACR,SAAS,EAAEI,OAAO,EAAEC,KAAK,CAACI,IAAI,CAAC;AACxD;;;;"}
@@ -0,0 +1,5 @@
1
+ var HOME_PATH = "/";
2
+ var ADMIN_PATH = "/admin";
3
+
4
+ export { ADMIN_PATH, HOME_PATH };
5
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sources":["../../../src/react-utils/PrivateRoute/constants.js"],"sourcesContent":["export const HOME_PATH = \"/\";\nexport const ADMIN_PATH = \"/admin\";\n"],"names":["HOME_PATH","ADMIN_PATH"],"mappings":"AAAO,IAAMA,SAAS,GAAG;AAClB,IAAMC,UAAU,GAAG;;;;"}
@@ -5,5 +5,7 @@ import '../../objectWithoutProperties-DN7d1SzH.js';
5
5
  import '@bigbinary/neeto-molecules/ErrorPage';
6
6
  import 'ramda';
7
7
  import 'react-router-dom';
8
+ import './utils.js';
9
+ import './constants.js';
8
10
  import 'react/jsx-runtime';
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;"}
@@ -0,0 +1,14 @@
1
+ import { HOME_PATH, ADMIN_PATH } from './constants.js';
2
+
3
+ var getHomeUrl = function getHomeUrl(path) {
4
+ if (!path) return HOME_PATH;
5
+ if (Array.isArray(path)) {
6
+ return path.some(function (p) {
7
+ return p === null || p === void 0 ? void 0 : p.includes(ADMIN_PATH);
8
+ }) ? ADMIN_PATH : HOME_PATH;
9
+ }
10
+ return path.includes(ADMIN_PATH) ? ADMIN_PATH : HOME_PATH;
11
+ };
12
+
13
+ export { getHomeUrl };
14
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../../../src/react-utils/PrivateRoute/utils.js"],"sourcesContent":["import { ADMIN_PATH, HOME_PATH } from \"./constants\";\n\nexport const getHomeUrl = path => {\n if (!path) return HOME_PATH;\n\n if (Array.isArray(path)) {\n return path.some(p => p?.includes(ADMIN_PATH)) ? ADMIN_PATH : HOME_PATH;\n }\n\n return path.includes(ADMIN_PATH) ? ADMIN_PATH : HOME_PATH;\n};\n"],"names":["getHomeUrl","path","HOME_PATH","Array","isArray","some","p","includes","ADMIN_PATH"],"mappings":";;IAEaA,UAAU,GAAG,SAAbA,UAAUA,CAAGC,IAAI,EAAI;AAChC,EAAA,IAAI,CAACA,IAAI,EAAE,OAAOC,SAAS;AAE3B,EAAA,IAAIC,KAAK,CAACC,OAAO,CAACH,IAAI,CAAC,EAAE;AACvB,IAAA,OAAOA,IAAI,CAACI,IAAI,CAAC,UAAAC,CAAC,EAAA;MAAA,OAAIA,CAAC,aAADA,CAAC,KAAA,MAAA,GAAA,MAAA,GAADA,CAAC,CAAEC,QAAQ,CAACC,UAAU,CAAC;KAAC,CAAA,GAAGA,UAAU,GAAGN,SAAS;AACzE;EAEA,OAAOD,IAAI,CAACM,QAAQ,CAACC,UAAU,CAAC,GAAGA,UAAU,GAAGN,SAAS;AAC3D;;;;"}
@@ -47,6 +47,8 @@ import './HoneybadgerErrorBoundary/utils.js';
47
47
  import '../objectWithoutProperties-DN7d1SzH.js';
48
48
  import '@bigbinary/neeto-molecules/ErrorPage';
49
49
  import 'react-router-dom';
50
+ import './PrivateRoute/utils.js';
51
+ import './PrivateRoute/constants.js';
50
52
  import 'react-helmet';
51
53
  import '../slicedToArray-DmsZvA_9.js';
52
54
  import '../unsupportedIterableToArray-Dqz8Y8_I.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigbinary/neeto-commons-frontend",
3
- "version": "4.13.92",
3
+ "version": "4.13.93",
4
4
  "description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
5
5
  "repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
6
6
  "author": "Amaljith K <amaljith.k@bigbinary.com>",
@@ -83,9 +83,10 @@
83
83
  "@babel/runtime": "7.26.10",
84
84
  "@babel/types": "^7.20.7",
85
85
  "@bigbinary/babel-preset-neeto": "1.0.8",
86
- "@bigbinary/eslint-plugin-neeto": "^1.6.2",
86
+ "@bigbinary/eslint-plugin-neeto": "1.8.0",
87
87
  "@bigbinary/neeto-audit-frontend": "^2.3.1",
88
88
  "@bigbinary/neeto-cist": "1.0.11",
89
+ "@bigbinary/neeto-commons-frontend": "4.4.6",
89
90
  "@bigbinary/neeto-editor": "1.38.1",
90
91
  "@bigbinary/neeto-hotkeys": "^1.0.7",
91
92
  "@bigbinary/neeto-icons": "1.20.5",
@@ -108,6 +109,7 @@
108
109
  "@rollup/plugin-replace": "5.0.4",
109
110
  "@svgr/rollup": "8.1.0",
110
111
  "@tailwindcss/container-queries": "^0.1.1",
112
+ "@tailwindcss/postcss": "^4.1.18",
111
113
  "@tanstack/react-query": "5.59.20",
112
114
  "@tanstack/react-query-devtools": "5.59.20",
113
115
  "@testing-library/jest-dom": "5.16.2",
@@ -179,7 +181,7 @@
179
181
  "postcss-loader": "^7.0.1",
180
182
  "postcss-preset-env": "7.8.2",
181
183
  "prettier": "3",
182
- "prettier-plugin-tailwindcss": "0.6.14",
184
+ "prettier-plugin-tailwindcss": "^0.7.2",
183
185
  "qs": "6.13.0",
184
186
  "ramda": "0.29.1",
185
187
  "react": "18.2.0",
@@ -199,7 +201,7 @@
199
201
  "rollup-plugin-styles": "4.0.0",
200
202
  "sass": "1.62.0",
201
203
  "sass-loader": "^13.0.2",
202
- "tailwindcss": "^3.4.1",
204
+ "tailwindcss": "^4.1.18",
203
205
  "ua-parser-js": "^2.0.3",
204
206
  "unified": "11.0.0",
205
207
  "util": "^0.12.5",
@@ -210,8 +212,9 @@
210
212
  },
211
213
  "peerDependencies": {
212
214
  "@bigbinary/babel-preset-neeto": "1.0.8",
213
- "@bigbinary/eslint-plugin-neeto": "^1.6.2",
215
+ "@bigbinary/eslint-plugin-neeto": "1.8.0",
214
216
  "@bigbinary/neeto-cist": "1.0.11",
217
+ "@bigbinary/neeto-commons-frontend": "4.4.6",
215
218
  "@bigbinary/neeto-editor": "1.38.1",
216
219
  "@bigbinary/neeto-hotkeys": "^1.0.7",
217
220
  "@bigbinary/neeto-icons": "1.20.5",
@@ -224,6 +227,7 @@
224
227
  "@rails/actioncable": "7.2.100",
225
228
  "@svgr/rollup": "8.1.0",
226
229
  "@tailwindcss/container-queries": "^0.1.1",
230
+ "@tailwindcss/postcss": "^4.1.18",
227
231
  "@tanstack/react-query": "5.59.20",
228
232
  "@tanstack/react-query-devtools": "5.59.20",
229
233
  "@tippyjs/react": "4.2.6",
@@ -261,7 +265,7 @@
261
265
  "react-toastify": "8.0.2",
262
266
  "sass": "1.62.0",
263
267
  "shakapacker": "^6.5.5",
264
- "tailwindcss": "^3.4.1",
268
+ "tailwindcss": "^4.1.18",
265
269
  "ua-parser-js": "^2.0.3",
266
270
  "util": "^0.12.5",
267
271
  "uuid": "10.0.0",
package/react-utils.d.ts CHANGED
@@ -180,6 +180,7 @@ export function PrivateRoute(props: {
180
180
  redirectRoute?: string;
181
181
  errorPage?: React.ReactNode;
182
182
  permissions?: string[];
183
+ homeUrl?: string;
183
184
  } & RouteProps): JSX.Element;
184
185
  type OptionsType = {
185
186
  root?: Element | null;