@zengenti/contensis-react-base 3.0.2-beta.32 → 3.0.2-beta.34

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.
Files changed (58) hide show
  1. package/cjs/{App-21a7d836.js → App-c74fb1ff.js} +8 -8
  2. package/cjs/App-c74fb1ff.js.map +1 -0
  3. package/cjs/{ContensisDeliveryApi-c079b03a.js → ContensisDeliveryApi-c373405a.js} +154 -121
  4. package/cjs/ContensisDeliveryApi-c373405a.js.map +1 -0
  5. package/cjs/{RouteLoader-7f0d107a.js → RouteLoader-c048673f.js} +3 -3
  6. package/cjs/{RouteLoader-7f0d107a.js.map → RouteLoader-c048673f.js.map} +1 -1
  7. package/cjs/{ToJs-6e9cfa69.js → ToJs-c5bbd17a.js} +2 -2
  8. package/cjs/{ToJs-6e9cfa69.js.map → ToJs-c5bbd17a.js.map} +1 -1
  9. package/cjs/client.js +8 -8
  10. package/cjs/contensis-react-base.js +8 -8
  11. package/cjs/forms.js +3 -1
  12. package/cjs/forms.js.map +1 -1
  13. package/cjs/{login-2a6b5be0.js → login-3df93749.js} +3 -3
  14. package/cjs/{login-2a6b5be0.js.map → login-3df93749.js.map} +1 -1
  15. package/cjs/redux.js +3 -3
  16. package/cjs/routing.js +3 -3
  17. package/cjs/{selectors-bcca60f4.js → selectors-c7873cd7.js} +2 -1
  18. package/cjs/{selectors-bcca60f4.js.map → selectors-c7873cd7.js.map} +1 -1
  19. package/cjs/user.js +3 -3
  20. package/cjs/util.js +3 -3
  21. package/cjs/{version-4077e706.js → version-6998435a.js} +2 -2
  22. package/cjs/{version-4077e706.js.map → version-6998435a.js.map} +1 -1
  23. package/cjs/{version-fe28099e.js → version-fe0119b6.js} +3 -3
  24. package/cjs/{version-fe28099e.js.map → version-fe0119b6.js.map} +1 -1
  25. package/esm/{App-2af18a99.js → App-ade8773a.js} +8 -8
  26. package/esm/App-ade8773a.js.map +1 -0
  27. package/esm/{ContensisDeliveryApi-5660ee0e.js → ContensisDeliveryApi-5bb364b9.js} +154 -121
  28. package/esm/ContensisDeliveryApi-5bb364b9.js.map +1 -0
  29. package/esm/{RouteLoader-6eac364e.js → RouteLoader-e6c2c8d6.js} +3 -3
  30. package/esm/{RouteLoader-6eac364e.js.map → RouteLoader-e6c2c8d6.js.map} +1 -1
  31. package/esm/{ToJs-9b30636a.js → ToJs-7233c038.js} +2 -2
  32. package/esm/{ToJs-9b30636a.js.map → ToJs-7233c038.js.map} +1 -1
  33. package/esm/client.js +9 -9
  34. package/esm/contensis-react-base.js +9 -9
  35. package/esm/forms.js +3 -1
  36. package/esm/forms.js.map +1 -1
  37. package/esm/{login-71ff3fcb.js → login-c3cfb5ad.js} +3 -3
  38. package/esm/{login-71ff3fcb.js.map → login-c3cfb5ad.js.map} +1 -1
  39. package/esm/redux.js +6 -6
  40. package/esm/routing.js +3 -3
  41. package/esm/{selectors-74de49a3.js → selectors-ff21e98a.js} +2 -2
  42. package/esm/{selectors-74de49a3.js.map → selectors-ff21e98a.js.map} +1 -1
  43. package/esm/user.js +4 -4
  44. package/esm/util.js +3 -3
  45. package/esm/{version-b15807c5.js → version-88653900.js} +3 -3
  46. package/esm/{version-b15807c5.js.map → version-88653900.js.map} +1 -1
  47. package/esm/{version-ef107106.js → version-aebe50f2.js} +2 -2
  48. package/esm/{version-ef107106.js.map → version-aebe50f2.js.map} +1 -1
  49. package/models/routing/util/queries.d.ts +3 -2
  50. package/models/user/util/CookieConstants.d.ts +8 -0
  51. package/models/util/CachedDeliveryApi.d.ts +25 -0
  52. package/models/util/ContensisDeliveryApi.d.ts +20 -44
  53. package/models/util/LruCache.d.ts +12 -0
  54. package/package.json +1 -1
  55. package/cjs/App-21a7d836.js.map +0 -1
  56. package/cjs/ContensisDeliveryApi-c079b03a.js.map +0 -1
  57. package/esm/App-2af18a99.js.map +0 -1
  58. package/esm/ContensisDeliveryApi-5660ee0e.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"RouteLoader-7f0d107a.js","sources":["../src/routing/components/NotFound.tsx","../src/routing/components/Status.tsx","../src/routing/components/RouteLoader.tsx"],"sourcesContent":["import React from 'react';\n\nconst NotFound = ({\n statusCode,\n statusText,\n}: {\n statusCode: number;\n statusText: string;\n}) => (\n <>\n <header>\n <h1>{statusCode || '404'} Page Not Found</h1>\n {statusText && (\n <h2\n style={{\n background: '#eee',\n color: '#666',\n fontSize: '100%',\n padding: '10px',\n }}\n >\n {statusText}\n </h2>\n )}\n </header>\n </>\n);\n\nexport default NotFound;\n","import React, { PropsWithChildren } from 'react';\nimport { Route } from 'react-router-dom';\n\nexport const Status = ({\n code,\n children,\n}: PropsWithChildren<{ code: number }>) => {\n return (\n <Route\n render={({ staticContext }) => {\n if (staticContext) staticContext.statusCode = code;\n return children;\n }}\n />\n );\n};\n","import React, { useEffect, useCallback } from 'react';\nimport { connect } from 'react-redux';\nimport { hot } from 'react-hot-loader';\nimport { Redirect, useLocation } from 'react-router-dom';\nimport { renderRoutes, matchRoutes, RouteConfig } from 'react-router-config';\nimport { createSelector } from 'reselect';\n\nimport NotFound from './NotFound';\nimport { Status } from './Status';\n\nimport {\n selectCurrentPath,\n selectCurrentProject,\n selectIsNotFound,\n selectMappedEntry,\n selectRouteEntry,\n selectRouteEntryContentTypeId,\n selectRouteErrorMessage,\n selectRouteIsError,\n selectRouteLoading,\n selectRouteStatusCode,\n} from '../redux/selectors';\nimport { setNavigationPath } from '../redux/actions';\n\nimport {\n selectUserGroups,\n selectUserIsAuthenticated,\n} from '~/user/redux/selectors';\nimport { matchUserGroup } from '~/user/util/matchGroups';\n\nimport { toJS } from '~/util/ToJs';\nimport { Entry } from 'contensis-delivery-api/lib/models';\nimport { AppRootProps, RouteComponentProps, RouteLoaderProps } from '../routes';\n\nconst replaceDoubleSlashRecursive = (path: string) => {\n const nextPath = path.replace(/\\/\\//, '/');\n\n if (nextPath.match(/\\/\\//)) {\n return replaceDoubleSlashRecursive(nextPath);\n }\n\n return nextPath;\n};\n\nconst getTrimmedPath = path => {\n if (path !== '/') {\n const nextPath = replaceDoubleSlashRecursive(path);\n const lastChar = nextPath[nextPath.length - 1];\n if (lastChar === '/') {\n return nextPath.substring(0, nextPath.length - 1);\n }\n }\n return path;\n};\n\ninterface IReduxProps {\n contentTypeId: string | null;\n entry: Entry | null;\n isError: boolean;\n isNotFound: boolean;\n isLoading: boolean;\n isLoggedIn: boolean;\n mappedEntry: any;\n projectId: string;\n setNavigationPath: typeof setNavigationPath;\n statePath: string;\n statusCode: any;\n statusText: string;\n userGroups: any;\n}\n\nconst RouteLoader = ({\n contentTypeId,\n entry,\n isError,\n isLoading,\n isLoggedIn,\n isNotFound,\n loadingComponent,\n mappedEntry,\n notFoundComponent,\n projectId,\n routes,\n setNavigationPath,\n statePath,\n statusCode,\n statusText,\n userGroups,\n withEvents,\n trailingSlashRedirectCode = 302,\n}: AppRootProps & RouteLoaderProps & IReduxProps) => {\n const location = useLocation();\n // Always ensure paths are trimmed of trailing slashes so urls are always unique\n const trimmedPath = getTrimmedPath(location.pathname);\n\n // Match any Static Routes a developer has defined\n const matchedStaticRoute = () =>\n matchRoutes(routes.StaticRoutes as RouteConfig[], location.pathname);\n const isStaticRoute = () => matchedStaticRoute().length > 0;\n\n const staticRoute = isStaticRoute() && matchedStaticRoute()[0];\n const routeRequiresLogin = staticRoute && staticRoute.route.requireLogin;\n\n const setPath = useCallback(() => {\n // Use serverPath to control the path we send to siteview node api to resolve a route\n let serverPath = '';\n if (staticRoute && staticRoute.match && staticRoute.match.isExact) {\n const { match, route } = staticRoute;\n\n if (route.path?.includes('*')) {\n // Send the whole url to api if we have matched route containing wildcard\n serverPath = match.url;\n } else if (typeof route.fetchNodeLevel === 'number') {\n // Send all url parts to a specified level to api\n serverPath = match.url\n .split('/')\n .splice(0, route.fetchNodeLevel + 1)\n .join('/');\n } else if (route.fetchNode?.params) {\n const fetchNodeParams: string[] = route.fetchNode.params;\n const routeParams: { [key: string]: string } = match.params;\n\n const regexExp = new RegExp(\n Object.keys(routeParams)\n .map(p => `:${p}`)\n .join('|'),\n 'g'\n );\n\n serverPath = match.path\n .replace(/\\?/g, '')\n .replace(regexExp, matched => {\n const param = matched.replace(':', '');\n if (fetchNodeParams.includes(param)) return routeParams[param];\n else return '';\n })\n .replace(/\\/$/, '');\n } else {\n // Send all non-parameterised url parts to api\n serverPath = (route.path as string)\n ?.split('/')\n .filter(p => !p.startsWith(':'))\n .join('/');\n }\n }\n\n setNavigationPath(\n serverPath || trimmedPath,\n location,\n staticRoute,\n withEvents,\n statePath,\n routes\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n setNavigationPath,\n // staticRoute,\n withEvents,\n location,\n routes,\n // statePath,\n trimmedPath,\n ]);\n\n if (typeof window == 'undefined') setPath();\n\n useEffect(() => {\n setPath();\n }, [location, setPath]);\n\n // Need to redirect when url endswith a /\n if (location.pathname.length > trimmedPath.length) {\n return (\n <Status code={trailingSlashRedirectCode}>\n <Redirect to={`${trimmedPath}${location.search}${location.hash}`} />\n </Status>\n );\n }\n\n // Render any Static Routes a developer has defined\n if (isStaticRoute() && !(!isLoggedIn && routeRequiresLogin)) {\n if (matchUserGroup(userGroups, routeRequiresLogin))\n return renderRoutes(\n routes.StaticRoutes as RouteConfig[],\n {\n projectId,\n contentTypeId,\n entry,\n mappedEntry,\n isLoggedIn,\n } as RouteComponentProps\n );\n }\n\n // Render a supplied Loading component if the route\n // is not a static route and is in a loading state\n if (isLoading && !isNotFound && loadingComponent) {\n const LoadingComponent = loadingComponent;\n return <LoadingComponent />;\n }\n\n // Match any defined Content Type Mappings\n if (contentTypeId && !(!isLoggedIn && routeRequiresLogin)) {\n const MatchedComponent = routes.ContentTypeMappings.find(\n item => item.contentTypeID === contentTypeId\n );\n\n if (MatchedComponent && !(MatchedComponent.requireLogin && !isLoggedIn)) {\n if (matchUserGroup(userGroups, MatchedComponent.requireLogin))\n return (\n <MatchedComponent.component\n projectId={projectId}\n contentTypeId={contentTypeId}\n entry={entry}\n mappedEntry={mappedEntry}\n isLoggedIn={isLoggedIn}\n />\n );\n }\n }\n\n const NotFoundComponent = notFoundComponent ? notFoundComponent : NotFound;\n if (isNotFound || isError) {\n return (\n <Status code={statusCode}>\n <NotFoundComponent statusCode={statusCode} statusText={statusText} />\n </Status>\n );\n }\n\n return null;\n};\nconst mapStateToPropsMemoized = createSelector(\n selectRouteEntryContentTypeId,\n selectRouteEntry,\n selectRouteIsError,\n selectIsNotFound,\n selectRouteLoading,\n selectUserIsAuthenticated,\n selectMappedEntry,\n selectCurrentProject,\n selectCurrentPath,\n selectRouteStatusCode,\n selectRouteErrorMessage,\n selectUserGroups,\n (\n contentTypeId,\n entry,\n isError,\n isNotFound,\n isLoading,\n isLoggedIn,\n mappedEntry,\n projectId,\n statePath,\n statusCode,\n statusText,\n userGroups\n ) => ({\n contentTypeId,\n entry,\n isError,\n isNotFound,\n isLoading,\n isLoggedIn,\n mappedEntry,\n projectId,\n statePath,\n statusCode,\n statusText,\n userGroups,\n })\n);\n\nconst mapDispatchToProps = {\n setNavigationPath,\n};\n\nexport default hot(module)(\n connect(mapStateToPropsMemoized, mapDispatchToProps)(toJS(RouteLoader))\n) as unknown as (props: AppRootProps & RouteLoaderProps) => JSX.Element;\n"],"names":["NotFound","statusCode","statusText","React","createElement","Fragment","style","background","color","fontSize","padding","Status","code","children","Route","render","staticContext","replaceDoubleSlashRecursive","path","nextPath","replace","match","getTrimmedPath","lastChar","length","substring","RouteLoader","contentTypeId","entry","isError","isLoading","isLoggedIn","isNotFound","loadingComponent","mappedEntry","notFoundComponent","projectId","routes","setNavigationPath","statePath","userGroups","withEvents","trailingSlashRedirectCode","location","useLocation","trimmedPath","pathname","matchedStaticRoute","matchRoutes","StaticRoutes","isStaticRoute","staticRoute","routeRequiresLogin","route","requireLogin","setPath","useCallback","serverPath","isExact","_route$path","_route$fetchNode","includes","url","fetchNodeLevel","split","splice","join","fetchNode","params","fetchNodeParams","routeParams","regexExp","RegExp","Object","keys","map","p","matched","param","_route$path2","filter","startsWith","window","useEffect","Redirect","to","search","hash","matchUserGroup","renderRoutes","LoadingComponent","MatchedComponent","ContentTypeMappings","find","item","contentTypeID","component","NotFoundComponent","mapStateToPropsMemoized","createSelector","selectRouteEntryContentTypeId","selectRouteEntry","selectRouteIsError","selectIsNotFound","selectRouteLoading","selectUserIsAuthenticated","selectMappedEntry","selectCurrentProject","selectCurrentPath","selectRouteStatusCode","selectRouteErrorMessage","selectUserGroups","mapDispatchToProps","hot","module","connect","toJS"],"mappings":";;;;;;;;;;;;;;;AAEA,MAAMA,QAAQ,GAAGA,CAAC;EAChBC,UAAU;AACVC,EAAAA,UAAAA;AAIF,CAAC,kBACCC,yBAAA,CAAAC,aAAA,CAAAD,yBAAA,CAAAE,QAAA,EACEF,IAAAA,eAAAA,yBAAA,CAAAC,aAAA,CACED,QAAAA,EAAAA,IAAAA,eAAAA,yBAAA,CAAAC,aAAA,CAAKH,IAAAA,EAAAA,IAAAA,EAAAA,UAAU,IAAI,KAAK,EAAC,iBAAe,CAAK,EAC5CC,UAAU,iBACTC,yBAAA,CAAAC,aAAA,CAAA,IAAA,EAAA;AACEE,EAAAA,KAAK,EAAE;AACLC,IAAAA,UAAU,EAAE,MAAM;AAClBC,IAAAA,KAAK,EAAE,MAAM;AACbC,IAAAA,QAAQ,EAAE,MAAM;AAChBC,IAAAA,OAAO,EAAE,MAAA;AACX,GAAA;AAAE,CAEDR,EAAAA,UAAU,CAEd,CACM,CAEZ;;ACvBM,MAAMS,MAAM,GAAGA,CAAC;EACrBC,IAAI;AACJC,EAAAA,QAAAA;AACmC,CAAC,KAAK;AACzC,EAAA,oBACEV,yBAAA,CAAAC,aAAA,CAACU,oBAAK,EAAA;AACJC,IAAAA,MAAM,EAAEA,CAAC;AAAEC,MAAAA,aAAAA;AAAc,KAAC,KAAK;AAC7B,MAAA,IAAIA,aAAa,EAAEA,aAAa,CAACf,UAAU,GAAGW,IAAI,CAAA;AAClD,MAAA,OAAOC,QAAQ,CAAA;AACjB,KAAA;G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EAChBC,4BAAkB,EAClBC,0BAAgB,EAChBC,4BAAkB,EAClBC,8BAAyB,EACzBC,2BAAiB,EACjBC,8BAAoB,EACpBC,2BAAiB,EACjBC,+BAAqB,EACrBC,iCAAuB,EACvBC,qBAAgB,EAChB,CACEpF,aAAa,EACbC,KAAK,EACLC,OAAO,EACPG,UAAU,EACVF,SAAS,EACTC,UAAU,EACVG,WAAW,EACXE,SAAS,EACTG,SAAS,EACTtC,UAAU,EACVC,UAAU,EACVsC,UAAU,MACN;EACJb,aAAa;EACbC,KAAK;EACLC,OAAO;EACPG,UAAU;EACVF,SAAS;EACTC,UAAU;EACVG,WAAW;EACXE,SAAS;EACTG,SAAS;EACTtC,UAAU;EACVC,UAAU;AACVsC,EAAAA,UAAAA;AACF,CAAC,CAAC,CACH,CAAA;AAED,MAAMwE,kBAAkB,GAAG;AACzB1E,qBAAAA,2BAAAA;AACF,CAAC,CAAA;AAED,oBAAe2E,kBAAG,CAACC,MAAM,CAAC,CACxBC,kBAAO,CAACjB,uBAAuB,EAAEc,kBAAkB,CAAC,CAACI,SAAI,CAAC1F,WAAW,CAAC,CAAC,CACxE;;;;"}
