@edx/frontend-platform 8.1.5 → 8.2.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-platform",
3
- "version": "8.1.5",
3
+ "version": "8.2.0",
4
4
  "description": "Foundational application framework for Open edX micro-frontend applications.",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -34,20 +34,20 @@
34
34
  "homepage": "https://github.com/openedx/frontend-platform#readme",
35
35
  "devDependencies": {
36
36
  "@edx/brand": "npm:@openedx/brand-openedx@^1.2.2",
37
- "@edx/browserslist-config": "1.4.0",
38
- "@openedx/frontend-build": "14.2.2",
39
- "@openedx/paragon": "22.13.0",
37
+ "@edx/browserslist-config": "1.5.0",
38
+ "@openedx/frontend-build": "^14.3.0",
39
+ "@openedx/paragon": "22.15.1",
40
40
  "@testing-library/jest-dom": "6.6.3",
41
- "@testing-library/react": "12.1.5",
42
- "@testing-library/react-hooks": "^8.0.1",
41
+ "@testing-library/react": "16.2.0",
42
+ "@testing-library/dom": "10.4.0",
43
43
  "axios-mock-adapter": "^1.22.0",
44
44
  "husky": "8.0.3",
45
45
  "jest-environment-jsdom": "29.7.0",
46
46
  "jsdoc": "^4.0.0",
47
47
  "nodemon": "3.1.9",
48
48
  "prop-types": "15.8.1",
49
- "react": "17.0.2",
50
- "react-dom": "17.0.2",
49
+ "react": "18.3.1",
50
+ "react-dom": "18.3.1",
51
51
  "react-redux": "^8.1.1",
52
52
  "react-router-dom": "^6.6.1",
53
53
  "redux": "4.2.1"
@@ -56,7 +56,7 @@
56
56
  "@cospired/i18n-iso-languages": "4.2.0",
57
57
  "@formatjs/intl-pluralrules": "4.3.3",
58
58
  "@formatjs/intl-relativetimeformat": "10.0.1",
59
- "axios": "1.6.7",
59
+ "axios": "1.7.9",
60
60
  "axios-cache-interceptor": "1.6.2",
61
61
  "form-urlencoded": "4.1.4",
62
62
  "glob": "7.2.3",
@@ -77,10 +77,18 @@
77
77
  "@openedx/frontend-build": ">= 14.0.0",
78
78
  "@openedx/paragon": ">= 21.5.7 < 23.0.0",
79
79
  "prop-types": ">=15.7.2 <16.0.0",
80
- "react": "^16.9.0 || ^17.0.0",
81
- "react-dom": "^16.9.0 || ^17.0.0",
80
+ "react": "^16.9.0 || ^17.0.0 || ^18.0.0",
81
+ "react-dom": "^16.9.0 || ^17.0.0 || ^18.0.0",
82
82
  "react-redux": "^7.1.1 || ^8.1.1",
83
83
  "react-router-dom": "^6.0.0",
84
84
  "redux": "^4.0.4"
85
+ },
86
+ "peerDependenciesMeta": {
87
+ "redux": {
88
+ "optional": true
89
+ },
90
+ "react-redux": {
91
+ "optional": true
92
+ }
85
93
  }
86
94
  }
@@ -44,9 +44,11 @@ import { basename } from '../initialize';
44
44
  * @memberof module:React
45
45
  */
46
46
  export default function AppProvider(_ref) {
47
- var store = _ref.store,
47
+ var _ref$store = _ref.store,
48
+ store = _ref$store === void 0 ? null : _ref$store,
48
49
  children = _ref.children,
49
- wrapWithRouter = _ref.wrapWithRouter;
50
+ _ref$wrapWithRouter = _ref.wrapWithRouter,
51
+ wrapWithRouter = _ref$wrapWithRouter === void 0 ? true : _ref$wrapWithRouter;
50
52
  var _useState = useState(getConfig()),
51
53
  _useState2 = _slicedToArray(_useState, 2),
52
54
  config = _useState2[0],
@@ -90,13 +92,8 @@ export default function AppProvider(_ref) {
90
92
  }, children)) : children))));
