@panneau/app 4.0.38 → 4.0.40-alpha.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.
package/dist/index.js CHANGED
@@ -1,8 +1,6 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import _objectSpread from '@babel/runtime/helpers/objectSpread2';
3
1
  import { useMemoryRouter, createPathToRegexpParser } from '@folklore/routes';
4
- import { useCallback, useMemo, useState, useEffect, Fragment as Fragment$1 } from 'react';
5
- import { useLocation, useSearch, Route, Switch, Redirect, Router } from 'wouter';
2
+ import { useState, useEffect, Fragment as Fragment$1, useMemo, useCallback } from 'react';
3
+ import { useLocation, useSearch, Route, Redirect, Switch, Router } from 'wouter';
6
4
  import ActionsProvider from '@panneau/actions';
7
5
  import { useUser, useLogout, useAuth, AuthProvider } from '@panneau/auth';
8
6
  import { useUrlGenerator, usePanneauResources, usePanneau, usePanneauColorScheme, ResourceProvider, useActionsComponentsManager, useFormsComponents, useRoutes, usePagesComponentsManager, PanneauProvider, RoutesProvider, ModalProvider, ComponentsProvider } from '@panneau/core/contexts';
@@ -15,9 +13,7 @@ import { useResourceValues, IntlProvider } from '@panneau/intl';
15
13
  import ListsProvider from '@panneau/lists';
16
14
  import ModalsProvider from '@panneau/modals';
17
15
  import { UppyProvider } from '@panneau/uppy';
18
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
19
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
20
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
16
+ import { c } from 'react/compiler-runtime';
21
17
  import isObject from 'lodash/isObject';
22
18
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
23
19
  import classNames from 'classnames';
@@ -41,211 +37,349 @@ import { getComponentFromName } from '@panneau/core/utils';
41
37
  import Filters from '@panneau/filter-filters';
42
38
 
43
39
  function ResourceFormWrapper(props) {
44
- return /*#__PURE__*/jsx(ResourceForm, _objectSpread({}, props));
40
+ const $ = c(2);
41
+ let t0;
42
+ if ($[0] !== props) {
43
+ t0 = /*#__PURE__*/jsx(ResourceForm, {
44
+ ...props
45
+ });
46
+ $[0] = props;
47
+ $[1] = t0;
48
+ } else {
49
+ t0 = $[1];
50
+ }
51
+ return t0;
45
52
  }
46
53
 