1
+ {"version":3,"file":"RouteLoader-c048673f.js","sources":["../src/routing/components/NotFound.tsx","../src/routing/components/Status.tsx","../src/routing/components/RouteLoader.tsx"],"sourcesContent":["import React from 'react';\n\nconst NotFound = ({\n statusCode,\n statusText,\n}: {\n statusCode: number;\n statusText: string;\n}) => (\n <>\n <header>\n <h1>{statusCode || '404'} Page Not Found</h1>\n {statusText && (\n <h2\n style={{\n background: '#eee',\n color: '#666',\n fontSize: '100%',\n padding: '10px',\n }}\n >\n {statusText}\n </h2>\n )}\n </header>\n </>\n);\n\nexport default NotFound;\n","import React, { PropsWithChildren } from 'react';\nimport { Route } from 'react-router-dom';\n\nexport const Status = ({\n code,\n children,\n}: PropsWithChildren<{ code: number }>) => {\n return (\n <Route\n render={({ staticContext }) => {\n if (staticContext) staticContext.statusCode = code;\n return children;\n }}\n />\n );\n};\n","import React, { useEffect, useCallback } from 'react';\nimport { connect } from 'react-redux';\nimport { hot } from 'react-hot-loader';\nimport { Redirect, useLocation } from 'react-router-dom';\nimport { renderRoutes, matchRoutes, RouteConfig } from 'react-router-config';\nimport { createSelector } from 'reselect';\n\nimport NotFound from './NotFound';\nimport { Status } from './Status';\n\nimport {\n selectCurrentPath,\n selectCurrentProject,\n selectIsNotFound,\n selectMappedEntry,\n selectRouteEntry,\n selectRouteEntryContentTypeId,\n selectRouteErrorMessage,\n selectRouteIsError,\n selectRouteLoading,\n selectRouteStatusCode,\n} from '../redux/selectors';\nimport { setNavigationPath } from '../redux/actions';\n\nimport {\n selectUserGroups,\n selectUserIsAuthenticated,\n} from '~/user/redux/selectors';\nimport { matchUserGroup } from '~/user/util/matchGroups';\n\nimport { toJS } from '~/util/ToJs';\nimport { Entry } from 'contensis-delivery-api/lib/models';\nimport { AppRootProps, RouteComponentProps, RouteLoaderProps } from '../routes';\n\nconst replaceDoubleSlashRecursive = (path: string) => {\n const nextPath = path.replace(/\\/\\//, '/');\n\n if (nextPath.match(/\\/\\//)) {\n return replaceDoubleSlashRecursive(nextPath);\n }\n\n return nextPath;\n};\n\nconst getTrimmedPath = path => {\n if (path !== '/') {\n const nextPath = replaceDoubleSlashRecursive(path);\n const lastChar = nextPath[nextPath.length - 1];\n if (lastChar === '/') {\n return nextPath.substring(0, nextPath.length - 1);\n }\n }\n return path;\n};\n\ninterface IReduxProps {\n contentTypeId: string | null;\n entry: Entry | null;\n isError: boolean;\n isNotFound: boolean;\n isLoading: boolean;\n isLoggedIn: boolean;\n mappedEntry: any;\n projectId: string;\n setNavigationPath: typeof setNavigationPath;\n statePath: string;\n statusCode: any;\n statusText: string;\n userGroups: any;\n}\n\nconst RouteLoader = ({\n contentTypeId,\n entry,\n isError,\n isLoading,\n isLoggedIn,\n isNotFound,\n loadingComponent,\n mappedEntry,\n notFoundComponent,\n projectId,\n routes,\n setNavigationPath,\n statePath,\n statusCode,\n statusText,\n userGroups,\n withEvents,\n trailingSlashRedirectCode = 302,\n}: AppRootProps & RouteLoaderProps & IReduxProps) => {\n const location = useLocation();\n // Always ensure paths are trimmed of trailing slashes so urls are always unique\n const trimmedPath = getTrimmedPath(location.pathname);\n\n // Match any Static Routes a developer has defined\n const matchedStaticRoute = () =>\n matchRoutes(routes.StaticRoutes as RouteConfig[], location.pathname);\n const isStaticRoute = () => matchedStaticRoute().length > 0;\n\n const staticRoute = isStaticRoute() && matchedStaticRoute()[0];\n const routeRequiresLogin = staticRoute && staticRoute.route.requireLogin;\n\n const setPath = useCallback(() => {\n // Use serverPath to control the path we send to siteview node api to resolve a route\n let serverPath = '';\n if (staticRoute && staticRoute.match && staticRoute.match.isExact) {\n const { match, route } = staticRoute;\n\n if (route.path?.includes('*')) {\n // Send the whole url to api if we have matched route containing wildcard\n serverPath = match.url;\n } else if (typeof route.fetchNodeLevel === 'number') {\n // Send all url parts to a specified level to api\n serverPath = match.url\n .split('/')\n .splice(0, route.fetchNodeLevel + 1)\n .join('/');\n } else if (route.fetchNode?.params) {\n const fetchNodeParams: string[] = route.fetchNode.params;\n const routeParams: { [key: string]: string } = match.params;\n\n const regexExp = new RegExp(\n Object.keys(routeParams)\n .map(p => `:${p}`)\n .join('|'),\n 'g'\n );\n\n serverPath = match.path\n .replace(/\\?/g, '')\n .replace(regexExp, matched => {\n const param = matched.replace(':', '');\n if (fetchNodeParams.includes(param)) return routeParams[param];\n else return '';\n })\n .replace(/\\/$/, '');\n } else {\n // Send all non-parameterised url parts to api\n serverPath = (route.path as string)\n ?.split('/')\n .filter(p => !p.startsWith(':'))\n .join('/');\n }\n }\n\n setNavigationPath(\n serverPath || trimmedPath,\n location,\n staticRoute,\n withEvents,\n statePath,\n routes\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [\n setNavigationPath,\n // staticRoute,\n withEvents,\n location,\n routes,\n // statePath,\n trimmedPath,\n ]);\n\n if (typeof window == 'undefined') setPath();\n\n useEffect(() => {\n setPath();\n }, [location, setPath]);\n\n // Need to redirect when url endswith a /\n if (location.pathname.length > trimmedPath.length) {\n return (\n <Status code={trailingSlashRedirectCode}>\n <Redirect to={`${trimmedPath}${location.search}${location.hash}`} />\n </Status>\n );\n }\n\n // Render any Static Routes a developer has defined\n if (isStaticRoute() && !(!isLoggedIn && routeRequiresLogin)) {\n if (matchUserGroup(userGroups, routeRequiresLogin))\n return renderRoutes(\n routes.StaticRoutes as RouteConfig[],\n {\n projectId,\n contentTypeId,\n entry,\n mappedEntry,\n isLoggedIn,\n } as RouteComponentProps\n );\n }\n\n // Render a supplied Loading component if the route\n // is not a static route and is in a loading state\n if (isLoading && !isNotFound && loadingComponent) {\n const LoadingComponent = loadingComponent;\n return <LoadingComponent />;\n }\n\n // Match any defined Content Type Mappings\n if (contentTypeId && !(!isLoggedIn && routeRequiresLogin)) {\n const MatchedComponent = routes.ContentTypeMappings.find(\n item => item.contentTypeID === contentTypeId\n );\n\n if (MatchedComponent && !(MatchedComponent.requireLogin && !isLoggedIn)) {\n if (matchUserGroup(userGroups, MatchedComponent.requireLogin))\n return (\n <MatchedComponent.component\n projectId={projectId}\n contentTypeId={contentTypeId}\n entry={entry}\n mappedEntry={mappedEntry}\n isLoggedIn={isLoggedIn}\n />\n );\n }\n }\n\n const NotFoundComponent = notFoundComponent ? notFoundComponent : NotFound;\n if (isNotFound || isError) {\n return (\n <Status code={statusCode}>\n <NotFoundComponent statusCode={statusCode} statusText={statusText} />\n </Status>\n );\n }\n\n return null;\n};\nconst mapStateToPropsMemoized = createSelector(\n selectRouteEntryContentTypeId,\n selectRouteEntry,\n selectRouteIsError,\n selectIsNotFound,\n selectRouteLoading,\n selectUserIsAuthenticated,\n selectMappedEntry,\n selectCurrentProject,\n selectCurrentPath,\n selectRouteStatusCode,\n selectRouteErrorMessage,\n selectUserGroups,\n (\n contentTypeId,\n entry,\n isError,\n isNotFound,\n isLoading,\n isLoggedIn,\n mappedEntry,\n projectId,\n statePath,\n statusCode,\n statusText,\n userGroups\n ) => ({\n contentTypeId,\n entry,\n isError,\n isNotFound,\n isLoading,\n isLoggedIn,\n mappedEntry,\n projectId,\n statePath,\n statusCode,\n statusText,\n userGroups,\n })\n);\n\nconst mapDispatchToProps = {\n setNavigationPath,\n};\n\nexport default hot(module)(\n connect(mapStateToPropsMemoized, mapDispatchToProps)(toJS(RouteLoader))\n) as unknown as (props: AppRootProps & RouteLoaderProps) => JSX.Element;\n"],"names":["NotFound","statusCode","statusText","React","createElement","Fragment","style","background","color","fontSize","padding","Status","code","children","Route","render","staticContext","replaceDoubleSlashRecursive","path","nextPath","replace","match","getTrimmedPath","lastChar","length","substring","RouteLoader","contentTypeId","entry","isError","isLoading","isLoggedIn","isNotFound","loadingComponent","mappedEntry","notFoundComponent","projectId","routes","setNavigationPath","statePath","userGroups","withEvents","trailingSlashRedirectCode","location","useLocation","trimmedPath","pathname","matchedStaticRoute","matchRoutes","StaticRoutes","isStaticRoute","staticRoute","routeRequiresLogin","route","requireLogin","setPath","useCallback","serverPath","isExact","_route$path","_route$fetchNode","includes","url","fetchNodeLevel","split","splice","join","fetchNode","params","fetchNodeParams","routeParams","regexExp","RegExp","Object","keys","map","p","matched","param","_route$path2","filter","startsWith","window","useEffect","Redirect","to","search","hash","matchUserGroup","renderRoutes","LoadingComponent","MatchedComponent","ContentTypeMappings","find","item","contentTypeID","component","NotFoundComponent","mapStateToPropsMemoized","createSelector","selectRouteEntryContentTypeId","selectRouteEntry","selectRouteIsError","selectIsNotFound","selectRouteLoading","selectUserIsAuthenticated","selectMappedEntry","selectCurrentProject","selectCurrentPath","selectRouteStatusCode","selectRouteErrorMessage","selectUserGroups","mapDispatchToProps","hot","module","connect","toJS"],"mappings":";;;;;;;;;;;;;;;AAEA,MAAMA,QAAQ,GAAGA,CAAC;EAChBC,UAAU;AACVC,EAAAA,UAAAA;AAIF,CAAC,kBACCC,yBAAA,CAAAC,aAAA,CAAAD,yBAAA,CAAAE,QAAA,EACEF,IAAAA,eAAAA,yBAAA,CAA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,CAAA;AAED,MAAMwE,kBAAkB,GAAG;AACzB1E,qBAAAA,2BAAAA;AACF,CAAC,CAAA;AAED,oBAAe2E,kBAAG,CAACC,MAAM,CAAC,CACxBC,kBAAO,CAACjB,uBAAuB,EAAEc,kBAAkB,CAAC,CAACI,SAAI,CAAC1F,WAAW,CAAC,CAAC,CACxE;;;;"}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var selectors$1 = require('./selectors-bcca60f4.js');
3
+ var selectors$1 = require('./selectors-c7873cd7.js');
4
4
  var React = require('react');
