@bigbinary/neeto-commons-frontend 4.13.92 → 4.13.94
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/README.md +1 -0
- package/dist/cjs/react-utils/PrivateRoute/PrivateRoute.js +17 -13
- package/dist/cjs/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
- package/dist/cjs/react-utils/PrivateRoute/constants.js +8 -0
- package/dist/cjs/react-utils/PrivateRoute/constants.js.map +1 -0
- package/dist/cjs/react-utils/PrivateRoute/index.js +2 -0
- package/dist/cjs/react-utils/PrivateRoute/index.js.map +1 -1
- package/dist/cjs/react-utils/PrivateRoute/utils.js +16 -0
- package/dist/cjs/react-utils/PrivateRoute/utils.js.map +1 -0
- package/dist/cjs/react-utils/index.js +5 -0
- package/dist/cjs/react-utils/index.js.map +1 -1
- package/dist/cjs/react-utils/usePrefersReducedMotion/constants.js +6 -0
- package/dist/cjs/react-utils/usePrefersReducedMotion/constants.js.map +1 -0
- package/dist/cjs/react-utils/usePrefersReducedMotion/index.js +12 -0
- package/dist/cjs/react-utils/usePrefersReducedMotion/index.js.map +1 -0
- package/dist/cjs/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js +46 -0
- package/dist/cjs/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js.map +1 -0
- package/dist/react-utils/PrivateRoute/PrivateRoute.js +17 -13
- package/dist/react-utils/PrivateRoute/PrivateRoute.js.map +1 -1
- package/dist/react-utils/PrivateRoute/constants.js +5 -0
- package/dist/react-utils/PrivateRoute/constants.js.map +1 -0
- package/dist/react-utils/PrivateRoute/index.js +2 -0
- package/dist/react-utils/PrivateRoute/index.js.map +1 -1
- package/dist/react-utils/PrivateRoute/utils.js +14 -0
- package/dist/react-utils/PrivateRoute/utils.js.map +1 -0
- package/dist/react-utils/index.js +4 -0
- package/dist/react-utils/index.js.map +1 -1
- package/dist/react-utils/usePrefersReducedMotion/constants.js +4 -0
- package/dist/react-utils/usePrefersReducedMotion/constants.js.map +1 -0
- package/dist/react-utils/usePrefersReducedMotion/index.js +6 -0
- package/dist/react-utils/usePrefersReducedMotion/index.js.map +1 -0
- package/dist/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js +44 -0
- package/dist/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js.map +1 -0
- package/package.json +10 -6
- package/react-utils.d.ts +66 -0
package/README.md
CHANGED
|
@@ -64,6 +64,7 @@ React utilities [↗](./docs/react/README.md)
|
|
|
64
64
|
- [useMutationWithInvalidation](./docs/react/hooks/useMutationWithInvalidation.md)
|
|
65
65
|
- [useFetchNeetoApps](./docs/react/hooks/useFetchNeetoApps.md)
|
|
66
66
|
- [usePersistedQuery](./docs/react/hooks/usePersistedQuery.md)
|
|
67
|
+
- [usePrefersReducedMotion](./docs/react/hooks/usePrefersReducedMotion.md)
|
|
67
68
|
- [useIsElementVisibleInDom](./docs/react/hooks/useIsElementVisibleInDom.md)
|
|
68
69
|
- [useStateWithDependency](./docs/react/hooks/useStateWithDependency.md)
|
|
69
70
|
- [useQueryParams](./docs/react/hooks/useQueryParams.md)
|
|
@@ -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
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
|
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 @@
|
|
|
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;;;;;"}
|
|
@@ -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;;;;"}
|
|
@@ -15,6 +15,7 @@ var reactUtils_useMutationWithInvalidation_useMutationWithInvalidation = require
|
|
|
15
15
|
var reactUtils_useOnClickOutside_useOnClickOutside = require('./useOnClickOutside/useOnClickOutside.js');
|
|
16
16
|
var reactUtils_usePersistedQuery_usePersistedQuery = require('./usePersistedQuery/usePersistedQuery.js');
|
|
17
17
|
var reactUtils_usePrevious_usePrevious = require('./usePrevious/usePrevious.js');
|
|
18
|
+
var reactUtils_usePrefersReducedMotion_usePrefersReducedMotion = require('./usePrefersReducedMotion/usePrefersReducedMotion.js');
|
|
18
19
|
var reactUtils_useQueryParams_useQueryParams = require('./useQueryParams/useQueryParams.js');
|
|
19
20
|
var reactUtils_useRegisterNavigationCheckpoint_useRegisterNavigationCheckpoint = require('./useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js');
|
|
20
21
|
var reactUtils_useStateWithDependency_useStateWithDependency = require('./useStateWithDependency/useStateWithDependency.js');
|
|
@@ -49,6 +50,8 @@ require('./HoneybadgerErrorBoundary/utils.js');
|
|
|
49
50
|
require('../objectWithoutProperties-wSsbHFcG.js');
|
|
50
51
|
require('@bigbinary/neeto-molecules/ErrorPage');
|
|
51
52
|
require('react-router-dom');
|
|
53
|
+
require('./PrivateRoute/utils.js');
|
|
54
|
+
require('./PrivateRoute/constants.js');
|
|
52
55
|
require('react-helmet');
|
|
53
56
|
require('../slicedToArray-BcL7fKuL.js');
|
|
54
57
|
require('../unsupportedIterableToArray-BoHMiKNA.js');
|
|
@@ -77,6 +80,7 @@ require('../lodash-yQg9l0eZ.js');
|
|
|
77
80
|
require('@bigbinary/neeto-time-zones');
|
|
78
81
|
require('ua-parser-js');
|
|
79
82
|
require('@tanstack/react-query');
|
|
83
|
+
require('./usePrefersReducedMotion/constants.js');
|
|
80
84
|
require('./useBreakpoints/utils.js');
|
|
81
85
|
require('./useColumnConfig/useConfigApi.js');
|
|
82
86
|
require('./useColumnConfig/api.js');
|
|
@@ -111,6 +115,7 @@ exports.useMutationWithInvalidation = reactUtils_useMutationWithInvalidation_use
|
|
|
111
115
|
exports.useOnClickOutside = reactUtils_useOnClickOutside_useOnClickOutside;
|
|
112
116
|
exports.usePersistedQuery = reactUtils_usePersistedQuery_usePersistedQuery;
|
|
113
117
|
exports.usePrevious = reactUtils_usePrevious_usePrevious;
|
|
118
|
+
exports.usePrefersReducedMotion = reactUtils_usePrefersReducedMotion_usePrefersReducedMotion;
|
|
114
119
|
exports.useQueryParams = reactUtils_useQueryParams_useQueryParams;
|
|
115
120
|
exports.useNavigationCheckpoints = reactUtils_useRegisterNavigationCheckpoint_useRegisterNavigationCheckpoint.useNavigationCheckpoints;
|
|
116
121
|
exports.useRegisterNavigationCheckpoint = reactUtils_useRegisterNavigationCheckpoint_useRegisterNavigationCheckpoint.default;
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../../src/react-utils/usePrefersReducedMotion/constants.js"],"sourcesContent":["export const QUERY = \"(prefers-reduced-motion: no-preference)\";\n"],"names":["QUERY"],"mappings":";;AAAO,IAAMA,KAAK,GAAG;;;;"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var reactUtils_usePrefersReducedMotion_usePrefersReducedMotion = require('./usePrefersReducedMotion.js');
|
|
4
|
+
require('../../slicedToArray-BcL7fKuL.js');
|
|
5
|
+
require('../../unsupportedIterableToArray-BoHMiKNA.js');
|
|
6
|
+
require('react');
|
|
7
|
+
require('./constants.js');
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
module.exports = reactUtils_usePrefersReducedMotion_usePrefersReducedMotion;
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var slicedToArray = require('../../slicedToArray-BcL7fKuL.js');
|
|
4
|
+
var React = require('react');
|
|
5
|
+
var reactUtils_usePrefersReducedMotion_constants = require('./constants.js');
|
|
6
|
+
require('../../unsupportedIterableToArray-BoHMiKNA.js');
|
|
7
|
+
|
|
8
|
+
var isRenderingOnServer = typeof window === "undefined";
|
|
9
|
+
var getInitialState = function getInitialState() {
|
|
10
|
+
return (
|
|
11
|
+
// For our initial server render, we won't know if the user
|
|
12
|
+
// prefers reduced motion, but it doesn't matter. This value
|
|
13
|
+
// will be overwritten on the client, before any animations
|
|
14
|
+
// occur.
|
|
15
|
+
isRenderingOnServer ? true : !window.matchMedia(reactUtils_usePrefersReducedMotion_constants.QUERY).matches
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
var usePrefersReducedMotion = function usePrefersReducedMotion() {
|
|
19
|
+
var _useState = React.useState(getInitialState),
|
|
20
|
+
_useState2 = slicedToArray._slicedToArray(_useState, 2),
|
|
21
|
+
prefersReducedMotion = _useState2[0],
|
|
22
|
+
setPrefersReducedMotion = _useState2[1];
|
|
23
|
+
React.useEffect(function () {
|
|
24
|
+
if (isRenderingOnServer) return undefined;
|
|
25
|
+
var mediaQueryList = window.matchMedia(reactUtils_usePrefersReducedMotion_constants.QUERY);
|
|
26
|
+
var listener = function listener(event) {
|
|
27
|
+
setPrefersReducedMotion(!event.matches);
|
|
28
|
+
};
|
|
29
|
+
if (mediaQueryList.addEventListener) {
|
|
30
|
+
mediaQueryList.addEventListener("change", listener);
|
|
31
|
+
} else {
|
|
32
|
+
mediaQueryList.addListener(listener);
|
|
33
|
+
}
|
|
34
|
+
return function () {
|
|
35
|
+
if (mediaQueryList.removeEventListener) {
|
|
36
|
+
mediaQueryList.removeEventListener("change", listener);
|
|
37
|
+
} else {
|
|
38
|
+
mediaQueryList.removeListener(listener);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
return prefersReducedMotion;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
module.exports = usePrefersReducedMotion;
|
|
46
|
+
//# sourceMappingURL=usePrefersReducedMotion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrefersReducedMotion.js","sources":["../../../../src/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\nimport { QUERY } from \"./constants\";\n\nconst isRenderingOnServer = typeof window === \"undefined\";\n\nconst getInitialState = () =>\n // For our initial server render, we won't know if the user\n // prefers reduced motion, but it doesn't matter. This value\n // will be overwritten on the client, before any animations\n // occur.\n isRenderingOnServer ? true : !window.matchMedia(QUERY).matches;\n\nconst usePrefersReducedMotion = () => {\n const [prefersReducedMotion, setPrefersReducedMotion] =\n useState(getInitialState);\n\n useEffect(() => {\n if (isRenderingOnServer) return undefined;\n\n const mediaQueryList = window.matchMedia(QUERY);\n\n const listener = event => {\n setPrefersReducedMotion(!event.matches);\n };\n\n if (mediaQueryList.addEventListener) {\n mediaQueryList.addEventListener(\"change\", listener);\n } else {\n mediaQueryList.addListener(listener);\n }\n\n return () => {\n if (mediaQueryList.removeEventListener) {\n mediaQueryList.removeEventListener(\"change\", listener);\n } else {\n mediaQueryList.removeListener(listener);\n }\n };\n }, []);\n\n return prefersReducedMotion;\n};\n\nexport default usePrefersReducedMotion;\n"],"names":["isRenderingOnServer","window","getInitialState","matchMedia","QUERY","matches","usePrefersReducedMotion","_useState","useState","_useState2","_slicedToArray","prefersReducedMotion","setPrefersReducedMotion","useEffect","undefined","mediaQueryList","listener","event","addEventListener","addListener","removeEventListener","removeListener"],"mappings":";;;;;;;AAIA,IAAMA,mBAAmB,GAAG,OAAOC,MAAM,KAAK,WAAW;AAEzD,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,GAAA;AAAA,EAAA;AACnB;AACA;AACA;AACA;IACAF,mBAAmB,GAAG,IAAI,GAAG,CAACC,MAAM,CAACE,UAAU,CAACC,kDAAK,CAAC,CAACC;AAAO;AAAA,CAAA;AAEhE,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,GAAS;AACpC,EAAA,IAAAC,SAAA,GACEC,cAAQ,CAACN,eAAe,CAAC;IAAAO,UAAA,GAAAC,4BAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AADpBI,IAAAA,oBAAoB,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,uBAAuB,GAAAH,UAAA,CAAA,CAAA,CAAA;AAGpDI,EAAAA,eAAS,CAAC,YAAM;IACd,IAAIb,mBAAmB,EAAE,OAAOc,SAAS;AAEzC,IAAA,IAAMC,cAAc,GAAGd,MAAM,CAACE,UAAU,CAACC,kDAAK,CAAC;AAE/C,IAAA,IAAMY,QAAQ,GAAG,SAAXA,QAAQA,CAAGC,KAAK,EAAI;AACxBL,MAAAA,uBAAuB,CAAC,CAACK,KAAK,CAACZ,OAAO,CAAC;KACxC;IAED,IAAIU,cAAc,CAACG,gBAAgB,EAAE;AACnCH,MAAAA,cAAc,CAACG,gBAAgB,CAAC,QAAQ,EAAEF,QAAQ,CAAC;AACrD,KAAC,MAAM;AACLD,MAAAA,cAAc,CAACI,WAAW,CAACH,QAAQ,CAAC;AACtC;AAEA,IAAA,OAAO,YAAM;MACX,IAAID,cAAc,CAACK,mBAAmB,EAAE;AACtCL,QAAAA,cAAc,CAACK,mBAAmB,CAAC,QAAQ,EAAEJ,QAAQ,CAAC;AACxD,OAAC,MAAM;AACLD,QAAAA,cAAc,CAACM,cAAc,CAACL,QAAQ,CAAC;AACzC;KACD;GACF,EAAE,EAAE,CAAC;AAEN,EAAA,OAAOL,oBAAoB;AAC7B;;;;"}
|
|
@@ -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
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
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
|
|
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 @@
|
|
|
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;;;;"}
|
|
@@ -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;;;;"}
|
|
@@ -13,6 +13,7 @@ export { default as useMutationWithInvalidation } from './useMutationWithInvalid
|
|
|
13
13
|
export { default as useOnClickOutside } from './useOnClickOutside/useOnClickOutside.js';
|
|
14
14
|
export { default as usePersistedQuery } from './usePersistedQuery/usePersistedQuery.js';
|
|
15
15
|
export { default as usePrevious } from './usePrevious/usePrevious.js';
|
|
16
|
+
export { default as usePrefersReducedMotion } from './usePrefersReducedMotion/usePrefersReducedMotion.js';
|
|
16
17
|
export { default as useQueryParams } from './useQueryParams/useQueryParams.js';
|
|
17
18
|
export { useNavigationCheckpoints, default as useRegisterNavigationCheckpoint, useRemoveNavigationCheckpoint } from './useRegisterNavigationCheckpoint/useRegisterNavigationCheckpoint.js';
|
|
18
19
|
export { default as useStateWithDependency } from './useStateWithDependency/useStateWithDependency.js';
|
|
@@ -47,6 +48,8 @@ import './HoneybadgerErrorBoundary/utils.js';
|
|
|
47
48
|
import '../objectWithoutProperties-DN7d1SzH.js';
|
|
48
49
|
import '@bigbinary/neeto-molecules/ErrorPage';
|
|
49
50
|
import 'react-router-dom';
|
|
51
|
+
import './PrivateRoute/utils.js';
|
|
52
|
+
import './PrivateRoute/constants.js';
|
|
50
53
|
import 'react-helmet';
|
|
51
54
|
import '../slicedToArray-DmsZvA_9.js';
|
|
52
55
|
import '../unsupportedIterableToArray-Dqz8Y8_I.js';
|
|
@@ -75,6 +78,7 @@ import '../lodash-M8VRFvKw.js';
|
|
|
75
78
|
import '@bigbinary/neeto-time-zones';
|
|
76
79
|
import 'ua-parser-js';
|
|
77
80
|
import '@tanstack/react-query';
|
|
81
|
+
import './usePrefersReducedMotion/constants.js';
|
|
78
82
|
import './useBreakpoints/utils.js';
|
|
79
83
|
import './useColumnConfig/useConfigApi.js';
|
|
80
84
|
import './useColumnConfig/api.js';
|
|
@@ -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 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/react-utils/usePrefersReducedMotion/constants.js"],"sourcesContent":["export const QUERY = \"(prefers-reduced-motion: no-preference)\";\n"],"names":["QUERY"],"mappings":"AAAO,IAAMA,KAAK,GAAG;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { _ as _slicedToArray } from '../../slicedToArray-DmsZvA_9.js';
|
|
2
|
+
import { useState, useEffect } from 'react';
|
|
3
|
+
import { QUERY } from './constants.js';
|
|
4
|
+
import '../../unsupportedIterableToArray-Dqz8Y8_I.js';
|
|
5
|
+
|
|
6
|
+
var isRenderingOnServer = typeof window === "undefined";
|
|
7
|
+
var getInitialState = function getInitialState() {
|
|
8
|
+
return (
|
|
9
|
+
// For our initial server render, we won't know if the user
|
|
10
|
+
// prefers reduced motion, but it doesn't matter. This value
|
|
11
|
+
// will be overwritten on the client, before any animations
|
|
12
|
+
// occur.
|
|
13
|
+
isRenderingOnServer ? true : !window.matchMedia(QUERY).matches
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
var usePrefersReducedMotion = function usePrefersReducedMotion() {
|
|
17
|
+
var _useState = useState(getInitialState),
|
|
18
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
19
|
+
prefersReducedMotion = _useState2[0],
|
|
20
|
+
setPrefersReducedMotion = _useState2[1];
|
|
21
|
+
useEffect(function () {
|
|
22
|
+
if (isRenderingOnServer) return undefined;
|
|
23
|
+
var mediaQueryList = window.matchMedia(QUERY);
|
|
24
|
+
var listener = function listener(event) {
|
|
25
|
+
setPrefersReducedMotion(!event.matches);
|
|
26
|
+
};
|
|
27
|
+
if (mediaQueryList.addEventListener) {
|
|
28
|
+
mediaQueryList.addEventListener("change", listener);
|
|
29
|
+
} else {
|
|
30
|
+
mediaQueryList.addListener(listener);
|
|
31
|
+
}
|
|
32
|
+
return function () {
|
|
33
|
+
if (mediaQueryList.removeEventListener) {
|
|
34
|
+
mediaQueryList.removeEventListener("change", listener);
|
|
35
|
+
} else {
|
|
36
|
+
mediaQueryList.removeListener(listener);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}, []);
|
|
40
|
+
return prefersReducedMotion;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export { usePrefersReducedMotion as default };
|
|
44
|
+
//# sourceMappingURL=usePrefersReducedMotion.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrefersReducedMotion.js","sources":["../../../src/react-utils/usePrefersReducedMotion/usePrefersReducedMotion.js"],"sourcesContent":["import { useState, useEffect } from \"react\";\n\nimport { QUERY } from \"./constants\";\n\nconst isRenderingOnServer = typeof window === \"undefined\";\n\nconst getInitialState = () =>\n // For our initial server render, we won't know if the user\n // prefers reduced motion, but it doesn't matter. This value\n // will be overwritten on the client, before any animations\n // occur.\n isRenderingOnServer ? true : !window.matchMedia(QUERY).matches;\n\nconst usePrefersReducedMotion = () => {\n const [prefersReducedMotion, setPrefersReducedMotion] =\n useState(getInitialState);\n\n useEffect(() => {\n if (isRenderingOnServer) return undefined;\n\n const mediaQueryList = window.matchMedia(QUERY);\n\n const listener = event => {\n setPrefersReducedMotion(!event.matches);\n };\n\n if (mediaQueryList.addEventListener) {\n mediaQueryList.addEventListener(\"change\", listener);\n } else {\n mediaQueryList.addListener(listener);\n }\n\n return () => {\n if (mediaQueryList.removeEventListener) {\n mediaQueryList.removeEventListener(\"change\", listener);\n } else {\n mediaQueryList.removeListener(listener);\n }\n };\n }, []);\n\n return prefersReducedMotion;\n};\n\nexport default usePrefersReducedMotion;\n"],"names":["isRenderingOnServer","window","getInitialState","matchMedia","QUERY","matches","usePrefersReducedMotion","_useState","useState","_useState2","_slicedToArray","prefersReducedMotion","setPrefersReducedMotion","useEffect","undefined","mediaQueryList","listener","event","addEventListener","addListener","removeEventListener","removeListener"],"mappings":";;;;;AAIA,IAAMA,mBAAmB,GAAG,OAAOC,MAAM,KAAK,WAAW;AAEzD,IAAMC,eAAe,GAAG,SAAlBA,eAAeA,GAAA;AAAA,EAAA;AACnB;AACA;AACA;AACA;IACAF,mBAAmB,GAAG,IAAI,GAAG,CAACC,MAAM,CAACE,UAAU,CAACC,KAAK,CAAC,CAACC;AAAO;AAAA,CAAA;AAEhE,IAAMC,uBAAuB,GAAG,SAA1BA,uBAAuBA,GAAS;AACpC,EAAA,IAAAC,SAAA,GACEC,QAAQ,CAACN,eAAe,CAAC;IAAAO,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AADpBI,IAAAA,oBAAoB,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,uBAAuB,GAAAH,UAAA,CAAA,CAAA,CAAA;AAGpDI,EAAAA,SAAS,CAAC,YAAM;IACd,IAAIb,mBAAmB,EAAE,OAAOc,SAAS;AAEzC,IAAA,IAAMC,cAAc,GAAGd,MAAM,CAACE,UAAU,CAACC,KAAK,CAAC;AAE/C,IAAA,IAAMY,QAAQ,GAAG,SAAXA,QAAQA,CAAGC,KAAK,EAAI;AACxBL,MAAAA,uBAAuB,CAAC,CAACK,KAAK,CAACZ,OAAO,CAAC;KACxC;IAED,IAAIU,cAAc,CAACG,gBAAgB,EAAE;AACnCH,MAAAA,cAAc,CAACG,gBAAgB,CAAC,QAAQ,EAAEF,QAAQ,CAAC;AACrD,KAAC,MAAM;AACLD,MAAAA,cAAc,CAACI,WAAW,CAACH,QAAQ,CAAC;AACtC;AAEA,IAAA,OAAO,YAAM;MACX,IAAID,cAAc,CAACK,mBAAmB,EAAE;AACtCL,QAAAA,cAAc,CAACK,mBAAmB,CAAC,QAAQ,EAAEJ,QAAQ,CAAC;AACxD,OAAC,MAAM;AACLD,QAAAA,cAAc,CAACM,cAAc,CAACL,QAAQ,CAAC;AACzC;KACD;GACF,EAAE,EAAE,CAAC;AAEN,EAAA,OAAOL,oBAAoB;AAC7B;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "4.13.
|
|
3
|
+
"version": "4.13.94",
|
|
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": "
|
|
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.
|
|
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": "^
|
|
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": "
|
|
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": "^
|
|
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;
|
|
@@ -526,6 +527,71 @@ export function useOnClickOutside<T>(ref: React.MutableRefObject<T>, handler: (e
|
|
|
526
527
|
*
|
|
527
528
|
*/
|
|
528
529
|
export function usePrevious<T>(value: T): T;
|
|
530
|
+
/**
|
|
531
|
+
*
|
|
532
|
+
* The usePrefersReducedMotion hook is a utility that detects whether the user has
|
|
533
|
+
*
|
|
534
|
+
* preferred reduced motion enabled in their system settings. This is particularly
|
|
535
|
+
*
|
|
536
|
+
* useful for creating accessible user interfaces that respect user preferences for
|
|
537
|
+
*
|
|
538
|
+
* motion and animations. The hook listens to changes in the user's motion
|
|
539
|
+
*
|
|
540
|
+
* preferences and updates accordingly.
|
|
541
|
+
*
|
|
542
|
+
* This hook uses the CSS media query (prefers-reduced-motion: no-preference) to
|
|
543
|
+
*
|
|
544
|
+
* determine if the user prefers reduced motion. When the user has reduced motion
|
|
545
|
+
*
|
|
546
|
+
* enabled, the media query will not match, and the hook will return true.
|
|
547
|
+
*
|
|
548
|
+
* This hook does not accept any arguments.
|
|
549
|
+
*
|
|
550
|
+
* The following code snippet demonstrates the usage of usePrefersReducedMotion to
|
|
551
|
+
*
|
|
552
|
+
* conditionally apply animations based on user preferences.
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
*
|
|
556
|
+
* import { usePrefersReducedMotion } from "@bigbinary/neeto-commons-frontend/react-utils";
|
|
557
|
+
*
|
|
558
|
+
* const MyComponent = () => {
|
|
559
|
+
* const prefersReducedMotion = usePrefersReducedMotion();
|
|
560
|
+
*
|
|
561
|
+
* return (
|
|
562
|
+
* <div
|
|
563
|
+
* className={prefersReducedMotion ? "static" : "animate-fade-in"}
|
|
564
|
+
* >
|
|
565
|
+
* Content that respects motion preferences
|
|
566
|
+
* </div>
|
|
567
|
+
* );
|
|
568
|
+
* };
|
|
569
|
+
* @endexample
|
|
570
|
+
* You can also use this hook to conditionally render animation libraries or
|
|
571
|
+
*
|
|
572
|
+
* components:
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
*
|
|
576
|
+
* import { usePrefersReducedMotion } from "@bigbinary/neeto-commons-frontend/react-utils";
|
|
577
|
+
* import { motion } from "framer-motion";
|
|
578
|
+
*
|
|
579
|
+
* const AnimatedComponent = ({ children }) => {
|
|
580
|
+
* const prefersReducedMotion = usePrefersReducedMotion();
|
|
581
|
+
*
|
|
582
|
+
* return (
|
|
583
|
+
* <motion.div
|
|
584
|
+
* initial={{ opacity: 0 }}
|
|
585
|
+
* animate={{ opacity: 1 }}
|
|
586
|
+
* transition={{ duration: prefersReducedMotion ? 0 : 0.5 }}
|
|
587
|
+
* >
|
|
588
|
+
* {children}
|
|
589
|
+
* </motion.div>
|
|
590
|
+
* );
|
|
591
|
+
* };
|
|
592
|
+
* @endexample
|
|
593
|
+
*/
|
|
594
|
+
export function usePrefersReducedMotion(): boolean;
|
|
529
595
|
/**
|
|
530
596
|
*
|
|
531
597
|
* The useUpdateEffect hook is a variation of the standard useEffect hook in
|