@panneau/app 4.1.0 → 4.1.1

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 (2) hide show
  1. package/dist/index.js +115 -44
  2. package/package.json +42 -42
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ import { useMemoryRouter, createPathToRegexpParser } from '@folklore/routes';
3
3
  import { useLocation, useSearch, Route, Switch, Redirect, Router } from 'wouter';
4
4
  import ActionsProvider from '@panneau/actions';
5
5
  import { useUser, useLogout, useAuth, AuthProvider } from '@panneau/auth';
6
- import { useUrlGenerator, usePanneauResources, usePanneau, usePanneauColorScheme, ResourceProvider, useActionsComponentsManager, useRoutes, usePagesComponentsManager, ComponentsProvider, ModalProvider, RoutesProvider, PanneauProvider } from '@panneau/core/contexts';
6
+ import { useUrlGenerator, usePanneauResources, usePanneau, usePanneauColorScheme, ResourceProvider, useActionsComponentsManager, usePanneauAuth, useRoutes, usePagesComponentsManager, ComponentsProvider, ModalProvider, RoutesProvider, PanneauProvider } from '@panneau/core/contexts';
7
7
  import { useResourceItem, DataProvider } from '@panneau/data';
8
8
  import DisplaysProvider from '@panneau/displays';
9
9
  import FieldsProvider from '@panneau/fields';
@@ -1986,35 +1986,99 @@ function GuestLayout(t0) {
1986
1986
  return t12;
1987
1987
  }
1988
1988
 