5
5
 
6
6
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -125,4 +125,4 @@ exports.selectUserRegistrationIsLoading = selectUserRegistrationIsLoading;
125
125
  exports.selectUserRegistrationIsSuccess = selectUserRegistrationIsSuccess;
126
126
  exports.selectors = selectors;
127
127
  exports.toJS = toJS;
128
- //# sourceMappingURL=ToJs-6e9cfa69.js.map
128
+ //# sourceMappingURL=ToJs-c5bbd17a.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ToJs-6e9cfa69.js","sources":["../src/user/redux/selectors.ts","../src/user/util/matchGroups.ts","../src/util/ToJs.tsx"],"sourcesContent":["import { StateType } from '~/config';\nimport { AppState } from '~/redux/appstate';\nimport { getImmutableOrJS as getIn } from '~/redux/util';\n\nexport const selectUserIsLoading = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isLoading']);\n\nexport const selectUserIsAuthenticated = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isAuthenticated']);\n\nexport const selectUserIsAuthenticationError = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isAuthenticationError']);\n\nexport const selectUserIsError = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isError']);\n\n/**\n * DEPRECATED 12/2021 - use selectUserErrorMessage instead\n * @param state AppState\n * @returns string\n */\nexport const selectUserAuthenticationErrorMessage = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'errorMessage']);\n\nexport const selectUserErrorMessage = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'errorMessage']);\n\nexport const selectClientCredentials = (\n state: AppState,\n returnType?: StateType\n) =>\n getIn(\n state,\n ['user', 'authenticationState', 'clientCredentials'],\n {},\n returnType\n );\n\nexport const selectUser = (state: AppState, returnType?: StateType) =>\n getIn(state, 'user', {}, returnType);\n\nexport const selectUserIsZengentiStaff = (state: AppState) =>\n getIn(state, ['user', 'isZengentiStaff']);\n\nexport const selectUserGuid = (state: AppState) => getIn(state, ['user', 'id']);\n\nexport const selectUsername = (state: AppState) =>\n getIn(state, ['user', 'username']);\n\nexport const selectUserEmail = (state: AppState) =>\n getIn(state, ['user', 'email']);\n\nexport const selectUserGroups = (state: AppState, returnType?: StateType) =>\n getIn(state, ['user', 'groups'], [], returnType);\n\nexport const selectUserSecurityToken = (state: AppState) =>\n getIn(state, [\n 'user',\n 'authenticationState',\n 'clientCredentials',\n 'contensisClassicToken',\n ]);\n\nexport const selectUserRegistration = (\n state: AppState,\n returnType?: StateType\n) => getIn(state, ['user', 'registration'], {}, returnType);\n\nexport const selectUserRegistrationError = (state: AppState) =>\n getIn(state, ['user', 'registration', 'error'], false);\n\nexport const selectUserRegistrationIsLoading = (state: AppState) =>\n getIn(state, ['user', 'registration', 'isLoading'], false);\n\nexport const selectUserRegistrationIsSuccess = (state: AppState) =>\n getIn(state, ['user', 'registration', 'success'], false);\n\nexport const selectPasswordResetRequestSending = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'isSending']);\n\nexport const selectPasswordResetRequestSent = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'sent']);\n\nexport const selectPasswordResetRequestError = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'error']);\n\nexport const selectResetPasswordSending = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'isSending']);\n\nexport const selectResetPasswordSent = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'sent']);\n\nexport const selectResetPasswordError = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'error']);\n\nexport const selectChangePasswordSending = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'isSending']);\n\nexport const selectChangePasswordSent = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'sent']);\n\nexport const selectChangePasswordError = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'error']);\n","import { Group } from 'contensis-management-api/lib/models';\nimport { RequireLogin } from '~/routing/routes';\n\nexport const matchUserGroup = (\n userGroups: Group[] = [],\n requiredGroups: RequireLogin = []\n) => {\n if (\n !Array.isArray(requiredGroups) ||\n (Array.isArray(requiredGroups) && requiredGroups.length === 0)\n )\n return true;\n\n const groupMatch = requiredGroups.some(requiredGroup => {\n return userGroups.some(userGroup => {\n if (requiredGroup.id === userGroup.id) {\n return true;\n }\n if (requiredGroup.name === userGroup.name) {\n return true;\n }\n });\n });\n return groupMatch;\n};\n","/* eslint-disable react/display-name */\n/* eslint-disable @typescript-eslint/naming-convention */\nimport React from 'react';\n\nexport const toJS =\n <Props extends { [key: string]: any }>(\n WrappedComponent: React.ComponentType<Props>\n ): React.ComponentType<Props> =>\n (wrappedComponentProps: Props) => {\n const KEY = 0;\n const VALUE = 1;\n\n const propsJS = Object.entries(wrappedComponentProps).reduce<Props>(\n (newProps: any, wrappedComponentProp) => {\n const propKey = wrappedComponentProp[KEY];\n const propValue = wrappedComponentProp[VALUE];\n newProps[propKey] =\n propValue && typeof propValue === 'object' && 'toJS' in propValue\n ? propValue.toJS()\n : propValue;\n return newProps as Props;\n },\n {} as Props\n );\n\n return <WrappedComponent {...propsJS} />;\n };\n"],"names":["selectUserIsLoading","state","getIn","selectUserIsAuthenticated","selectUserIsAuthenticationError","selectUserIsError","selectUserAuthenticationErrorMessage","selectUserErrorMessage","selectClientCredentials","returnType","selectUser","selectUserIsZengentiStaff","selectUserGuid","selectUsername","selectUserEmail","selectUserGroups","selectUserSecurityToken","selectUserRegistration","selectUserRegistrationError","selectUserRegistrationIsLoading","selectUserRegistrationIsSuccess","selectPasswordResetRequestSending","selectPasswordResetRequestSent","selectPasswordResetRequestError","selectResetPasswordSending","selectResetPasswordSent","selectResetPasswordError","selectChangePasswordSending","selectChangePasswordSent","selectChangePasswordError","matchUserGroup","userGroups","requiredGroups","Array","isArray","length","groupMatch","some","requiredGroup","userGroup","id","name","toJS","WrappedComponent","wrappedComponentProps","KEY","VALUE","propsJS","Object","entries","reduce","newProps","wrappedComponentProp","propKey","propValue","React","createElement"],"mappings":";;;;;;;;;MAIaA,mBAAmB,GAAIC,KAAe,IACjDC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,WAAW,CAAC,EAAC;MAE/CE,yBAAyB,GAAIF,KAAe,IACvDC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,iBAAiB,CAAC,EAAC;MAErDG,+BAA+B,GAAIH,KAAe,IAC7DC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,uBAAuB,CAAC,EAAC;MAE3DI,iBAAiB,GAAIJ,KAAe,IAC/CC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,SAAS,CAAC,EAAC;;AAE1D;AACA;AACA;AACA;AACA;AACO,MAAMK,oCAAoC,GAAIL,KAAe,IAClEC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,cAAc,CAAC,CAAC,CAAA;MAElDM,sBAAsB,GAAIN,KAAe,IACpDC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,cAAc,CAAC,EAAC;AAExD,MAAMO,uBAAuB,GAAGA,CACrCP,KAAe,EACfQ,UAAsB,KAEtBP,4BAAK,CACHD,KAAK,EACL,CAAC,MAAM,EAAE,qBAAqB,EAAE,mBAAmB,CAAC,EACpD,EAAE,EACFQ,UAAU,EACX;MAEUC,UAA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CACH,CAAA;AAED,EAAA,oBAAOI,yBAAA,CAAAC,aAAA,CAACb,gBAAgB,EAAKI,OAAO,CAAI,CAAA;AAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"ToJs-c5bbd17a.js","sources":["../src/user/redux/selectors.ts","../src/user/util/matchGroups.ts","../src/util/ToJs.tsx"],"sourcesContent":["import { StateType } from '~/config';\nimport { AppState } from '~/redux/appstate';\nimport { getImmutableOrJS as getIn } from '~/redux/util';\n\nexport const selectUserIsLoading = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isLoading']);\n\nexport const selectUserIsAuthenticated = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isAuthenticated']);\n\nexport const selectUserIsAuthenticationError = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isAuthenticationError']);\n\nexport const selectUserIsError = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'isError']);\n\n/**\n * DEPRECATED 12/2021 - use selectUserErrorMessage instead\n * @param state AppState\n * @returns string\n */\nexport const selectUserAuthenticationErrorMessage = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'errorMessage']);\n\nexport const selectUserErrorMessage = (state: AppState) =>\n getIn(state, ['user', 'authenticationState', 'errorMessage']);\n\nexport const selectClientCredentials = (\n state: AppState,\n returnType?: StateType\n) =>\n getIn(\n state,\n ['user', 'authenticationState', 'clientCredentials'],\n {},\n returnType\n );\n\nexport const selectUser = (state: AppState, returnType?: StateType) =>\n getIn(state, 'user', {}, returnType);\n\nexport const selectUserIsZengentiStaff = (state: AppState) =>\n getIn(state, ['user', 'isZengentiStaff']);\n\nexport const selectUserGuid = (state: AppState) => getIn(state, ['user', 'id']);\n\nexport const selectUsername = (state: AppState) =>\n getIn(state, ['user', 'username']);\n\nexport const selectUserEmail = (state: AppState) =>\n getIn(state, ['user', 'email']);\n\nexport const selectUserGroups = (state: AppState, returnType?: StateType) =>\n getIn(state, ['user', 'groups'], [], returnType);\n\nexport const selectUserSecurityToken = (state: AppState) =>\n getIn(state, [\n 'user',\n 'authenticationState',\n 'clientCredentials',\n 'contensisClassicToken',\n ]);\n\nexport const selectUserRegistration = (\n state: AppState,\n returnType?: StateType\n) => getIn(state, ['user', 'registration'], {}, returnType);\n\nexport const selectUserRegistrationError = (state: AppState) =>\n getIn(state, ['user', 'registration', 'error'], false);\n\nexport const selectUserRegistrationIsLoading = (state: AppState) =>\n getIn(state, ['user', 'registration', 'isLoading'], false);\n\nexport const selectUserRegistrationIsSuccess = (state: AppState) =>\n getIn(state, ['user', 'registration', 'success'], false);\n\nexport const selectPasswordResetRequestSending = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'isSending']);\n\nexport const selectPasswordResetRequestSent = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'sent']);\n\nexport const selectPasswordResetRequestError = (state: AppState) =>\n getIn(state, ['user', 'passwordResetRequest', 'error']);\n\nexport const selectResetPasswordSending = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'isSending']);\n\nexport const selectResetPasswordSent = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'sent']);\n\nexport const selectResetPasswordError = (state: AppState) =>\n getIn(state, ['user', 'resetPassword', 'error']);\n\nexport const selectChangePasswordSending = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'isSending']);\n\nexport const selectChangePasswordSent = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'sent']);\n\nexport const selectChangePasswordError = (state: AppState) =>\n getIn(state, ['user', 'changePassword', 'error']);\n","import { Group } from 'contensis-management-api/lib/models';\nimport { RequireLogin } from '~/routing/routes';\n\nexport const matchUserGroup = (\n userGroups: Group[] = [],\n requiredGroups: RequireLogin = []\n) => {\n if (\n !Array.isArray(requiredGroups) ||\n (Array.isArray(requiredGroups) && requiredGroups.length === 0)\n )\n return true;\n\n const groupMatch = requiredGroups.some(requiredGroup => {\n return userGroups.some(userGroup => {\n if (requiredGroup.id === userGroup.id) {\n return true;\n }\n if (requiredGroup.name === userGroup.name) {\n return true;\n }\n });\n });\n return groupMatch;\n};\n","/* eslint-disable react/display-name */\n/* eslint-disable @typescript-eslint/naming-convention */\nimport React from 'react';\n\nexport const toJS =\n <Props extends { [key: string]: any }>(\n WrappedComponent: React.ComponentType<Props>\n ): React.ComponentType<Props> =>\n (wrappedComponentProps: Props) => {\n const KEY = 0;\n const VALUE = 1;\n\n const propsJS = Object.entries(wrappedComponentProps).reduce<Props>(\n (newProps: any, wrappedComponentProp) => {\n const propKey = wrappedComponentProp[KEY];\n const propValue = wrappedComponentProp[VALUE];\n newProps[propKey] =\n propValue && typeof propValue === 'object' && 'toJS' in propValue\n ? propValue.toJS()\n : propValue;\n return newProps as Props;\n },\n {} as Props\n );\n\n return <WrappedComponent {...propsJS} />;\n };\n"],"names":["selectUserIsLoading","state","getIn","selectUserIsAuthenticated","selectUserIsAuthenticationError","selectUserIsError","selectUserAuthenticationErrorMessage","selectUserErrorMessage","selectClientCredentials","returnType","selectUser","selectUserIsZengentiStaff","selectUserGuid","selectUsername","selectUserEmail","selectUserGroups","selectUserSecurityToken","selectUserRegistration","selectUserRegistrationError","selectUserRegistrationIsLoading","selectUserRegistrationIsSuccess","selectPasswordResetRequestSending","selectPasswordResetRequestSent","selectPasswordResetRequestError","selectResetPasswordSending","selectResetPasswordSent","selectResetPasswordError","selectChangePasswordSending","selectChangePasswordSent","selectChangePasswordError","matchUserGroup","userGroups","requiredGroups","Array","isArray","length","groupMatch","some","requiredGroup","userGroup","id","name","toJS","WrappedComponent","wrappedComponentProps","KEY","VALUE","propsJS","Object","entries","reduce","newProps","wrappedComponentProp","propKey","propValue","React","createElement"],"mappings":";;;;;;;;;MAIaA,mBAAmB,GAAIC,KAAe,IACjDC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,EAAE,qBAAqB,EAAE,WAAW,CAAC,EAAC;MAE/CE,yBAAyB,GAAIF,KAAe,IACvDC,4BAAK,CAACD,KAAK,EAAE,CAAC,MAAM,E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QAAA,OAAO,IAAI,CAAA;AACb,OAAA;AACF,KAAC,CAAC,CAAA;AACJ,GAAC,CAAC,CAAA;AACF,EAAA,OAAOL,UAAU,CAAA;AACnB;;ACxBA;MAIaM,IAAI,GAEbC,gBAA4C,IAE7CC,qBAA4B,IAAK;EAChC,MAAMC,GAAG,GAAG,CAAC,CAAA;EACb,MAAMC,KAAK,GAAG,CAAC,CAAA;AAEf,EAAA,MAAMC,OAAO,GAAGC,MAAM,CAACC,OAAO,CAACL,qBAAqB,CAAC,CAACM,MAAM,CAC1D,CAACC,QAAa,EAAEC,oBAAoB,KAAK;AACvC,IAAA,MAAMC,OAAO,GAAGD,oBAAoB,CAACP,GAAG,CAAC,CAAA;AACzC,IAAA,MAAMS,SAAS,GAAGF,oBAAoB,CAACN,KAAK,CAAC,CAAA;IAC7CK,QAAQ,CAACE,OAAO,CAAC,GACfC,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAI,MAAM,IAAIA,SAAS,GAC7DA,SAAS,CAACZ,IAAI,EAAE,GAChBY,SAAS,CAAA;AACf,IAAA,OAAOH,QAAQ,CAAA;GAChB,EACD,EAAE,CACH,CAAA;AAED,EAAA,oBAAOI,yBAAA,CAAAC,aAAA,CAACb,gBAAgB,EAAKI,OAAO,CAAI,CAAA;AAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/cjs/client.js CHANGED
@@ -11,11 +11,11 @@ var reactRouterDom = require('react-router-dom');
11
11
  var component = require('@loadable/component');