47
- function AccountMenu(_ref) {
48
- var _ref$withAccountForm = _ref.withAccountForm,
49
- withAccountForm = _ref$withAccountForm === void 0 ? false : _ref$withAccountForm,
50
- _ref$className = _ref.className,
51
- className = _ref$className === void 0 ? null : _ref$className,
52
- _ref$itemClassName = _ref.itemClassName,
53
- itemClassName = _ref$itemClassName === void 0 ? null : _ref$itemClassName,
54
- _ref$linkClassName = _ref.linkClassName,
55
- linkClassName = _ref$linkClassName === void 0 ? null : _ref$linkClassName;
56
- var route = useUrlGenerator();
57
- var user = useUser();
58
- var logout = useLogout();
59
- var onClickLogout = useCallback(function (e) {
60
- e.preventDefault();
61
- logout();
62
- }, [logout]);
63
- var items = useMemo(function () {
64
- return user !== null ? [{
65
- id: 'account',
54
+ function AccountMenu(t0) {
55
+ const $ = c(12);
56
+ const {
57
+ withAccountForm: t1,
58
+ className: t2,
59
+ itemClassName: t3,
60
+ linkClassName: t4
61
+ } = t0;
62
+ const withAccountForm = t1 === undefined ? false : t1;
63
+ const className = t2 === undefined ? null : t2;
64
+ const itemClassName = t3 === undefined ? null : t3;
65
+ const linkClassName = t4 === undefined ? null : t4;
66
+ const route = useUrlGenerator();
67
+ const user = useUser();
68
+ const logout = useLogout();
69
+ let t5;
70
+ if ($[0] !== logout) {
71
+ t5 = e => {
72
+ e.preventDefault();
73
+ logout();
74
+ };
75
+ $[0] = logout;
76
+ $[1] = t5;
77
+ } else {
78
+ t5 = $[1];
79
+ }
80
+ const onClickLogout = t5;
81
+ let t6;
82
+ if ($[2] !== onClickLogout || $[3] !== route || $[4] !== user || $[5] !== withAccountForm) {
83
+ t6 = user !== null ? [{
84
+ id: "account",
66
85
  label: /*#__PURE__*/jsx(FormattedMessage, {
67
- id: "IuqEHB",
68
- defaultMessage: [{
69
- "type": 0,
70
- "value": "Account"
71
- }]
86
+ id: "IuqEHB"
72
87
  }),
73
- href: route('account'),
74
- dropdown: [].concat(_toConsumableArray(withAccountForm ? [{
88
+ href: route("account"),
89
+ dropdown: [...(withAccountForm ? [{
75
90
  label: /*#__PURE__*/jsx(FormattedMessage, {
76
- id: "V7Us0a",
77
- defaultMessage: [{
78
- "type": 0,
79
- "value": "Update account"
80
- }]
91
+ id: "V7Us0a"
81
92
  }),
82
- href: route('account')
83
- }] : []), [{
93
+ href: route("account")
94
+ }] : []), {
84
95
  label: /*#__PURE__*/jsx(FormattedMessage, {
85
- id: "REIcPg",
86
- defaultMessage: [{
87
- "type": 0,
88
- "value": "Logout"
89
- }]
96
+ id: "REIcPg"
90
97
  }),
91
- href: route('auth.logout'),
98
+ href: route("auth.logout"),
92
99
  onClick: onClickLogout
93
- }])
100
+ }]
94
101
  }] : [{
95
102
  label: /*#__PURE__*/jsx(FormattedMessage, {
96
- id: "d0g58T",
97
- defaultMessage: [{
98
- "type": 0,
99
- "value": "Login"
100
- }]
103
+ id: "d0g58T"
101
104
  }),
102
- href: route('auth.login')
105
+ href: route("auth.login")
103
106
  }];
104
- }, [user, route, onClickLogout, withAccountForm]);
105
- return items !== null ? /*#__PURE__*/jsx(Menu, {
106
- className: className,
107
- itemClassName: itemClassName,
108
- linkClassName: linkClassName,
109
- items: items,
110
- dropdownAlign: "end"
111
- }) : null;
107
+ $[2] = onClickLogout;
108
+ $[3] = route;
109
+ $[4] = user;
110
+ $[5] = withAccountForm;
111
+ $[6] = t6;
112
+ } else {
113
+ t6 = $[6];
114
+ }
115
+ const items = t6;
116
+ let t7;
117
+ if ($[7] !== className || $[8] !== itemClassName || $[9] !== items || $[10] !== linkClassName) {
118
+ t7 = items !== null ? /*#__PURE__*/jsx(Menu, {
119
+ className: className,
120
+ itemClassName: itemClassName,
121
+ linkClassName: linkClassName,
122
+ items: items,
123
+ dropdownAlign: "end"
124
+ }) : null;
125
+ $[7] = className;
126
+ $[8] = itemClassName;
127
+ $[9] = items;
128
+ $[10] = linkClassName;
129
+ $[11] = t7;
130
+ } else {
131
+ t7 = $[11];
132
+ }
133
+ return t7;
112
134
  }
113
135
 
114
- function ResourcesMenu(_ref) {
115
- var _ref$className = _ref.className,
116
- className = _ref$className === void 0 ? null : _ref$className,
117
- _ref$itemClassName = _ref.itemClassName,
118
- itemClassName = _ref$itemClassName === void 0 ? null : _ref$itemClassName,
119
- _ref$linkClassName = _ref.linkClassName,
120
- linkClassName = _ref$linkClassName === void 0 ? null : _ref$linkClassName;
121
- var _useLocation = useLocation(),
122
- _useLocation2 = _slicedToArray(_useLocation, 1),
123
- pathname = _useLocation2[0];
124
- var resources = usePanneauResources();
125
- var resourceRoute = useResourceUrlGenerator();
126
- var items = useMemo(function () {
127
- return resources.filter(function (_ref2) {
128
- var _ref2$settings = _ref2.settings,
129
- _ref2$settings2 = _ref2$settings === void 0 ? {} : _ref2$settings,
130
- _ref2$settings2$hideI = _ref2$settings2.hideInNavbar,
131
- hideInNavbar = _ref2$settings2$hideI === void 0 ? false : _ref2$settings2$hideI;
132
- return !hideInNavbar;
133
- }).map(function (it) {
134
- var url = resourceRoute(it, 'index');
135
- return {
136
- id: it.id,
137
- label: it.name,
138
- href: url,
139
- active: pathname.substr(0, url.length) === url
136
+ function ResourcesMenu(t0) {
137
+ const $ = c(12);
138
+ const {
139
+ className: t1,
140
+ itemClassName: t2,
141
+ linkClassName: t3
142
+ } = t0;
143
+ const className = t1 === undefined ? null : t1;
144
+ const itemClassName = t2 === undefined ? null : t2;
145
+ const linkClassName = t3 === undefined ? null : t3;
146
+ const [pathname] = useLocation();
147
+ const resources = usePanneauResources();
148
+ const resourceRoute = useResourceUrlGenerator();
149
+ let t4;
150
+ if ($[0] !== pathname || $[1] !== resourceRoute || $[2] !== resources) {
151
+ let t5;
152
+ if ($[4] !== pathname || $[5] !== resourceRoute) {
153
+ t5 = it => {
154
+ const url = resourceRoute(it, "index");
155
+ return {
156
+ id: it.id,
157
+ label: it.name,
158
+ href: url,
159
+ active: pathname.substr(0, url.length) === url
160
+ };
140
161
  };
162
+ $[4] = pathname;
163
+ $[5] = resourceRoute;
164
+ $[6] = t5;
165
+ } else {
166
+ t5 = $[6];
167
+ }
168
+ t4 = resources.filter(_temp$5).map(t5);
169
+ $[0] = pathname;
170
+ $[1] = resourceRoute;
171
+ $[2] = resources;
172
+ $[3] = t4;
173
+ } else {
174
+ t4 = $[3];
175
+ }
176
+ const items = t4;
177
+ let t5;
178
+ if ($[7] !== className || $[8] !== itemClassName || $[9] !== items || $[10] !== linkClassName) {
179
+ t5 = /*#__PURE__*/jsx(Menu, {
180
+ items: items,
181
+ className: className,
182
+ itemClassName: itemClassName,
183
+ linkClassName: linkClassName
141
184
  });
142
- }, [resources, pathname, resourceRoute]);
143
- return /*#__PURE__*/jsx(Menu, {
144
- items: items,
145
- className: className,
146
- itemClassName: itemClassName,
147
- linkClassName: linkClassName
148
- });
185
+ $[7] = className;
186
+ $[8] = itemClassName;
187
+ $[9] = items;
188
+ $[10] = linkClassName;
189
+ $[11] = t5;
190
+ } else {
191
+ t5 = $[11];
192
+ }
193
+ return t5;
194
+ }
195
+ function _temp$5(t0) {
196
+ const {
197
+ settings: t1
198
+ } = t0;
199
+ const {
200
+ hideInNavbar: t2
201
+ } = t1 === undefined ? {} : t1;
202
+ const hideInNavbar = t2 === undefined ? false : t2;
203
+ return !hideInNavbar;
149
204
  }
150
205
 
151
- var _excluded$4 = ["loading", "theme", "vertical", "position", "className"];
152
- function MainNavbar(_ref) {
153
- var _ref$loading = _ref.loading,
154
- loading = _ref$loading === void 0 ? false : _ref$loading;
155
- _ref.theme;
156
- var _ref$vertical = _ref.vertical,
157
- vertical = _ref$vertical === void 0 ? false : _ref$vertical;
158
- _ref.position;
159
- var className = _ref.className,
160
- props = _objectWithoutProperties(_ref, _excluded$4);
161
- var _usePanneau = usePanneau(),
162
- name = _usePanneau.name,
163
- _usePanneau$menus = _usePanneau.menus,
164
- menus = _usePanneau$menus === void 0 ? null : _usePanneau$menus;
165
- var _ref2 = menus || {},
166
- _ref2$main = _ref2.main,
167
- main = _ref2$main === void 0 ? null : _ref2$main,
168
- _ref2$guest = _ref2.guest,
169
- guest = _ref2$guest === void 0 ? null : _ref2$guest;
170
- var _usePanneauColorSchem = usePanneauColorScheme(),
171
- background = _usePanneauColorSchem.background;
172
- var route = useUrlGenerator();
173
- var user = useUser();
174
- var navClassNames = vertical ? 'navbar-nav d-flex flex-column' : 'navbar-nav';
175
- var items = useMemo(function () {
176
- var menuItems = (user !== null ? main : guest) || [];
177
- var hasResources = menuItems.indexOf('resources') !== -1;
178
- var hasAccount = menuItems.indexOf('account') !== -1;
179
- return [!hasResources && user !== null ? 'resources' : null].concat(_toConsumableArray(menuItems), [!hasAccount && menuItems.indexOf('separator') === -1 ? 'separator' : null, !hasAccount ? 'account' : null]).filter(function (it) {
180
- return it !== null;
181
- }).reduce(function (currentItems, item, index) {
182
- if (item === 'resources') {
183
- return [].concat(_toConsumableArray(currentItems), [/*#__PURE__*/jsx(ResourcesMenu, {
184
- className: navClassNames,
185
- itemClassName: "nav-item",
186
- linkClassName: "nav-link"
187
- }, "menu-item-resource-".concat(index + 1))]);
188
- }
189
- if (item === 'account') {
190
- return [].concat(_toConsumableArray(currentItems), [/*#__PURE__*/jsx(AccountMenu, {
191
- className: navClassNames,
192
- itemClassName: "nav-item",
193
- linkClassName: "nav-link"
194
- }, "menu-item-account-".concat(index + 1))]);
195
- }
196
- if (item === 'separator') {
197
- return [].concat(_toConsumableArray(currentItems), [/*#__PURE__*/jsx("span", {
198
- className: "ms-auto"
199
- }, "menu-item-spacer-".concat(index + 1))]);
200
- }
201
- var lastItem = currentItems.length > 0 ? currentItems[currentItems.length - 1] : null;
202
- return isArray(lastItem) ? [].concat(_toConsumableArray(currentItems.slice(0, currentItems.length - 1)), [[].concat(_toConsumableArray(lastItem), [item])]) : [].concat(_toConsumableArray(currentItems), [[item]]);
203
- }, []).map(function (it, index) {
204
- return isArray(it) ? /*#__PURE__*/jsx(Menu, {
205
- items: it,
206
+ function MainNavbar(t0) {
207
+ const $ = c(31);
208
+ let className;
209
+ let props;
210
+ let t1;
211
+ let t2;
212
+ let t3;
213
+ let t4;
214
+ if ($[0] !== t0) {
215
+ ({
216
+ loading: t1,
217
+ theme: t2,
218
+ vertical: t3,
219
+ position: t4,
220
+ className,
221
+ ...props
222
+ } = t0);
223
+ $[0] = t0;
224
+ $[1] = className;
225
+ $[2] = props;
226
+ $[3] = t1;
227
+ $[4] = t2;
228
+ $[5] = t3;
229
+ $[6] = t4;
230
+ } else {
231
+ className = $[1];
232
+ props = $[2];
233
+ t1 = $[3];
234
+ t2 = $[4];
235
+ t3 = $[5];
236
+ t4 = $[6];
237
+ }
238
+ const loading = t1 === undefined ? false : t1;
239
+ const vertical = t3 === undefined ? false : t3;
240
+ const {
241
+ name,
242
+ menus: t5
243
+ } = usePanneau();
244
+ const menus = t5 === undefined ? null : t5;
245
+ let t6;
246
+ if ($[7] !== menus) {
247
+ t6 = menus || {};
248
+ $[7] = menus;
249
+ $[8] = t6;
250
+ } else {
251
+ t6 = $[8];
252
+ }
253
+ const {
254
+ main: t7,
255
+ guest: t8
256
+ } = t6;
257
+ const main = t7 === undefined ? null : t7;
258
+ const guest = t8 === undefined ? null : t8;
259
+ const {
260
+ background
261
+ } = usePanneauColorScheme();
262
+ const route = useUrlGenerator();
263
+ const user = useUser();
264
+ const navClassNames = vertical ? "navbar-nav d-flex flex-column" : "navbar-nav";
265
+ let t9;
266
+ if ($[9] !== guest || $[10] !== main || $[11] !== navClassNames || $[12] !== user) {
267
+ const menuItems = (user !== null ? main : guest) || [];
268
+ const hasResources = menuItems.indexOf("resources") !== -1;
269
+ const hasAccount = menuItems.indexOf("account") !== -1;
270
+ let t10;
271
+ if ($[14] !== navClassNames) {
272
+ t10 = (currentItems, item, index) => {
273
+ if (item === "resources") {
274
+ return [...currentItems, /*#__PURE__*/jsx(ResourcesMenu, {
275
+ className: navClassNames,
276
+ itemClassName: "nav-item",
277
+ linkClassName: "nav-link"
278
+ }, `menu-item-resource-${index + 1}`)];
279
+ }
280
+ if (item === "account") {
281
+ return [...currentItems, /*#__PURE__*/jsx(AccountMenu, {
282
+ className: navClassNames,
283
+ itemClassName: "nav-item",
284
+ linkClassName: "nav-link"
285
+ }, `menu-item-account-${index + 1}`)];
286
+ }
287
+ if (item === "separator") {
288
+ return [...currentItems, /*#__PURE__*/jsx("span", {
289
+ className: "ms-auto"
290
+ }, `menu-item-spacer-${index + 1}`)];
291
+ }
292
+ const lastItem = currentItems.length > 0 ? currentItems[currentItems.length - 1] : null;
293
+ return isArray(lastItem) ? [...currentItems.slice(0, currentItems.length - 1), [...lastItem, item]] : [...currentItems, [item]];
294
+ };
295
+ $[14] = navClassNames;
296
+ $[15] = t10;
297
+ } else {
298
+ t10 = $[15];
299
+ }
300
+ let t11;
301
+ if ($[16] !== navClassNames) {
302
+ t11 = (it_0, index_0) => isArray(it_0) ? /*#__PURE__*/jsx(Menu, {
303
+ items: it_0,
206
304
  className: navClassNames,
207
305
  itemClassName: "nav-item",
208
306
  linkClassName: "nav-link"
209
- }, "submenu-item-".concat(index + 1)) : it;
210
- });
211
- }, [main, guest, user, navClassNames]);
212
- return /*#__PURE__*/jsxs(Navbar, _objectSpread(_objectSpread({
213
- theme: background,
214
- loading: loading,
215
- vertical: vertical,
216
- className: className
217
- }, props), {}, {
218
- children: [name !== null ? /*#__PURE__*/jsx(Link, {
219
- href: route('home'),
307
+ }, `submenu-item-${index_0 + 1}`) : it_0;
308
+ $[16] = navClassNames;
309
+ $[17] = t11;
310
+ } else {
311
+ t11 = $[17];
312
+ }
313
+ t9 = [!hasResources && user !== null ? "resources" : null, ...menuItems, !hasAccount && menuItems.indexOf("separator") === -1 ? "separator" : null, !hasAccount ? "account" : null].filter(_temp$4).reduce(t10, []).map(t11);
314
+ $[9] = guest;
315
+ $[10] = main;
316
+ $[11] = navClassNames;
317
+ $[12] = user;
318
+ $[13] = t9;
319
+ } else {
320
+ t9 = $[13];
321
+ }
322
+ const items = t9;
323
+ let t10;
324
+ if ($[18] !== loading || $[19] !== name || $[20] !== route || $[21] !== vertical) {
325
+ t10 = name !== null ? /*#__PURE__*/jsx(Link, {
326
+ href: route("home"),
220
327
  className: "navbar-brand",
221
328
  children: /*#__PURE__*/jsx("span", {
222
329
  className: classNames([{
223
- 'text-opacity-75': loading,
224
- 'ms-2': vertical
330
+ "text-opacity-75": loading,
331
+ "ms-2": vertical
225
332
  }]),
226
333
  children: name
227
334
  })
228
- }) : null, items]
229
- }));
335
+ }) : null;
336
+ $[18] = loading;
337
+ $[19] = name;
338
+ $[20] = route;
339
+ $[21] = vertical;
340
+ $[22] = t10;
341
+ } else {
342
+ t10 = $[22];
343
+ }
344
+ let t11;
345
+ if ($[23] !== background || $[24] !== className || $[25] !== items || $[26] !== loading || $[27] !== props || $[28] !== t10 || $[29] !== vertical) {
346
+ t11 = /*#__PURE__*/jsxs(Navbar, {
347
+ theme: background,
348
+ loading: loading,
349
+ vertical: vertical,
350
+ className: className,
351
+ ...props,
352
+ children: [t10, items]
353
+ });
354
+ $[23] = background;
355
+ $[24] = className;
356
+ $[25] = items;
357
+ $[26] = loading;
358
+ $[27] = props;
359
+ $[28] = t10;
360
+ $[29] = vertical;
361
+ $[30] = t11;
362
+ } else {
363
+ t11 = $[30];
364
+ }
365
+ return t11;
366
+ }
367
+ function _temp$4(it) {
368
+ return it !== null;
230
369
  }
231
370
 
232
- function MainLayout(_ref) {
233
- var _ref$fullscreen = _ref.fullscreen,
234
- fullscreen = _ref$fullscreen === void 0 ? false : _ref$fullscreen,
235
- _ref$loading = _ref.loading,
236
- loading = _ref$loading === void 0 ? false : _ref$loading,
237
- _ref$children = _ref.children,
238
- children = _ref$children === void 0 ? null : _ref$children;
239
- var _usePanneauColorSchem = usePanneauColorScheme(),
240
- _usePanneauColorSchem2 = _usePanneauColorSchem.theme,
241
- theme = _usePanneauColorSchem2 === void 0 ? null : _usePanneauColorSchem2,
242
- _usePanneauColorSchem3 = _usePanneauColorSchem.sidebarPosition,
243
- sidebarPosition = _usePanneauColorSchem3 === void 0 ? null : _usePanneauColorSchem3,
244
- _usePanneauColorSchem4 = _usePanneauColorSchem.background,
245
- background = _usePanneauColorSchem4 === void 0 ? null : _usePanneauColorSchem4,
246
- _usePanneauColorSchem5 = _usePanneauColorSchem.text,
247
- text = _usePanneauColorSchem5 === void 0 ? null : _usePanneauColorSchem5;
248
- var vertical = sidebarPosition === 'left' || sidebarPosition === 'right';
371
+ function MainLayout({
372
+ fullscreen = false,
373
+ loading = false,
374
+ children = null
375
+ }) {
376
+ const {
377
+ theme = null,
378
+ sidebarPosition = null,
379
+ background = null,
380
+ text = null
381
+ } = usePanneauColorScheme();
382
+ const vertical = sidebarPosition === 'left' || sidebarPosition === 'right';
249
383
  return /*#__PURE__*/jsxs("div", {
250
384
  className: classNames(['d-flex', 'min-vh-100', {
251
385
  'flex-column': !vertical
@@ -269,9 +403,11 @@ function MainLayout(_ref) {
269
403
  loading: loading,
270
404
  vertical: vertical
271
405
  }), /*#__PURE__*/jsx("div", {
272
- className: classNames(['flex-grow-1', _defineProperty(_defineProperty({
273
- 'd-flex flex-column': fullscreen
274
- }, "bg-".concat(background), background !== null), "text-".concat(text), text !== null)]),
406
+ className: classNames(['flex-grow-1', {
407
+ 'd-flex flex-column': fullscreen,
408
+ [`bg-${background}`]: background !== null,
409
+ [`text-${text}`]: text !== null
410
+ }]),
275
411
  children: children
276
412
  }), /*#__PURE__*/jsx(Modals, {
277
413
  theme: theme
@@ -279,23 +415,20 @@ function MainLayout(_ref) {
279
415
  });
280
416
  }
281
417
 
282
- function PageHeader(_ref) {
283
- var _ref$title = _ref.title,
284
- title = _ref$title === void 0 ? null : _ref$title,
285
- _ref$actions = _ref.actions,
286
- actions = _ref$actions === void 0 ? null : _ref$actions,
287
- _ref$small = _ref.small,
288
- small = _ref$small === void 0 ? false : _ref$small,
289
- _ref$className = _ref.className,
290
- className = _ref$className === void 0 ? null : _ref$className,
291
- _ref$children = _ref.children,
292
- children = _ref$children === void 0 ? null : _ref$children;
418
+ function PageHeader({
419
+ title = null,
420
+ actions = null,
421
+ small = false,
422
+ className = null,
423
+ children = null
424
+ }) {
293
425
  // TODO: fix page header components
294
426
  // const { components } = usePanneau();
295
- var _usePanneauColorSchem = usePanneauColorScheme(),
296
- text = _usePanneauColorSchem.text,
297
- background = _usePanneauColorSchem.background;
298
- var inner = /*#__PURE__*/jsxs("div", {
427
+ const {
428
+ text,
429
+ background
430
+ } = usePanneauColorScheme();
431
+ const inner = /*#__PURE__*/jsxs("div", {
299
432
  className: "d-flex align-items-center flex-wrap",
300
433
  children: [title !== null ? /*#__PURE__*/jsx("h1", {
301
434
  className: classNames(['mb-0', 'h2']),
@@ -308,7 +441,12 @@ function PageHeader(_ref) {
308
441
  }) : null]
309
442
  });
310
443
  return /*#__PURE__*/jsxs("div", {
311
- className: classNames(['py-4', _defineProperty(_defineProperty(_defineProperty(_defineProperty({}, "bg-".concat(background), background !== null), "text-".concat(text), text !== null), "border-bottom", background || text !== null), className, className !== null)]),
444
+ className: classNames(['py-4', {
445
+ [`bg-${background}`]: background !== null,
446
+ [`text-${text}`]: text !== null,
447
+ [`border-bottom`]: background || text !== null,
448
+ [className]: className !== null
449
+ }]),
312
450
  children: [/*#__PURE__*/jsx("div", {
313
451
  className: "container-sm",
314
452
  children: small ? /*#__PURE__*/jsx("div", {
@@ -322,634 +460,1285 @@ function PageHeader(_ref) {
322
460
  });
323
461
  }
324
462
 
325
- function ResourceCreatePage(_ref) {
326
- var resource = _ref.resource;
327
- var _useLocation = useLocation(),
328
- _useLocation2 = _slicedToArray(_useLocation, 2),
329
- navigate = _useLocation2[1];
330
- var search = useSearch();
331
- var resourceRoute = useResourceUrlGenerator(resource);
332
- var _useMemo = useMemo(function () {
333
- return queryString.parse(search, {
334
- arrayFormat: 'bracket'
335
- });
336
- }, [search]),
337
- _useMemo$type = _useMemo.type,
338
- type = _useMemo$type === void 0 ? null : _useMemo$type;
339
- var resourceValues = useResourceValues(resource);
340
- var typeName = useResourceTypeName(resource, type);
341
- var onSuccess = useCallback(function () {
342
- navigate("".concat(resourceRoute('index'), "?created=true"));
343
- }, [navigate, resourceRoute]);
344
- return /*#__PURE__*/jsx(ResourceProvider, {
345
- resource: resource,
346
- children: /*#__PURE__*/jsx(MainLayout, {
463
+ function ResourceCreatePage(t0) {
464
+ const $ = c(20);
465
+ const {
466
+ resource
467
+ } = t0;
468
+ const [, navigate] = useLocation();
469
+ const search = useSearch();
470
+ const resourceRoute = useResourceUrlGenerator(resource);
471
+ let t1;
472
+ if ($[0] !== search) {
473
+ t1 = queryString.parse(search, {
474
+ arrayFormat: "bracket"
475
+ });
476
+ $[0] = search;
477
+ $[1] = t1;
478
+ } else {
479
+ t1 = $[1];
480
+ }
481
+ const {
482
+ type: t2
483
+ } = t1;
484
+ const type = t2 === undefined ? null : t2;
485
+ const resourceValues = useResourceValues(resource);
486
+ const typeName = useResourceTypeName(resource, type);
487
+ let t3;
488
+ if ($[2] !== navigate || $[3] !== resourceRoute) {
489
+ t3 = () => {
490
+ navigate(`${resourceRoute("index")}?created=true`);
491
+ };
492
+ $[2] = navigate;
493
+ $[3] = resourceRoute;
494
+ $[4] = t3;
495
+ } else {
496
+ t3 = $[4];
497
+ }
498
+ const onComplete = t3;
499
+ let t4;
500
+ if ($[5] !== resourceValues) {
501
+ t4 = /*#__PURE__*/jsx(FormattedMessage, {
502
+ id: "6viUpq",
503
+ values: resourceValues
504
+ });
505
+ $[5] = resourceValues;
506
+ $[6] = t4;
507
+ } else {
508
+ t4 = $[6];
509
+ }
510
+ let t5;
511
+ if ($[7] !== typeName) {
512
+ t5 = typeName !== null ? /*#__PURE__*/jsxs("span", {
513
+ className: "text-body-secondary",
514
+ children: [" (", typeName, ")"]
515
+ }) : null;
516
+ $[7] = typeName;
517
+ $[8] = t5;
518
+ } else {
519
+ t5 = $[8];
520
+ }
521
+ let t6;
522
+ if ($[9] !== t4 || $[10] !== t5) {
523
+ t6 = /*#__PURE__*/jsx(PageHeader, {
524
+ title: /*#__PURE__*/jsxs(Fragment, {
525
+ children: [t4, t5]
526
+ }),
527
+ small: true
528
+ });
529
+ $[9] = t4;
530
+ $[10] = t5;
531
+ $[11] = t6;
532
+ } else {
533
+ t6 = $[11];
534
+ }
535
+ let t7;
536
+ if ($[12] !== onComplete || $[13] !== resource || $[14] !== t6 || $[15] !== type) {
537
+ t7 = /*#__PURE__*/jsx(MainLayout, {
347
538
  children: /*#__PURE__*/jsx(ResourceFormWrapper, {
348
539
  resource: resource,
349
540
  type: type,
350
- onSuccess: onSuccess,
541
+ onComplete: onComplete,
351
542
  withContainer: true,
352
- header: /*#__PURE__*/jsx(PageHeader, {
353
- title: /*#__PURE__*/jsxs(Fragment, {
354
- children: [/*#__PURE__*/jsx(FormattedMessage, {
355
- values: resourceValues,
356
- id: "6viUpq",
357
- defaultMessage: [{
358
- "type": 0,
359
- "value": "Create "
360
- }, {
361
- "type": 1,
362
- "value": "a_singular"
363
- }]
364
- }), typeName !== null ? /*#__PURE__*/jsxs("span", {
365
- className: "text-body-secondary",
366
- children: [" (", typeName, ")"]
367
- }) : null]
368
- }),
369
- small: true
370
- })
543
+ header: t6
371
544
  })
372
- })
373
- });
545
+ });
546
+ $[12] = onComplete;
547
+ $[13] = resource;
548
+ $[14] = t6;
549
+ $[15] = type;
550
+ $[16] = t7;
551
+ } else {
552
+ t7 = $[16];
553
+ }
554
+ let t8;
555
+ if ($[17] !== resource || $[18] !== t7) {
556
+ t8 = /*#__PURE__*/jsx(ResourceProvider, {
557
+ resource: resource,
558
+ children: t7
559
+ });
560
+ $[17] = resource;
561
+ $[18] = t7;
562
+ $[19] = t8;
563
+ } else {
564
+ t8 = $[19];
565
+ }
566
+ return t8;
374
567
  }
375
568
 
376
- function ResourceDeletePage(_ref) {
377
- var itemId = _ref.itemId,
378
- resource = _ref.resource;
379
- var _useLocation = useLocation(),
380
- _useLocation2 = _slicedToArray(_useLocation, 2),
381
- navigate = _useLocation2[1];
382
- var resourceRoute = useResourceUrlGenerator(resource);
383
- var _useResourceItem = useResourceItem(resource, itemId),
384
- item = _useResourceItem.item,
385
- loading = _useResourceItem.loading,
386
- error = _useResourceItem.error;
387
- var _ref2 = item || {},
388
- _ref2$type = _ref2.type,
389
- type = _ref2$type === void 0 ? null : _ref2$type;
390
- var resourceValues = useResourceValues(resource);
391
- var typeName = useResourceTypeName(resource, type);
392
- var onSuccess = useCallback(function () {
393
- return navigate("".concat(resourceRoute('index'), "?deleted=true"));
394
- }, [navigate, resourceRoute]);
395
- return /*#__PURE__*/jsx(ResourceProvider, {
396
- resource: resource,
397
- children: /*#__PURE__*/jsxs(MainLayout, {
398
- loading: loading,
399
- children: [item !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
400
- resource: resource,
401
- item: item,
402
- onSuccess: onSuccess,
403
- isDelete: true,
404
- withContainer: true,
405
- header: /*#__PURE__*/jsx(PageHeader, {
406
- title: /*#__PURE__*/jsxs(Fragment, {
407
- children: [/*#__PURE__*/jsx(FormattedMessage, {
408
- values: resourceValues,
409
- id: "zN5N/Q",
410
- defaultMessage: [{
411
- "type": 0,
412
- "value": "Delete "
413
- }, {
414
- "type": 1,
415
- "value": "a_singular"
416
- }]
417
- }), typeName !== null ? /*#__PURE__*/jsxs("span", {
418
- className: "text-body-secondary",
419
- children: [' ', "(", typeName, ")"]
420
- }) : null]
421
- }),
422
- small: true
423
- })
424
- }) : null, item === null && loading && !error ? /*#__PURE__*/jsx(Loading, {
425
- className: "mw-25 my-4 m-auto",
426
- withDelay: true,
427
- children: /*#__PURE__*/jsx(FormattedMessage, {
428
- id: "TV3jir",
429
- defaultMessage: [{
430
- "type": 0,
431
- "value": "Loading"
432
- }]
433
- })
434
- }) : null]
435
- })
436
- });
569
+ function ResourceDeletePage(t0) {
570
+ const $ = c(22);
571
+ const {
572
+ itemId,
573
+ resource
574
+ } = t0;
575
+ const [, navigate] = useLocation();
576
+ const resourceRoute = useResourceUrlGenerator(resource);
577
+ const {
578
+ item,
579
+ isLoading,
580
+ error
581
+ } = useResourceItem(resource, itemId);
582
+ let t1;
583
+ if ($[0] !== item) {
584
+ t1 = item || {};
585
+ $[0] = item;
586
+ $[1] = t1;
587
+ } else {
588
+ t1 = $[1];
589
+ }
590
+ const {
591
+ type: t2
592
+ } = t1;
593
+ const type = t2 === undefined ? null : t2;
594
+ const resourceValues = useResourceValues(resource);
595
+ const typeName = useResourceTypeName(resource, type);
596
+ let t3;
597
+ if ($[2] !== navigate || $[3] !== resourceRoute) {
598
+ t3 = () => navigate(`${resourceRoute("index")}?deleted=true`);
599
+ $[2] = navigate;
600
+ $[3] = resourceRoute;
601
+ $[4] = t3;
602
+ } else {
603
+ t3 = $[4];
604
+ }
605
+ const onComplete = t3;
606
+ let t4;
607
+ if ($[5] !== item || $[6] !== onComplete || $[7] !== resource || $[8] !== resourceValues || $[9] !== typeName) {
608
+ t4 = item !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
609
+ resource: resource,
610
+ item: item,
611
+ onComplete: onComplete,
612
+ isDelete: true,
613
+ withContainer: true,
614
+ header: /*#__PURE__*/jsx(PageHeader, {
615
+ title: /*#__PURE__*/jsxs(Fragment, {
616
+ children: [/*#__PURE__*/jsx(FormattedMessage, {
617
+ id: "zN5N/Q",
618
+ values: resourceValues
619
+ }), typeName !== null ? /*#__PURE__*/jsxs("span", {
620
+ className: "text-body-secondary",
621
+ children: [" ", "(", typeName, ")"]
622
+ }) : null]
623
+ }),
624
+ small: true
625
+ })
626
+ }) : null;
627
+ $[5] = item;
628
+ $[6] = onComplete;
629
+ $[7] = resource;
630
+ $[8] = resourceValues;
631
+ $[9] = typeName;
632
+ $[10] = t4;
633
+ } else {
634
+ t4 = $[10];
635
+ }
636
+ let t5;
637
+ if ($[11] !== error || $[12] !== isLoading || $[13] !== item) {
638
+ t5 = item === null && isLoading && !error ? /*#__PURE__*/jsx(Loading, {
639
+ className: "mw-25 my-4 m-auto",
640
+ withDelay: true,
641
+ children: /*#__PURE__*/jsx(FormattedMessage, {
642
+ id: "TV3jir"
643
+ })
644
+ }) : null;
645
+ $[11] = error;
646
+ $[12] = isLoading;
647
+ $[13] = item;
648
+ $[14] = t5;
649
+ } else {
650
+ t5 = $[14];
651
+ }
652
+ let t6;
653
+ if ($[15] !== isLoading || $[16] !== t4 || $[17] !== t5) {
654
+ t6 = /*#__PURE__*/jsxs(MainLayout, {
655
+ loading: isLoading,
656
+ children: [t4, t5]
657
+ });
658
+ $[15] = isLoading;
659
+ $[16] = t4;
660
+ $[17] = t5;
661
+ $[18] = t6;
662
+ } else {
663
+ t6 = $[18];
664
+ }
665
+ let t7;
666
+ if ($[19] !== resource || $[20] !== t6) {
667
+ t7 = /*#__PURE__*/jsx(ResourceProvider, {
668
+ resource: resource,
669
+ children: t6
670
+ });
671
+ $[19] = resource;
672
+ $[20] = t6;
673
+ $[21] = t7;
674
+ } else {
675
+ t7 = $[21];
676
+ }
677
+ return t7;
437
678
  }
438
679
 
439
- function ResourceEditPage(_ref) {
440
- var itemId = _ref.itemId,
441
- resource = _ref.resource;
442
- var _useResourceItem = useResourceItem(resource, itemId),
443
- item = _useResourceItem.item,
444
- loading = _useResourceItem.loading,
445
- error = _useResourceItem.error;
446
- var _ref2 = item || {},
447
- _ref2$type = _ref2.type,
448
- type = _ref2$type === void 0 ? null : _ref2$type;
449
- var _useState = useState(item),
450
- _useState2 = _slicedToArray(_useState, 2),
451
- editItem = _useState2[0],
452
- setEditItem = _useState2[1];
453
- var typeName = useResourceTypeName(resource, type);
454
- var onSuccess = useCallback(function (newItem) {
455
- return setEditItem(newItem);
456
- }, []);
457
- useEffect(function () {
458
- setEditItem(item);
459
- }, [item, setEditItem]);
460
- var resourceValues = useResourceValues(resource);
461
- return /*#__PURE__*/jsx(ResourceProvider, {
462
- resource: resource,
463
- children: /*#__PURE__*/jsxs(MainLayout, {
464
- loading: loading,
465
- children: [editItem !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
466
- resource: resource,
467
- item: editItem,
468
- type: type,
469
- onSuccess: onSuccess,
470
- withContainer: true,
471
- header: /*#__PURE__*/jsx(PageHeader, {
472
- title: /*#__PURE__*/jsxs(Fragment, {
473
- children: [/*#__PURE__*/jsx(FormattedMessage, {
474
- values: resourceValues,
475
- id: "mCfzkJ",
476
- defaultMessage: [{
477
- "type": 0,
478
- "value": "Edit "
479
- }, {
480
- "type": 1,
481
- "value": "a_singular"
482
- }]
483
- }), typeName !== null ? /*#__PURE__*/jsxs("span", {
484
- className: "text-body-secondary",
485
- children: [' ', "(", typeName, ")"]
486
- }) : null]
487
- }),
488
- small: true
489
- })
490
- }) : null, editItem === null && loading && !error ? /*#__PURE__*/jsx(Loading, {
491
- className: "mw-25 my-4 m-auto",
492
- withDelay: true,
493
- children: /*#__PURE__*/jsx(FormattedMessage, {
494
- id: "TV3jir",
495
- defaultMessage: [{
496
- "type": 0,
497
- "value": "Loading"
498
- }]
499
- })
500
- }) : null]
501
- })
502
- });
680
+ function ResourceEditPage(t0) {
681
+ const $ = c(23);
682
+ const {
683
+ itemId,
684
+ resource
685
+ } = t0;
686
+ const {
687
+ item,
688
+ isLoading,
689
+ error
690
+ } = useResourceItem(resource, itemId);
691
+ let t1;
692
+ if ($[0] !== item) {
693
+ t1 = item || {};
694
+ $[0] = item;
695
+ $[1] = t1;
696
+ } else {
697
+ t1 = $[1];
698
+ }
699
+ const {
700
+ type: t2
701
+ } = t1;
702
+ const type = t2 === undefined ? null : t2;
703
+ const [editItem, setEditItem] = useState(item);
704
+ const typeName = useResourceTypeName(resource, type);
705
+ let t3;
706
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
707
+ t3 = newItem => setEditItem(newItem);
708
+ $[2] = t3;
709
+ } else {
710
+ t3 = $[2];
711
+ }
712
+ const onComplete = t3;
713
+ let t4;
714
+ let t5;
715
+ if ($[3] !== item) {
716
+ t4 = () => {
717
+ setEditItem(item);
718
+ };
719
+ t5 = [item, setEditItem];
720
+ $[3] = item;
721
+ $[4] = t4;
722
+ $[5] = t5;
723
+ } else {
724
+ t4 = $[4];
725
+ t5 = $[5];
726
+ }
727
+ useEffect(t4, t5);
728
+ const resourceValues = useResourceValues(resource);
729
+ let t6;
730
+ if ($[6] !== editItem || $[7] !== resource || $[8] !== resourceValues || $[9] !== type || $[10] !== typeName) {
731
+ t6 = editItem !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
732
+ resource: resource,
733
+ item: editItem,
734
+ type: type,
735
+ onComplete: onComplete,
736
+ withContainer: true,
737
+ header: /*#__PURE__*/jsx(PageHeader, {
738
+ title: /*#__PURE__*/jsxs(Fragment, {
739
+ children: [/*#__PURE__*/jsx(FormattedMessage, {
740
+ id: "mCfzkJ",
741
+ values: resourceValues
742
+ }), typeName !== null ? /*#__PURE__*/jsxs("span", {
743
+ className: "text-body-secondary",
744
+ children: [" ", "(", typeName, ")"]
745
+ }) : null]
746
+ }),
747
+ small: true
748
+ })
749
+ }) : null;
750
+ $[6] = editItem;
751
+ $[7] = resource;
752
+ $[8] = resourceValues;
753
+ $[9] = type;
754
+ $[10] = typeName;
755
+ $[11] = t6;
756
+ } else {
757
+ t6 = $[11];
758
+ }
759
+ let t7;
760
+ if ($[12] !== editItem || $[13] !== error || $[14] !== isLoading) {
761
+ t7 = editItem === null && isLoading && !error ? /*#__PURE__*/jsx(Loading, {
762
+ className: "mw-25 my-4 m-auto",
763
+ withDelay: true,
764
+ children: /*#__PURE__*/jsx(FormattedMessage, {
765
+ id: "TV3jir"
766
+ })
767
+ }) : null;
768
+ $[12] = editItem;
769
+ $[13] = error;
770
+ $[14] = isLoading;
771
+ $[15] = t7;
772
+ } else {
773
+ t7 = $[15];
774
+ }
775
+ let t8;
776
+ if ($[16] !== isLoading || $[17] !== t6 || $[18] !== t7) {
777
+ t8 = /*#__PURE__*/jsxs(MainLayout, {
778
+ loading: isLoading,
779
+ children: [t6, t7]
780
+ });
781
+ $[16] = isLoading;
782
+ $[17] = t6;
783
+ $[18] = t7;
784
+ $[19] = t8;
785
+ } else {
786
+ t8 = $[19];
787
+ }
788
+ let t9;
789
+ if ($[20] !== resource || $[21] !== t8) {
790
+ t9 = /*#__PURE__*/jsx(ResourceProvider, {
791
+ resource: resource,
792
+ children: t8
793
+ });
794
+ $[20] = resource;
795
+ $[21] = t8;
796
+ $[22] = t9;
797
+ } else {
798
+ t9 = $[22];
799
+ }
800
+ return t9;
503
801
  }
504
802
 
505
- function ResourceCreateButton(_ref) {
506
- var resource = _ref.resource,
507
- _ref$size = _ref.size,
508
- size = _ref$size === void 0 ? 'lg' : _ref$size,
509
- _ref$className = _ref.className,
510
- className = _ref$className === void 0 ? null : _ref$className;
511
- var _resource$types = resource.types,
512
- types = _resource$types === void 0 ? null : _resource$types;
513
- var resourceRoute = useResourceUrlGenerator(resource);
514
- var resourceValues = useResourceValues(resource);
515
- var _useState = useState(false),
516
- _useState2 = _slicedToArray(_useState, 2),
517
- dropdownOpened = _useState2[0],
518
- setDropdownOpened = _useState2[1];
519
- var onClickDropdown = useCallback(function (e) {
520
- e.preventDefault();
521
- e.stopPropagation();
522
- setDropdownOpened(!dropdownOpened);
523
- }, [setDropdownOpened, dropdownOpened]);
524
- var finalTypes = types !== null ? types.filter(function (_ref2) {
525
- var _ref2$settings = _ref2.settings,
526
- _ref2$settings2 = _ref2$settings === void 0 ? {} : _ref2$settings,
527
- _ref2$settings2$canCr = _ref2$settings2.canCreate,
528
- canCreate = _ref2$settings2$canCr === void 0 ? true : _ref2$settings2$canCr;
529
- return canCreate;
530
- }) : null;
531
- var hasMultipleTypes = finalTypes !== null && finalTypes.length > 1;
532
- var onDropdownClickOutside = useCallback(function () {
533
- if (dropdownOpened) {
534
- setDropdownOpened(false);
803
+ function ResourceCreateButton(t0) {
804
+ const $ = c(24);
805
+ const {
806
+ resource,
807
+ size: t1,
808
+ className: t2
809
+ } = t0;
810
+ const size = t1 === undefined ? "lg" : t1;
811
+ const className = t2 === undefined ? null : t2;
812
+ const {
813
+ types: t3
814
+ } = resource;
815
+ const types = t3 === undefined ? null : t3;
816
+ const resourceRoute = useResourceUrlGenerator(resource);
817
+ const resourceValues = useResourceValues(resource);
818
+ const [dropdownOpened, setDropdownOpened] = useState(false);
819
+ let t4;
820
+ if ($[0] !== dropdownOpened) {
821
+ t4 = e => {
822
+ e.preventDefault();
823
+ e.stopPropagation();
824
+ setDropdownOpened(!dropdownOpened);
825
+ };
826
+ $[0] = dropdownOpened;
827
+ $[1] = t4;
828
+ } else {
829
+ t4 = $[1];
830
+ }
831
+ const onClickDropdown = t4;
832
+ let t5;
833
+ if ($[2] !== className || $[3] !== dropdownOpened || $[4] !== onClickDropdown || $[5] !== resourceRoute || $[6] !== resourceValues || $[7] !== size || $[8] !== types) {
834
+ const finalTypes = types !== null ? types.filter(_temp$3) : null;
835
+ const hasMultipleTypes = finalTypes !== null && finalTypes.length > 1;
836
+ let t6;
837
+ if ($[10] !== dropdownOpened) {
838
+ t6 = () => {
839
+ if (dropdownOpened) {
840
+ setDropdownOpened(false);
841
+ }
842
+ };
843
+ $[10] = dropdownOpened;
844
+ $[11] = t6;
845
+ } else {
846
+ t6 = $[11];
535
847
  }
536
- }, [setDropdownOpened, dropdownOpened]);
537
- var button = /*#__PURE__*/jsx(Button, {
538
- href: !hasMultipleTypes ? "".concat(resourceRoute('create')).concat(finalTypes !== null && finalTypes.length === 1 ? "?type=".concat(finalTypes[0].id) : '') : '#',
539
- size: size,
540
- theme: "primary",
541
- className: classNames([_defineProperty({
542
- 'dropdown-toggle': hasMultipleTypes
543
- }, className, className !== null)]),
544
- onClick: hasMultipleTypes ? onClickDropdown : null,
545
- children: /*#__PURE__*/jsx(FormattedMessage, {
546
- values: resourceValues,
547
- id: "l+ddDH",
548
- defaultMessage: [{
549
- "type": 0,
550
- "value": "Create "
551
- }, {
552
- "type": 1,
553
- "value": "a_singular"
554
- }]
555
- })
556
- });
557
- return hasMultipleTypes ? /*#__PURE__*/jsxs("div", {
558
- className: classNames(['dropdown', {
559
- show: dropdownOpened
560
- }]),
561
- children: [button, /*#__PURE__*/jsx(Dropdown, {
562
- items: finalTypes.map(function (it) {
563
- return {
848
+ const onDropdownClickOutside = t6;
849
+ const t7 = !hasMultipleTypes ? `${resourceRoute("create")}${finalTypes !== null && finalTypes.length === 1 ? `?type=${finalTypes[0].id}` : ""}` : "#";
850
+ const t8 = className !== null;
851
+ let t9;
852
+ if ($[12] !== className || $[13] !== hasMultipleTypes || $[14] !== t8) {
853
+ t9 = classNames([{
854
+ "dropdown-toggle": hasMultipleTypes,
855
+ [className]: t8
856
+ }]);
857
+ $[12] = className;
858
+ $[13] = hasMultipleTypes;
859
+ $[14] = t8;
860
+ $[15] = t9;
861
+ } else {
862
+ t9 = $[15];
863
+ }
864
+ const t10 = hasMultipleTypes ? onClickDropdown : null;
865
+ let t11;
866
+ if ($[16] !== resourceValues) {
867
+ t11 = /*#__PURE__*/jsx(FormattedMessage, {
868
+ id: "l+ddDH",
869
+ values: resourceValues
870
+ });
871
+ $[16] = resourceValues;
872
+ $[17] = t11;
873
+ } else {
874
+ t11 = $[17];
875
+ }
876
+ let t12;
877
+ if ($[18] !== size || $[19] !== t10 || $[20] !== t11 || $[21] !== t7 || $[22] !== t9) {
878
+ t12 = /*#__PURE__*/jsx(Button, {
879
+ href: t7,
880
+ size: size,
881
+ theme: "primary",
882
+ className: t9,
883
+ onClick: t10,
884
+ children: t11
885
+ });
886
+ $[18] = size;
887
+ $[19] = t10;
888
+ $[20] = t11;
889
+ $[21] = t7;
890
+ $[22] = t9;
891
+ $[23] = t12;
892
+ } else {
893
+ t12 = $[23];
894
+ }
895
+ const button = t12;
896
+ t5 = hasMultipleTypes ? /*#__PURE__*/jsxs("div", {
897
+ className: classNames(["dropdown", {
898
+ show: dropdownOpened
899
+ }]),
900
+ children: [button, /*#__PURE__*/jsx(Dropdown, {
901
+ items: finalTypes.map(it => ({
564
902
  id: it.id,
565
903
  label: it.name,
566
- href: "".concat(resourceRoute('create'), "?type=").concat(it.id)
567
- };
568
- }),
569
- visible: dropdownOpened,
570
- align: "end",
571
- onClickOutside: onDropdownClickOutside
572
- })]
573
- }) : button;
904
+ href: `${resourceRoute("create")}?type=${it.id}`
905
+ })),
906
+ visible: dropdownOpened,
907
+ align: "end",
908
+ onClickOutside: onDropdownClickOutside
909
+ })]
910
+ }) : button;
911
+ $[2] = className;
912
+ $[3] = dropdownOpened;
913
+ $[4] = onClickDropdown;
914
+ $[5] = resourceRoute;
915
+ $[6] = resourceValues;
916
+ $[7] = size;
917
+ $[8] = types;
918
+ $[9] = t5;
919
+ } else {
920
+ t5 = $[9];
921
+ }
922
+ return t5;
923
+ }
924
+ function _temp$3(t0) {
925
+ const {
926
+ settings: t1
927
+ } = t0;
928
+ const {
929
+ canCreate: t2
930
+ } = t1 === undefined ? {} : t1;
931
+ const canCreate = t2 === undefined ? true : t2;
932
+ return canCreate;
574
933
  }
575
934
 
576
- var _excluded$3 = ["resource"];
577
935
  // Kept for backward compatibility with exports
578
- function ResourceItemsList(_ref) {
579
- var resource = _ref.resource,
580
- props = _objectWithoutProperties(_ref, _excluded$3);
581
- var _ref2 = isObject(resource) ? resource : {
936
+ function ResourceItemsList(t0) {
937
+ const $ = c(8);
938
+ let props;
939
+ let resource;
940
+ if ($[0] !== t0) {
941
+ ({
942
+ resource,
943
+ ...props
944
+ } = t0);
945
+ $[0] = t0;
946
+ $[1] = props;
947
+ $[2] = resource;
948
+ } else {
949
+ props = $[1];
950
+ resource = $[2];
951
+ }
952
+ let t1;
953
+ if ($[3] !== resource) {
954
+ t1 = isObject(resource) ? resource : {
582
955
  id: resource
583
- },
584
- _ref2$id = _ref2.id,
585
- finalResource = _ref2$id === void 0 ? null : _ref2$id;
586
- return /*#__PURE__*/jsx(ResourceList, _objectSpread({
587
- resource: finalResource
588
- }, props));
956
+ };
957
+ $[3] = resource;
958
+ $[4] = t1;
959
+ } else {
960
+ t1 = $[4];
961
+ }
962
+ const {
963
+ id: t2
964
+ } = t1;
965
+ const finalResource = t2 === undefined ? null : t2;
966
+ let t3;
967
+ if ($[5] !== finalResource || $[6] !== props) {
968
+ t3 = /*#__PURE__*/jsx(ResourceList, {
969
+ resource: finalResource,
970
+ ...props
971
+ });
972
+ $[5] = finalResource;
973
+ $[6] = props;
974
+ $[7] = t3;
975
+ } else {
976
+ t3 = $[7];
977
+ }
978
+ return t3;
589
979
  }
590
980
 
591
- var _excluded$2 = ["id", "component", "withQuery", "href"];
592
- var DEFAULT_ACTIONS = ['create'];
593
- function ResourceIndexPage(_ref) {
594
- var resource = _ref.resource,
595
- _ref$defaultActions = _ref.defaultActions,
596
- defaultActions = _ref$defaultActions === void 0 ? DEFAULT_ACTIONS : _ref$defaultActions,
597
- _ref$actionsProps = _ref.actionsProps,
598
- actionsProps = _ref$actionsProps === void 0 ? null : _ref$actionsProps;
599
- var _usePanneauColorSchem = usePanneauColorScheme(),
600
- _usePanneauColorSchem2 = _usePanneauColorSchem.theme,
601
- theme = _usePanneauColorSchem2 === void 0 ? null : _usePanneauColorSchem2;
602
- var name = resource.name,
603
- _resource$settings = resource.settings,
604
- settings = _resource$settings === void 0 ? {} : _resource$settings,
605
- _resource$index = resource.index,
606
- index = _resource$index === void 0 ? {} : _resource$index;
607
- var _ref2 = settings || {},
608
- _ref2$canCreate = _ref2.canCreate,
609
- canCreate = _ref2$canCreate === void 0 ? true : _ref2$canCreate,
610
- _ref2$indexIsPaginate = _ref2.indexIsPaginated,
611
- paginated = _ref2$indexIsPaginate === void 0 ? false : _ref2$indexIsPaginate;
612
- var _ref3 = index || {},
613
- _ref3$actions = _ref3.actions,
614
- indexActions = _ref3$actions === void 0 ? null : _ref3$actions;
615
- var finalActions = useMemo(function () {
616
- return (indexActions || defaultActions.filter(function (it) {
617
- return it !== 'create' || canCreate;
618
- })).map(function (it) {
619
- return it === 'create' ? {
620
- id: 'create',
621
- component: ResourceCreateButton,
622
- size: 'md',
623
- theme: 'primary'
624
- } : it;
981
+ const DEFAULT_ACTIONS = ['create'];
982
+ function ResourceIndexPage(t0) {
983
+ const $ = c(70);
984
+ const {
985
+ resource,
986
+ defaultActions: t1,
987
+ actionsProps: t2
988
+ } = t0;
989
+ const defaultActions = t1 === undefined ? DEFAULT_ACTIONS : t1;
990
+ const actionsProps = t2 === undefined ? null : t2;
991
+ const {
992
+ theme: t3
993
+ } = usePanneauColorScheme();
994
+ const theme = t3 === undefined ? null : t3;
995
+ const {
996
+ name,
997
+ settings: t4,
998
+ index: t5
999
+ } = resource;
1000
+ let t6;
1001
+ if ($[0] !== t4) {
1002
+ t6 = t4 === undefined ? {} : t4;
1003
+ $[0] = t4;
1004
+ $[1] = t6;
1005
+ } else {
1006
+ t6 = $[1];
1007
+ }
1008
+ const settings = t6;
1009
+ let t7;
1010
+ if ($[2] !== t5) {
1011
+ t7 = t5 === undefined ? {} : t5;
1012
+ $[2] = t5;
1013
+ $[3] = t7;
1014
+ } else {
1015
+ t7 = $[3];
1016
+ }
1017
+ const index = t7;
1018
+ let t8;
1019
+ if ($[4] !== settings) {
1020
+ t8 = settings || {};
1021
+ $[4] = settings;
1022
+ $[5] = t8;
1023
+ } else {
1024
+ t8 = $[5];
1025
+ }
1026
+ const {
1027
+ canCreate: t9,
1028
+ indexIsPaginated: t10
1029
+ } = t8;
1030
+ const canCreate = t9 === undefined ? true : t9;
1031
+ const paginated = t10 === undefined ? false : t10;
1032
+ let t11;
1033
+ if ($[6] !== index) {
1034
+ t11 = index || {};
1035
+ $[6] = index;
1036
+ $[7] = t11;
1037
+ } else {
1038
+ t11 = $[7];
1039
+ }
1040
+ const {
1041
+ actions: t12
1042
+ } = t11;
1043
+ const indexActions = t12 === undefined ? null : t12;
1044
+ let t13;
1045
+ if ($[8] !== canCreate || $[9] !== defaultActions || $[10] !== indexActions) {
1046
+ t13 = indexActions || defaultActions.filter(it => it !== "create" || canCreate);
1047
+ $[8] = canCreate;
1048
+ $[9] = defaultActions;
1049
+ $[10] = indexActions;
1050
+ $[11] = t13;
1051
+ } else {
1052
+ t13 = $[11];
1053
+ }
1054
+ let t14;
1055
+ if ($[12] !== t13) {
1056
+ t14 = t13.map(_temp$2);
1057
+ $[12] = t13;
1058
+ $[13] = t14;
1059
+ } else {
1060
+ t14 = $[13];
1061
+ }
1062
+ const finalActions = t14;
1063
+ const resourceValues = useResourceValues(resource);
1064
+ const actionsComponentsManager = useActionsComponentsManager();
1065
+ const [, navigate] = useLocation();
1066
+ const search = useSearch();
1067
+ let t15;
1068
+ if ($[14] !== search) {
1069
+ t15 = queryString.parse(search, {
1070
+ arrayFormat: "bracket"
625
1071
  });
626
- }, [canCreate, indexActions, defaultActions]);
627
- var resourceValues = useResourceValues(resource);
628
- var actionsComponentsManager = useActionsComponentsManager();
629
- var _useLocation = useLocation(),
630
- _useLocation2 = _slicedToArray(_useLocation, 2),
631
- navigate = _useLocation2[1];
632
- var search = useSearch();
633
- var query = useMemo(function () {
634
- return queryString.parse(search, {
635
- arrayFormat: 'bracket'
1072
+ $[14] = search;
1073
+ $[15] = t15;
1074
+ } else {
1075
+ t15 = $[15];
1076
+ }
1077
+ const query = t15;
1078
+ const listQuery = query;
1079
+ let t16;
1080
+ if ($[16] !== query) {
1081
+ t16 = query || {};
1082
+ $[16] = query;
1083
+ $[17] = t16;
1084
+ } else {
1085
+ t16 = $[17];
1086
+ }
1087
+ const {
1088
+ created: t17,
1089
+ deleted: t18
1090
+ } = t16;
1091
+ const created = t17 === undefined ? false : t17;
1092
+ const deleted = t18 === undefined ? false : t18;
1093
+ const resourceRoute = useResourceUrlGenerator(resource);
1094
+ let t19;
1095
+ if ($[18] !== resourceRoute) {
1096
+ t19 = resourceRoute("index");
1097
+ $[18] = resourceRoute;
1098
+ $[19] = t19;
1099
+ } else {
1100
+ t19 = $[19];
1101
+ }
1102
+ const url = t19;
1103
+ let t20;
1104
+ if ($[20] !== navigate || $[21] !== url) {
1105
+ t20 = submitQuery => {
1106
+ const newQuery = submitQuery !== null ? Object.keys(submitQuery).reduce((currentQuery, key) => {
1107
+ const value = submitQuery[key];
1108
+ return value !== null ? {
1109
+ ...currentQuery,
1110
+ [key]: value
1111
+ } : currentQuery;
1112
+ }, {}) : null;
1113
+ navigate(`${url}${newQuery !== null ? `?${queryString.stringify(newQuery, {
1114
+ arrayFormat: "bracket"
1115
+ })}` : ""}`);
1116
+ };
1117
+ $[20] = navigate;
1118
+ $[21] = url;
1119
+ $[22] = t20;
1120
+ } else {
1121
+ t20 = $[22];
1122
+ }
1123
+ const onQueryChange = t20;
1124
+ let t21;
1125
+ if ($[23] !== navigate || $[24] !== url) {
1126
+ t21 = () => {
1127
+ const resetQuery = queryString.stringify(null, {
1128
+ arrayFormat: "bracket"
1129
+ });
1130
+ navigate(`${url}?${resetQuery}`);
1131
+ };
1132
+ $[23] = navigate;
1133
+ $[24] = url;
1134
+ $[25] = t21;
1135
+ } else {
1136
+ t21 = $[25];
1137
+ }
1138
+ const onQueryReset = t21;
1139
+ let t22;
1140
+ if ($[26] !== navigate || $[27] !== url) {
1141
+ t22 = () => {
1142
+ navigate(url, {
1143
+ replace: true
1144
+ });
1145
+ };
1146
+ $[26] = navigate;
1147
+ $[27] = url;
1148
+ $[28] = t22;
1149
+ } else {
1150
+ t22 = $[28];
1151
+ }
1152
+ const onClickCloseAlert = t22;
1153
+ let t23;
1154
+ if ($[29] !== actionsComponentsManager || $[30] !== finalActions || $[31] !== onQueryChange || $[32] !== query || $[33] !== resource) {
1155
+ t23 = finalActions.length > 0 ? /*#__PURE__*/jsx("div", {
1156
+ className: "d-flex align-items-center",
1157
+ children: finalActions.map(t24 => {
1158
+ const {
1159
+ id,
1160
+ component: t25,
1161
+ withQuery: t26,
1162
+ href: t27,
1163
+ ...otherProps
1164
+ } = t24;
1165
+ const component = t25 === undefined ? Button : t25;
1166
+ const withQuery = t26 === undefined ? false : t26;
1167
+ const href = t27 === undefined ? null : t27;
1168
+ const ActionComponent = isString(component) ? actionsComponentsManager.getComponent(component) : component;
1169
+ const isButton = ActionComponent === Button;
1170
+ let finalHref = href;
1171
+ if (isButton && withQuery && href !== null) {
1172
+ finalHref = `${finalHref}${finalHref.indexOf("?") !== -1 ? "&" : "?"}${queryString.stringify(query, {
1173
+ arrayFormat: "bracket"
1174
+ })}`;
1175
+ }
1176
+ return ActionComponent !== null ? /*#__PURE__*/jsx(ActionComponent, {
1177
+ href: finalHref,
1178
+ ...otherProps,
1179
+ ...(!isButton ? {
1180
+ resource,
1181
+ query,
1182
+ onQueryChange
1183
+ } : {})
1184
+ }, `action-${id}`) : null;
1185
+ })
1186
+ }) : null;
1187
+ $[29] = actionsComponentsManager;
1188
+ $[30] = finalActions;
1189
+ $[31] = onQueryChange;
1190
+ $[32] = query;
1191
+ $[33] = resource;
1192
+ $[34] = t23;
1193
+ } else {
1194
+ t23 = $[34];
1195
+ }
1196
+ let t24;
1197
+ if ($[35] !== name || $[36] !== t23) {
1198
+ t24 = /*#__PURE__*/jsx(PageHeader, {
1199
+ title: name,
1200
+ actions: t23
636
1201
  });
637
- }, [search]);
638
- var listQuery = useMemo(function () {
639
- return query;
640
- }, [query]); // TODO: omit routes
641
- var _ref4 = query || {},
642
- _ref4$created = _ref4.created,
643
- created = _ref4$created === void 0 ? false : _ref4$created,
644
- _ref4$deleted = _ref4.deleted,
645
- deleted = _ref4$deleted === void 0 ? false : _ref4$deleted;
646
- var resourceRoute = useResourceUrlGenerator(resource);
647
- var url = resourceRoute('index');
648
- var onQueryChange = useCallback(function (submitQuery) {
649
- var newQuery = submitQuery !== null ? Object.keys(submitQuery).reduce(function (currentQuery, key) {
650
- var value = submitQuery[key];
651
- return value !== null ? _objectSpread(_objectSpread({}, currentQuery), {}, _defineProperty({}, key, value)) : currentQuery;
652
- }, {}) : null;
653
- navigate("".concat(url).concat(newQuery !== null ? "?".concat(queryString.stringify(newQuery, {
654
- arrayFormat: 'bracket'
655
- })) : ''));
656
- }, [navigate, url]);
657
- var onQueryReset = useCallback(function () {
658
- var resetQuery = queryString.stringify(null, {
659
- arrayFormat: 'bracket'
1202
+ $[35] = name;
1203
+ $[36] = t23;
1204
+ $[37] = t24;
1205
+ } else {
1206
+ t24 = $[37];
1207
+ }
1208
+ let t25;
1209
+ if ($[38] === Symbol.for("react.memo_cache_sentinel")) {
1210
+ t25 = classNames(["container-sm py-4"]);
1211
+ $[38] = t25;
1212
+ } else {
1213
+ t25 = $[38];
1214
+ }
1215
+ let t26;
1216
+ if ($[39] !== created || $[40] !== onClickCloseAlert || $[41] !== resourceValues) {
1217
+ t26 = created ? /*#__PURE__*/jsx(Alert, {
1218
+ className: "mb-4",
1219
+ onClose: onClickCloseAlert,
1220
+ children: /*#__PURE__*/jsx(FormattedMessage, {
1221
+ id: "bfP/d8",
1222
+ values: resourceValues
1223
+ })
1224
+ }) : null;
1225
+ $[39] = created;
1226
+ $[40] = onClickCloseAlert;
1227
+ $[41] = resourceValues;
1228
+ $[42] = t26;
1229
+ } else {
1230
+ t26 = $[42];
1231
+ }
1232
+ let t27;
1233
+ if ($[43] !== deleted || $[44] !== onClickCloseAlert || $[45] !== resourceValues) {
1234
+ t27 = deleted ? /*#__PURE__*/jsx(Alert, {
1235
+ className: "mb-4",
1236
+ onClose: onClickCloseAlert,
1237
+ children: /*#__PURE__*/jsx(FormattedMessage, {
1238
+ id: "dkRdks",
1239
+ values: resourceValues
1240
+ })
1241
+ }) : null;
1242
+ $[43] = deleted;
1243
+ $[44] = onClickCloseAlert;
1244
+ $[45] = resourceValues;
1245
+ $[46] = t27;
1246
+ } else {
1247
+ t27 = $[46];
1248
+ }
1249
+ let t28;
1250
+ if ($[47] !== actionsProps) {
1251
+ t28 = actionsProps || {};
1252
+ $[47] = actionsProps;
1253
+ $[48] = t28;
1254
+ } else {
1255
+ t28 = $[48];
1256
+ }
1257
+ let t29;
1258
+ if ($[49] !== t28) {
1259
+ t29 = {
1260
+ size: "sm",
1261
+ ...t28
1262
+ };
1263
+ $[49] = t28;
1264
+ $[50] = t29;
1265
+ } else {
1266
+ t29 = $[50];
1267
+ }
1268
+ let t30;
1269
+ if ($[51] !== listQuery || $[52] !== onQueryChange || $[53] !== onQueryReset || $[54] !== paginated || $[55] !== resource || $[56] !== t29 || $[57] !== theme || $[58] !== url) {
1270
+ t30 = /*#__PURE__*/jsx(ResourceItemsList, {
1271
+ resource: resource,
1272
+ baseUrl: url,
1273
+ query: listQuery,
1274
+ paginated: paginated,
1275
+ onQueryChange: onQueryChange,
1276
+ onQueryReset: onQueryReset,
1277
+ theme: theme,
1278
+ actionsProps: t29
660
1279
  });
661
- navigate("".concat(url, "?").concat(resetQuery));
662
- }, [navigate, url]);
663
- var onClickCloseAlert = useCallback(function () {
664
- navigate(url, {
665
- replace: true
1280
+ $[51] = listQuery;
1281
+ $[52] = onQueryChange;
1282
+ $[53] = onQueryReset;
1283
+ $[54] = paginated;
1284
+ $[55] = resource;
1285
+ $[56] = t29;
1286
+ $[57] = theme;
1287
+ $[58] = url;
1288
+ $[59] = t30;
1289
+ } else {
1290
+ t30 = $[59];
1291
+ }
1292
+ let t31;
1293
+ if ($[60] !== t26 || $[61] !== t27 || $[62] !== t30) {
1294
+ t31 = /*#__PURE__*/jsxs("div", {
1295
+ className: t25,
1296
+ children: [t26, t27, t30]
666
1297
  });
667
- }, [navigate, url]);
668
- return /*#__PURE__*/jsx(ResourceProvider, {
669
- resource: resource,
670
- children: /*#__PURE__*/jsxs(MainLayout, {
671
- children: [/*#__PURE__*/jsx(PageHeader, {
672
- title: name,
673
- actions: finalActions.length > 0 ? /*#__PURE__*/jsx("div", {
674
- className: "d-flex align-items-center",
675
- children: finalActions.map(function (_ref5) {
676
- var id = _ref5.id,
677
- _ref5$component = _ref5.component,
678
- component = _ref5$component === void 0 ? Button : _ref5$component,
679
- _ref5$withQuery = _ref5.withQuery,
680
- withQuery = _ref5$withQuery === void 0 ? false : _ref5$withQuery,
681
- _ref5$href = _ref5.href,
682
- href = _ref5$href === void 0 ? null : _ref5$href,
683
- otherProps = _objectWithoutProperties(_ref5, _excluded$2);
684
- var ActionComponent = isString(component) ? actionsComponentsManager.getComponent(component) : component;
685
- var isButton = ActionComponent === Button;
686
- var finalHref = href;
687
- if (isButton && withQuery && href !== null) {
688
- finalHref = "".concat(finalHref).concat(finalHref.indexOf('?') !== -1 ? '&' : '?').concat(queryString.stringify(query, {
689
- arrayFormat: 'bracket'
690
- }));
691
- }
692
- return ActionComponent !== null ? /*#__PURE__*/jsx(ActionComponent, _objectSpread(_objectSpread({
693
- href: finalHref
694
- }, otherProps), !isButton ? {
695
- resource: resource,
696
- query: query,
697
- onQueryChange: onQueryChange
698
- } : {}), "action-".concat(id)) : null;
699
- })
700
- }) : null
701
- }), /*#__PURE__*/jsxs("div", {
702
- className: classNames(['container-sm py-4']),
703
- children: [created ? /*#__PURE__*/jsx(Alert, {
704
- className: "mb-4",
705
- onClose: onClickCloseAlert,
706
- children: /*#__PURE__*/jsx(FormattedMessage, {
707
- values: resourceValues,
708
- id: "bfP/d8",
709
- defaultMessage: [{
710
- "type": 1,
711
- "value": "The_singular"
712
- }, {
713
- "type": 0,
714
- "value": " has been created."
715
- }]
716
- })
717
- }) : null, deleted ? /*#__PURE__*/jsx(Alert, {
718
- className: "mb-4",
719
- onClose: onClickCloseAlert,
720
- children: /*#__PURE__*/jsx(FormattedMessage, {
721
- values: resourceValues,
722
- id: "dkRdks",
723
- defaultMessage: [{
724
- "type": 1,
725
- "value": "The_singular"
726
- }, {
727
- "type": 0,
728
- "value": " has been deleted."
729
- }]
730
- })
731
- }) : null, /*#__PURE__*/jsx(ResourceItemsList, {
732
- resource: resource,
733
- baseUrl: url,
734
- query: listQuery,
735
- paginated: paginated,
736
- onQueryChange: onQueryChange,
737
- onQueryReset: onQueryReset,
738
- theme: theme,
739
- actionsProps: _objectSpread({
740
- size: 'sm'
741
- }, actionsProps || {})
742
- })]
743
- })]
744
- })
745
- });
1298
+ $[60] = t26;
1299
+ $[61] = t27;
1300
+ $[62] = t30;
1301
+ $[63] = t31;
1302
+ } else {
1303
+ t31 = $[63];
1304
+ }
1305
+ let t32;
1306
+ if ($[64] !== t24 || $[65] !== t31) {
1307
+ t32 = /*#__PURE__*/jsxs(MainLayout, {
1308
+ children: [t24, t31]
1309
+ });
1310
+ $[64] = t24;
1311
+ $[65] = t31;
1312
+ $[66] = t32;
1313
+ } else {
1314
+ t32 = $[66];
1315
+ }
1316
+ let t33;
1317
+ if ($[67] !== resource || $[68] !== t32) {
1318
+ t33 = /*#__PURE__*/jsx(ResourceProvider, {
1319
+ resource: resource,
1320
+ children: t32
1321
+ });
1322
+ $[67] = resource;
1323
+ $[68] = t32;
1324
+ $[69] = t33;
1325
+ } else {
1326
+ t33 = $[69];
1327
+ }
1328
+ return t33;
1329
+ }
1330
+ function _temp$2(it_0) {
1331
+ return it_0 === "create" ? {
1332
+ id: "create",
1333
+ component: ResourceCreateButton,
1334
+ size: "md",
1335
+ theme: "primary"
1336
+ } : it_0;
746
1337
  }
747
1338
 
748
- function ResourceShowPage(_ref) {
749
- var resource = _ref.resource,
750
- itemId = _ref.itemId;
751
- var name = resource.name;
752
- var _useResourceItem = useResourceItem(resource, itemId),
753
- item = _useResourceItem.item,
754
- loading = _useResourceItem.loading,
755
- error = _useResourceItem.error;
756
- var _ref2 = item || {},
757
- _ref2$type = _ref2.type,
758
- type = _ref2$type === void 0 ? null : _ref2$type;
759
- return /*#__PURE__*/jsx(ResourceProvider, {
760
- resource: resource,
761
- children: /*#__PURE__*/jsxs(MainLayout, {
762
- loading: loading,
763
- children: [item !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
764
- resource: resource,
765
- item: item,
766
- type: type,
767
- disabled: true,
768
- header: /*#__PURE__*/jsx(PageHeader, {
769
- title: "".concat(name, " #").concat(itemId),
770
- small: true
771
- }),
772
- withContainer: true
773
- }) : null, item === null && loading && !error ? /*#__PURE__*/jsx(Loading, {
774
- className: "mw-25 my-4 m-auto",
775
- withDelay: true,
776
- children: /*#__PURE__*/jsx(FormattedMessage, {
777
- id: "TV3jir",
778
- defaultMessage: [{
779
- "type": 0,
780
- "value": "Loading"
781
- }]
782
- })
783
- }) : null]
784
- })
785
- });
1339
+ function ResourceShowPage(t0) {
1340
+ const $ = c(19);
1341
+ const {
1342
+ resource,
1343
+ itemId
1344
+ } = t0;
1345
+ const {
1346
+ name
1347
+ } = resource;
1348
+ const {
1349
+ item,
1350
+ isLoading,
1351
+ error
1352
+ } = useResourceItem(resource, itemId);
1353
+ let t1;
1354
+ if ($[0] !== item) {
1355
+ t1 = item || {};
1356
+ $[0] = item;
1357
+ $[1] = t1;
1358
+ } else {
1359
+ t1 = $[1];
1360
+ }
1361
+ const {
1362
+ type: t2
1363
+ } = t1;
1364
+ const type = t2 === undefined ? null : t2;
1365
+ let t3;
1366
+ if ($[2] !== item || $[3] !== itemId || $[4] !== name || $[5] !== resource || $[6] !== type) {
1367
+ t3 = item !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
1368
+ resource: resource,
1369
+ item: item,
1370
+ type: type,
1371
+ disabled: true,
1372
+ header: /*#__PURE__*/jsx(PageHeader, {
1373
+ title: `${name} #${itemId}`,
1374
+ small: true
1375
+ }),
1376
+ withContainer: true
1377
+ }) : null;
1378
+ $[2] = item;
1379
+ $[3] = itemId;
1380
+ $[4] = name;
1381
+ $[5] = resource;
1382
+ $[6] = type;
1383
+ $[7] = t3;
1384
+ } else {
1385
+ t3 = $[7];
1386
+ }
1387
+ let t4;
1388
+ if ($[8] !== error || $[9] !== isLoading || $[10] !== item) {
1389
+ t4 = item === null && isLoading && !error ? /*#__PURE__*/jsx(Loading, {
1390
+ className: "mw-25 my-4 m-auto",
1391
+ withDelay: true,
1392
+ children: /*#__PURE__*/jsx(FormattedMessage, {
1393
+ id: "TV3jir"
1394
+ })
1395
+ }) : null;
1396
+ $[8] = error;
1397
+ $[9] = isLoading;
1398
+ $[10] = item;
1399
+ $[11] = t4;
1400
+ } else {
1401
+ t4 = $[11];
1402
+ }
1403
+ let t5;
1404
+ if ($[12] !== isLoading || $[13] !== t3 || $[14] !== t4) {
1405
+ t5 = /*#__PURE__*/jsxs(MainLayout, {
1406
+ loading: isLoading,
1407
+ children: [t3, t4]
1408
+ });
1409
+ $[12] = isLoading;
1410
+ $[13] = t3;
1411
+ $[14] = t4;
1412
+ $[15] = t5;
1413
+ } else {
1414
+ t5 = $[15];
1415
+ }
1416
+ let t6;
1417
+ if ($[16] !== resource || $[17] !== t5) {
1418
+ t6 = /*#__PURE__*/jsx(ResourceProvider, {
1419
+ resource: resource,
1420
+ children: t5
1421
+ });
1422
+ $[16] = resource;
1423
+ $[17] = t5;
1424
+ $[18] = t6;
1425
+ } else {
1426
+ t6 = $[18];
1427
+ }
1428
+ return t6;
786
1429
  }
787
1430
 
788
- function ResourceDuplicatePage(_ref) {
789
- var itemId = _ref.itemId,
790
- resource = _ref.resource;
791
- var _useLocation = useLocation(),
792
- _useLocation2 = _slicedToArray(_useLocation, 2),
793
- navigate = _useLocation2[1];
794
- var resourceRoute = useResourceUrlGenerator(resource);
795
- var _useResourceItem = useResourceItem(resource, itemId),
796
- item = _useResourceItem.item,
797
- loading = _useResourceItem.loading,
798
- error = _useResourceItem.error;
799
- var _ref2 = item || {},
800
- _ref2$type = _ref2.type,
801
- type = _ref2$type === void 0 ? null : _ref2$type;
802
- var resourceValues = useResourceValues(resource);
803
- var typeName = useResourceTypeName(resource, type);
804
- var onSuccess = useCallback(function () {
805
- var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
806
- _ref3$id = _ref3.id,
807
- id = _ref3$id === void 0 ? null : _ref3$id;
808
- return navigate("".concat(resourceRoute('edit', {
809
- id: id
810
- }), "?duplicated=true"));
811
- }, [navigate, resourceRoute]);
812
- return /*#__PURE__*/jsx(ResourceProvider, {
813
- resource: resource,
814
- children: /*#__PURE__*/jsxs(MainLayout, {
815
- loading: loading,
816
- children: [item !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
817
- resource: resource,
818
- item: item,
819
- onSuccess: onSuccess,
820
- isDuplicate: true,
821
- withContainer: true,
822
- header: /*#__PURE__*/jsx(PageHeader, {
823
- title: /*#__PURE__*/jsxs(Fragment, {
824
- children: [/*#__PURE__*/jsx(FormattedMessage, {
825
- values: resourceValues,
826
- id: "G7M4nI",
827
- defaultMessage: [{
828
- "type": 0,
829
- "value": "Duplicate "
830
- }, {
831
- "type": 1,
832
- "value": "a_singular"
833
- }]
834
- }), typeName !== null ? /*#__PURE__*/jsxs("span", {
835
- className: "text-body-secondary",
836
- children: [' ', "(", typeName, ")"]
837
- }) : null]
838
- }),
839
- small: true
840
- })
841
- }) : null, item === null && loading && !error ? /*#__PURE__*/jsx(Loading, {
842
- className: "mw-25 my-4 m-auto",
843
- withDelay: true,
844
- children: /*#__PURE__*/jsx(FormattedMessage, {
845
- id: "TV3jir",
846
- defaultMessage: [{
847
- "type": 0,
848
- "value": "Loading"
849
- }]
850
- })
851
- }) : null]
852
- })
853
- });
1431
+ function ResourceDuplicatePage(t0) {
1432
+ const $ = c(22);
1433
+ const {
1434
+ itemId,
1435
+ resource
1436
+ } = t0;
1437
+ const [, navigate] = useLocation();
1438
+ const resourceRoute = useResourceUrlGenerator(resource);
1439
+ const {
1440
+ item,
1441
+ isLoading,
1442
+ error
1443
+ } = useResourceItem(resource, itemId);
1444
+ let t1;
1445
+ if ($[0] !== item) {
1446
+ t1 = item || {};
1447
+ $[0] = item;
1448
+ $[1] = t1;
1449
+ } else {
1450
+ t1 = $[1];
1451
+ }
1452
+ const {
1453
+ type: t2
1454
+ } = t1;
1455
+ const type = t2 === undefined ? null : t2;
1456
+ const resourceValues = useResourceValues(resource);
1457
+ const typeName = useResourceTypeName(resource, type);
1458
+ let t3;
1459
+ if ($[2] !== navigate || $[3] !== resourceRoute) {
1460
+ t3 = t4 => {
1461
+ const {
1462
+ id: t5
1463
+ } = t4 === undefined ? {} : t4;
1464
+ const id = t5 === undefined ? null : t5;
1465
+ return navigate(`${resourceRoute("edit", {
1466
+ id
1467
+ })}?duplicated=true`);
1468
+ };
1469
+ $[2] = navigate;
1470
+ $[3] = resourceRoute;
1471
+ $[4] = t3;
1472
+ } else {
1473
+ t3 = $[4];
1474
+ }
1475
+ const onComplete = t3;
1476
+ let t4;
1477
+ if ($[5] !== item || $[6] !== onComplete || $[7] !== resource || $[8] !== resourceValues || $[9] !== typeName) {
1478
+ t4 = item !== null ? /*#__PURE__*/jsx(ResourceFormWrapper, {
1479
+ resource: resource,
1480
+ item: item,
1481
+ onComplete: onComplete,
1482
+ isDuplicate: true,
1483
+ withContainer: true,
1484
+ header: /*#__PURE__*/jsx(PageHeader, {
1485
+ title: /*#__PURE__*/jsxs(Fragment, {
1486
+ children: [/*#__PURE__*/jsx(FormattedMessage, {
1487
+ id: "G7M4nI",
1488
+ values: resourceValues
1489
+ }), typeName !== null ? /*#__PURE__*/jsxs("span", {
1490
+ className: "text-body-secondary",
1491
+ children: [" ", "(", typeName, ")"]
1492
+ }) : null]
1493
+ }),
1494
+ small: true
1495
+ })
1496
+ }) : null;
1497
+ $[5] = item;
1498
+ $[6] = onComplete;
1499
+ $[7] = resource;
1500
+ $[8] = resourceValues;
1501
+ $[9] = typeName;
1502
+ $[10] = t4;
1503
+ } else {
1504
+ t4 = $[10];
1505
+ }
1506
+ let t5;
1507
+ if ($[11] !== error || $[12] !== isLoading || $[13] !== item) {
1508
+ t5 = item === null && isLoading && !error ? /*#__PURE__*/jsx(Loading, {
1509
+ className: "mw-25 my-4 m-auto",
1510
+ withDelay: true,
1511
+ children: /*#__PURE__*/jsx(FormattedMessage, {
1512
+ id: "TV3jir"
1513
+ })
1514
+ }) : null;
1515
+ $[11] = error;
1516
+ $[12] = isLoading;
1517
+ $[13] = item;
1518
+ $[14] = t5;
1519
+ } else {
1520
+ t5 = $[14];
1521
+ }
1522
+ let t6;
1523
+ if ($[15] !== isLoading || $[16] !== t4 || $[17] !== t5) {
1524
+ t6 = /*#__PURE__*/jsxs(MainLayout, {
1525
+ loading: isLoading,
1526
+ children: [t4, t5]
1527
+ });
1528
+ $[15] = isLoading;
1529
+ $[16] = t4;
1530
+ $[17] = t5;
1531
+ $[18] = t6;
1532
+ } else {
1533
+ t6 = $[18];
1534
+ }
1535
+ let t7;
1536
+ if ($[19] !== resource || $[20] !== t6) {
1537
+ t7 = /*#__PURE__*/jsx(ResourceProvider, {
1538
+ resource: resource,
1539
+ children: t6
1540
+ });
1541
+ $[19] = resource;
1542
+ $[20] = t6;
1543
+ $[21] = t7;
1544
+ } else {
1545
+ t7 = $[21];
1546
+ }
1547
+ return t7;
854
1548
  }
855
1549
 
856
- function ResourceLink(_ref) {
857
- var resource = _ref.resource;
858
- var route = useUrlGenerator();
859
- var _ref2 = resource || {},
860
- resourceId = _ref2.id;
861
- var resourceValues = useResourceValues(resource);
862
- return /*#__PURE__*/jsx(Link, {
863
- className: "d-block my-2",
864
- href: route('resources.index', {
865
- resource: resourceId
866
- }),
867
- children: /*#__PURE__*/jsx(FormattedMessage, {
868
- values: resourceValues,
869
- id: "FntHPK",
870
- defaultMessage: [{
871
- "type": 0,
872
- "value": "View "
873
- }, {
874
- "type": 1,
875
- "value": "the_plural"
876
- }]
877
- })
1550
+ function ResourceLink(t0) {
1551
+ const $ = c(6);
1552
+ const {
1553
+ resource
1554
+ } = t0;
1555
+ const route = useUrlGenerator();
1556
+ const {
1557
+ id: resourceId
1558
+ } = resource || {};
1559
+ const resourceValues = useResourceValues(resource);
1560
+ const T0 = Link;
1561
+ const t1 = "d-block my-2";
1562
+ const t2 = route("resources.index", {
1563
+ resource: resourceId
878
1564
  });
1565
+ let t3;
1566
+ if ($[0] !== resourceValues) {
1567
+ t3 = /*#__PURE__*/jsx(FormattedMessage, {
1568
+ id: "FntHPK",
1569
+ values: resourceValues
1570
+ });
1571
+ $[0] = resourceValues;
1572
+ $[1] = t3;
1573
+ } else {
1574
+ t3 = $[1];
1575
+ }
1576
+ let t4;
1577
+ if ($[2] !== T0 || $[3] !== t2 || $[4] !== t3) {
1578
+ t4 = /*#__PURE__*/jsx(T0, {
1579
+ className: t1,
1580
+ href: t2,
1581
+ children: t3
1582
+ });
1583
+ $[2] = T0;
1584
+ $[3] = t2;
1585
+ $[4] = t3;
1586
+ $[5] = t4;
1587
+ } else {
1588
+ t4 = $[5];
1589
+ }
1590
+ return t4;
879
1591
  }
880
1592
  function HomePage() {
881
- var resources = usePanneauResources();
882
- var visibleResources = resources.filter(function (_ref3) {
883
- var _ref3$settings = _ref3.settings,
884
- _ref3$settings2 = _ref3$settings === void 0 ? {} : _ref3$settings,
885
- _ref3$settings2$hideI = _ref3$settings2.hideInNavbar,
886
- hideInNavbar = _ref3$settings2$hideI === void 0 ? false : _ref3$settings2$hideI;
887
- return !hideInNavbar;
888
- });
889
- return /*#__PURE__*/jsx(MainLayout, {
890
- children: /*#__PURE__*/jsx("div", {
891
- className: "container-sm py-4",
892
- children: visibleResources.map(function (resource) {
893
- var _ref4 = resource || {},
894
- resourceId = _ref4.id;
895
- return /*#__PURE__*/jsx(ResourceLink, {
896
- resource: resource
897
- }, "resource-link-".concat(resourceId));
898
- })
899
- })
900
- });
1593
+ const $ = c(10);
1594
+ const resources = usePanneauResources();
1595
+ let T0;
1596
+ let t0;
1597
+ let t1;
1598
+ if ($[0] !== resources) {
1599
+ const visibleResources = resources.filter(_temp$1);
1600
+ T0 = MainLayout;
1601
+ t0 = "container-sm py-4";
1602
+ t1 = visibleResources.map(_temp2$1);
1603
+ $[0] = resources;
1604
+ $[1] = T0;
1605
+ $[2] = t0;
1606
+ $[3] = t1;
1607
+ } else {
1608
+ T0 = $[1];
1609
+ t0 = $[2];
1610
+ t1 = $[3];
1611
+ }
1612
+ let t2;
1613
+ if ($[4] !== t0 || $[5] !== t1) {
1614
+ t2 = /*#__PURE__*/jsx("div", {
1615
+ className: t0,
1616
+ children: t1
1617
+ });
1618
+ $[4] = t0;
1619
+ $[5] = t1;
1620
+ $[6] = t2;
1621
+ } else {
1622
+ t2 = $[6];
1623
+ }
1624
+ let t3;
1625
+ if ($[7] !== T0 || $[8] !== t2) {
1626
+ t3 = /*#__PURE__*/jsx(T0, {
1627
+ children: t2
1628
+ });
1629
+ $[7] = T0;
1630
+ $[8] = t2;
1631
+ $[9] = t3;
1632
+ } else {
1633
+ t3 = $[9];
1634
+ }
1635
+ return t3;
1636
+ }
1637
+ function _temp2$1(resource) {
1638
+ const {
1639
+ id: resourceId
1640
+ } = resource || {};
1641
+ return /*#__PURE__*/jsx(ResourceLink, {
1642
+ resource: resource
1643
+ }, `resource-link-${resourceId}`);
1644
+ }
1645
+ function _temp$1(t0) {
1646
+ const {
1647
+ settings: t1
1648
+ } = t0;
1649
+ const {
1650
+ hideInNavbar: t2
1651
+ } = t1 === undefined ? {} : t1;
1652
+ const hideInNavbar = t2 === undefined ? false : t2;
1653
+ return !hideInNavbar;
901
1654
  }
902
1655
 
903
1656
  function AccountPage() {
904
- return /*#__PURE__*/jsx(MainLayout, {
905
- children: /*#__PURE__*/jsx("div", {
906
- className: "container-sm py-4",
907
- children: "Account page"
908
- })
909
- });
1657
+ const $ = c(1);
1658
+ let t0;
1659
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1660
+ t0 = /*#__PURE__*/jsx(MainLayout, {
1661
+ children: /*#__PURE__*/jsx("div", {
1662
+ className: "container-sm py-4",
1663
+ children: "Account page"
1664
+ })
1665
+ });
1666
+ $[0] = t0;
1667
+ } else {
1668
+ t0 = $[0];
1669
+ }
1670
+ return t0;
910
1671
  }
911
1672
 
912
- function LoginForm(_ref) {
913
- var _ref$className = _ref.className,
914
- className = _ref$className === void 0 ? null : _ref$className,
915
- _ref$onSuccess = _ref.onSuccess,
916
- onSuccess = _ref$onSuccess === void 0 ? null : _ref$onSuccess;
917
- var url = useUrlGenerator();
918
- var _useAuth = useAuth(),
919
- login = _useAuth.login;
920
- var postForm = useCallback(function (action, _ref2) {
921
- var email = _ref2.email,
922
- password = _ref2.password;
923
- return login(email, password);
924
- }, [login]);
925
- var FormComponents = useFormsComponents();
926
- var FormComponent = getComponentFromName('login', FormComponents);
927
- return FormComponent !== null ? /*#__PURE__*/jsx(FormComponent, {
928
- action: url('auth.login'),
929
- postForm: postForm,
930
- onComplete: onSuccess,
931
- className: className,
932
- submitButtonLabel: /*#__PURE__*/jsx(FormattedMessage, {
933
- id: "g6qbbX",
934
- defaultMessage: [{
935
- "type": 0,
936
- "value": "Log in"
937
- }]
938
- })
939
- }) : null;
1673
+ function LoginForm(t0) {
1674
+ const $ = c(10);
1675
+ const {
1676
+ className: t1,
1677
+ onComplete: t2
1678
+ } = t0;
1679
+ const className = t1 === undefined ? null : t1;
1680
+ const onComplete = t2 === undefined ? null : t2;
1681
+ const url = useUrlGenerator();
1682
+ const {
1683
+ login
1684
+ } = useAuth();
1685
+ let t3;
1686
+ if ($[0] !== login) {
1687
+ t3 = (action, t4) => {
1688
+ const {
1689
+ email,
1690
+ password
1691
+ } = t4;
1692
+ return login(email, password);
1693
+ };
1694
+ $[0] = login;
1695
+ $[1] = t3;
1696
+ } else {
1697
+ t3 = $[1];
1698
+ }
1699
+ const postForm = t3;
1700
+ const FormComponents = useFormsComponents();
1701
+ let t4;
1702
+ if ($[2] !== FormComponents) {
1703
+ t4 = getComponentFromName("login", FormComponents);
1704
+ $[2] = FormComponents;
1705
+ $[3] = t4;
1706
+ } else {
1707
+ t4 = $[3];
1708
+ }
1709
+ const FormComponent = t4;
1710
+ let t5;
1711
+ if ($[4] !== FormComponent || $[5] !== className || $[6] !== onComplete || $[7] !== postForm || $[8] !== url) {
1712
+ t5 = FormComponent !== null ? /*#__PURE__*/jsx(FormComponent, {
1713
+ action: url("auth.login"),
1714
+ postForm: postForm,
1715
+ onComplete: onComplete,
1716
+ className: className,
1717
+ submitButtonLabel: /*#__PURE__*/jsx(FormattedMessage, {
1718
+ id: "g6qbbX"
1719
+ })
1720
+ }) : null;
1721
+ $[4] = FormComponent;
1722
+ $[5] = className;
1723
+ $[6] = onComplete;
1724
+ $[7] = postForm;
1725
+ $[8] = url;
1726
+ $[9] = t5;
1727
+ } else {
1728
+ t5 = $[9];
1729
+ }
1730
+ return t5;
940
1731
  }
941
1732
 
942
- function GuestLayout(_ref) {
943
- var _ref$fullscreen = _ref.fullscreen,
944
- fullscreen = _ref$fullscreen === void 0 ? false : _ref$fullscreen,
945
- children = _ref.children;
946
- var _usePanneauColorSchem = usePanneauColorScheme(),
947
- _usePanneauColorSchem2 = _usePanneauColorSchem.theme,
948
- theme = _usePanneauColorSchem2 === void 0 ? null : _usePanneauColorSchem2,
949
- _usePanneauColorSchem3 = _usePanneauColorSchem.background,
950
- background = _usePanneauColorSchem3 === void 0 ? null : _usePanneauColorSchem3,
951
- _usePanneauColorSchem4 = _usePanneauColorSchem.text,
952
- text = _usePanneauColorSchem4 === void 0 ? null : _usePanneauColorSchem4;
1733
+ function GuestLayout({
1734
+ fullscreen = false,
1735
+ children
1736
+ }) {
1737
+ const {
1738
+ theme = null,
1739
+ background = null,
1740
+ text = null
1741
+ } = usePanneauColorScheme();
953
1742
  return /*#__PURE__*/jsxs("div", {
954
1743
  className: classNames([{
955
1744
  'd-flex flex-column min-vh-100': fullscreen
@@ -958,9 +1747,11 @@ function GuestLayout(_ref) {
958
1747
  children: [/*#__PURE__*/jsx(MainNavbar, {
959
1748
  className: classNames(['sticky-top', 'px-3'])
960
1749
  }), /*#__PURE__*/jsx("div", {
961
- className: classNames(_defineProperty(_defineProperty({
962
- 'd-flex flex-column flex-grow-1': fullscreen
963
- }, "bg-".concat(background), background !== null), "text-".concat(text), text !== null)),
1750
+ className: classNames({
1751
+ 'd-flex flex-column flex-grow-1': fullscreen,
1752
+ [`bg-${background}`]: background !== null,
1753
+ [`text-${text}`]: text !== null
1754
+ }),
964
1755
  children: /*#__PURE__*/jsx("div", {
965
1756
  className: classNames({
966
1757
  'w-100 my-auto': fullscreen
@@ -972,478 +1763,866 @@ function GuestLayout(_ref) {
972
1763
  }
973
1764
 
974
1765
  function LoginPage() {
975
- var route = useUrlGenerator();
976
- // Sadly necessary to update cookies and routes correctly from the backend,
977
- // make it post directly instead of api call
978
- var onSuccess = useCallback(function () {
979
- window.location.href = route('home');
980
- }, [route]);
981
- return /*#__PURE__*/jsx(GuestLayout, {
982
- fullscreen: true,
983
- children: /*#__PURE__*/jsx("div", {
984
- className: "container-sm py-4",
1766
+ const $ = c(5);
1767
+ const route = useUrlGenerator();
1768
+ let t0;
1769
+ if ($[0] !== route) {
1770
+ t0 = () => {
1771
+ window.location.href = route("home");
1772
+ };
1773
+ $[0] = route;
1774
+ $[1] = t0;
1775
+ } else {
1776
+ t0 = $[1];
1777
+ }
1778
+ const onComplete = t0;
1779
+ let t1;
1780
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1781
+ t1 = /*#__PURE__*/jsx("h1", {
1782
+ className: "mb-4",
1783
+ children: /*#__PURE__*/jsx(FormattedMessage, {
1784
+ id: "AeOZq+"
1785
+ })
1786
+ });
1787
+ $[2] = t1;
1788
+ } else {
1789
+ t1 = $[2];
1790
+ }
1791
+ let t2;
1792
+ if ($[3] !== onComplete) {
1793
+ t2 = /*#__PURE__*/jsx(GuestLayout, {
1794
+ fullscreen: true,
985
1795
  children: /*#__PURE__*/jsx("div", {
986
- className: "row justify-content-center",
987
- children: /*#__PURE__*/jsxs("div", {
988
- className: "col-12 col-sm-8 col-md-6",
989
- children: [/*#__PURE__*/jsx("h1", {
990
- className: "mb-4",
991
- children: /*#__PURE__*/jsx(FormattedMessage, {
992
- id: "AeOZq+",
993
- defaultMessage: [{
994
- "type": 0,
995
- "value": "Login"
996
- }]
997
- })
998
- }), /*#__PURE__*/jsx(LoginForm, {
999
- onSuccess: onSuccess
1000
- })]
1796
+ className: "container-sm py-4",
1797
+ children: /*#__PURE__*/jsx("div", {
1798
+ className: "row justify-content-center",
1799
+ children: /*#__PURE__*/jsxs("div", {
1800
+ className: "col-12 col-sm-8 col-md-6",
1801
+ children: [t1, /*#__PURE__*/jsx(LoginForm, {
1802
+ onComplete: onComplete
1803
+ })]
1804
+ })
1001
1805
  })
1002
1806
  })
1003
- })
1004
- });
1807
+ });
1808
+ $[3] = onComplete;
1809
+ $[4] = t2;
1810
+ } else {
1811
+ t2 = $[4];
1812
+ }
1813
+ return t2;
1005
1814
  }
1006
1815
 
1007
- function ErrorPage(_ref) {
1008
- var _ref$statusCode = _ref.statusCode,
1009
- statusCode = _ref$statusCode === void 0 ? null : _ref$statusCode;
1010
- var code = statusCode || 404;
1011
- var title = useMemo(function () {
1012
- switch (code) {
1013
- case 401:
1014
- return /*#__PURE__*/jsx(FormattedMessage, {
1015
- id: "6nwWPR",
1016
- defaultMessage: [{
1017
- "type": 0,
1018
- "value": "Error 401"
1019
- }]
1020
- });
1021
- case 403:
1022
- return /*#__PURE__*/jsx(FormattedMessage, {
1023
- id: "Pih2UO",
1024
- defaultMessage: [{
1025
- "type": 0,
1026
- "value": "Error 403"
1027
- }]
1028
- });
1029
- case 404:
1030
- return /*#__PURE__*/jsx(FormattedMessage, {
1031
- id: "6Ie+vL",
1032
- defaultMessage: [{
1033
- "type": 0,
1034
- "value": "Error 404"
1035
- }]
1036
- });
1037
- case 500:
1038
- return /*#__PURE__*/jsx(FormattedMessage, {
1039
- id: "owrRHV",
1040
- defaultMessage: [{
1041
- "type": 0,
1042
- "value": "Error 500"
1043
- }]
1044
- });
1045
- default:
1046
- return /*#__PURE__*/jsx(FormattedMessage, {
1047
- id: "6Ie+vL",
1048
- defaultMessage: [{
1049
- "type": 0,
1050
- "value": "Error 404"
1051
- }]
1052
- });
1053
- }
1054
- }, [statusCode]);
1055
- var description = useMemo(function () {
1056
- switch (code) {
1057
- case 401:
1058
- return /*#__PURE__*/jsx(FormattedMessage, {
1059
- id: "82P2dS",
1060
- defaultMessage: [{
1061
- "type": 0,
1062
- "value": "You are not authorized to access this page."
1063
- }]
1064
- });
1065
- case 403:
1066
- return /*#__PURE__*/jsx(FormattedMessage, {
1067
- id: "8HFiMs",
1068
- defaultMessage: [{
1069
- "type": 0,
1070
- "value": "Access to this page is forbidden"
1071
- }]
1072
- });
1073
- case 404:
1074
- return /*#__PURE__*/jsx(FormattedMessage, {
1075
- id: "naie2b",
1076
- defaultMessage: [{
1077
- "type": 0,
1078
- "value": "This page doesn't exist"
1079
- }]
1080
- });
1081
- case 500:
1082
- return /*#__PURE__*/jsx(FormattedMessage, {
1083
- id: "yALN2p",
1084
- defaultMessage: [{
1085
- "type": 0,
1086
- "value": "There was an error"
1087
- }]
1088
- });
1089
- default:
1090
- return /*#__PURE__*/jsx(FormattedMessage, {
1091
- id: "naie2b",
1092
- defaultMessage: [{
1093
- "type": 0,
1094
- "value": "This page doesn't exist"
1095
- }]
1096
- });
1097
- }
1098
- }, [statusCode]);
1099
- return /*#__PURE__*/jsx(GuestLayout, {
1100
- fullscreen: true,
1101
- children: /*#__PURE__*/jsx("div", {
1102
- className: "container-sm py-4",
1816
+ function ErrorPage(t0) {
1817
+ const $ = c(17);
1818
+ const {
1819
+ statusCode: t1
1820
+ } = t0;
1821
+ const statusCode = t1 === undefined ? null : t1;
1822
+ const code = statusCode || 404;
1823
+ let t2;
1824
+ bb0: switch (code) {
1825
+ case 401:
1826
+ {
1827
+ let t3;
1828
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
1829
+ t3 = /*#__PURE__*/jsx(FormattedMessage, {
1830
+ id: "6nwWPR"
1831
+ });
1832
+ $[0] = t3;
1833
+ } else {
1834
+ t3 = $[0];
1835
+ }
1836
+ t2 = t3;
1837
+ break bb0;
1838
+ }
1839
+ case 403:
1840
+ {
1841
+ let t3;
1842
+ if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
1843
+ t3 = /*#__PURE__*/jsx(FormattedMessage, {
1844
+ id: "Pih2UO"
1845
+ });
1846
+ $[1] = t3;
1847
+ } else {
1848
+ t3 = $[1];
1849
+ }
1850
+ t2 = t3;
1851
+ break bb0;
1852
+ }
1853
+ case 404:
1854
+ {
1855
+ let t3;
1856
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
1857
+ t3 = /*#__PURE__*/jsx(FormattedMessage, {
1858
+ id: "6Ie+vL"
1859
+ });
1860
+ $[2] = t3;
1861
+ } else {
1862
+ t3 = $[2];
1863
+ }
1864
+ t2 = t3;
1865
+ break bb0;
1866
+ }
1867
+ case 500:
1868
+ {
1869
+ let t3;
1870
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
1871
+ t3 = /*#__PURE__*/jsx(FormattedMessage, {
1872
+ id: "owrRHV"
1873
+ });
1874
+ $[3] = t3;
1875
+ } else {
1876
+ t3 = $[3];
1877
+ }
1878
+ t2 = t3;
1879
+ break bb0;
1880
+ }
1881
+ default:
1882
+ {
1883
+ let t3;
1884
+ if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
1885
+ t3 = /*#__PURE__*/jsx(FormattedMessage, {
1886
+ id: "6Ie+vL"
1887
+ });
1888
+ $[4] = t3;
1889
+ } else {
1890
+ t3 = $[4];
1891
+ }
1892
+ t2 = t3;
1893
+ }
1894
+ }
1895
+ const title = t2;
1896
+ let t3;
1897
+ bb1: switch (code) {
1898
+ case 401:
1899
+ {
1900
+ let t4;
1901
+ if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
1902
+ t4 = /*#__PURE__*/jsx(FormattedMessage, {
1903
+ id: "82P2dS"
1904
+ });
1905
+ $[5] = t4;
1906
+ } else {
1907
+ t4 = $[5];
1908
+ }
1909
+ t3 = t4;
1910
+ break bb1;
1911
+ }
1912
+ case 403:
1913
+ {
1914
+ let t4;
1915
+ if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
1916
+ t4 = /*#__PURE__*/jsx(FormattedMessage, {
1917
+ id: "8HFiMs"
1918
+ });
1919
+ $[6] = t4;
1920
+ } else {
1921
+ t4 = $[6];
1922
+ }
1923
+ t3 = t4;
1924
+ break bb1;
1925
+ }
1926
+ case 404:
1927
+ {
1928
+ let t4;
1929
+ if ($[7] === Symbol.for("react.memo_cache_sentinel")) {
1930
+ t4 = /*#__PURE__*/jsx(FormattedMessage, {
1931
+ id: "naie2b"
1932
+ });
1933
+ $[7] = t4;
1934
+ } else {
1935
+ t4 = $[7];
1936
+ }
1937
+ t3 = t4;
1938
+ break bb1;
1939
+ }
1940
+ case 500:
1941
+ {
1942
+ let t4;
1943
+ if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
1944
+ t4 = /*#__PURE__*/jsx(FormattedMessage, {
1945
+ id: "yALN2p"
1946
+ });
1947
+ $[8] = t4;
1948
+ } else {
1949
+ t4 = $[8];
1950
+ }
1951
+ t3 = t4;
1952
+ break bb1;
1953
+ }
1954
+ default:
1955
+ {
1956
+ let t4;
1957
+ if ($[9] === Symbol.for("react.memo_cache_sentinel")) {
1958
+ t4 = /*#__PURE__*/jsx(FormattedMessage, {
1959
+ id: "naie2b"
1960
+ });
1961
+ $[9] = t4;
1962
+ } else {
1963
+ t4 = $[9];
1964
+ }
1965
+ t3 = t4;
1966
+ }
1967
+ }
1968
+ const description = t3;
1969
+ let t4;
1970
+ if ($[10] !== title) {
1971
+ t4 = /*#__PURE__*/jsx("h1", {
1972
+ children: title
1973
+ });
1974
+ $[10] = title;
1975
+ $[11] = t4;
1976
+ } else {
1977
+ t4 = $[11];
1978
+ }
1979
+ let t5;
1980
+ if ($[12] !== description) {
1981
+ t5 = /*#__PURE__*/jsx("p", {
1982
+ children: description
1983
+ });
1984
+ $[12] = description;
1985
+ $[13] = t5;
1986
+ } else {
1987
+ t5 = $[13];
1988
+ }
1989
+ let t6;
1990
+ if ($[14] !== t4 || $[15] !== t5) {
1991
+ t6 = /*#__PURE__*/jsx(GuestLayout, {
1992
+ fullscreen: true,
1103
1993
  children: /*#__PURE__*/jsx("div", {
1104
- className: "row justify-content-center",
1105
- children: /*#__PURE__*/jsxs("div", {
1106
- className: "col-12 col-sm-8 col-md-6",
1107
- children: [/*#__PURE__*/jsx("h1", {
1108
- children: title
1109
- }), /*#__PURE__*/jsx("p", {
1110
- children: description
1111
- })]
1994
+ className: "container-sm py-4",
1995
+ children: /*#__PURE__*/jsx("div", {
1996
+ className: "row justify-content-center",
1997
+ children: /*#__PURE__*/jsxs("div", {
1998
+ className: "col-12 col-sm-8 col-md-6",
1999
+ children: [t4, t5]
2000
+ })
1112
2001
  })
1113
2002
  })
1114
- })
1115
- });
2003
+ });
2004
+ $[14] = t4;
2005
+ $[15] = t5;
2006
+ $[16] = t6;
2007
+ } else {
2008
+ t6 = $[16];
2009
+ }
2010
+ return t6;
1116
2011
  }
1117
2012
 
1118
- var _excluded$1 = ["path", "component"];
1119
- function createResourceRoutes(resource, _ref) {
1120
- var route = _ref.route,
1121
- componentsManager = _ref.componentsManager,
1122
- _ref$pages = _ref.pages,
1123
- pages = _ref$pages === void 0 ? {} : _ref$pages;
1124
- var resourceId = resource.id,
1125
- _resource$pages = resource.pages,
1126
- resourcePages = _resource$pages === void 0 ? {} : _resource$pages,
1127
- _resource$extraRoutes = resource.extraRoutes,
1128
- extraRoutes = _resource$extraRoutes === void 0 ? [] : _resource$extraRoutes;
2013
+ function createResourceRoutes(resource, {
2014
+ route,
2015
+ componentsManager,
2016
+ pages = {}
2017
+ }) {
2018
+ const {
2019
+ id: resourceId,
2020
+ pages: resourcePages = {},
2021
+ extraRoutes = []
2022
+ } = resource;
1129
2023
 
1130
2024
  // Load custom pages from resource
1131
- var _ref2 = pages || {},
1132
- _ref2$index = _ref2.index,
1133
- indexPage = _ref2$index === void 0 ? null : _ref2$index,
1134
- _ref2$show = _ref2.show,
1135
- showPage = _ref2$show === void 0 ? null : _ref2$show,
1136
- _ref2$create = _ref2.create,
1137
- createPage = _ref2$create === void 0 ? null : _ref2$create,
1138
- _ref2$edit = _ref2.edit,
1139
- editPage = _ref2$edit === void 0 ? null : _ref2$edit,
1140
- _ref2$delete = _ref2["delete"],
1141
- deletePage = _ref2$delete === void 0 ? null : _ref2$delete,
1142
- _ref2$duplicate = _ref2.duplicate,
1143
- duplicatePage = _ref2$duplicate === void 0 ? null : _ref2$duplicate;
1144
- var _ref3 = resourcePages || {},
1145
- _ref3$index = _ref3.index,
1146
- resourceIndexPage = _ref3$index === void 0 ? null : _ref3$index,
1147
- _ref3$show = _ref3.show,
1148
- resourceShowPage = _ref3$show === void 0 ? null : _ref3$show,
1149
- _ref3$create = _ref3.create,
1150
- resourceCreatePage = _ref3$create === void 0 ? null : _ref3$create,
1151
- _ref3$edit = _ref3.edit,
1152
- resourceEditPage = _ref3$edit === void 0 ? null : _ref3$edit,
1153
- _ref3$delete = _ref3["delete"],
1154
- resourceDeletePage = _ref3$delete === void 0 ? null : _ref3$delete,
1155
- _ref3$duplicate = _ref3.duplicate,
1156
- resourceDuplicatePage = _ref3$duplicate === void 0 ? null : _ref3$duplicate;
1157
- var ResourceIndexComponent = componentsManager.getComponent(resourceIndexPage === null || resourceIndexPage === void 0 ? void 0 : resourceIndexPage.component) || componentsManager.getComponent(indexPage === null || indexPage === void 0 ? void 0 : indexPage.component) || ResourceIndexPage;
1158
- var ResourceShowComponent = componentsManager.getComponent(resourceShowPage === null || resourceShowPage === void 0 ? void 0 : resourceShowPage.component) || componentsManager.getComponent(showPage === null || showPage === void 0 ? void 0 : showPage.component) || ResourceShowPage;
1159
- var ResourceCreateComponent = componentsManager.getComponent(resourceCreatePage === null || resourceCreatePage === void 0 ? void 0 : resourceCreatePage.component) || componentsManager.getComponent(createPage === null || createPage === void 0 ? void 0 : createPage.component) || ResourceCreatePage;
1160
- var ResourceEditComponent = componentsManager.getComponent(resourceEditPage === null || resourceEditPage === void 0 ? void 0 : resourceEditPage.component) || componentsManager.getComponent(editPage === null || editPage === void 0 ? void 0 : editPage.component) || ResourceEditPage;
1161
- var ResourceDeleteComponent = componentsManager.getComponent(resourceDeletePage === null || resourceDeletePage === void 0 ? void 0 : resourceDeletePage.component) || componentsManager.getComponent(deletePage === null || deletePage === void 0 ? void 0 : deletePage.component) || ResourceDeletePage;
1162
- var ResourceDuplicateComponent = componentsManager.getComponent(resourceDuplicatePage === null || resourceDuplicatePage === void 0 ? void 0 : resourceDuplicatePage.component) || componentsManager.getComponent(duplicatePage === null || duplicatePage === void 0 ? void 0 : duplicatePage.component) || ResourceDuplicatePage;
2025
+ const {
2026
+ index: indexPage = null,
2027
+ show: showPage = null,
2028
+ create: createPage = null,
2029
+ edit: editPage = null,
2030
+ delete: deletePage = null,
2031
+ duplicate: duplicatePage = null
2032
+ } = pages || {};
2033
+ const {
2034
+ index: resourceIndexPage = null,
2035
+ show: resourceShowPage = null,
2036
+ create: resourceCreatePage = null,
2037
+ edit: resourceEditPage = null,
2038
+ delete: resourceDeletePage = null,
2039
+ duplicate: resourceDuplicatePage = null
2040
+ } = resourcePages || {};
2041
+ const ResourceIndexComponent = componentsManager.getComponent(resourceIndexPage?.component) || componentsManager.getComponent(indexPage?.component) || ResourceIndexPage;
2042
+ const ResourceShowComponent = componentsManager.getComponent(resourceShowPage?.component) || componentsManager.getComponent(showPage?.component) || ResourceShowPage;
2043
+ const ResourceCreateComponent = componentsManager.getComponent(resourceCreatePage?.component) || componentsManager.getComponent(createPage?.component) || ResourceCreatePage;
2044
+ const ResourceEditComponent = componentsManager.getComponent(resourceEditPage?.component) || componentsManager.getComponent(editPage?.component) || ResourceEditPage;
2045
+ const ResourceDeleteComponent = componentsManager.getComponent(resourceDeletePage?.component) || componentsManager.getComponent(deletePage?.component) || ResourceDeletePage;
2046
+ const ResourceDuplicateComponent = componentsManager.getComponent(resourceDuplicatePage?.component) || componentsManager.getComponent(duplicatePage?.component) || ResourceDuplicatePage;
1163
2047
  return [/*#__PURE__*/jsx(Route, {
1164
2048
  path: route('resources.create', {
1165
2049
  resource: resourceId
1166
2050
  }),
1167
2051
  exact: true,
1168
- children: function children() {
1169
- return /*#__PURE__*/jsx(ResourceCreateComponent, {
1170
- resource: resource
1171
- });
1172
- }
1173
- }, "".concat(resourceId, "-create")), /*#__PURE__*/jsx(Route, {
2052
+ children: () => /*#__PURE__*/jsx(ResourceCreateComponent, {
2053
+ resource: resource
2054
+ })
2055
+ }, `${resourceId}-create`), /*#__PURE__*/jsx(Route, {
1174
2056
  path: route('resources.show', {
1175
2057
  resource: resourceId,
1176
2058
  id: ':id'
1177
2059
  }),
1178
- children: function children(_ref4) {
1179
- var _ref4$id = _ref4.id,
1180
- id = _ref4$id === void 0 ? null : _ref4$id;
1181
- return /*#__PURE__*/jsx(ResourceShowComponent, {
1182
- itemId: id,
1183
- resource: resource
1184
- });
1185
- }
1186
- }, "".concat(resourceId, "-show")), /*#__PURE__*/jsx(Route, {
2060
+ children: ({
2061
+ id = null
2062
+ }) => /*#__PURE__*/jsx(ResourceShowComponent, {
2063
+ itemId: id,
2064
+ resource: resource
2065
+ })
2066
+ }, `${resourceId}-show`), /*#__PURE__*/jsx(Route, {
1187
2067
  path: route('resources.edit', {
1188
2068
  resource: resourceId,
1189
2069
  id: ':id'
1190
2070
  }),
1191
- children: function children(_ref5) {
1192
- var _ref5$id = _ref5.id,
1193
- id = _ref5$id === void 0 ? null : _ref5$id;
1194
- return /*#__PURE__*/jsx(ResourceEditComponent, {
1195
- itemId: id,
1196
- resource: resource
1197
- });
1198
- }
1199
- }, "".concat(resourceId, "-edit")), /*#__PURE__*/jsx(Route, {
2071
+ children: ({
2072
+ id = null
2073
+ }) => /*#__PURE__*/jsx(ResourceEditComponent, {
2074
+ itemId: id,
2075
+ resource: resource
2076
+ })
2077
+ }, `${resourceId}-edit`), /*#__PURE__*/jsx(Route, {
1200
2078
  path: route('resources.delete', {
1201
2079
  resource: resourceId,
1202
2080
  id: ':id'
1203
2081
  }),
1204
- children: function children(_ref6) {
1205
- var _ref6$id = _ref6.id,
1206
- id = _ref6$id === void 0 ? null : _ref6$id;
1207
- return /*#__PURE__*/jsx(ResourceDeleteComponent, {
1208
- itemId: id,
1209
- resource: resource
1210
- });
1211
- }
1212
- }, "".concat(resourceId, "-delete")), /*#__PURE__*/jsx(Route, {
2082
+ children: ({
2083
+ id = null
2084
+ }) => /*#__PURE__*/jsx(ResourceDeleteComponent, {
2085
+ itemId: id,
2086
+ resource: resource
2087
+ })
2088
+ }, `${resourceId}-delete`), /*#__PURE__*/jsx(Route, {
1213
2089
  path: route('resources.duplicate', {
1214
2090
  resource: resourceId,
1215
2091
  id: ':id'
1216
2092
  }),
1217
- children: function children(_ref7) {
1218
- var _ref7$id = _ref7.id,
1219
- id = _ref7$id === void 0 ? null : _ref7$id;
1220
- return /*#__PURE__*/jsx(ResourceDuplicateComponent, {
1221
- itemId: id,
1222
- resource: resource
1223
- });
1224
- }
1225
- }, "".concat(resourceId, "-duplicate"))].concat(_toConsumableArray(extraRoutes.map(function (_ref8) {
1226
- var path = _ref8.path,
1227
- component = _ref8.component,
1228
- pageProps = _objectWithoutProperties(_ref8, _excluded$1);
1229
- var RouteComponent = componentsManager.getComponent(component);
2093
+ children: ({
2094
+ id = null
2095
+ }) => /*#__PURE__*/jsx(ResourceDuplicateComponent, {
2096
+ itemId: id,
2097
+ resource: resource
2098
+ })
2099
+ }, `${resourceId}-duplicate`), ...extraRoutes.map(({
2100
+ path,
2101
+ component,
2102
+ ...pageProps
2103
+ }) => {
2104
+ const RouteComponent = componentsManager.getComponent(component);
1230
2105
  return RouteComponent !== null ? /*#__PURE__*/jsx(Route, {
1231
2106
  path: path,
1232
- children: function children() {
1233
- return /*#__PURE__*/jsx(RouteComponent, _objectSpread({
1234
- resource: resource
1235
- }, pageProps));
1236
- }
1237
- }, "route-".concat(path)) : null;
1238
- })), [/*#__PURE__*/jsx(Route, {
2107
+ children: () => /*#__PURE__*/jsx(RouteComponent, {
2108
+ resource: resource,
2109
+ ...pageProps
2110
+ })
2111
+ }, `route-${path}`) : null;
2112
+ }), /*#__PURE__*/jsx(Route, {
1239
2113
  path: route('resources.index', {
1240
2114
  resource: resourceId
1241
2115
  }),
1242
- children: function children() {
1243
- return /*#__PURE__*/jsx(ResourceIndexComponent, {
1244
- resource: resource
1245
- });
1246
- }
1247
- }, "".concat(resourceId, "-index"))]);
2116
+ children: () => /*#__PURE__*/jsx(ResourceIndexComponent, {
2117
+ resource: resource
2118
+ })
2119
+ }, `${resourceId}-index`)];
1248
2120
  }
1249
2121
 
1250
- var _excluded = ["home", "login", "account", "error", "index", "show", "create", "edit", "delete", "duplicate"],
1251
- _excluded2 = ["path", "route", "component"];
1252
- function PanneauRoutes(_ref) {
1253
- var _ref$statusCode = _ref.statusCode,
1254
- initialStatusCode = _ref$statusCode === void 0 ? null : _ref$statusCode;
1255
- var routes = useRoutes();
1256
- var _useLocation = useLocation(),
1257
- _useLocation2 = _slicedToArray(_useLocation, 1),
1258
- pathname = _useLocation2[0];
1259
- var _useState = useState({
2122
+ function PanneauRoutes(t0) {
2123
+ const $ = c(103);
2124
+ const {
2125
+ statusCode: t1
2126
+ } = t0;
2127
+ const initialStatusCode = t1 === undefined ? null : t1;
2128
+ const routes = useRoutes();
2129
+ const [pathname] = useLocation();
2130
+ let t2;
2131
+ if ($[0] !== initialStatusCode || $[1] !== pathname) {
2132
+ t2 = {
1260
2133
  statusCode: initialStatusCode,
1261
- pathname: pathname
1262
- }),
1263
- _useState2 = _slicedToArray(_useState, 2),
1264
- _useState2$ = _useState2[0],
1265
- statusCode = _useState2$.statusCode,
1266
- lastPathname = _useState2$.pathname,
1267
- setInitialRequest = _useState2[1];
1268
- var user = useUser();
1269
- var route = useUrlGenerator();
1270
- var resources = usePanneauResources();
1271
- var componentsManager = usePagesComponentsManager();
1272
- useEffect(function () {
1273
- if (pathname !== lastPathname) {
1274
- setInitialRequest({
1275
- pathname: pathname,
1276
- statusCode: null
2134
+ pathname
2135
+ };
2136
+ $[0] = initialStatusCode;
2137
+ $[1] = pathname;
2138
+ $[2] = t2;
2139
+ } else {
2140
+ t2 = $[2];
2141
+ }
2142
+ const [t3, setInitialRequest] = useState(t2);
2143
+ const {
2144
+ statusCode,
2145
+ pathname: lastPathname
2146
+ } = t3;
2147
+ const user = useUser();
2148
+ const route = useUrlGenerator();
2149
+ const resources = usePanneauResources();
2150
+ const componentsManager = usePagesComponentsManager();
2151
+ let t4;
2152
+ let t5;
2153
+ if ($[3] !== lastPathname || $[4] !== pathname) {
2154
+ t4 = () => {
2155
+ if (pathname !== lastPathname) {
2156
+ setInitialRequest({
2157
+ pathname,
2158
+ statusCode: null
2159
+ });
2160
+ }
2161
+ };
2162
+ t5 = [pathname, lastPathname];
2163
+ $[3] = lastPathname;
2164
+ $[4] = pathname;
2165
+ $[5] = t4;
2166
+ $[6] = t5;
2167
+ } else {
2168
+ t4 = $[5];
2169
+ t5 = $[6];
2170
+ }
2171
+ useEffect(t4, t5);
2172
+ const {
2173
+ pages: t6,
2174
+ routes: routesDefinition
2175
+ } = usePanneau();
2176
+ const pages = t6 === undefined ? null : t6;
2177
+ let t7;
2178
+ if ($[7] !== pages) {
2179
+ t7 = pages || {};
2180
+ $[7] = pages;
2181
+ $[8] = t7;
2182
+ } else {
2183
+ t7 = $[8];
2184
+ }
2185
+ let otherPages;
2186
+ let t10;
2187
+ let t11;
2188
+ let t12;
2189
+ let t13;
2190
+ let t14;
2191
+ let t15;
2192
+ let t16;
2193
+ let t17;
2194
+ let t8;
2195
+ let t9;
2196
+ if ($[9] !== t7) {
2197
+ ({
2198
+ home: t8,
2199
+ login: t9,
2200
+ account: t10,
2201
+ error: t11,
2202
+ index: t12,
2203
+ show: t13,
2204
+ create: t14,
2205
+ edit: t15,
2206
+ delete: t16,
2207
+ duplicate: t17,
2208
+ ...otherPages
2209
+ } = t7);
2210
+ $[9] = t7;
2211
+ $[10] = otherPages;
2212
+ $[11] = t10;
2213
+ $[12] = t11;
2214
+ $[13] = t12;
2215
+ $[14] = t13;
2216
+ $[15] = t14;
2217
+ $[16] = t15;
2218
+ $[17] = t16;
2219
+ $[18] = t17;
2220
+ $[19] = t8;
2221
+ $[20] = t9;
2222
+ } else {
2223
+ otherPages = $[10];
2224
+ t10 = $[11];
2225
+ t11 = $[12];
2226
+ t12 = $[13];
2227
+ t13 = $[14];
2228
+ t14 = $[15];
2229
+ t15 = $[16];
2230
+ t16 = $[17];
2231
+ t17 = $[18];
2232
+ t8 = $[19];
2233
+ t9 = $[20];
2234
+ }
2235
+ const homePage = t8 === undefined ? null : t8;
2236
+ const loginPage = t9 === undefined ? null : t9;
2237
+ const accountPage = t10 === undefined ? null : t10;
2238
+ const errorPage = t11 === undefined ? null : t11;
2239
+ let t18;
2240
+ if ($[21] !== routesDefinition) {
2241
+ t18 = Object.keys(routesDefinition).filter(_temp);
2242
+ $[21] = routesDefinition;
2243
+ $[22] = t18;
2244
+ } else {
2245
+ t18 = $[22];
2246
+ }
2247
+ let t19;
2248
+ if ($[23] !== routesDefinition || $[24] !== t18) {
2249
+ t19 = t18.filter(key_0 => {
2250
+ const routeDef = routesDefinition[key_0];
2251
+ return isObject(routeDef) && typeof routeDef.component !== "undefined" && typeof routeDef.path !== "undefined";
2252
+ });
2253
+ $[23] = routesDefinition;
2254
+ $[24] = t18;
2255
+ $[25] = t19;
2256
+ } else {
2257
+ t19 = $[25];
2258
+ }
2259
+ let t20;
2260
+ if ($[26] !== routesDefinition || $[27] !== t19) {
2261
+ t20 = t19.map(key_1 => routesDefinition[key_1]);
2262
+ $[26] = routesDefinition;
2263
+ $[27] = t19;
2264
+ $[28] = t20;
2265
+ } else {
2266
+ t20 = $[28];
2267
+ }
2268
+ let t21;
2269
+ if ($[29] !== otherPages) {
2270
+ t21 = Object.keys(otherPages);
2271
+ $[29] = otherPages;
2272
+ $[30] = t21;
2273
+ } else {
2274
+ t21 = $[30];
2275
+ }
2276
+ let t22;
2277
+ if ($[31] !== otherPages || $[32] !== t21) {
2278
+ t22 = t21.map(key_2 => otherPages[key_2]).filter(_temp2);
2279
+ $[31] = otherPages;
2280
+ $[32] = t21;
2281
+ $[33] = t22;
2282
+ } else {
2283
+ t22 = $[33];
2284
+ }
2285
+ let t23;
2286
+ if ($[34] !== t20 || $[35] !== t22) {
2287
+ t23 = [...t20, ...t22];
2288
+ $[34] = t20;
2289
+ $[35] = t22;
2290
+ $[36] = t23;
2291
+ } else {
2292
+ t23 = $[36];
2293
+ }
2294
+ const customRoutes = t23;
2295
+ let t24;
2296
+ if ($[37] !== componentsManager || $[38] !== homePage?.component) {
2297
+ t24 = componentsManager.getComponent(homePage?.component) || HomePage;
2298
+ $[37] = componentsManager;
2299
+ $[38] = homePage?.component;
2300
+ $[39] = t24;
2301
+ } else {
2302
+ t24 = $[39];
2303
+ }
2304
+ const HomeComponent = t24;
2305
+ let t25;
2306
+ if ($[40] !== componentsManager || $[41] !== loginPage?.component) {
2307
+ t25 = componentsManager.getComponent(loginPage?.component) || LoginPage;
2308
+ $[40] = componentsManager;
2309
+ $[41] = loginPage?.component;
2310
+ $[42] = t25;
2311
+ } else {
2312
+ t25 = $[42];
2313
+ }
2314
+ const LoginComponent = t25;
2315
+ let t26;
2316
+ if ($[43] !== accountPage?.component || $[44] !== componentsManager) {
2317
+ t26 = componentsManager.getComponent(accountPage?.component) || AccountPage;
2318
+ $[43] = accountPage?.component;
2319
+ $[44] = componentsManager;
2320
+ $[45] = t26;
2321
+ } else {
2322
+ t26 = $[45];
2323
+ }
2324
+ const AccountComponent = t26;
2325
+ let t27;
2326
+ if ($[46] !== componentsManager || $[47] !== errorPage?.component) {
2327
+ t27 = componentsManager.getComponent(errorPage?.component) || ErrorPage;
2328
+ $[46] = componentsManager;
2329
+ $[47] = errorPage?.component;
2330
+ $[48] = t27;
2331
+ } else {
2332
+ t27 = $[48];
2333
+ }
2334
+ const ErrorComponent = t27;
2335
+ if (statusCode !== null) {
2336
+ let t28;
2337
+ if ($[49] !== ErrorComponent || $[50] !== errorPage || $[51] !== statusCode) {
2338
+ t28 = /*#__PURE__*/jsx(ErrorComponent, {
2339
+ statusCode: statusCode,
2340
+ ...errorPage
1277
2341
  });
2342
+ $[49] = ErrorComponent;
2343
+ $[50] = errorPage;
2344
+ $[51] = statusCode;
2345
+ $[52] = t28;
2346
+ } else {
2347
+ t28 = $[52];
1278
2348
  }
1279
- }, [pathname, lastPathname]);
1280
-
1281
- // Custom Pages
1282
- var _usePanneau = usePanneau(),
1283
- _usePanneau$pages = _usePanneau.pages,
1284
- pages = _usePanneau$pages === void 0 ? null : _usePanneau$pages,
1285
- routesDefinition = _usePanneau.routes;
1286
- var _ref2 = pages || {},
1287
- _ref2$home = _ref2.home,
1288
- homePage = _ref2$home === void 0 ? null : _ref2$home,
1289
- _ref2$login = _ref2.login,
1290
- loginPage = _ref2$login === void 0 ? null : _ref2$login,
1291
- _ref2$account = _ref2.account,
1292
- accountPage = _ref2$account === void 0 ? null : _ref2$account,
1293
- _ref2$error = _ref2.error,
1294
- errorPage = _ref2$error === void 0 ? null : _ref2$error;
1295
- _ref2.index;
1296
- _ref2.show;
1297
- _ref2.create;
1298
- _ref2.edit;
1299
- _ref2["delete"];
1300
- _ref2.duplicate;
1301
- var otherPages = _objectWithoutProperties(_ref2, _excluded);
1302
- var customRoutes = useMemo(function () {
1303
- return [].concat(_toConsumableArray(Object.keys(routesDefinition).filter(function (key) {
1304
- return key.match(/^(resources\.|auth\.)/) === null && key !== 'home' && key !== 'account';
1305
- }).filter(function (key) {
1306
- var routeDef = routesDefinition[key];
1307
- return isObject(routeDef) && typeof routeDef.component !== 'undefined' && typeof routeDef.path !== 'undefined';
1308
- }).map(function (key) {
1309
- return routesDefinition[key];
1310
- })), _toConsumableArray(Object.keys(otherPages).map(function (key) {
1311
- return otherPages[key];
1312
- }).filter(function (_ref3) {
1313
- var _ref3$path = _ref3.path,
1314
- path = _ref3$path === void 0 ? null : _ref3$path,
1315
- _ref3$route = _ref3.route,
1316
- pageRoute = _ref3$route === void 0 ? null : _ref3$route;
1317
- return path !== null || pageRoute !== null;
1318
- })));
1319
- }, [routesDefinition, otherPages]);
1320
- var HomeComponent = componentsManager.getComponent(homePage === null || homePage === void 0 ? void 0 : homePage.component) || HomePage;
1321
- var LoginComponent = componentsManager.getComponent(loginPage === null || loginPage === void 0 ? void 0 : loginPage.component) || LoginPage;
1322
- var AccountComponent = componentsManager.getComponent(accountPage === null || accountPage === void 0 ? void 0 : accountPage.component) || AccountPage;
1323
- var ErrorComponent = componentsManager.getComponent(errorPage === null || errorPage === void 0 ? void 0 : errorPage.component) || ErrorPage;
1324
-
1325
- // If there is an error status code
1326
- if (statusCode !== null) {
1327
- return /*#__PURE__*/jsx(ErrorComponent, _objectSpread({
1328
- statusCode: statusCode
1329
- }, errorPage));
2349
+ return t28;
1330
2350
  }
1331
-
1332
- // If user is unauthenticated
1333
2351
  if (user === null) {
1334
- return /*#__PURE__*/jsxs(Switch, {
1335
- children: [/*#__PURE__*/jsx(Route, {
1336
- path: routes['auth.login'],
1337
- children: /*#__PURE__*/jsx(LoginComponent, _objectSpread({}, loginPage))
1338
- }), /*#__PURE__*/jsx(Route, {
2352
+ const t28 = routes["auth.login"];
2353
+ let t29;
2354
+ if ($[53] !== LoginComponent || $[54] !== loginPage) {
2355
+ t29 = /*#__PURE__*/jsx(LoginComponent, {
2356
+ ...loginPage
2357
+ });
2358
+ $[53] = LoginComponent;
2359
+ $[54] = loginPage;
2360
+ $[55] = t29;
2361
+ } else {
2362
+ t29 = $[55];
2363
+ }
2364
+ let t30;
2365
+ if ($[56] !== t28 || $[57] !== t29) {
2366
+ t30 = /*#__PURE__*/jsx(Route, {
2367
+ path: t28,
2368
+ children: t29
2369
+ });
2370
+ $[56] = t28;
2371
+ $[57] = t29;
2372
+ $[58] = t30;
2373
+ } else {
2374
+ t30 = $[58];
2375
+ }
2376
+ let t31;
2377
+ if ($[59] !== route) {
2378
+ t31 = route("auth.login");
2379
+ $[59] = route;
2380
+ $[60] = t31;
2381
+ } else {
2382
+ t31 = $[60];
2383
+ }
2384
+ const t32 = `${t31}?next=${encodeURIComponent(pathname)}`;
2385
+ let t33;
2386
+ if ($[61] !== t32) {
2387
+ t33 = /*#__PURE__*/jsx(Route, {
1339
2388
  children: /*#__PURE__*/jsx(Redirect, {
1340
- to: "".concat(route('auth.login'), "?next=").concat(encodeURIComponent(pathname))
2389
+ to: t32
1341
2390
  })
1342
- })]
1343
- });
2391
+ });
2392
+ $[61] = t32;
2393
+ $[62] = t33;
2394
+ } else {
2395
+ t33 = $[62];
2396
+ }
2397
+ let t34;
2398
+ if ($[63] !== t30 || $[64] !== t33) {
2399
+ t34 = /*#__PURE__*/jsxs(Switch, {
2400
+ children: [t30, t33]
2401
+ });
2402
+ $[63] = t30;
2403
+ $[64] = t33;
2404
+ $[65] = t34;
2405
+ } else {
2406
+ t34 = $[65];
2407
+ }
2408
+ return t34;
1344
2409
  }
1345
-
1346
- // Normal routes
1347
- return /*#__PURE__*/jsxs(Switch, {
1348
- children: [user !== null ? /*#__PURE__*/jsx(Route, {
1349
- path: routes['auth.login'],
2410
+ let t28;
2411
+ if ($[66] !== routes || $[67] !== user) {
2412
+ t28 = user !== null ? /*#__PURE__*/jsx(Route, {
2413
+ path: routes["auth.login"],
1350
2414
  children: /*#__PURE__*/jsx(Redirect, {
1351
2415
  to: routes.home,
1352
2416
  replace: true
1353
2417
  })
1354
- }) : null, resources.map(function (resource) {
1355
- var _ref4 = resource || {},
1356
- resourceId = _ref4.id;
1357
- return /*#__PURE__*/jsx(Fragment$1, {
1358
- children: createResourceRoutes(resource, {
1359
- route: route,
1360
- componentsManager: componentsManager,
1361
- pages: pages
1362
- })
1363
- }, "resource-".concat(resourceId));
1364
- }), /*#__PURE__*/jsx(Route, {
2418
+ }) : null;
2419
+ $[66] = routes;
2420
+ $[67] = user;
2421
+ $[68] = t28;
2422
+ } else {
2423
+ t28 = $[68];
2424
+ }
2425
+ let t29;
2426
+ if ($[69] !== componentsManager || $[70] !== pages || $[71] !== resources || $[72] !== route) {
2427
+ let t30;
2428
+ if ($[74] !== componentsManager || $[75] !== pages || $[76] !== route) {
2429
+ t30 = resource => {
2430
+ const {
2431
+ id: resourceId
2432
+ } = resource || {};
2433
+ return /*#__PURE__*/jsx(Fragment$1, {
2434
+ children: createResourceRoutes(resource, {
2435
+ route,
2436
+ componentsManager,
2437
+ pages
2438
+ })
2439
+ }, `resource-${resourceId}`);
2440
+ };
2441
+ $[74] = componentsManager;
2442
+ $[75] = pages;
2443
+ $[76] = route;
2444
+ $[77] = t30;
2445
+ } else {
2446
+ t30 = $[77];
2447
+ }
2448
+ t29 = resources.map(t30);
2449
+ $[69] = componentsManager;
2450
+ $[70] = pages;
2451
+ $[71] = resources;
2452
+ $[72] = route;
2453
+ $[73] = t29;
2454
+ } else {
2455
+ t29 = $[73];
2456
+ }
2457
+ let t30;
2458
+ if ($[78] !== AccountComponent || $[79] !== accountPage) {
2459
+ t30 = /*#__PURE__*/jsx(AccountComponent, {
2460
+ ...accountPage
2461
+ });
2462
+ $[78] = AccountComponent;
2463
+ $[79] = accountPage;
2464
+ $[80] = t30;
2465
+ } else {
2466
+ t30 = $[80];
2467
+ }
2468
+ let t31;
2469
+ if ($[81] !== routes.account || $[82] !== t30) {
2470
+ t31 = /*#__PURE__*/jsx(Route, {
1365
2471
  path: routes.account,
1366
- children: /*#__PURE__*/jsx(AccountComponent, _objectSpread({}, accountPage))
1367
- }), customRoutes.map(function (_ref5) {
1368
- var _ref5$path = _ref5.path,
1369
- path = _ref5$path === void 0 ? null : _ref5$path,
1370
- _ref5$route = _ref5.route,
1371
- pageRoute = _ref5$route === void 0 ? null : _ref5$route,
1372
- component = _ref5.component,
1373
- props = _objectWithoutProperties(_ref5, _excluded2);
1374
- var PageComponent = componentsManager.getComponent(component);
1375
- var finalPath = path || routes[pageRoute];
2472
+ children: t30
2473
+ });
2474
+ $[81] = routes.account;
2475
+ $[82] = t30;
2476
+ $[83] = t31;
2477
+ } else {
2478
+ t31 = $[83];
2479
+ }
2480
+ let t32;
2481
+ if ($[84] !== componentsManager || $[85] !== customRoutes || $[86] !== routes) {
2482
+ t32 = customRoutes.map(t33 => {
2483
+ const {
2484
+ path: t34,
2485
+ route: t35,
2486
+ component,
2487
+ ...props
2488
+ } = t33;
2489
+ const path_0 = t34 === undefined ? null : t34;
2490
+ const pageRoute_0 = t35 === undefined ? null : t35;
2491
+ const PageComponent = componentsManager.getComponent(component);
2492
+ const finalPath = path_0 || routes[pageRoute_0];
1376
2493
  return PageComponent !== null ? /*#__PURE__*/jsx(Route, {
1377
- path: path || routes[pageRoute],
1378
- children: /*#__PURE__*/jsx(PageComponent, _objectSpread({}, props))
1379
- }, "custom-route-".concat(finalPath)) : null;
1380
- }), /*#__PURE__*/jsx(Route, {
2494
+ path: path_0 || routes[pageRoute_0],
2495
+ children: /*#__PURE__*/jsx(PageComponent, {
2496
+ ...props
2497
+ })
2498
+ }, `custom-route-${finalPath}`) : null;
2499
+ });
2500
+ $[84] = componentsManager;
2501
+ $[85] = customRoutes;
2502
+ $[86] = routes;
2503
+ $[87] = t32;
2504
+ } else {
2505
+ t32 = $[87];
2506
+ }
2507
+ let t33;
2508
+ if ($[88] !== HomeComponent || $[89] !== homePage) {
2509
+ t33 = /*#__PURE__*/jsx(HomeComponent, {
2510
+ ...homePage
2511
+ });
2512
+ $[88] = HomeComponent;
2513
+ $[89] = homePage;
2514
+ $[90] = t33;
2515
+ } else {
2516
+ t33 = $[90];
2517
+ }
2518
+ let t34;
2519
+ if ($[91] !== routes.home || $[92] !== t33) {
2520
+ t34 = /*#__PURE__*/jsx(Route, {
1381
2521
  path: routes.home,
1382
- children: /*#__PURE__*/jsx(HomeComponent, _objectSpread({}, homePage))
1383
- }), /*#__PURE__*/jsx(Route, {
2522
+ children: t33
2523
+ });
2524
+ $[91] = routes.home;
2525
+ $[92] = t33;
2526
+ $[93] = t34;
2527
+ } else {
2528
+ t34 = $[93];
2529
+ }
2530
+ let t35;
2531
+ if ($[94] !== ErrorComponent) {
2532
+ t35 = /*#__PURE__*/jsx(Route, {
1384
2533
  children: /*#__PURE__*/jsx(ErrorComponent, {})
1385
- })]
1386
- });
2534
+ });
2535
+ $[94] = ErrorComponent;
2536
+ $[95] = t35;
2537
+ } else {
2538
+ t35 = $[95];
2539
+ }
2540
+ let t36;
2541
+ if ($[96] !== t28 || $[97] !== t29 || $[98] !== t31 || $[99] !== t32 || $[100] !== t34 || $[101] !== t35) {
2542
+ t36 = /*#__PURE__*/jsxs(Switch, {
2543
+ children: [t28, t29, t31, t32, t34, t35]
2544
+ });
2545
+ $[96] = t28;
2546
+ $[97] = t29;
2547
+ $[98] = t31;
2548
+ $[99] = t32;
2549
+ $[100] = t34;
2550
+ $[101] = t35;
2551
+ $[102] = t36;
2552
+ } else {
2553
+ t36 = $[102];
2554
+ }
2555
+ return t36;
2556
+ }
2557
+ function _temp2(t0) {
2558
+ const {
2559
+ path: t1,
2560
+ route: t2
2561
+ } = t0;
2562
+ const path = t1 === undefined ? null : t1;
2563
+ const pageRoute = t2 === undefined ? null : t2;
2564
+ return path !== null || pageRoute !== null;
2565
+ }
2566
+ function _temp(key) {
2567
+ return key.match(/^(resources\.|auth\.)/) === null && key !== "home" && key !== "account";
1387
2568
  }
1388
2569
 
1389
- var pathToRegexpParser = createPathToRegexpParser();
1390
- var DEFAULT_ROUTES = {};
1391
- var DEFAULT_LOCALES = [];
1392
- function Container(_ref) {
1393
- var definition = _ref.definition,
1394
- _ref$components = _ref.components,
1395
- components = _ref$components === void 0 ? null : _ref$components,
1396
- _ref$user = _ref.user,
1397
- user = _ref$user === void 0 ? null : _ref$user,
1398
- _ref$memoryRouter = _ref.memoryRouter,
1399
- memoryRouter = _ref$memoryRouter === void 0 ? false : _ref$memoryRouter,
1400
- _ref$baseUrl = _ref.baseUrl,
1401
- baseUrl = _ref$baseUrl === void 0 ? null : _ref$baseUrl,
1402
- _ref$uppy = _ref.uppy,
1403
- uppy = _ref$uppy === void 0 ? null : _ref$uppy,
1404
- _ref$statusCode = _ref.statusCode,
1405
- statusCode = _ref$statusCode === void 0 ? null : _ref$statusCode;
1406
- var _ref2 = definition || {},
1407
- _ref2$intl = _ref2.intl,
1408
- _ref2$intl2 = _ref2$intl === void 0 ? {} : _ref2$intl,
1409
- _ref2$intl2$locale = _ref2$intl2.locale,
1410
- locale = _ref2$intl2$locale === void 0 ? 'en' : _ref2$intl2$locale,
1411
- _ref2$intl2$locales = _ref2$intl2.locales,
1412
- locales = _ref2$intl2$locales === void 0 ? DEFAULT_LOCALES : _ref2$intl2$locales,
1413
- _ref2$routes = _ref2.routes,
1414
- routes = _ref2$routes === void 0 ? DEFAULT_ROUTES : _ref2$routes,
1415
- _ref2$settings = _ref2.settings,
1416
- _ref2$settings2 = _ref2$settings === void 0 ? {} : _ref2$settings,
1417
- _ref2$settings2$memor = _ref2$settings2.memoryRouter,
1418
- usesMemoryRouter = _ref2$settings2$memor === void 0 ? false : _ref2$settings2$memor;
1419
- var isMemoryRouter = memoryRouter || usesMemoryRouter || false;
1420
- var extraMessages = useMemo(function () {
1421
- var _definition$intl = definition.intl,
1422
- _definition$intl2 = _definition$intl === void 0 ? {} : _definition$intl,
1423
- _definition$intl2$mes = _definition$intl2.messages,
1424
- messages = _definition$intl2$mes === void 0 ? null : _definition$intl2$mes,
1425
- _definition$resources = definition.resources,
1426
- resources = _definition$resources === void 0 ? [] : _definition$resources;
1427
- return _objectSpread(_objectSpread({}, messages), resources.reduce(function (allMessages, _ref3) {
1428
- var id = _ref3.id,
1429
- _ref3$intl = _ref3.intl,
1430
- _ref3$intl2 = _ref3$intl === void 0 ? {} : _ref3$intl,
1431
- _ref3$intl2$messages = _ref3$intl2.messages,
1432
- resourceMessages = _ref3$intl2$messages === void 0 ? {} : _ref3$intl2$messages;
1433
- return _objectSpread(_objectSpread({}, allMessages), Object.keys(resourceMessages).reduce(function (allResourceMessages, key) {
1434
- return _objectSpread(_objectSpread({}, allResourceMessages), {}, _defineProperty({}, "resources.".concat(id, ".").concat(key), resourceMessages[key]));
1435
- }, {}));
1436
- }, {}));
2570
+ const pathToRegexpParser = createPathToRegexpParser();
2571
+ const DEFAULT_ROUTES = {};
2572
+ const DEFAULT_LOCALES = [];
2573
+ function Container({
2574
+ definition,
2575
+ components = null,
2576
+ user = null,
2577
+ memoryRouter = false,
2578
+ baseUrl = null,
2579
+ uppy = null,
2580
+ statusCode = null
2581
+ }) {
2582
+ const {
2583
+ intl: {
2584
+ locale = 'en',
2585
+ locales = DEFAULT_LOCALES
2586
+ } = {},
2587
+ routes = DEFAULT_ROUTES,
2588
+ settings: {
2589
+ memoryRouter: usesMemoryRouter = false
2590
+ } = {}
2591
+ } = definition || {};
2592
+ const isMemoryRouter = memoryRouter || usesMemoryRouter || false;
2593
+ const extraMessages = useMemo(() => {
2594
+ const {
2595
+ intl: {
2596
+ messages = null
2597
+ } = {},
2598
+ resources = []
2599
+ } = definition;
2600
+ return {
2601
+ ...messages,
2602
+ ...resources.reduce((allMessages, {
2603
+ id,
2604
+ intl: {
2605
+ messages: resourceMessages = {}
2606
+ } = {}
2607
+ }) => ({
2608
+ ...allMessages,
2609
+ ...Object.keys(resourceMessages).reduce((allResourceMessages, key) => ({
2610
+ ...allResourceMessages,
2611
+ [`resources.${id}.${key}`]: resourceMessages[key]
2612
+ }), {})
2613
+ }), {})
2614
+ };
1437
2615
  }, [definition]);
1438
- var onUnauthorized = useCallback(function () {
2616
+ const onUnauthorized = useCallback(() => {
1439
2617
  window.location.href = baseUrl || '/';
1440
2618
  }, [baseUrl]);
1441
- var onLogout = useCallback(function () {
2619
+ const onLogout = useCallback(() => {
1442
2620
  window.location.reload();
1443
2621
  }, []);
1444
- var _useMemoryRouter = useMemoryRouter(),
1445
- memoryLocationHook = _useMemoryRouter.hook,
1446
- memorySearchHook = _useMemoryRouter.searchHook;
2622
+ const {
2623
+ hook: memoryLocationHook,
2624
+ searchHook: memorySearchHook
2625
+ } = useMemoryRouter();
1447
2626
  return /*#__PURE__*/jsx(Router, {
1448
2627
  hook: isMemoryRouter ? memoryLocationHook : undefined,
1449
2628
  searchHook: isMemoryRouter ? memorySearchHook : undefined,
@@ -1454,7 +2633,8 @@ function Container(_ref) {
1454
2633
  extraMessages: extraMessages,
1455
2634
  children: /*#__PURE__*/jsx(PanneauProvider, {
1456
2635
  definition: definition,
1457
- children: /*#__PURE__*/jsx(UppyProvider, _objectSpread(_objectSpread({}, uppy), {}, {
2636
+ children: /*#__PURE__*/jsx(UppyProvider, {
2637
+ ...uppy,
1458
2638
  children: /*#__PURE__*/jsx(RoutesProvider, {
1459
2639
  routes: routes,
1460
2640
  children: /*#__PURE__*/jsx(FieldsProvider, {
@@ -1490,14 +2670,25 @@ function Container(_ref) {
1490
2670
  })
1491
2671
  })
1492
2672
  })
1493
- }))
2673
+ })
1494
2674
  })
1495
2675
  })
1496
2676
  });
1497
2677
  }
1498
2678
 
1499
2679
  function ResourceFilters(props) {
1500
- return /*#__PURE__*/jsx(Filters, _objectSpread({}, props));
2680
+ const $ = c(2);
2681
+ let t0;
2682
+ if ($[0] !== props) {
2683
+ t0 = /*#__PURE__*/jsx(Filters, {
2684
+ ...props
2685
+ });
2686
+ $[0] = props;
2687
+ $[1] = t0;
2688
+ } else {
2689
+ t0 = $[1];
2690
+ }
2691
+ return t0;
1501
2692
  }
1502
2693
 
1503
2694
  export { GuestLayout, MainLayout, PageHeader, ResourceFilters, ResourceFormWrapper as ResourceForm, ResourceItemsList, Container as default };