91
93
  }
92
94
  AppProvider.propTypes = {
93
- // eslint-disable-next-line react/forbid-prop-types
94
- store: PropTypes.object,
95
+ store: PropTypes.shape(),
95
96
  children: PropTypes.node.isRequired,
96
97
  wrapWithRouter: PropTypes.bool
97
98
  };
98
- AppProvider.defaultProps = {
99
- store: null,
100
- wrapWithRouter: true
101
- };
102
99
  //# sourceMappingURL=AppProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AppProvider.js","names":["React","useState","useMemo","PropTypes","BrowserRouter","Router","OptionalReduxProvider","ErrorBoundary","AppContext","useAppEvent","useTrackColorSchemeChoice","getAuthenticatedUser","AUTHENTICATED_USER_CHANGED","getConfig","CONFIG_CHANGED","getLocale","getMessages","IntlProvider","LOCALE_CHANGED","basename","AppProvider","_ref","store","children","wrapWithRouter","_useState","_useState2","_slicedToArray","config","setConfig","_useState3","_useState4","authenticatedUser","setAuthenticatedUser","_useState5","_useState6","locale","setLocale","appContextValue","createElement","messages","Provider","value","propTypes","object","node","isRequired","bool","defaultProps"],"sources":["../../src/react/AppProvider.jsx"],"sourcesContent":["import React, { useState, useMemo } from 'react';\nimport PropTypes from 'prop-types';\nimport { BrowserRouter as Router } from 'react-router-dom';\n\nimport OptionalReduxProvider from './OptionalReduxProvider';\n\nimport ErrorBoundary from './ErrorBoundary';\nimport AppContext from './AppContext';\nimport { useAppEvent, useTrackColorSchemeChoice } from './hooks';\nimport { getAuthenticatedUser, AUTHENTICATED_USER_CHANGED } from '../auth';\nimport { getConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\nimport {\n getLocale,\n getMessages,\n IntlProvider,\n LOCALE_CHANGED,\n} from '../i18n';\nimport { basename } from '../initialize';\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * subscribe(APP_READY, () => {\n * ReactDOM.render(\n * <AppProvider>\n * <HelloWorld />\n * </AppProvider>\n * )\n * });\n * ```\n *\n * This will provide the following to HelloWorld:\n * - An error boundary as described above.\n * - An `AppContext` provider for React context data.\n * - IntlProvider for @edx/frontend-i18n internationalization\n * - Optionally a redux `Provider`. Will only be included if a `store` property is passed to\n * `AppProvider`.\n * - A `Router` for react-router.\n *\n * @param {Object} props\n * @param {Object} [props.store] A redux store.\n * @memberof module:React\n */\nexport default function AppProvider({ store, children, wrapWithRouter }) {\n const [config, setConfig] = useState(getConfig());\n const [authenticatedUser, setAuthenticatedUser] = useState(getAuthenticatedUser());\n const [locale, setLocale] = useState(getLocale());\n\n useTrackColorSchemeChoice();\n\n useAppEvent(AUTHENTICATED_USER_CHANGED, () => {\n setAuthenticatedUser(getAuthenticatedUser());\n });\n\n useAppEvent(CONFIG_CHANGED, () => {\n setConfig(getConfig());\n });\n\n useAppEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n const appContextValue = useMemo(() => ({ authenticatedUser, config, locale }), [authenticatedUser, config, locale]);\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <AppContext.Provider\n value={appContextValue}\n >\n <OptionalReduxProvider store={store}>\n {wrapWithRouter ? (\n <Router basename={basename}>\n <div data-testid=\"browser-router\">\n {children}\n </div>\n </Router>\n ) : children}\n </OptionalReduxProvider>\n </AppContext.Provider>\n </ErrorBoundary>\n </IntlProvider>\n );\n}\n\nAppProvider.propTypes = {\n // eslint-disable-next-line react/forbid-prop-types\n store: PropTypes.object,\n children: PropTypes.node.isRequired,\n wrapWithRouter: PropTypes.bool,\n};\n\nAppProvider.defaultProps = {\n store: null,\n wrapWithRouter: true,\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,aAAa,IAAIC,MAAM,QAAQ,kBAAkB;AAE1D,OAAOC,qBAAqB,MAAM,yBAAyB;AAE3D,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,SAASC,WAAW,EAAEC,yBAAyB,QAAQ,SAAS;AAChE,SAASC,oBAAoB,EAAEC,0BAA0B,QAAQ,SAAS;AAC1E,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,cAAc,QAAQ,cAAc;AAC7C,SACEC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,cAAc,QACT,SAAS;AAChB,SAASC,QAAQ,QAAQ,eAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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AiB,EAAEJ,MAAM,EAAEQ,MAAM,CAAC,CAAC;EAEnH,oBACEpC,KAAA,CAAAuC,aAAA,CAACtB,YAAY;IAACmB,MAAM,EAAEA,MAAO;IAACI,QAAQ,EAAExB,WAAW,CAAC;EAAE,gBACpDhB,KAAA,CAAAuC,aAAA,CAAChC,aAAa,qBACZP,KAAA,CAAAuC,aAAA,CAAC/B,UAAU,CAACiC,QAAQ;IAClBC,KAAK,EAAEJ;EAAgB,gBAEvBtC,KAAA,CAAAuC,aAAA,CAACjC,qBAAqB;IAACgB,KAAK,EAAEA;EAAM,GACjCE,cAAc,gBACbxB,KAAA,CAAAuC,aAAA,CAAClC,MAAM;IAACc,QAAQ,EAAEA;EAAS,gBACzBnB,KAAA,CAAAuC,aAAA;IAAK,eAAY;EAAgB,GAC9BhB,QACE,CACC,CAAC,GACPA,QACiB,CACJ,CACR,CACH,CAAC;AAEnB;AAEAH,WAAW,CAACuB,SAAS,GAAG;EACtB;EACArB,KAAK,EAAEnB,SAAS,CAACyC,MAAM;EACvBrB,QAAQ,EAAEpB,SAAS,CAAC0C,IAAI,CAACC,UAAU;EACnCtB,cAAc,EAAErB,SAAS,CAAC4C;AAC5B,CAAC;AAED3B,WAAW,CAAC4B,YAAY,GAAG;EACzB1B,KAAK,EAAE,IAAI;EACXE,cAAc,EAAE;AAClB,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"AppProvider.js","names":["React","useState","useMemo","PropTypes","BrowserRouter","Router","OptionalReduxProvider","ErrorBoundary","AppContext","useAppEvent","useTrackColorSchemeChoice","getAuthenticatedUser","AUTHENTICATED_USER_CHANGED","getConfig","CONFIG_CHANGED","getLocale","getMessages","IntlProvider","LOCALE_CHANGED","basename","AppProvider","_ref","_ref$store","store","children","_ref$wrapWithRouter","wrapWithRouter","_useState","_useState2","_slicedToArray","config","setConfig","_useState3","_useState4","authenticatedUser","setAuthenticatedUser","_useState5","_useState6","locale","setLocale","appContextValue","createElement","messages","Provider","value","propTypes","shape","node","isRequired","bool"],"sources":["../../src/react/AppProvider.jsx"],"sourcesContent":["import React, { useState, useMemo } from 'react';\nimport PropTypes from 'prop-types';\nimport { BrowserRouter as Router } from 'react-router-dom';\n\nimport OptionalReduxProvider from './OptionalReduxProvider';\n\nimport ErrorBoundary from './ErrorBoundary';\nimport AppContext from './AppContext';\nimport { useAppEvent, useTrackColorSchemeChoice } from './hooks';\nimport { getAuthenticatedUser, AUTHENTICATED_USER_CHANGED } from '../auth';\nimport { getConfig } from '../config';\nimport { CONFIG_CHANGED } from '../constants';\nimport {\n getLocale,\n getMessages,\n IntlProvider,\n LOCALE_CHANGED,\n} from '../i18n';\nimport { basename } from '../initialize';\n\n/**\n * A wrapper component for React-based micro-frontends to initialize a number of common data/\n * context providers.\n *\n * ```\n * subscribe(APP_READY, () => {\n * ReactDOM.render(\n * <AppProvider>\n * <HelloWorld />\n * </AppProvider>\n * )\n * });\n * ```\n *\n * This will provide the following to HelloWorld:\n * - An error boundary as described above.\n * - An `AppContext` provider for React context data.\n * - IntlProvider for @edx/frontend-i18n internationalization\n * - Optionally a redux `Provider`. Will only be included if a `store` property is passed to\n * `AppProvider`.\n * - A `Router` for react-router.\n *\n * @param {Object} props\n * @param {Object} [props.store] A redux store.\n * @memberof module:React\n */\nexport default function AppProvider({ store = null, children, wrapWithRouter = true }) {\n const [config, setConfig] = useState(getConfig());\n const [authenticatedUser, setAuthenticatedUser] = useState(getAuthenticatedUser());\n const [locale, setLocale] = useState(getLocale());\n\n useTrackColorSchemeChoice();\n\n useAppEvent(AUTHENTICATED_USER_CHANGED, () => {\n setAuthenticatedUser(getAuthenticatedUser());\n });\n\n useAppEvent(CONFIG_CHANGED, () => {\n setConfig(getConfig());\n });\n\n useAppEvent(LOCALE_CHANGED, () => {\n setLocale(getLocale());\n });\n\n const appContextValue = useMemo(() => ({ authenticatedUser, config, locale }), [authenticatedUser, config, locale]);\n\n return (\n <IntlProvider locale={locale} messages={getMessages()}>\n <ErrorBoundary>\n <AppContext.Provider\n value={appContextValue}\n >\n <OptionalReduxProvider store={store}>\n {wrapWithRouter ? (\n <Router basename={basename}>\n <div data-testid=\"browser-router\">\n {children}\n </div>\n </Router>\n ) : children}\n </OptionalReduxProvider>\n </AppContext.Provider>\n </ErrorBoundary>\n </IntlProvider>\n );\n}\n\nAppProvider.propTypes = {\n store: PropTypes.shape(),\n children: PropTypes.node.isRequired,\n wrapWithRouter: PropTypes.bool,\n};\n"],"mappings":";;;;;;AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,OAAO,QAAQ,OAAO;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,aAAa,IAAIC,MAAM,QAAQ,kBAAkB;AAE1D,OAAOC,qBAAqB,MAAM,yBAAyB;AAE3D,OAAOC,aAAa,MAAM,iBAAiB;AAC3C,OAAOC,UAAU,MAAM,cAAc;AACrC,SAASC,WAAW,EAAEC,yBAAyB,QAAQ,SAAS;AAChE,SAASC,oBAAoB,EAAEC,0BAA0B,QAAQ,SAAS;AAC1E,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,cAAc,QAAQ,cAAc;AAC7C,SACEC,SAAS,EACTC,WAAW,EACXC,YAAY,EACZC,cAAc,QACT,SAAS;AAChB,SAASC,QAAQ,QAAQ,eAAe;;AAExC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,WAAWA,CAAAC,IAAA,EAAoD;EAAA,IAAAC,UAAA,GAAAD,IAAA,CAAjDE,KAAK;IAALA,KAAK,GAAAD,UAAA,cAAG,IAAI,GAAAA,UAAA;IAAEE,QAAQ,GAAAH,IAAA,CAARG,QAAQ;IAAAC,mBAAA,GAAAJ,IAAA,CAAEK,cAAc;IAAdA,cAAc,GAAAD,mBAAA,cAAG,IAAI,GAAAA,mBAAA;EACjF,IAAAE,SAAA,GAA4B1B,QAAQ,CAACY,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BC,KAAK,EAAEJ;EAAgB,gBAEvBxC,KAAA,CAAAyC,aAAA,CAACnC,qBAAqB;IAACiB,KAAK,EAAEA;EAAM,GACjCG,cAAc,gBACb1B,KAAA,CAAAyC,aAAA,CAACpC,MAAM;IAACc,QAAQ,EAAEA;EAAS,gBACzBnB,KAAA,CAAAyC,aAAA;IAAK,eAAY;EAAgB,GAC9BjB,QACE,CACC,CAAC,GACPA,QACiB,CACJ,CACR,CACH,CAAC;AAEnB;AAEAJ,WAAW,CAACyB,SAAS,GAAG;EACtBtB,KAAK,EAAEpB,SAAS,CAAC2C,KAAK,CAAC,CAAC;EACxBtB,QAAQ,EAAErB,SAAS,CAAC4C,IAAI,CAACC,UAAU;EACnCtB,cAAc,EAAEvB,SAAS,CAAC8C;AAC5B,CAAC","ignoreList":[]}