12
12
  var queryString = require('query-string');
13
13
  var reactCookie = require('react-cookie');
14
- var version = require('./version-4077e706.js');
15
- var version$1 = require('./version-fe28099e.js');
16
- var App = require('./App-21a7d836.js');
17
- var selectors = require('./selectors-bcca60f4.js');
18
- var ContensisDeliveryApi = require('./ContensisDeliveryApi-c079b03a.js');
14
+ var version = require('./version-6998435a.js');
15
+ var version$1 = require('./version-fe0119b6.js');
16
+ var App = require('./App-c74fb1ff.js');
17
+ var selectors = require('./selectors-c7873cd7.js');
18
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-c373405a.js');
19
19
  require('redux');
20
20
  require('redux-thunk');
21
21
  require('redux-saga');
@@ -26,13 +26,13 @@ require('./reducers-9afb5f89.js');
26
26
  require('@redux-saga/core/effects');
27
27
  require('history');
28
28
  require('loglevel');
29
- require('./login-2a6b5be0.js');
30
- require('./ToJs-6e9cfa69.js');
29
+ require('./login-3df93749.js');
30
+ require('./ToJs-c5bbd17a.js');
31
31
  require('jsonpath-mapper');
32
32
  require('await-to-js');
33
33
  require('js-cookie');