1989
+ function getLink(link, defaultLink) {
1990
+ if (typeof link === 'string') {
1991
+ return link;
1992
+ }
1993
+ return link === true ? defaultLink : null;
1994
+ }
1989
1995
  function LoginPage() {
1990
- const $ = c(5);
1996
+ const $ = c(15);
1991
1997
  const route = useUrlGenerator();
1998
+ const {
1999
+ forgotPassword,
2000
+ register
2001
+ } = usePanneauAuth();
1992
2002
  let t0;
1993
- if ($[0] !== route) {
1994
- t0 = () => {
1995
- window.location.href = route("home");
1996
- };
1997
- $[0] = route;
2003
+ if ($[0] !== forgotPassword) {
2004
+ t0 = getLink(forgotPassword, "/forgot-password");
2005
+ $[0] = forgotPassword;
1998
2006
  $[1] = t0;
1999
2007
  } else {
2000
2008
  t0 = $[1];
2001
2009
  }
2002
- const onComplete = t0;
2010
+ const forgotPasswordLink = t0;
2003
2011
  let t1;
2004
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
2005
- t1 = /*#__PURE__*/jsx("h1", {
2012
+ if ($[2] !== register) {
2013
+ t1 = getLink(register, "/register");
2014
+ $[2] = register;
2015
+ $[3] = t1;
2016
+ } else {
2017
+ t1 = $[3];
2018
+ }
2019
+ const registerLink = t1;
2020
+ let t2;
2021
+ if ($[4] !== route) {
2022
+ t2 = () => {
2023
+ window.location.href = route("home");
2024
+ };
2025
+ $[4] = route;
2026
+ $[5] = t2;
2027
+ } else {
2028
+ t2 = $[5];
2029
+ }
2030
+ const onComplete = t2;
2031
+ let t3;
2032
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
2033
+ t3 = /*#__PURE__*/jsx("h1", {
2006
2034
  className: "mb-4",
2007
2035
  children: /*#__PURE__*/jsx(FormattedMessage, {
2008
2036
  id: "AeOZq+"
2009
2037
  })
2010
2038
  });
2011
- $[2] = t1;
2039
+ $[6] = t3;
2012
2040
  } else {
2013
- t1 = $[2];
2041
+ t3 = $[6];
2014
2042
  }
2015
- let t2;
2016
- if ($[3] !== onComplete) {
2017
- t2 = /*#__PURE__*/jsx(GuestLayout, {
2043
+ let t4;
2044
+ if ($[7] !== onComplete) {
2045
+ t4 = /*#__PURE__*/jsx(LoginForm, {
2046
+ onComplete: onComplete
2047
+ });
2048
+ $[7] = onComplete;
2049
+ $[8] = t4;
2050
+ } else {
2051
+ t4 = $[8];
2052
+ }
2053
+ let t5;
2054
+ if ($[9] !== forgotPasswordLink || $[10] !== registerLink) {
2055
+ t5 = forgotPasswordLink !== null || registerLink !== null ? /*#__PURE__*/jsxs("div", {
2056
+ className: "d-flex flex-wrap gap-3 mt-4",
2057
+ children: [forgotPasswordLink !== null ? /*#__PURE__*/jsx(Link, {
2058
+ href: forgotPasswordLink,
2059
+ external: true,
2060
+ target: "_self",
2061
+ children: /*#__PURE__*/jsx(FormattedMessage, {
2062
+ id: "ZBNqY2"
2063
+ })
2064
+ }) : null, registerLink !== null ? /*#__PURE__*/jsx(Link, {
2065
+ href: registerLink,
2066
+ external: true,
2067
+ target: "_self",
2068
+ children: /*#__PURE__*/jsx(FormattedMessage, {
2069
+ id: "PQX/ph"
2070
+ })
2071
+ }) : null]
2072
+ }) : null;
2073
+ $[9] = forgotPasswordLink;
2074
+ $[10] = registerLink;
2075
+ $[11] = t5;
2076
+ } else {
2077
+ t5 = $[11];
2078
+ }
2079
+ let t6;
2080
+ if ($[12] !== t4 || $[13] !== t5) {
2081
+ t6 = /*#__PURE__*/jsx(GuestLayout, {
2018
2082
  fullscreen: true,
2019
2083
  children: /*#__PURE__*/jsx("div", {
2020
2084
  className: "container-sm py-4",
@@ -2022,19 +2086,18 @@ function LoginPage() {
2022
2086
  className: "row justify-content-center",
2023
2087
  children: /*#__PURE__*/jsxs("div", {
2024
2088
  className: "col-12 col-sm-8 col-md-6",
2025
- children: [t1, /*#__PURE__*/jsx(LoginForm, {
2026
- onComplete: onComplete
2027
- })]
2089
+ children: [t3, t4, t5]
2028
2090
  })
2029
2091
  })
2030
2092
  })
2031
2093
  });
2032
- $[3] = onComplete;
2033
- $[4] = t2;
2094
+ $[12] = t4;
2095
+ $[13] = t5;
2096
+ $[14] = t6;
2034
2097
  } else {
2035
- t2 = $[4];
2098
+ t6 = $[14];
2036
2099
  }
2037
- return t2;
2100
+ return t6;
2038
2101
  }
2039
2102
 
2040
2103
  function ErrorPage(t0) {
@@ -2244,13 +2307,34 @@ function createResourceRoutes(resource, {
2244
2307
  pages: resourcePages = {},
2245
2308
  extraRoutes = []
2246
2309
  } = resource;
2247
- const ResourceIndexComponent = componentsManager.getComponent(resourcePages?.resourceIndexPage?.component) || componentsManager.getComponent(pages?.indexPage?.component) || ResourceIndexPage;
2248
- const ResourceShowComponent = componentsManager.getComponent(resourcePages?.resourceShowPage?.component) || componentsManager.getComponent(pages?.showPage?.component) || ResourceShowPage;
2249
- const ResourceCreateComponent = componentsManager.getComponent(resourcePages?.resourceCreatePage?.component) || componentsManager.getComponent(pages?.createPage?.component) || ResourceCreatePage;
2250
- const ResourceEditComponent = componentsManager.getComponent(resourcePages?.resourceEditPage?.component) || componentsManager.getComponent(pages?.editPage?.component) || ResourceEditPage;
2251
- const ResourceDeleteComponent = componentsManager.getComponent(resourcePages?.resourceDeletePage?.component) || componentsManager.getComponent(pages?.deletePage?.component) || ResourceDeletePage;
2252
- const ResourceDuplicateComponent = componentsManager.getComponent(resourcePages?.resourceDuplicatePage?.component) || componentsManager.getComponent(pages?.duplicatePage?.component) || ResourceDuplicatePage;
2253
- return [/*#__PURE__*/jsx(Route, {
2310
+
2311
+ // Resolution order: resource typed key (`pages.show`), resource legacy key
2312
+ // (`pages.resourceShowPage`), panneau typed key (`pages.show`), panneau legacy key
2313
+ // (`pages.showPage`), then the built-in page
2314
+ const ResourceIndexComponent = componentsManager.getComponent(resourcePages?.index?.component) || componentsManager.getComponent(resourcePages?.resourceIndexPage?.component) || componentsManager.getComponent(pages?.index?.component) || componentsManager.getComponent(pages?.indexPage?.component) || ResourceIndexPage;
2315
+ const ResourceShowComponent = componentsManager.getComponent(resourcePages?.show?.component) || componentsManager.getComponent(resourcePages?.resourceShowPage?.component) || componentsManager.getComponent(pages?.show?.component) || componentsManager.getComponent(pages?.showPage?.component) || ResourceShowPage;
2316
+ const ResourceCreateComponent = componentsManager.getComponent(resourcePages?.create?.component) || componentsManager.getComponent(resourcePages?.resourceCreatePage?.component) || componentsManager.getComponent(pages?.create?.component) || componentsManager.getComponent(pages?.createPage?.component) || ResourceCreatePage;
2317
+ const ResourceEditComponent = componentsManager.getComponent(resourcePages?.edit?.component) || componentsManager.getComponent(resourcePages?.resourceEditPage?.component) || componentsManager.getComponent(pages?.edit?.component) || componentsManager.getComponent(pages?.editPage?.component) || ResourceEditPage;
2318
+ const ResourceDeleteComponent = componentsManager.getComponent(resourcePages?.delete?.component) || componentsManager.getComponent(resourcePages?.resourceDeletePage?.component) || componentsManager.getComponent(pages?.delete?.component) || componentsManager.getComponent(pages?.deletePage?.component) || ResourceDeletePage;
2319
+ const ResourceDuplicateComponent = componentsManager.getComponent(resourcePages?.duplicate?.component) || componentsManager.getComponent(resourcePages?.resourceDuplicatePage?.component) || componentsManager.getComponent(pages?.duplicate?.component) || componentsManager.getComponent(pages?.duplicatePage?.component) || ResourceDuplicatePage;
2320
+
2321
+ // Extra routes are registered first so they are not shadowed by the
2322
+ // generic `/:resource/:id` show route
2323
+ const extraRoutesElements = extraRoutes.map(({
2324
+ path,
2325
+ component,
2326
+ ...pageProps
2327
+ }) => {
2328
+ const RouteComponent = componentsManager.getComponent(component);
2329
+ return RouteComponent !== null ? /*#__PURE__*/jsx(Route, {
2330
+ path: path,
2331
+ children: () => /*#__PURE__*/jsx(RouteComponent, {
2332
+ resource: resource,
2333
+ ...pageProps
2334
+ })
2335
+ }, `route-${path}`) : null;
2336
+ });
2337
+ return [...extraRoutesElements, /*#__PURE__*/jsx(Route, {
2254
2338
  path: route('resources.create', {
2255
2339
  resource: resourceId
2256
2340
  }),
@@ -2301,20 +2385,7 @@ function createResourceRoutes(resource, {
2301
2385
  itemId: id,
2302
2386
  resource: resource
2303
2387
  })
2304
- }, `${resourceId}-duplicate`), ...extraRoutes.map(({
2305
- path,
2306
- component,
2307
- ...pageProps
2308
- }) => {
2309
- const RouteComponent = componentsManager.getComponent(component);
2310
- return RouteComponent !== null ? /*#__PURE__*/jsx(Route, {
2311
- path: path,
2312
- children: () => /*#__PURE__*/jsx(RouteComponent, {
2313
- resource: resource,
2314
- ...pageProps
2315
- })
2316
- }, `route-${path}`) : null;
2317
- }), /*#__PURE__*/jsx(Route, {
2388
+ }, `${resourceId}-duplicate`), /*#__PURE__*/jsx(Route, {
2318
2389
  path: route('resources.index', {
2319
2390
  resource: resourceId
2320
2391
  }),
@@ -2380,7 +2451,7 @@ function PanneauRoutes(t0) {
2380
2451
  } = usePanneau() || {};
2381
2452
  const pages = t5 === undefined ? null : t5;
2382
2453
  const routesDefinition = t6 === undefined ? null : t6;
2383
- const builtinPages = ["home", "login", "account", "error", "index", "show", "create", "edit", "delete", "duplicate"];
2454
+ const builtinPages = ["home", "login", "account", "error", "index", "show", "create", "edit", "delete", "duplicate", "indexPage", "showPage", "createPage", "editPage", "deletePage", "duplicatePage"];
2384
2455
  const otherPages = Object.keys(pages || {}).filter(key => builtinPages.indexOf(key) === -1).reduce((acc, key_0) => ({
2385
2456
  ...acc,
2386
2457
  [key_0]: pages[key_0]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@panneau/app",
3
- "version": "4.1.0",
3
+ "version": "4.1.1",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -67,46 +67,46 @@
67
67
  "@fortawesome/fontawesome-svg-core": "^6.5.1",
68
68
  "@fortawesome/free-solid-svg-icons": "^6.5.1",
69
69
  "@fortawesome/react-fontawesome": "^0.2.0",
70
- "@panneau/actions": "^4.1.0",
71
- "@panneau/auth": "^4.1.0",
72
- "@panneau/core": "^4.1.0",
73
- "@panneau/data": "^4.1.0",
74
- "@panneau/displays": "^4.1.0",
75
- "@panneau/element-accordion": "^4.1.0",
76
- "@panneau/element-alert": "^4.1.0",
77
- "@panneau/element-avatar": "^4.1.0",
78
- "@panneau/element-breadcrumbs": "^4.1.0",
79
- "@panneau/element-button": "^4.1.0",
80
- "@panneau/element-buttons": "^4.1.0",
81
- "@panneau/element-dropdown": "^4.1.0",
82
- "@panneau/element-form": "^4.1.0",
83
- "@panneau/element-form-group": "^4.1.0",
84
- "@panneau/element-grid": "^4.1.0",
85
- "@panneau/element-icon": "^4.1.0",
86
- "@panneau/element-label": "^4.1.0",
87
- "@panneau/element-link": "^4.1.0",
88
- "@panneau/element-loading": "^4.1.0",
89
- "@panneau/element-media-card": "^4.1.0",
90
- "@panneau/element-media-player": "^4.1.0",
91
- "@panneau/element-menu": "^4.1.0",
92
- "@panneau/element-modal": "^4.1.0",
93
- "@panneau/element-navbar": "^4.1.0",
94
- "@panneau/element-pagination": "^4.1.0",
95
- "@panneau/element-radios": "^4.1.0",
96
- "@panneau/element-range": "^4.1.0",
97
- "@panneau/element-resource-card": "^4.1.0",
98
- "@panneau/fields": "^4.1.0",
99
- "@panneau/filter-filters": "^4.1.0",
100
- "@panneau/filters": "^4.1.0",
101
- "@panneau/form": "^4.1.0",
102
- "@panneau/form-resource": "^4.1.0",
103
- "@panneau/forms": "^4.1.0",
104
- "@panneau/intl": "^4.1.0",
105
- "@panneau/list-resource-items": "^4.1.0",
106
- "@panneau/lists": "^4.1.0",
107
- "@panneau/modals": "^4.1.0",
108
- "@panneau/themes": "^4.1.0",
109
- "@panneau/uppy": "^4.1.0",
70
+ "@panneau/actions": "^4.1.1",
71
+ "@panneau/auth": "^4.1.1",
72
+ "@panneau/core": "^4.1.1",
73
+ "@panneau/data": "^4.1.1",
74
+ "@panneau/displays": "^4.1.1",
75
+ "@panneau/element-accordion": "^4.1.1",
76
+ "@panneau/element-alert": "^4.1.1",
77
+ "@panneau/element-avatar": "^4.1.1",
78
+ "@panneau/element-breadcrumbs": "^4.1.1",
79
+ "@panneau/element-button": "^4.1.1",
80
+ "@panneau/element-buttons": "^4.1.1",
81
+ "@panneau/element-dropdown": "^4.1.1",
82
+ "@panneau/element-form": "^4.1.1",
83
+ "@panneau/element-form-group": "^4.1.1",
84
+ "@panneau/element-grid": "^4.1.1",
85
+ "@panneau/element-icon": "^4.1.1",
86
+ "@panneau/element-label": "^4.1.1",
87
+ "@panneau/element-link": "^4.1.1",
88
+ "@panneau/element-loading": "^4.1.1",
89
+ "@panneau/element-media-card": "^4.1.1",
90
+ "@panneau/element-media-player": "^4.1.1",
91
+ "@panneau/element-menu": "^4.1.1",
92
+ "@panneau/element-modal": "^4.1.1",
93
+ "@panneau/element-navbar": "^4.1.1",
94
+ "@panneau/element-pagination": "^4.1.1",
95
+ "@panneau/element-radios": "^4.1.1",
96
+ "@panneau/element-range": "^4.1.1",
97
+ "@panneau/element-resource-card": "^4.1.1",
98
+ "@panneau/fields": "^4.1.1",
99
+ "@panneau/filter-filters": "^4.1.1",
100
+ "@panneau/filters": "^4.1.1",
101
+ "@panneau/form": "^4.1.1",
102
+ "@panneau/form-resource": "^4.1.1",
103
+ "@panneau/forms": "^4.1.1",
104
+ "@panneau/intl": "^4.1.1",
105
+ "@panneau/list-resource-items": "^4.1.1",
106
+ "@panneau/lists": "^4.1.1",
107
+ "@panneau/modals": "^4.1.1",
108
+ "@panneau/themes": "^4.1.1",
109
+ "@panneau/uppy": "^4.1.1",
110
110
  "classnames": "^2.5.1",
111
111
  "lodash-es": "^4.17.21",
112
112
  "query-string": "^9.0.0",
@@ -124,5 +124,5 @@
124
124
  "publishConfig": {
125
125
  "access": "public"
126
126
  },
127
- "gitHead": "8a6accc1aab59368bf546c83b9433dfe94ccf767"
127
+ "gitHead": "28b394278cffa0c927989873dd4b3f184635ceff"
128
128
  }