@@ -18,11 +18,12 @@ import { getLoginRedirectUrl } from '../auth';
18
18
  * @see {@link module:frontend-platform/analytics~sendPageEvent}
19
19
  * @memberof module:React
20
20
  * @param {Object} props
21
- * @param {string} props.redirectUrl The URL anonymous users should be redirected to, rather than
21
+ * @param {string} [props.redirectUrl] The URL anonymous users should be redirected to, rather than
22
22
  * viewing the route's contents.
23
23
  */
24
24
  export default function AuthenticatedPageRoute(_ref) {
25
- var redirectUrl = _ref.redirectUrl,
25
+ var _ref$redirectUrl = _ref.redirectUrl,
26
+ redirectUrl = _ref$redirectUrl === void 0 ? null : _ref$redirectUrl,
26
27
  children = _ref.children;
27
28
  var _useContext = useContext(AppContext),
28
29
  authenticatedUser = _useContext.authenticatedUser;
@@ -37,7 +38,4 @@ AuthenticatedPageRoute.propTypes = {
37
38
  redirectUrl: PropTypes.string,
38
39
  children: PropTypes.node.isRequired
39
40
  };
40
- AuthenticatedPageRoute.defaultProps = {
41
- redirectUrl: null
42
- };
43
41
  //# sourceMappingURL=AuthenticatedPageRoute.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AuthenticatedPageRoute.js","names":["React","useContext","PropTypes","AppContext","PageWrap","getLoginRedirectUrl","AuthenticatedPageRoute","_ref","redirectUrl","children","_useContext","authenticatedUser","destination","global","location","href","assign","createElement","propTypes","string","node","isRequired","defaultProps"],"sources":["../../src/react/AuthenticatedPageRoute.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\n\nimport AppContext from './AppContext';\nimport PageWrap from './PageWrap';\nimport { getLoginRedirectUrl } from '../auth';\n\n/**\n * A react-router route that redirects to the login page when the route becomes active and the user\n * is not authenticated. If the application has been initialized with `requireAuthenticatedUser`\n * false, an authenticatedPageRoute can be used to protect a subset of the application's routes,\n * rather than the entire application.\n *\n * It can optionally accept an override URL to redirect to instead of the login page.\n *\n * Like a `PageWrap`, also calls `sendPageEvent` when the route becomes active.\n *\n * @see PageWrap\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n * @param {string} props.redirectUrl The URL anonymous users should be redirected to, rather than\n * viewing the route's contents.\n */\nexport default function AuthenticatedPageRoute({ redirectUrl, children }) {\n const { authenticatedUser } = useContext(AppContext);\n if (authenticatedUser === null) {\n const destination = redirectUrl || getLoginRedirectUrl(global.location.href);\n global.location.assign(destination);\n\n return null;\n }\n\n return (\n <PageWrap>\n {children}\n </PageWrap>\n );\n}\n\nAuthenticatedPageRoute.propTypes = {\n redirectUrl: PropTypes.string,\n children: PropTypes.node.isRequired,\n};\n\nAuthenticatedPageRoute.defaultProps = {\n redirectUrl: null,\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,SAAS,MAAM,YAAY;AAElC,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,mBAAmB,QAAQ,SAAS;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,sBAAsBA,CAAAC,IAAA,EAA4B;EAAA,IAAzBC,WAAW,GAAAD,IAAA,CAAXC,WAAW;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EACpE,IAAAC,WAAA,GAA8BT,UAAU,CAACE,UAAU,CAAC;IAA5CQ,iBAAiB,GAAAD,WAAA,CAAjBC,iBAAiB;EACzB,IAAIA,iBAAiB,KAAK,IAAI,EAAE;IAC9B,IAAMC,WAAW,GAAGJ,WAAW,IAAIH,mBAAmB,CAACQ,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC;IAC5EF,MAAM,CAACC,QAAQ,CAACE,MAAM,CAACJ,WAAW,CAAC;IAEnC,OAAO,IAAI;EACb;EAEA,oBACEZ,KAAA,CAAAiB,aAAA,CAACb,QAAQ,QACNK,QACO,CAAC;AAEf;AAEAH,sBAAsB,CAACY,SAAS,GAAG;EACjCV,WAAW,EAAEN,SAAS,CAACiB,MAAM;EAC7BV,QAAQ,EAAEP,SAAS,CAACkB,IAAI,CAACC;AAC3B,CAAC;AAEDf,sBAAsB,CAACgB,YAAY,GAAG;EACpCd,WAAW,EAAE;AACf,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"AuthenticatedPageRoute.js","names":["React","useContext","PropTypes","AppContext","PageWrap","getLoginRedirectUrl","AuthenticatedPageRoute","_ref","_ref$redirectUrl","redirectUrl","children","_useContext","authenticatedUser","destination","global","location","href","assign","createElement","propTypes","string","node","isRequired"],"sources":["../../src/react/AuthenticatedPageRoute.jsx"],"sourcesContent":["import React, { useContext } from 'react';\nimport PropTypes from 'prop-types';\n\nimport AppContext from './AppContext';\nimport PageWrap from './PageWrap';\nimport { getLoginRedirectUrl } from '../auth';\n\n/**\n * A react-router route that redirects to the login page when the route becomes active and the user\n * is not authenticated. If the application has been initialized with `requireAuthenticatedUser`\n * false, an authenticatedPageRoute can be used to protect a subset of the application's routes,\n * rather than the entire application.\n *\n * It can optionally accept an override URL to redirect to instead of the login page.\n *\n * Like a `PageWrap`, also calls `sendPageEvent` when the route becomes active.\n *\n * @see PageWrap\n * @see {@link module:frontend-platform/analytics~sendPageEvent}\n * @memberof module:React\n * @param {Object} props\n * @param {string} [props.redirectUrl] The URL anonymous users should be redirected to, rather than\n * viewing the route's contents.\n */\nexport default function AuthenticatedPageRoute({ redirectUrl = null, children }) {\n const { authenticatedUser } = useContext(AppContext);\n if (authenticatedUser === null) {\n const destination = redirectUrl || getLoginRedirectUrl(global.location.href);\n global.location.assign(destination);\n\n return null;\n }\n\n return (\n <PageWrap>\n {children}\n </PageWrap>\n );\n}\n\nAuthenticatedPageRoute.propTypes = {\n redirectUrl: PropTypes.string,\n children: PropTypes.node.isRequired,\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,UAAU,QAAQ,OAAO;AACzC,OAAOC,SAAS,MAAM,YAAY;AAElC,OAAOC,UAAU,MAAM,cAAc;AACrC,OAAOC,QAAQ,MAAM,YAAY;AACjC,SAASC,mBAAmB,QAAQ,SAAS;;AAE7C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,sBAAsBA,CAAAC,IAAA,EAAmC;EAAA,IAAAC,gBAAA,GAAAD,IAAA,CAAhCE,WAAW;IAAXA,WAAW,GAAAD,gBAAA,cAAG,IAAI,GAAAA,gBAAA;IAAEE,QAAQ,GAAAH,IAAA,CAARG,QAAQ;EAC3E,IAAAC,WAAA,GAA8BV,UAAU,CAACE,UAAU,CAAC;IAA5CS,iBAAiB,GAAAD,WAAA,CAAjBC,iBAAiB;EACzB,IAAIA,iBAAiB,KAAK,IAAI,EAAE;IAC9B,IAAMC,WAAW,GAAGJ,WAAW,IAAIJ,mBAAmB,CAACS,MAAM,CAACC,QAAQ,CAACC,IAAI,CAAC;IAC5EF,MAAM,CAACC,QAAQ,CAACE,MAAM,CAACJ,WAAW,CAAC;IAEnC,OAAO,IAAI;EACb;EAEA,oBACEb,KAAA,CAAAkB,aAAA,CAACd,QAAQ,QACNM,QACO,CAAC;AAEf;AAEAJ,sBAAsB,CAACa,SAAS,GAAG;EACjCV,WAAW,EAAEP,SAAS,CAACkB,MAAM;EAC7BV,QAAQ,EAAER,SAAS,CAACmB,IAAI,CAACC;AAC3B,CAAC","ignoreList":[]}
@@ -1,29 +1,41 @@
1
- import React from 'react';
1
+ import React, { lazy, Suspense } from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { Provider } from 'react-redux';
3
+ var DynamicProvider = /*#__PURE__*/lazy(function () {
4
+ return import('react-redux').then(function (module) {
5
+ return {
6
+ "default": module.Provider
7
+ };
8
+ })["catch"](function () {
9
+ return {
10
+ "default": function _default(_ref) {
11
+ var children = _ref.children;
12
+ return children;
13
+ }
14
+ };
15
+ });
16
+ });
4
17
 
5
18
  /**
6
19
  * @memberof module:React
7
20
  * @param {Object} props
8
21
  */
9
- export default function OptionalReduxProvider(_ref) {
10
- var store = _ref.store,
11
- children = _ref.children;
22
+ export default function OptionalReduxProvider(_ref2) {
23
+ var _ref2$store = _ref2.store,
24
+ store = _ref2$store === void 0 ? null : _ref2$store,
25
+ children = _ref2.children;
12
26
  if (store === null) {
13
27
  return children;
14
28
  }
15
- return /*#__PURE__*/React.createElement(Provider, {
29
+ return /*#__PURE__*/React.createElement(Suspense, {
30
+ fallback: null
31
+ }, /*#__PURE__*/React.createElement(DynamicProvider, {
16
32
  store: store
17
33
  }, /*#__PURE__*/React.createElement("div", {
18
34
  "data-testid": "redux-provider"
19
- }, children));
35
+ }, children)));
20
36
  }
21
37
  OptionalReduxProvider.propTypes = {
22
- store: PropTypes.object,
23
- // eslint-disable-line
38
+ store: PropTypes.shape(),
24
39
  children: PropTypes.node.isRequired
25
40
  };
26
- OptionalReduxProvider.defaultProps = {
27
- store: null
28
- };
29
41
  //# sourceMappingURL=OptionalReduxProvider.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionalReduxProvider.js","names":["React","PropTypes","Provider","OptionalReduxProvider","_ref","store","children","createElement","propTypes","object","node","isRequired","defaultProps"],"sources":["../../src/react/OptionalReduxProvider.jsx"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport { Provider } from 'react-redux';\n\n/**\n * @memberof module:React\n * @param {Object} props\n */\nexport default function OptionalReduxProvider({ store, children }) {\n if (store === null) {\n return children;\n }\n\n return (\n <Provider store={store}>\n <div data-testid=\"redux-provider\">\n {children}\n </div>\n </Provider>\n );\n}\n\nOptionalReduxProvider.propTypes = {\n store: PropTypes.object, // eslint-disable-line\n children: PropTypes.node.isRequired,\n};\n\nOptionalReduxProvider.defaultProps = {\n store: null,\n};\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,QAAQ,QAAQ,aAAa;;AAEtC;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAAC,IAAA,EAAsB;EAAA,IAAnBC,KAAK,GAAAD,IAAA,CAALC,KAAK;IAAEC,QAAQ,GAAAF,IAAA,CAARE,QAAQ;EAC7D,IAAID,KAAK,KAAK,IAAI,EAAE;IAClB,OAAOC,QAAQ;EACjB;EAEA,oBACEN,KAAA,CAAAO,aAAA,CAACL,QAAQ;IAACG,KAAK,EAAEA;EAAM,gBACrBL,KAAA,CAAAO,aAAA;IAAK,eAAY;EAAgB,GAC9BD,QACE,CACG,CAAC;AAEf;AAEAH,qBAAqB,CAACK,SAAS,GAAG;EAChCH,KAAK,EAAEJ,SAAS,CAACQ,MAAM;EAAE;EACzBH,QAAQ,EAAEL,SAAS,CAACS,IAAI,CAACC;AAC3B,CAAC;AAEDR,qBAAqB,CAACS,YAAY,GAAG;EACnCP,KAAK,EAAE;AACT,CAAC","ignoreList":[]}
1
+ {"version":3,"file":"OptionalReduxProvider.js","names":["React","lazy","Suspense","PropTypes","DynamicProvider","then","module","Provider","default","_ref","children","OptionalReduxProvider","_ref2","_ref2$store","store","createElement","fallback","propTypes","shape","node","isRequired"],"sources":["../../src/react/OptionalReduxProvider.jsx"],"sourcesContent":["import React, { lazy, Suspense } from 'react';\nimport PropTypes from 'prop-types';\n\nconst DynamicProvider = lazy(() => import('react-redux')\n .then((module) => ({ default: module.Provider }))\n .catch(() => ({ default: ({ children }) => children })));\n\n/**\n * @memberof module:React\n * @param {Object} props\n */\nexport default function OptionalReduxProvider({ store = null, children }) {\n if (store === null) {\n return children;\n }\n\n return (\n <Suspense fallback={null}>\n <DynamicProvider store={store}>\n <div data-testid=\"redux-provider\">\n {children}\n </div>\n </DynamicProvider>\n </Suspense>\n );\n}\n\nOptionalReduxProvider.propTypes = {\n store: PropTypes.shape(),\n children: PropTypes.node.isRequired,\n};\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,IAAI,EAAEC,QAAQ,QAAQ,OAAO;AAC7C,OAAOC,SAAS,MAAM,YAAY;AAElC,IAAMC,eAAe,gBAAGH,IAAI,CAAC;EAAA,OAAM,MAAM,CAAC,aAAa,CAAC,CACrDI,IAAI,CAAC,UAACC,MAAM;IAAA,OAAM;MAAE,WAASA,MAAM,CAACC;IAAS,CAAC;EAAA,CAAC,CAAC,SAC3C,CAAC;IAAA,OAAO;MAAE,WAAS,SAATC,QAAOA,CAAAC,IAAA;QAAA,IAAKC,QAAQ,GAAAD,IAAA,CAARC,QAAQ;QAAA,OAAOA,QAAQ;MAAA;IAAC,CAAC;EAAA,CAAC,CAAC;AAAA,EAAC;;AAE1D;AACA;AACA;AACA;AACA,eAAe,SAASC,qBAAqBA,CAAAC,KAAA,EAA6B;EAAA,IAAAC,WAAA,GAAAD,KAAA,CAA1BE,KAAK;IAALA,KAAK,GAAAD,WAAA,cAAG,IAAI,GAAAA,WAAA;IAAEH,QAAQ,GAAAE,KAAA,CAARF,QAAQ;EACpE,IAAII,KAAK,KAAK,IAAI,EAAE;IAClB,OAAOJ,QAAQ;EACjB;EAEA,oBACEV,KAAA,CAAAe,aAAA,CAACb,QAAQ;IAACc,QAAQ,EAAE;EAAK,gBACvBhB,KAAA,CAAAe,aAAA,CAACX,eAAe;IAACU,KAAK,EAAEA;EAAM,gBAC5Bd,KAAA,CAAAe,aAAA;IAAK,eAAY;EAAgB,GAC9BL,QACE,CACU,CACT,CAAC;AAEf;AAEAC,qBAAqB,CAACM,SAAS,GAAG;EAChCH,KAAK,EAAEX,SAAS,CAACe,KAAK,CAAC,CAAC;EACxBR,QAAQ,EAAEP,SAAS,CAACgB,IAAI,CAACC;AAC3B,CAAC","ignoreList":[]}