34
34
  require('contensis-delivery-api');
35
- require('./RouteLoader-7f0d107a.js');
35
+ require('./RouteLoader-c048673f.js');
36
36
  require('react-router-config');
37
37
  require('reselect');
38
38
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var ContensisDeliveryApi = require('./ContensisDeliveryApi-c079b03a.js');
5
+ var ContensisDeliveryApi = require('./ContensisDeliveryApi-c373405a.js');
6
6
  var contensisDeliveryApi = require('contensis-delivery-api');
7
7
  var React = require('react');
8
8
  var reactRedux = require('react-redux');
@@ -34,10 +34,10 @@ var lodash = require('lodash');
34
34
  var _commonjsHelpers = require('./_commonjsHelpers-b3309d7b.js');
35
35
  var lodashClean = require('lodash-clean');
36
36
  var reactCookie = require('react-cookie');
37
- var version = require('./version-4077e706.js');
38
- var App = require('./App-21a7d836.js');
39
- var version$1 = require('./version-fe28099e.js');
40
- var selectors = require('./selectors-bcca60f4.js');
37
+ var version = require('./version-6998435a.js');
38
+ var App = require('./App-c74fb1ff.js');
39
+ var version$1 = require('./version-fe0119b6.js');
40
+ var selectors = require('./selectors-c7873cd7.js');
41
41
  var chalk = require('chalk');
42
42
  require('loglevel');
43
43
  require('@redux-saga/core/effects');
@@ -47,12 +47,12 @@ require('redux-saga');
47
47
  require('redux-injectors');
48
48
  require('./reducers-9afb5f89.js');
49
49
  require('history');
50
- require('./login-2a6b5be0.js');
51
- require('./ToJs-6e9cfa69.js');
50
+ require('./login-3df93749.js');
51
+ require('./ToJs-c5bbd17a.js');
52
52
  require('await-to-js');
53
53
  require('js-cookie');
54
54
  require('react-hot-loader');
55
- require('./RouteLoader-7f0d107a.js');
55
+ require('./RouteLoader-c048673f.js');
56
56
 
57
57
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
58
58
 
package/cjs/forms.js CHANGED
@@ -4949,6 +4949,7 @@ const countries = [{
4949
4949
  const CountrySelect = ({
4950
4950
  formId,
4951
4951
  id,
4952
+ label,
4952
4953
  field,
4953
4954
  validations,
4954
4955
  defaultValue,
@@ -5007,7 +5008,7 @@ const CountrySelect = ({
5007
5008
  }, /*#__PURE__*/React__default["default"].createElement("label", {
5008
5009
  className: "input__label",
5009
5010
  htmlFor: "country-searchable-select"
5010
- }, "Select a country", isRequired ? /*#__PURE__*/React__default["default"].createElement("span", {
5011
+ }, label, isRequired ? /*#__PURE__*/React__default["default"].createElement("span", {
5011
5012
  className: "label__required"
5012
5013
  }, "(required)") : /*#__PURE__*/React__default["default"].createElement("span", {
5013
5014
  className: "label__optional"
@@ -5230,6 +5231,7 @@ const FormComposer = ({
5230
5231
  formId: formId,
5231
5232
  field: field,
5232
5233
  id: field.id,
5234
+ label: field.name && field.name[defaultLanguage],
5233
5235
  validations: field.validations,
5234
5236
  defaultValue: field === null || field === void 0 ? void 0 : (_field$default = field.default) === null || _field$default === void 0 ? void 0 : _field$default[defaultLanguage],
5235
5237
  placeholder: field === null || field === void 0 ? void 0 : (_field$editor = field.editor) === null || _field$editor === void 0 ? void 0 : (_field$editor$propert = _field$editor.properties) === null || _field$editor$propert === void 0 ? void 0 : (_field$editor$propert2 = _field$editor$propert.placeholderText) === null || _field$editor$propert2 === void 0 ? void 0 : _field$editor$propert2[defaultLanguage]