@panneau/app 3.0.124 → 3.0.127
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/es/index.js +35 -9
- package/lib/index.js +1434 -252
- package/package.json +40 -39
package/lib/index.js
CHANGED
@@ -4,10 +4,17 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
5
5
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
6
6
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
7
|
-
var
|
8
|
-
var PropTypes = require('prop-types');
|
7
|
+
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
9
8
|
var React = require('react');
|
10
|
-
var
|
9
|
+
var PropTypes = require('prop-types');
|
10
|
+
var pathToRegexp = require('path-to-regexp');
|
11
|
+
var mitt = require('mitt');
|
12
|
+
var _createForOfIteratorHelper = require('@babel/runtime/helpers/createForOfIteratorHelper');
|
13
|
+
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
14
|
+
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
15
|
+
var _toArray = require('@babel/runtime/helpers/toArray');
|
16
|
+
var regexparam = require('regexparam');
|
17
|
+
var index_js = require('use-sync-external-store/shim/index.js');
|
11
18
|
var auth = require('@panneau/auth');
|
12
19
|
var core = require('@panneau/core');
|
13
20
|
var contexts = require('@panneau/core/contexts');
|
@@ -20,13 +27,10 @@ var intl = require('@panneau/intl');
|
|
20
27
|
var ListsProvider = require('@panneau/lists');
|
21
28
|
var ModalsProvider = require('@panneau/modals');
|
22
29
|
var uppy = require('@panneau/uppy');
|
23
|
-
var _toConsumableArray = require('@babel/runtime/helpers/toConsumableArray');
|
24
|
-
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
|
25
|
-
var _slicedToArray = require('@babel/runtime/helpers/slicedToArray');
|
26
30
|
var isObject = require('lodash/isObject');
|
27
31
|
var classNames = require('classnames');
|
28
32
|
var isString = require('lodash/isString');
|
29
|
-
var
|
33
|
+
var _typeof = require('@babel/runtime/helpers/typeof');
|
30
34
|
var reactIntl = require('react-intl');
|
31
35
|
var hooks = require('@panneau/core/hooks');
|
32
36
|
var Alert = require('@panneau/element-alert');
|
@@ -39,54 +43,1208 @@ var Menu = require('@panneau/element-menu');
|
|
39
43
|
var Navbar = require('@panneau/element-navbar');
|
40
44
|
var Label = require('@panneau/element-label');
|
41
45
|
var ResourceList = require('@panneau/list-resource-items');
|
46
|
+
var Loading = require('@panneau/element-loading');
|
42
47
|
var ResourceForm$1 = require('@panneau/form-resource');
|
43
48
|
var utils = require('@panneau/core/utils');
|
44
49
|
var Filters = require('@panneau/filter-filters');
|
45
50
|
|
46
|
-
function
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
var
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
var
|
64
|
-
|
65
|
-
|
66
|
-
var
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
var
|
74
|
-
|
75
|
-
|
51
|
+
function _interopNamespaceDefault(e) {
|
52
|
+
var n = Object.create(null);
|
53
|
+
if (e) {
|
54
|
+
Object.keys(e).forEach(function (k) {
|
55
|
+
if (k !== 'default') {
|
56
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
57
|
+
Object.defineProperty(n, k, d.get ? d : {
|
58
|
+
enumerable: true,
|
59
|
+
get: function () { return e[k]; }
|
60
|
+
});
|
61
|
+
}
|
62
|
+
});
|
63
|
+
}
|
64
|
+
n.default = e;
|
65
|
+
return Object.freeze(n);
|
66
|
+
}
|
67
|
+
|
68
|
+
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
69
|
+
|
70
|
+
// React.useInsertionEffect is not available in React <18
|
71
|
+
var useEffect = React__namespace.useEffect,
|
72
|
+
useLayoutEffect = React__namespace.useLayoutEffect,
|
73
|
+
useRef = React__namespace.useRef,
|
74
|
+
useBuiltinInsertionEffect = React__namespace.useInsertionEffect;
|
75
|
+
|
76
|
+
// Copied from:
|
77
|
+
// https://github.com/facebook/react/blob/main/packages/shared/ExecutionEnvironment.js
|
78
|
+
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
79
|
+
|
80
|
+
// Copied from:
|
81
|
+
// https://github.com/reduxjs/react-redux/blob/master/src/utils/useIsomorphicLayoutEffect.ts
|
82
|
+
// "React currently throws a warning when using useLayoutEffect on the server.
|
83
|
+
// To get around it, we can conditionally useEffect on the server (no-op) and
|
84
|
+
// useLayoutEffect in the browser."
|
85
|
+
var useIsomorphicLayoutEffect = canUseDOM ? useLayoutEffect : useEffect;
|
86
|
+
|
87
|
+
// useInsertionEffect is already a noop on the server.
|
88
|
+
// See: https://github.com/facebook/react/blob/main/packages/react-server/src/ReactFizzHooks.js
|
89
|
+
var useInsertionEffect = useBuiltinInsertionEffect || useIsomorphicLayoutEffect;
|
90
|
+
|
91
|
+
// Userland polyfill while we wait for the forthcoming
|
92
|
+
// https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
93
|
+
// Note: "A high-fidelity polyfill for useEvent is not possible because
|
94
|
+
// there is no lifecycle or Hook in React that we can use to switch
|
95
|
+
// .current at the right timing."
|
96
|
+
// So we will have to make do with this "close enough" approach for now.
|
97
|
+
var useEvent = function useEvent(fn) {
|
98
|
+
var ref = useRef([fn, function () {
|
99
|
+
return ref[0].apply(ref, arguments);
|
100
|
+
}]).current;
|
101
|
+
// Per Dan Abramov: useInsertionEffect executes marginally closer to the
|
102
|
+
// correct timing for ref synchronization than useLayoutEffect on React 18.
|
103
|
+
// See: https://github.com/facebook/react/pull/25881#issuecomment-1356244360
|
104
|
+
useInsertionEffect(function () {
|
105
|
+
ref[0] = fn;
|
106
|
+
});
|
107
|
+
return ref[1];
|
108
|
+
};
|
109
|
+
|
110
|
+
/**
|
111
|
+
* History API docs @see https://developer.mozilla.org/en-US/docs/Web/API/History
|
112
|
+
*/
|
113
|
+
var eventPopstate = "popstate";
|
114
|
+
var eventPushState = "pushState";
|
115
|
+
var eventReplaceState = "replaceState";
|
116
|
+
var eventHashchange = "hashchange";
|
117
|
+
var events = [eventPopstate, eventPushState, eventReplaceState, eventHashchange];
|
118
|
+
var subscribeToLocationUpdates = function subscribeToLocationUpdates(callback) {
|
119
|
+
for (var _i = 0, _events = events; _i < _events.length; _i++) {
|
120
|
+
var event = _events[_i];
|
121
|
+
addEventListener(event, callback);
|
122
|
+
}
|
123
|
+
return function () {
|
124
|
+
for (var _i2 = 0, _events2 = events; _i2 < _events2.length; _i2++) {
|
125
|
+
var _event = _events2[_i2];
|
126
|
+
removeEventListener(_event, callback);
|
127
|
+
}
|
128
|
+
};
|
129
|
+
};
|
130
|
+
var useLocationProperty = function useLocationProperty(fn, ssrFn) {
|
131
|
+
return index_js.useSyncExternalStore(subscribeToLocationUpdates, fn, ssrFn);
|
132
|
+
};
|
133
|
+
var currentSearch = function currentSearch() {
|
134
|
+
return location.search;
|
135
|
+
};
|
136
|
+
var useSearch$1 = function useSearch() {
|
137
|
+
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
138
|
+
_ref$ssrSearch = _ref.ssrSearch,
|
139
|
+
ssrSearch = _ref$ssrSearch === void 0 ? "" : _ref$ssrSearch;
|
140
|
+
return useLocationProperty(currentSearch, function () {
|
141
|
+
return ssrSearch;
|
142
|
+
});
|
143
|
+
};
|
144
|
+
var currentPathname = function currentPathname() {
|
145
|
+
return location.pathname;
|
146
|
+
};
|
147
|
+
var usePathname = function usePathname() {
|
148
|
+
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
149
|
+
ssrPath = _ref2.ssrPath;
|
150
|
+
return useLocationProperty(currentPathname, ssrPath ? function () {
|
151
|
+
return ssrPath;
|
152
|
+
} : currentPathname);
|
153
|
+
};
|
154
|
+
var navigate = function navigate(to) {
|
155
|
+
var _ref3 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
156
|
+
_ref3$replace = _ref3.replace,
|
157
|
+
replace = _ref3$replace === void 0 ? false : _ref3$replace,
|
158
|
+
_ref3$state = _ref3.state,
|
159
|
+
state = _ref3$state === void 0 ? null : _ref3$state;
|
160
|
+
return history[replace ? eventReplaceState : eventPushState](state, "", to);
|
161
|
+
};
|
162
|
+
|
163
|
+
// the 2nd argument of the `useBrowserLocation` return value is a function
|
164
|
+
// that allows to perform a navigation.
|
165
|
+
var useBrowserLocation = function useBrowserLocation() {
|
166
|
+
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
167
|
+
return [usePathname(opts), navigate];
|
168
|
+
};
|
169
|
+
var patchKey = Symbol["for"]("wouter_v3");
|
170
|
+
|
171
|
+
// While History API does have `popstate` event, the only
|
172
|
+
// proper way to listen to changes via `push/replaceState`
|
173
|
+
// is to monkey-patch these methods.
|
174
|
+
//
|
175
|
+
// See https://stackoverflow.com/a/4585031
|
176
|
+
if (typeof history !== "undefined" && typeof window[patchKey] === "undefined") {
|
177
|
+
var _loop = function _loop() {
|
178
|
+
var type = _arr[_i3];
|
179
|
+
var original = history[type];
|
180
|
+
// TODO: we should be using unstable_batchedUpdates to avoid multiple re-renders,
|
181
|
+
// however that will require an additional peer dependency on react-dom.
|
182
|
+
// See: https://github.com/reactwg/react-18/discussions/86#discussioncomment-1567149
|
183
|
+
history[type] = function () {
|
184
|
+
var result = original.apply(this, arguments);
|
185
|
+
var event = new Event(type);
|
186
|
+
event.arguments = arguments;
|
187
|
+
dispatchEvent(event);
|
188
|
+
return result;
|
189
|
+
};
|
190
|
+
};
|
191
|
+
for (var _i3 = 0, _arr = [eventPushState, eventReplaceState]; _i3 < _arr.length; _i3++) {
|
192
|
+
_loop();
|
193
|
+
}
|
194
|
+
|
195
|
+
// patch history object only once
|
196
|
+
// See: https://github.com/molefrog/wouter/issues/167
|
197
|
+
Object.defineProperty(window, patchKey, {
|
198
|
+
value: true
|
199
|
+
});
|
200
|
+
}
|
201
|
+
|
202
|
+
var _excluded$4 = ["children"],
|
203
|
+
_excluded2$1 = ["path", "nest", "match"],
|
204
|
+
_excluded3 = ["to", "href", "onClick", "asChild", "children", "replace", "state"];
|
205
|
+
|
206
|
+
/*
|
207
|
+
* Transforms `path` into its relative `base` version
|
208
|
+
* If base isn't part of the path provided returns absolute path e.g. `~/app`
|
209
|
+
*/
|
210
|
+
var relativePath = function relativePath() {
|
211
|
+
var base = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
212
|
+
var path = arguments.length > 1 ? arguments[1] : undefined;
|
213
|
+
return !path.toLowerCase().indexOf(base.toLowerCase()) ? path.slice(base.length) || "/" : "~" + path;
|
214
|
+
};
|
215
|
+
var absolutePath = function absolutePath(to) {
|
216
|
+
var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "";
|
217
|
+
return to[0] === "~" ? to.slice(1) : base + to;
|
218
|
+
};
|
219
|
+
|
220
|
+
/*
|
221
|
+
* Removes leading question mark
|
222
|
+
*/
|
223
|
+
var stripQm = function stripQm(str) {
|
224
|
+
return str[0] === "?" ? str.slice(1) : str;
|
225
|
+
};
|
226
|
+
|
227
|
+
/*
|
228
|
+
* decodes escape sequences such as %20
|
229
|
+
*/
|
230
|
+
var unescape = function unescape(str) {
|
231
|
+
try {
|
232
|
+
return decodeURI(str);
|
233
|
+
} catch (_e) {
|
234
|
+
// fail-safe mode: if string can't be decoded do nothing
|
235
|
+
return str;
|
236
|
+
}
|
237
|
+
};
|
238
|
+
|
239
|
+
/*
|
240
|
+
* Router and router context. Router is a lightweight object that represents the current
|
241
|
+
* routing options: how location is managed, base path etc.
|
242
|
+
*
|
243
|
+
* There is a default router present for most of the use cases, however it can be overridden
|
244
|
+
* via the <Router /> component.
|
245
|
+
*/
|
246
|
+
|
247
|
+
var defaultRouter = {
|
248
|
+
hook: useBrowserLocation,
|
249
|
+
searchHook: useSearch$1,
|
250
|
+
parser: regexparam.parse,
|
251
|
+
base: "",
|
252
|
+
// this option is used to override the current location during SSR
|
253
|
+
ssrPath: undefined,
|
254
|
+
ssrSearch: undefined
|
255
|
+
};
|
256
|
+
var RouterCtx = React.createContext(defaultRouter);
|
257
|
+
|
258
|
+
// gets the closest parent router from the context
|
259
|
+
var useRouter = function useRouter() {
|
260
|
+
return React.useContext(RouterCtx);
|
261
|
+
};
|
262
|
+
|
263
|
+
/**
|
264
|
+
* Parameters context. Used by `useParams()` to get the
|
265
|
+
* matched params from the innermost `Route` component.
|
266
|
+
*/
|
267
|
+
|
268
|
+
var ParamsCtx = React.createContext({});
|
269
|
+
|
270
|
+
/*
|
271
|
+
* Part 1, Hooks API: useRoute and useLocation
|
272
|
+
*/
|
273
|
+
|
274
|
+
// Internal version of useLocation to avoid redundant useRouter calls
|
275
|
+
|
276
|
+
var useLocationFromRouter = function useLocationFromRouter(router) {
|
277
|
+
var _router$hook = router.hook(router),
|
278
|
+
_router$hook2 = _slicedToArray(_router$hook, 2),
|
279
|
+
location = _router$hook2[0],
|
280
|
+
navigate = _router$hook2[1];
|
281
|
+
|
282
|
+
// the function reference should stay the same between re-renders, so that
|
283
|
+
// it can be passed down as an element prop without any performance concerns.
|
284
|
+
// (This is achieved via `useEvent`.)
|
285
|
+
return [unescape(relativePath(router.base, location)), useEvent(function (to, navOpts) {
|
286
|
+
return navigate(absolutePath(to, router.base), navOpts);
|
287
|
+
})];
|
288
|
+
};
|
289
|
+
var useLocation = function useLocation() {
|
290
|
+
return useLocationFromRouter(useRouter());
|
291
|
+
};
|
292
|
+
var useSearch = function useSearch() {
|
293
|
+
var router = useRouter();
|
294
|
+
return unescape(stripQm(router.searchHook(router)));
|
295
|
+
};
|
296
|
+
var matchRoute = function matchRoute(parser, route, path, loose) {
|
297
|
+
// when parser is in "loose" mode, `$base` is equal to the
|
298
|
+
// first part of the route that matches the pattern
|
299
|
+
// (e.g. for pattern `/a/:b` and path `/a/1/2/3` the `$base` is `a/1`)
|
300
|
+
// we use this for route nesting
|
301
|
+
var _parser = parser(route || "*", loose),
|
302
|
+
pattern = _parser.pattern,
|
303
|
+
keys = _parser.keys;
|
304
|
+
var _ref = pattern.exec(path) || [],
|
305
|
+
_ref2 = _toArray(_ref),
|
306
|
+
$base = _ref2[0],
|
307
|
+
matches = _ref2.slice(1);
|
308
|
+
return $base !== undefined ? [true,
|
309
|
+
// an object with parameters matched, e.g. { foo: "bar" } for "/:foo"
|
310
|
+
// we "zip" two arrays here to construct the object
|
311
|
+
// ["foo"], ["bar"] → { foo: "bar" }
|
312
|
+
Object.fromEntries(keys.map(function (key, i) {
|
313
|
+
return [key, matches[i]];
|
314
|
+
}))].concat(_toConsumableArray(loose ? [$base] : [])) : [false, null];
|
315
|
+
};
|
316
|
+
|
317
|
+
/*
|
318
|
+
* Part 2, Low Carb Router API: Router, Route, Link, Switch
|
319
|
+
*/
|
320
|
+
|
321
|
+
var Router = function Router(_ref3) {
|
322
|
+
var children = _ref3.children,
|
323
|
+
props = _objectWithoutProperties(_ref3, _excluded$4);
|
324
|
+
// the router we will inherit from - it is the closest router in the tree,
|
325
|
+
// unless the custom `hook` is provided (in that case it's the default one)
|
326
|
+
var parent_ = useRouter();
|
327
|
+
var parent = props.hook ? defaultRouter : parent_;
|
328
|
+
|
329
|
+
// holds to the context value: the router object
|
330
|
+
var value = parent;
|
331
|
+
|
332
|
+
// what is happening below: to avoid unnecessary rerenders in child components,
|
333
|
+
// we ensure that the router object reference is stable, unless there are any
|
334
|
+
// changes that require reload (e.g. `base` prop changes -> all components that
|
335
|
+
// get the router from the context should rerender, even if the component is memoized).
|
336
|
+
// the expected behaviour is:
|
337
|
+
//
|
338
|
+
// 1) when the resulted router is no different from the parent, use parent
|
339
|
+
// 2) if the custom `hook` prop is provided, we always inherit from the
|
340
|
+
// default router instead. this resets all previously overridden options.
|
341
|
+
// 3) when the router is customized here, it should stay stable between renders
|
342
|
+
var ref = React.useRef({}),
|
343
|
+
prev = ref.current,
|
344
|
+
next = prev;
|
345
|
+
for (var k in parent) {
|
346
|
+
var option = k === "base" ? /* base is special case, it is appended to the parent's base */
|
347
|
+
parent[k] + (props[k] || "") : props[k] || parent[k];
|
348
|
+
if (prev === next && option !== next[k]) {
|
349
|
+
ref.current = next = _objectSpread({}, next);
|
350
|
+
}
|
351
|
+
next[k] = option;
|
352
|
+
|
353
|
+
// the new router is no different from the parent, use parent
|
354
|
+
if (option !== parent[k]) value = next;
|
355
|
+
}
|
356
|
+
return React.createElement(RouterCtx.Provider, {
|
357
|
+
value: value,
|
358
|
+
children: children
|
359
|
+
});
|
360
|
+
};
|
361
|
+
var h_route = function h_route(_ref4, params) {
|
362
|
+
var children = _ref4.children,
|
363
|
+
component = _ref4.component;
|
364
|
+
// React-Router style `component` prop
|
365
|
+
if (component) return React.createElement(component, {
|
366
|
+
params: params
|
367
|
+
});
|
368
|
+
|
369
|
+
// support render prop or plain children
|
370
|
+
return typeof children === "function" ? children(params) : children;
|
371
|
+
};
|
372
|
+
var Route = function Route(_ref5) {
|
373
|
+
var path = _ref5.path,
|
374
|
+
nest = _ref5.nest,
|
375
|
+
match = _ref5.match,
|
376
|
+
renderProps = _objectWithoutProperties(_ref5, _excluded2$1);
|
377
|
+
var router = useRouter();
|
378
|
+
var _useLocationFromRoute = useLocationFromRouter(router),
|
379
|
+
_useLocationFromRoute2 = _slicedToArray(_useLocationFromRoute, 1),
|
380
|
+
location = _useLocationFromRoute2[0];
|
381
|
+
var _ref6 = // `match` is a special prop to give up control to the parent,
|
382
|
+
// it is used by the `Switch` to avoid double matching
|
383
|
+
match !== null && match !== void 0 ? match : matchRoute(router.parser, path, location, nest),
|
384
|
+
_ref7 = _slicedToArray(_ref6, 3),
|
385
|
+
matches = _ref7[0],
|
386
|
+
params = _ref7[1],
|
387
|
+
base = _ref7[2];
|
388
|
+
if (!matches) return null;
|
389
|
+
var children = base ? React.createElement(Router, {
|
390
|
+
base: base
|
391
|
+
}, h_route(renderProps, params)) : h_route(renderProps, params);
|
392
|
+
return React.createElement(ParamsCtx.Provider, {
|
393
|
+
value: params,
|
394
|
+
children: children
|
395
|
+
});
|
396
|
+
};
|
397
|
+
React.forwardRef(function (props, ref) {
|
398
|
+
var router = useRouter();
|
399
|
+
var _useLocationFromRoute3 = useLocationFromRouter(router),
|
400
|
+
_useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
|
401
|
+
navigate = _useLocationFromRoute4[1];
|
402
|
+
var to = props.to,
|
403
|
+
_props$href = props.href,
|
404
|
+
_href = _props$href === void 0 ? to : _props$href,
|
405
|
+
_onClick = props.onClick,
|
406
|
+
asChild = props.asChild,
|
407
|
+
children = props.children;
|
408
|
+
props.replace;
|
409
|
+
props.state;
|
410
|
+
var restProps = _objectWithoutProperties(props, _excluded3);
|
411
|
+
var onClick = useEvent(function (event) {
|
412
|
+
// ignores the navigation when clicked using right mouse button or
|
413
|
+
// by holding a special modifier key: ctrl, command, win, alt, shift
|
414
|
+
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) return;
|
415
|
+
_onClick && _onClick(event); // TODO: is it safe to use _onClick?.(event)
|
416
|
+
if (!event.defaultPrevented) {
|
417
|
+
event.preventDefault();
|
418
|
+
navigate(_href, props);
|
419
|
+
}
|
420
|
+
});
|
421
|
+
|
422
|
+
// handle nested routers and absolute paths
|
423
|
+
var href = _href[0] === "~" ? _href.slice(1) : router.base + _href;
|
424
|
+
return asChild && React.isValidElement(children) ? React.cloneElement(children, {
|
425
|
+
href: href,
|
426
|
+
onClick: onClick
|
427
|
+
}) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
|
428
|
+
href: href,
|
429
|
+
onClick: onClick,
|
430
|
+
children: children,
|
431
|
+
ref: ref
|
432
|
+
}));
|
433
|
+
});
|
434
|
+
var flattenChildren = function flattenChildren(children) {
|
435
|
+
var _ref8;
|
436
|
+
return Array.isArray(children) ? (_ref8 = []).concat.apply(_ref8, _toConsumableArray(children.map(function (c) {
|
437
|
+
return c && c.type === React.Fragment ? flattenChildren(c.props.children) : flattenChildren(c);
|
438
|
+
}))) : [children];
|
439
|
+
};
|
440
|
+
var Switch = function Switch(_ref9) {
|
441
|
+
var children = _ref9.children,
|
442
|
+
location = _ref9.location;
|
443
|
+
var router = useRouter();
|
444
|
+
var _useLocationFromRoute5 = useLocationFromRouter(router),
|
445
|
+
_useLocationFromRoute6 = _slicedToArray(_useLocationFromRoute5, 1),
|
446
|
+
originalLocation = _useLocationFromRoute6[0];
|
447
|
+
var _iterator = _createForOfIteratorHelper(flattenChildren(children)),
|
448
|
+
_step;
|
449
|
+
try {
|
450
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
451
|
+
var element = _step.value;
|
452
|
+
var match = 0;
|
453
|
+
if (React.isValidElement(element) &&
|
454
|
+
// we don't require an element to be of type Route,
|
455
|
+
// but we do require it to contain a truthy `path` prop.
|
456
|
+
// this allows to use different components that wrap Route
|
457
|
+
// inside of a switch, for example <AnimatedRoute />.
|
458
|
+
(match = matchRoute(router.parser, element.props.path, location || originalLocation, element.props.nest))[0]) return React.cloneElement(element, {
|
459
|
+
match: match
|
460
|
+
});
|
461
|
+
}
|
462
|
+
} catch (err) {
|
463
|
+
_iterator.e(err);
|
464
|
+
} finally {
|
465
|
+
_iterator.f();
|
466
|
+
}
|
467
|
+
return null;
|
468
|
+
};
|
469
|
+
var Redirect = function Redirect(props) {
|
470
|
+
var to = props.to,
|
471
|
+
_props$href2 = props.href,
|
472
|
+
href = _props$href2 === void 0 ? to : _props$href2;
|
473
|
+
var _useLocation = useLocation(),
|
474
|
+
_useLocation2 = _slicedToArray(_useLocation, 2),
|
475
|
+
navigate = _useLocation2[1];
|
476
|
+
var redirect = useEvent(function () {
|
477
|
+
return navigate(to || href, props);
|
478
|
+
});
|
479
|
+
|
480
|
+
// redirect is guaranteed to be stable since it is returned from useEvent
|
481
|
+
useIsomorphicLayoutEffect(function () {
|
482
|
+
redirect();
|
483
|
+
}, []); // eslint-disable-line react-hooks/exhaustive-deps
|
484
|
+
|
485
|
+
return null;
|
486
|
+
};
|
487
|
+
|
488
|
+
({
|
489
|
+
children: PropTypes.node.isRequired,
|
490
|
+
routes: PropTypes.objectOf(PropTypes.string).isRequired,
|
491
|
+
basePath: PropTypes.string
|
492
|
+
});
|
493
|
+
function parseLocation(location) {
|
494
|
+
var search = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
495
|
+
var hash = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
496
|
+
var _split = (location || '').split('?', 2),
|
497
|
+
_split2 = _slicedToArray(_split, 2),
|
498
|
+
pathname = _split2[0],
|
499
|
+
_split2$ = _split2[1],
|
500
|
+
searchFromPath = _split2$ === void 0 ? null : _split2$;
|
501
|
+
var _split3 = (searchFromPath || '').split('#', 2),
|
502
|
+
_split4 = _slicedToArray(_split3, 2),
|
503
|
+
searchWithoutHash = _split4[0],
|
504
|
+
_split4$ = _split4[1],
|
505
|
+
hashFromPath = _split4$ === void 0 ? null : _split4$;
|
506
|
+
return {
|
507
|
+
pathname: pathname !== '' ? pathname : '/',
|
508
|
+
search: search || searchWithoutHash || null,
|
509
|
+
hash: hash || hashFromPath || null
|
510
|
+
};
|
511
|
+
}
|
512
|
+
function useMemoryRouter() {
|
513
|
+
var _ref3 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
514
|
+
_ref3$path = _ref3.path,
|
515
|
+
path = _ref3$path === void 0 ? '/' : _ref3$path,
|
516
|
+
_ref3$static = _ref3["static"],
|
517
|
+
staticLocation = _ref3$static === void 0 ? false : _ref3$static;
|
518
|
+
_ref3.record;
|
519
|
+
var currentPath = parseLocation(path);
|
520
|
+
var emitter = mitt();
|
521
|
+
var navigateImplementation = function navigateImplementation(newPath) {
|
522
|
+
var newParsedPath = parseLocation(newPath);
|
523
|
+
currentPath = newParsedPath;
|
524
|
+
emitter.emit('navigate', path);
|
525
|
+
};
|
526
|
+
var navigate = !staticLocation ? navigateImplementation : function () {
|
527
|
+
return null;
|
528
|
+
};
|
529
|
+
var subscribe = function subscribe(cb) {
|
530
|
+
emitter.on('navigate', cb);
|
531
|
+
return function () {
|
532
|
+
return emitter.off('navigate', cb);
|
533
|
+
};
|
534
|
+
};
|
535
|
+
function reset() {
|
536
|
+
navigateImplementation(path);
|
537
|
+
}
|
538
|
+
var locationHook = function locationHook() {
|
539
|
+
return [React.useSyncExternalStore(subscribe, function () {
|
540
|
+
return currentPath.pathname;
|
541
|
+
}), navigate];
|
542
|
+
};
|
543
|
+
var searchHook = function searchHook() {
|
544
|
+
return React.useSyncExternalStore(subscribe, function () {
|
545
|
+
return currentPath.search || '';
|
546
|
+
});
|
547
|
+
};
|
548
|
+
return {
|
549
|
+
hook: locationHook,
|
550
|
+
searchHook: searchHook,
|
551
|
+
reset: reset,
|
552
|
+
navigate: navigate
|
553
|
+
};
|
554
|
+
}
|
555
|
+
function createPathToRegexpParser(opts) {
|
556
|
+
return function (path, loose) {
|
557
|
+
var keys = [];
|
558
|
+
var isWildcard = path.match(/(\/|^)\*$/) !== null;
|
559
|
+
var pattern = pathToRegexp.pathToRegexp(isWildcard ? path.replace(/(\/|^)\*$/, '$1(.*)') : path, keys, _objectSpread({
|
560
|
+
end: !loose && !isWildcard
|
561
|
+
}, opts));
|
562
|
+
return {
|
563
|
+
pattern: pattern,
|
564
|
+
// `pathToRegexp` returns some metadata about the keys,
|
565
|
+
// we want to strip it to just an array of keys
|
566
|
+
keys: keys.map(function (k) {
|
567
|
+
return k.name;
|
568
|
+
})
|
569
|
+
};
|
570
|
+
};
|
571
|
+
}
|
572
|
+
|
573
|
+
var token = '%[a-f0-9]{2}';
|
574
|
+
var singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');
|
575
|
+
var multiMatcher = new RegExp('(' + token + ')+', 'gi');
|
576
|
+
function decodeComponents(components, split) {
|
577
|
+
try {
|
578
|
+
// Try to decode the entire string first
|
579
|
+
return [decodeURIComponent(components.join(''))];
|
580
|
+
} catch (_unused) {
|
581
|
+
// Do nothing
|
582
|
+
}
|
583
|
+
if (components.length === 1) {
|
584
|
+
return components;
|
585
|
+
}
|
586
|
+
split = split || 1;
|
587
|
+
|
588
|
+
// Split the array in 2 parts
|
589
|
+
var left = components.slice(0, split);
|
590
|
+
var right = components.slice(split);
|
591
|
+
return Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));
|
592
|
+
}
|
593
|
+
function decode$1(input) {
|
594
|
+
try {
|
595
|
+
return decodeURIComponent(input);
|
596
|
+
} catch (_unused2) {
|
597
|
+
var tokens = input.match(singleMatcher) || [];
|
598
|
+
for (var i = 1; i < tokens.length; i++) {
|
599
|
+
input = decodeComponents(tokens, i).join('');
|
600
|
+
tokens = input.match(singleMatcher) || [];
|
601
|
+
}
|
602
|
+
return input;
|
603
|
+
}
|
604
|
+
}
|
605
|
+
function customDecodeURIComponent(input) {
|
606
|
+
// Keep track of all the replacements and prefill the map with the `BOM`
|
607
|
+
var replaceMap = {
|
608
|
+
'%FE%FF': "\uFFFD\uFFFD",
|
609
|
+
'%FF%FE': "\uFFFD\uFFFD"
|
610
|
+
};
|
611
|
+
var match = multiMatcher.exec(input);
|
612
|
+
while (match) {
|
613
|
+
try {
|
614
|
+
// Decode as big chunks as possible
|
615
|
+
replaceMap[match[0]] = decodeURIComponent(match[0]);
|
616
|
+
} catch (_unused3) {
|
617
|
+
var result = decode$1(match[0]);
|
618
|
+
if (result !== match[0]) {
|
619
|
+
replaceMap[match[0]] = result;
|
620
|
+
}
|
621
|
+
}
|
622
|
+
match = multiMatcher.exec(input);
|
623
|
+
}
|
624
|
+
|
625
|
+
// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else
|
626
|
+
replaceMap['%C2'] = "\uFFFD";
|
627
|
+
var entries = Object.keys(replaceMap);
|
628
|
+
for (var _i = 0, _entries = entries; _i < _entries.length; _i++) {
|
629
|
+
var key = _entries[_i];
|
630
|
+
// Replace all decoded components
|
631
|
+
input = input.replace(new RegExp(key, 'g'), replaceMap[key]);
|
632
|
+
}
|
633
|
+
return input;
|
634
|
+
}
|
635
|
+
function decodeUriComponent(encodedURI) {
|
636
|
+
if (typeof encodedURI !== 'string') {
|
637
|
+
throw new TypeError('Expected `encodedURI` to be of type `string`, got `' + _typeof(encodedURI) + '`');
|
638
|
+
}
|
639
|
+
try {
|
640
|
+
// Try the built in decoder first
|
641
|
+
return decodeURIComponent(encodedURI);
|
642
|
+
} catch (_unused4) {
|
643
|
+
// Fallback to a more advanced decoder
|
644
|
+
return customDecodeURIComponent(encodedURI);
|
645
|
+
}
|
646
|
+
}
|
647
|
+
|
648
|
+
function splitOnFirst(string, separator) {
|
649
|
+
if (!(typeof string === 'string' && typeof separator === 'string')) {
|
650
|
+
throw new TypeError('Expected the arguments to be of type `string`');
|
651
|
+
}
|
652
|
+
if (string === '' || separator === '') {
|
653
|
+
return [];
|
654
|
+
}
|
655
|
+
var separatorIndex = string.indexOf(separator);
|
656
|
+
if (separatorIndex === -1) {
|
657
|
+
return [];
|
658
|
+
}
|
659
|
+
return [string.slice(0, separatorIndex), string.slice(separatorIndex + separator.length)];
|
660
|
+
}
|
661
|
+
|
662
|
+
function includeKeys(object, predicate) {
|
663
|
+
var result = {};
|
664
|
+
if (Array.isArray(predicate)) {
|
665
|
+
var _iterator = _createForOfIteratorHelper(predicate),
|
666
|
+
_step;
|
667
|
+
try {
|
668
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
669
|
+
var key = _step.value;
|
670
|
+
var descriptor = Object.getOwnPropertyDescriptor(object, key);
|
671
|
+
if (descriptor !== null && descriptor !== void 0 && descriptor.enumerable) {
|
672
|
+
Object.defineProperty(result, key, descriptor);
|
673
|
+
}
|
674
|
+
}
|
675
|
+
} catch (err) {
|
676
|
+
_iterator.e(err);
|
677
|
+
} finally {
|
678
|
+
_iterator.f();
|
679
|
+
}
|
680
|
+
} else {
|
681
|
+
// `Reflect.ownKeys()` is required to retrieve symbol properties
|
682
|
+
var _iterator2 = _createForOfIteratorHelper(Reflect.ownKeys(object)),
|
683
|
+
_step2;
|
684
|
+
try {
|
685
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
686
|
+
var _key = _step2.value;
|
687
|
+
var _descriptor = Object.getOwnPropertyDescriptor(object, _key);
|
688
|
+
if (_descriptor.enumerable) {
|
689
|
+
var value = object[_key];
|
690
|
+
if (predicate(_key, value, object)) {
|
691
|
+
Object.defineProperty(result, _key, _descriptor);
|
692
|
+
}
|
693
|
+
}
|
694
|
+
}
|
695
|
+
} catch (err) {
|
696
|
+
_iterator2.e(err);
|
697
|
+
} finally {
|
698
|
+
_iterator2.f();
|
699
|
+
}
|
700
|
+
}
|
701
|
+
return result;
|
702
|
+
}
|
703
|
+
|
704
|
+
const isNullOrUndefined = value => value === null || value === undefined;
|
705
|
+
|
706
|
+
// eslint-disable-next-line unicorn/prefer-code-point
|
707
|
+
const strictUriEncode = string => encodeURIComponent(string).replaceAll(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);
|
708
|
+
|
709
|
+
const encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');
|
710
|
+
|
711
|
+
function encoderForArrayFormat(options) {
|
712
|
+
switch (options.arrayFormat) {
|
713
|
+
case 'index': {
|
714
|
+
return key => (result, value) => {
|
715
|
+
const index = result.length;
|
716
|
+
|
717
|
+
if (
|
718
|
+
value === undefined
|
719
|
+
|| (options.skipNull && value === null)
|
720
|
+
|| (options.skipEmptyString && value === '')
|
721
|
+
) {
|
722
|
+
return result;
|
723
|
+
}
|
724
|
+
|
725
|
+
if (value === null) {
|
726
|
+
return [
|
727
|
+
...result, [encode(key, options), '[', index, ']'].join(''),
|
728
|
+
];
|
729
|
+
}
|
730
|
+
|
731
|
+
return [
|
732
|
+
...result,
|
733
|
+
[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join(''),
|
734
|
+
];
|
735
|
+
};
|
736
|
+
}
|
737
|
+
|
738
|
+
case 'bracket': {
|
739
|
+
return key => (result, value) => {
|
740
|
+
if (
|
741
|
+
value === undefined
|
742
|
+
|| (options.skipNull && value === null)
|
743
|
+
|| (options.skipEmptyString && value === '')
|
744
|
+
) {
|
745
|
+
return result;
|
746
|
+
}
|
747
|
+
|
748
|
+
if (value === null) {
|
749
|
+
return [
|
750
|
+
...result,
|
751
|
+
[encode(key, options), '[]'].join(''),
|
752
|
+
];
|
753
|
+
}
|
754
|
+
|
755
|
+
return [
|
756
|
+
...result,
|
757
|
+
[encode(key, options), '[]=', encode(value, options)].join(''),
|
758
|
+
];
|
759
|
+
};
|
760
|
+
}
|
761
|
+
|
762
|
+
case 'colon-list-separator': {
|
763
|
+
return key => (result, value) => {
|
764
|
+
if (
|
765
|
+
value === undefined
|
766
|
+
|| (options.skipNull && value === null)
|
767
|
+
|| (options.skipEmptyString && value === '')
|
768
|
+
) {
|
769
|
+
return result;
|
770
|
+
}
|
771
|
+
|
772
|
+
if (value === null) {
|
773
|
+
return [
|
774
|
+
...result,
|
775
|
+
[encode(key, options), ':list='].join(''),
|
776
|
+
];
|
777
|
+
}
|
778
|
+
|
779
|
+
return [
|
780
|
+
...result,
|
781
|
+
[encode(key, options), ':list=', encode(value, options)].join(''),
|
782
|
+
];
|
783
|
+
};
|
784
|
+
}
|
785
|
+
|
786
|
+
case 'comma':
|
787
|
+
case 'separator':
|
788
|
+
case 'bracket-separator': {
|
789
|
+
const keyValueSeparator = options.arrayFormat === 'bracket-separator'
|
790
|
+
? '[]='
|
791
|
+
: '=';
|
792
|
+
|
793
|
+
return key => (result, value) => {
|
794
|
+
if (
|
795
|
+
value === undefined
|
796
|
+
|| (options.skipNull && value === null)
|
797
|
+
|| (options.skipEmptyString && value === '')
|
798
|
+
) {
|
799
|
+
return result;
|
800
|
+
}
|
801
|
+
|
802
|
+
// Translate null to an empty string so that it doesn't serialize as 'null'
|
803
|
+
value = value === null ? '' : value;
|
804
|
+
|
805
|
+
if (result.length === 0) {
|
806
|
+
return [[encode(key, options), keyValueSeparator, encode(value, options)].join('')];
|
807
|
+
}
|
808
|
+
|
809
|
+
return [[result, encode(value, options)].join(options.arrayFormatSeparator)];
|
810
|
+
};
|
811
|
+
}
|
812
|
+
|
813
|
+
default: {
|
814
|
+
return key => (result, value) => {
|
815
|
+
if (
|
816
|
+
value === undefined
|
817
|
+
|| (options.skipNull && value === null)
|
818
|
+
|| (options.skipEmptyString && value === '')
|
819
|
+
) {
|
820
|
+
return result;
|
821
|
+
}
|
822
|
+
|
823
|
+
if (value === null) {
|
824
|
+
return [
|
825
|
+
...result,
|
826
|
+
encode(key, options),
|
827
|
+
];
|
828
|
+
}
|
829
|
+
|
830
|
+
return [
|
831
|
+
...result,
|
832
|
+
[encode(key, options), '=', encode(value, options)].join(''),
|
833
|
+
];
|
834
|
+
};
|
835
|
+
}
|
836
|
+
}
|
837
|
+
}
|
838
|
+
|
839
|
+
function parserForArrayFormat(options) {
|
840
|
+
let result;
|
841
|
+
|
842
|
+
switch (options.arrayFormat) {
|
843
|
+
case 'index': {
|
844
|
+
return (key, value, accumulator) => {
|
845
|
+
result = /\[(\d*)]$/.exec(key);
|
846
|
+
|
847
|
+
key = key.replace(/\[\d*]$/, '');
|
848
|
+
|
849
|
+
if (!result) {
|
850
|
+
accumulator[key] = value;
|
851
|
+
return;
|
852
|
+
}
|
853
|
+
|
854
|
+
if (accumulator[key] === undefined) {
|
855
|
+
accumulator[key] = {};
|
856
|
+
}
|
857
|
+
|
858
|
+
accumulator[key][result[1]] = value;
|
859
|
+
};
|
860
|
+
}
|
861
|
+
|
862
|
+
case 'bracket': {
|
863
|
+
return (key, value, accumulator) => {
|
864
|
+
result = /(\[])$/.exec(key);
|
865
|
+
key = key.replace(/\[]$/, '');
|
866
|
+
|
867
|
+
if (!result) {
|
868
|
+
accumulator[key] = value;
|
869
|
+
return;
|
870
|
+
}
|
871
|
+
|
872
|
+
if (accumulator[key] === undefined) {
|
873
|
+
accumulator[key] = [value];
|
874
|
+
return;
|
875
|
+
}
|
876
|
+
|
877
|
+
accumulator[key] = [...accumulator[key], value];
|
878
|
+
};
|
879
|
+
}
|
880
|
+
|
881
|
+
case 'colon-list-separator': {
|
882
|
+
return (key, value, accumulator) => {
|
883
|
+
result = /(:list)$/.exec(key);
|
884
|
+
key = key.replace(/:list$/, '');
|
885
|
+
|
886
|
+
if (!result) {
|
887
|
+
accumulator[key] = value;
|
888
|
+
return;
|
889
|
+
}
|
890
|
+
|
891
|
+
if (accumulator[key] === undefined) {
|
892
|
+
accumulator[key] = [value];
|
893
|
+
return;
|
894
|
+
}
|
895
|
+
|
896
|
+
accumulator[key] = [...accumulator[key], value];
|
897
|
+
};
|
898
|
+
}
|
899
|
+
|
900
|
+
case 'comma':
|
901
|
+
case 'separator': {
|
902
|
+
return (key, value, accumulator) => {
|
903
|
+
const isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);
|
904
|
+
const isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));
|
905
|
+
value = isEncodedArray ? decode(value, options) : value;
|
906
|
+
const newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : (value === null ? value : decode(value, options));
|
907
|
+
accumulator[key] = newValue;
|
908
|
+
};
|
909
|
+
}
|
910
|
+
|
911
|
+
case 'bracket-separator': {
|
912
|
+
return (key, value, accumulator) => {
|
913
|
+
const isArray = /(\[])$/.test(key);
|
914
|
+
key = key.replace(/\[]$/, '');
|
915
|
+
|
916
|
+
if (!isArray) {
|
917
|
+
accumulator[key] = value ? decode(value, options) : value;
|
918
|
+
return;
|
919
|
+
}
|
920
|
+
|
921
|
+
const arrayValue = value === null
|
922
|
+
? []
|
923
|
+
: value.split(options.arrayFormatSeparator).map(item => decode(item, options));
|
924
|
+
|
925
|
+
if (accumulator[key] === undefined) {
|
926
|
+
accumulator[key] = arrayValue;
|
927
|
+
return;
|
928
|
+
}
|
929
|
+
|
930
|
+
accumulator[key] = [...accumulator[key], ...arrayValue];
|
931
|
+
};
|
932
|
+
}
|
933
|
+
|
934
|
+
default: {
|
935
|
+
return (key, value, accumulator) => {
|
936
|
+
if (accumulator[key] === undefined) {
|
937
|
+
accumulator[key] = value;
|
938
|
+
return;
|
939
|
+
}
|
940
|
+
|
941
|
+
accumulator[key] = [...[accumulator[key]].flat(), value];
|
942
|
+
};
|
943
|
+
}
|
944
|
+
}
|
945
|
+
}
|
946
|
+
|
947
|
+
function validateArrayFormatSeparator(value) {
|
948
|
+
if (typeof value !== 'string' || value.length !== 1) {
|
949
|
+
throw new TypeError('arrayFormatSeparator must be single character string');
|
950
|
+
}
|
951
|
+
}
|
952
|
+
|
953
|
+
function encode(value, options) {
|
954
|
+
if (options.encode) {
|
955
|
+
return options.strict ? strictUriEncode(value) : encodeURIComponent(value);
|
956
|
+
}
|
957
|
+
|
958
|
+
return value;
|
959
|
+
}
|
960
|
+
|
961
|
+
function decode(value, options) {
|
962
|
+
if (options.decode) {
|
963
|
+
return decodeUriComponent(value);
|
964
|
+
}
|
965
|
+
|
966
|
+
return value;
|
967
|
+
}
|
968
|
+
|
969
|
+
function keysSorter(input) {
|
970
|
+
if (Array.isArray(input)) {
|
971
|
+
return input.sort();
|
972
|
+
}
|
973
|
+
|
974
|
+
if (typeof input === 'object') {
|
975
|
+
return keysSorter(Object.keys(input))
|
976
|
+
.sort((a, b) => Number(a) - Number(b))
|
977
|
+
.map(key => input[key]);
|
978
|
+
}
|
979
|
+
|
980
|
+
return input;
|
981
|
+
}
|
982
|
+
|
983
|
+
function removeHash(input) {
|
984
|
+
const hashStart = input.indexOf('#');
|
985
|
+
if (hashStart !== -1) {
|
986
|
+
input = input.slice(0, hashStart);
|
987
|
+
}
|
988
|
+
|
989
|
+
return input;
|
990
|
+
}
|
991
|
+
|
992
|
+
function getHash(url) {
|
993
|
+
let hash = '';
|
994
|
+
const hashStart = url.indexOf('#');
|
995
|
+
if (hashStart !== -1) {
|
996
|
+
hash = url.slice(hashStart);
|
997
|
+
}
|
998
|
+
|
999
|
+
return hash;
|
1000
|
+
}
|
1001
|
+
|
1002
|
+
function parseValue(value, options) {
|
1003
|
+
if (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {
|
1004
|
+
value = Number(value);
|
1005
|
+
} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {
|
1006
|
+
value = value.toLowerCase() === 'true';
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
return value;
|
1010
|
+
}
|
1011
|
+
|
1012
|
+
function extract(input) {
|
1013
|
+
input = removeHash(input);
|
1014
|
+
const queryStart = input.indexOf('?');
|
1015
|
+
if (queryStart === -1) {
|
1016
|
+
return '';
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
return input.slice(queryStart + 1);
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
function parse(query, options) {
|
1023
|
+
options = {
|
1024
|
+
decode: true,
|
1025
|
+
sort: true,
|
1026
|
+
arrayFormat: 'none',
|
1027
|
+
arrayFormatSeparator: ',',
|
1028
|
+
parseNumbers: false,
|
1029
|
+
parseBooleans: false,
|
1030
|
+
...options,
|
1031
|
+
};
|
1032
|
+
|
1033
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
1034
|
+
|
1035
|
+
const formatter = parserForArrayFormat(options);
|
1036
|
+
|
1037
|
+
// Create an object with no prototype
|
1038
|
+
const returnValue = Object.create(null);
|
1039
|
+
|
1040
|
+
if (typeof query !== 'string') {
|
1041
|
+
return returnValue;
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
query = query.trim().replace(/^[?#&]/, '');
|
1045
|
+
|
1046
|
+
if (!query) {
|
1047
|
+
return returnValue;
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
for (const parameter of query.split('&')) {
|
1051
|
+
if (parameter === '') {
|
1052
|
+
continue;
|
1053
|
+
}
|
1054
|
+
|
1055
|
+
const parameter_ = options.decode ? parameter.replaceAll('+', ' ') : parameter;
|
1056
|
+
|
1057
|
+
let [key, value] = splitOnFirst(parameter_, '=');
|
1058
|
+
|
1059
|
+
if (key === undefined) {
|
1060
|
+
key = parameter_;
|
1061
|
+
}
|
1062
|
+
|
1063
|
+
// Missing `=` should be `null`:
|
1064
|
+
// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
|
1065
|
+
value = value === undefined ? null : (['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options));
|
1066
|
+
formatter(decode(key, options), value, returnValue);
|
1067
|
+
}
|
1068
|
+
|
1069
|
+
for (const [key, value] of Object.entries(returnValue)) {
|
1070
|
+
if (typeof value === 'object' && value !== null) {
|
1071
|
+
for (const [key2, value2] of Object.entries(value)) {
|
1072
|
+
value[key2] = parseValue(value2, options);
|
1073
|
+
}
|
1074
|
+
} else {
|
1075
|
+
returnValue[key] = parseValue(value, options);
|
1076
|
+
}
|
1077
|
+
}
|
1078
|
+
|
1079
|
+
if (options.sort === false) {
|
1080
|
+
return returnValue;
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
// TODO: Remove the use of `reduce`.
|
1084
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
1085
|
+
return (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce((result, key) => {
|
1086
|
+
const value = returnValue[key];
|
1087
|
+
result[key] = Boolean(value) && typeof value === 'object' && !Array.isArray(value) ? keysSorter(value) : value;
|
1088
|
+
return result;
|
1089
|
+
}, Object.create(null));
|
1090
|
+
}
|
1091
|
+
|
1092
|
+
function stringify(object, options) {
|
1093
|
+
if (!object) {
|
1094
|
+
return '';
|
1095
|
+
}
|
1096
|
+
|
1097
|
+
options = {
|
1098
|
+
encode: true,
|
1099
|
+
strict: true,
|
1100
|
+
arrayFormat: 'none',
|
1101
|
+
arrayFormatSeparator: ',',
|
1102
|
+
...options,
|
1103
|
+
};
|
1104
|
+
|
1105
|
+
validateArrayFormatSeparator(options.arrayFormatSeparator);
|
1106
|
+
|
1107
|
+
const shouldFilter = key => (
|
1108
|
+
(options.skipNull && isNullOrUndefined(object[key]))
|
1109
|
+
|| (options.skipEmptyString && object[key] === '')
|
1110
|
+
);
|
1111
|
+
|
1112
|
+
const formatter = encoderForArrayFormat(options);
|
1113
|
+
|
1114
|
+
const objectCopy = {};
|
1115
|
+
|
1116
|
+
for (const [key, value] of Object.entries(object)) {
|
1117
|
+
if (!shouldFilter(key)) {
|
1118
|
+
objectCopy[key] = value;
|
1119
|
+
}
|
1120
|
+
}
|
1121
|
+
|
1122
|
+
const keys = Object.keys(objectCopy);
|
1123
|
+
|
1124
|
+
if (options.sort !== false) {
|
1125
|
+
keys.sort(options.sort);
|
1126
|
+
}
|
1127
|
+
|
1128
|
+
return keys.map(key => {
|
1129
|
+
const value = object[key];
|
1130
|
+
|
1131
|
+
if (value === undefined) {
|
1132
|
+
return '';
|
1133
|
+
}
|
1134
|
+
|
1135
|
+
if (value === null) {
|
1136
|
+
return encode(key, options);
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
if (Array.isArray(value)) {
|
1140
|
+
if (value.length === 0 && options.arrayFormat === 'bracket-separator') {
|
1141
|
+
return encode(key, options) + '[]';
|
1142
|
+
}
|
1143
|
+
|
1144
|
+
return value
|
1145
|
+
.reduce(formatter(key), [])
|
1146
|
+
.join('&');
|
1147
|
+
}
|
1148
|
+
|
1149
|
+
return encode(key, options) + '=' + encode(value, options);
|
1150
|
+
}).filter(x => x.length > 0).join('&');
|
1151
|
+
}
|
1152
|
+
|
1153
|
+
function parseUrl(url, options) {
|
1154
|
+
options = {
|
1155
|
+
decode: true,
|
1156
|
+
...options,
|
1157
|
+
};
|
1158
|
+
|
1159
|
+
let [url_, hash] = splitOnFirst(url, '#');
|
1160
|
+
|
1161
|
+
if (url_ === undefined) {
|
1162
|
+
url_ = url;
|
1163
|
+
}
|
1164
|
+
|
1165
|
+
return {
|
1166
|
+
url: url_?.split('?')?.[0] ?? '',
|
1167
|
+
query: parse(extract(url), options),
|
1168
|
+
...(options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}),
|
1169
|
+
};
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
function stringifyUrl(object, options) {
|
1173
|
+
options = {
|
1174
|
+
encode: true,
|
1175
|
+
strict: true,
|
1176
|
+
[encodeFragmentIdentifier]: true,
|
1177
|
+
...options,
|
1178
|
+
};
|
1179
|
+
|
1180
|
+
const url = removeHash(object.url).split('?')[0] || '';
|
1181
|
+
const queryFromUrl = extract(object.url);
|
1182
|
+
|
1183
|
+
const query = {
|
1184
|
+
...parse(queryFromUrl, {sort: false}),
|
1185
|
+
...object.query,
|
1186
|
+
};
|
1187
|
+
|
1188
|
+
let queryString = stringify(query, options);
|
1189
|
+
queryString &&= `?${queryString}`;
|
1190
|
+
|
1191
|
+
let hash = getHash(object.url);
|
1192
|
+
if (typeof object.fragmentIdentifier === 'string') {
|
1193
|
+
const urlObjectForFragmentEncode = new URL(url);
|
1194
|
+
urlObjectForFragmentEncode.hash = object.fragmentIdentifier;
|
1195
|
+
hash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;
|
1196
|
+
}
|
1197
|
+
|
1198
|
+
return `${url}${queryString}${hash}`;
|
1199
|
+
}
|
1200
|
+
|
1201
|
+
function pick(input, filter, options) {
|
1202
|
+
options = {
|
1203
|
+
parseFragmentIdentifier: true,
|
1204
|
+
[encodeFragmentIdentifier]: false,
|
1205
|
+
...options,
|
1206
|
+
};
|
1207
|
+
|
1208
|
+
const {url, query, fragmentIdentifier} = parseUrl(input, options);
|
1209
|
+
|
1210
|
+
return stringifyUrl({
|
1211
|
+
url,
|
1212
|
+
query: includeKeys(query, filter),
|
1213
|
+
fragmentIdentifier,
|
1214
|
+
}, options);
|
1215
|
+
}
|
1216
|
+
|
1217
|
+
function exclude(input, filter, options) {
|
1218
|
+
const exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);
|
1219
|
+
|
1220
|
+
return pick(input, exclusionFilter, options);
|
1221
|
+
}
|
1222
|
+
|
1223
|
+
var queryString = /*#__PURE__*/Object.freeze({
|
1224
|
+
__proto__: null,
|
1225
|
+
exclude: exclude,
|
1226
|
+
extract: extract,
|
1227
|
+
parse: parse,
|
1228
|
+
parseUrl: parseUrl,
|
1229
|
+
pick: pick,
|
1230
|
+
stringify: stringify,
|
1231
|
+
stringifyUrl: stringifyUrl
|
1232
|
+
});
|
76
1233
|
|
77
1234
|
/* eslint-disable react/jsx-props-no-spreading */
|
1235
|
+
// import PropTypes from 'prop-types';
|
78
1236
|
|
79
1237
|
// Kept for backward compatibility with exports
|
80
1238
|
var ResourceFormWrapper = function ResourceFormWrapper(props) {
|
81
|
-
return /*#__PURE__*/
|
1239
|
+
return /*#__PURE__*/React.createElement(ResourceForm$1, props);
|
82
1240
|
};
|
83
1241
|
var ResourceForm = ResourceFormWrapper;
|
84
1242
|
|
85
1243
|
var propTypes$j = {
|
86
|
-
withAccountForm:
|
87
|
-
className:
|
88
|
-
itemClassName:
|
89
|
-
linkClassName:
|
1244
|
+
withAccountForm: PropTypes.bool,
|
1245
|
+
className: PropTypes.string,
|
1246
|
+
itemClassName: PropTypes.string,
|
1247
|
+
linkClassName: PropTypes.string
|
90
1248
|
};
|
91
1249
|
var defaultProps$i = {
|
92
1250
|
withAccountForm: false,
|
@@ -109,7 +1267,7 @@ var AccountMenu = function AccountMenu(_ref) {
|
|
109
1267
|
var items = React.useMemo(function () {
|
110
1268
|
return user !== null ? [{
|
111
1269
|
id: 'account',
|
112
|
-
label: /*#__PURE__*/
|
1270
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
113
1271
|
id: "IuqEHB",
|
114
1272
|
defaultMessage: [{
|
115
1273
|
"type": 0,
|
@@ -117,8 +1275,8 @@ var AccountMenu = function AccountMenu(_ref) {
|
|
117
1275
|
}]
|
118
1276
|
}),
|
119
1277
|
href: route('account'),
|
120
|
-
dropdown: [].concat(
|
121
|
-
label: /*#__PURE__*/
|
1278
|
+
dropdown: [].concat(_toConsumableArray(withAccountForm ? [{
|
1279
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
122
1280
|
id: "V7Us0a",
|
123
1281
|
defaultMessage: [{
|
124
1282
|
"type": 0,
|
@@ -127,7 +1285,7 @@ var AccountMenu = function AccountMenu(_ref) {
|
|
127
1285
|
}),
|
128
1286
|
href: route('account')
|
129
1287
|
}] : []), [{
|
130
|
-
label: /*#__PURE__*/
|
1288
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
131
1289
|
id: "REIcPg",
|
132
1290
|
defaultMessage: [{
|
133
1291
|
"type": 0,
|
@@ -138,7 +1296,7 @@ var AccountMenu = function AccountMenu(_ref) {
|
|
138
1296
|
onClick: onClickLogout
|
139
1297
|
}])
|
140
1298
|
}] : [{
|
141
|
-
label: /*#__PURE__*/
|
1299
|
+
label: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
142
1300
|
id: "d0g58T",
|
143
1301
|
defaultMessage: [{
|
144
1302
|
"type": 0,
|
@@ -148,7 +1306,7 @@ var AccountMenu = function AccountMenu(_ref) {
|
|
148
1306
|
href: route('auth.login')
|
149
1307
|
}];
|
150
1308
|
}, [user, route, onClickLogout, withAccountForm]);
|
151
|
-
return items !== null ? /*#__PURE__*/
|
1309
|
+
return items !== null ? /*#__PURE__*/React.createElement(Menu, {
|
152
1310
|
className: className,
|
153
1311
|
itemClassName: itemClassName,
|
154
1312
|
linkClassName: linkClassName,
|
@@ -161,9 +1319,9 @@ AccountMenu.defaultProps = defaultProps$i;
|
|
161
1319
|
var AccountMenu$1 = AccountMenu;
|
162
1320
|
|
163
1321
|
var propTypes$i = {
|
164
|
-
className:
|
165
|
-
itemClassName:
|
166
|
-
linkClassName:
|
1322
|
+
className: PropTypes.string,
|
1323
|
+
itemClassName: PropTypes.string,
|
1324
|
+
linkClassName: PropTypes.string
|
167
1325
|
};
|
168
1326
|
var defaultProps$h = {
|
169
1327
|
className: null,
|
@@ -174,8 +1332,8 @@ var ResourcesMenu = function ResourcesMenu(_ref) {
|
|
174
1332
|
var className = _ref.className,
|
175
1333
|
itemClassName = _ref.itemClassName,
|
176
1334
|
linkClassName = _ref.linkClassName;
|
177
|
-
var _useLocation =
|
178
|
-
_useLocation2 =
|
1335
|
+
var _useLocation = useLocation(),
|
1336
|
+
_useLocation2 = _slicedToArray(_useLocation, 1),
|
179
1337
|
pathname = _useLocation2[0];
|
180
1338
|
var resources = contexts.usePanneauResources();
|
181
1339
|
var resourceRoute = hooks.useResourceUrlGenerator();
|
@@ -196,7 +1354,7 @@ var ResourcesMenu = function ResourcesMenu(_ref) {
|
|
196
1354
|
};
|
197
1355
|
});
|
198
1356
|
}, [resources, pathname, resourceRoute]);
|
199
|
-
return /*#__PURE__*/
|
1357
|
+
return /*#__PURE__*/React.createElement(Menu, {
|
200
1358
|
items: items,
|
201
1359
|
className: className,
|
202
1360
|
itemClassName: itemClassName,
|
@@ -227,11 +1385,11 @@ var MainNavbar = function MainNavbar(props) {
|
|
227
1385
|
var menuItems = (user !== null ? main : guest) || [];
|
228
1386
|
var hasResources = menuItems.indexOf('resources') !== -1;
|
229
1387
|
var hasAccount = menuItems.indexOf('account') !== -1;
|
230
|
-
return [!hasResources && user !== null ? 'resources' : null].concat(
|
1388
|
+
return [!hasResources && user !== null ? 'resources' : null].concat(_toConsumableArray(menuItems), [!hasAccount && menuItems.indexOf('separator') === -1 ? 'separator' : null, !hasAccount ? 'account' : null]).filter(function (it) {
|
231
1389
|
return it !== null;
|
232
1390
|
}).reduce(function (currentItems, item, index) {
|
233
1391
|
if (item === 'resources') {
|
234
|
-
return [].concat(
|
1392
|
+
return [].concat(_toConsumableArray(currentItems), [/*#__PURE__*/React.createElement(ResourcesMenu$1, {
|
235
1393
|
key: "menu-item-resource-".concat(index + 1),
|
236
1394
|
className: "navbar-nav",
|
237
1395
|
itemClassName: "nav-item",
|
@@ -239,7 +1397,7 @@ var MainNavbar = function MainNavbar(props) {
|
|
239
1397
|
})]);
|
240
1398
|
}
|
241
1399
|
if (item === 'account') {
|
242
|
-
return [].concat(
|
1400
|
+
return [].concat(_toConsumableArray(currentItems), [/*#__PURE__*/React.createElement(AccountMenu$1, {
|
243
1401
|
key: "menu-item-account-".concat(index + 1),
|
244
1402
|
className: "navbar-nav",
|
245
1403
|
itemClassName: "nav-item",
|
@@ -247,15 +1405,15 @@ var MainNavbar = function MainNavbar(props) {
|
|
247
1405
|
})]);
|
248
1406
|
}
|
249
1407
|
if (item === 'separator') {
|
250
|
-
return [].concat(
|
1408
|
+
return [].concat(_toConsumableArray(currentItems), [/*#__PURE__*/React.createElement("span", {
|
251
1409
|
key: "menu-item-spacer-".concat(index + 1),
|
252
1410
|
className: "ms-auto"
|
253
1411
|
})]);
|
254
1412
|
}
|
255
1413
|
var lastItem = currentItems.length > 0 ? currentItems[currentItems.length - 1] : null;
|
256
|
-
return
|
1414
|
+
return isArray(lastItem) ? [].concat(_toConsumableArray(currentItems.slice(0, currentItems.length - 1)), [[].concat(_toConsumableArray(lastItem), [item])]) : [].concat(_toConsumableArray(currentItems), [[item]]);
|
257
1415
|
}, []).map(function (it, index) {
|
258
|
-
return
|
1416
|
+
return isArray(it) ? /*#__PURE__*/React.createElement(Menu, {
|
259
1417
|
items: it,
|
260
1418
|
key: "submenu-item-".concat(index + 1),
|
261
1419
|
className: "navbar-nav",
|
@@ -264,9 +1422,9 @@ var MainNavbar = function MainNavbar(props) {
|
|
264
1422
|
}) : it;
|
265
1423
|
});
|
266
1424
|
}, [main]);
|
267
|
-
return /*#__PURE__*/
|
1425
|
+
return /*#__PURE__*/React.createElement(Navbar, Object.assign({
|
268
1426
|
theme: background
|
269
|
-
}, props), name !== null ? /*#__PURE__*/
|
1427
|
+
}, props), name !== null ? /*#__PURE__*/React.createElement(Link, {
|
270
1428
|
href: route('home'),
|
271
1429
|
className: "navbar-brand"
|
272
1430
|
}, name) : null, items);
|
@@ -278,8 +1436,8 @@ var MainNavbar$1 = MainNavbar;
|
|
278
1436
|
var styles$1 = {};
|
279
1437
|
|
280
1438
|
var propTypes$g = {
|
281
|
-
children:
|
282
|
-
fullscreen:
|
1439
|
+
children: PropTypes.node.isRequired,
|
1440
|
+
fullscreen: PropTypes.bool
|
283
1441
|
};
|
284
1442
|
var defaultProps$f = {
|
285
1443
|
fullscreen: false
|
@@ -294,16 +1452,16 @@ var MainLayout = function MainLayout(_ref) {
|
|
294
1452
|
background = _usePanneauColorSchem3 === void 0 ? null : _usePanneauColorSchem3,
|
295
1453
|
_usePanneauColorSchem4 = _usePanneauColorSchem.text,
|
296
1454
|
text = _usePanneauColorSchem4 === void 0 ? null : _usePanneauColorSchem4;
|
297
|
-
return /*#__PURE__*/
|
298
|
-
className:
|
1455
|
+
return /*#__PURE__*/React.createElement("div", {
|
1456
|
+
className: classNames([styles$1.container, 'd-flex', 'flex-column', 'min-vh-100']),
|
299
1457
|
"data-bs-theme": theme !== null ? theme : null
|
300
|
-
}, /*#__PURE__*/
|
301
|
-
className:
|
302
|
-
}), /*#__PURE__*/
|
303
|
-
className:
|
1458
|
+
}, /*#__PURE__*/React.createElement(MainNavbar$1, {
|
1459
|
+
className: classNames(['border-bottom', 'sticky-top', 'px-3'])
|
1460
|
+
}), /*#__PURE__*/React.createElement("div", {
|
1461
|
+
className: classNames(['flex-grow-1', _defineProperty(_defineProperty({
|
304
1462
|
'd-flex flex-column': fullscreen
|
305
1463
|
}, "bg-".concat(background), background !== null), "text-".concat(text), text !== null)])
|
306
|
-
}, children), /*#__PURE__*/
|
1464
|
+
}, children), /*#__PURE__*/React.createElement(elementModal.Modals, null));
|
307
1465
|
};
|
308
1466
|
MainLayout.propTypes = propTypes$g;
|
309
1467
|
MainLayout.defaultProps = defaultProps$f;
|
@@ -311,10 +1469,10 @@ var MainLayout$1 = MainLayout;
|
|
311
1469
|
|
312
1470
|
var propTypes$f = {
|
313
1471
|
title: core.PropTypes.label,
|
314
|
-
actions:
|
315
|
-
small:
|
316
|
-
className:
|
317
|
-
children:
|
1472
|
+
actions: PropTypes.node,
|
1473
|
+
small: PropTypes.bool,
|
1474
|
+
className: PropTypes.string,
|
1475
|
+
children: PropTypes.node
|
318
1476
|
};
|
319
1477
|
var defaultProps$e = {
|
320
1478
|
title: null,
|
@@ -335,22 +1493,22 @@ var PageHeader = function PageHeader(_ref) {
|
|
335
1493
|
var _usePanneauColorSchem = contexts.usePanneauColorScheme(),
|
336
1494
|
text = _usePanneauColorSchem.text,
|
337
1495
|
background = _usePanneauColorSchem.background;
|
338
|
-
var inner = /*#__PURE__*/
|
1496
|
+
var inner = /*#__PURE__*/React.createElement("div", {
|
339
1497
|
className: "d-flex align-items-center flex-wrap"
|
340
|
-
}, title !== null ? /*#__PURE__*/
|
341
|
-
className:
|
1498
|
+
}, title !== null ? /*#__PURE__*/React.createElement("h1", {
|
1499
|
+
className: classNames(['mb-0', {
|
342
1500
|
h2: small
|
343
1501
|
}])
|
344
|
-
}, /*#__PURE__*/
|
1502
|
+
}, /*#__PURE__*/React.createElement(Label, null, title)) : null, actions !== null ? /*#__PURE__*/React.createElement("div", {
|
345
1503
|
className: "ms-auto"
|
346
1504
|
}, actions) : null);
|
347
|
-
return /*#__PURE__*/
|
348
|
-
className:
|
349
|
-
}, /*#__PURE__*/
|
1505
|
+
return /*#__PURE__*/React.createElement("div", {
|
1506
|
+
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)])
|
1507
|
+
}, /*#__PURE__*/React.createElement("div", {
|
350
1508
|
className: "container-sm"
|
351
|
-
}, small ? /*#__PURE__*/
|
1509
|
+
}, small ? /*#__PURE__*/React.createElement("div", {
|
352
1510
|
className: "row justify-content-center"
|
353
|
-
}, /*#__PURE__*/
|
1511
|
+
}, /*#__PURE__*/React.createElement("div", {
|
354
1512
|
className: "col-12 col-md-8 col-lg-7"
|
355
1513
|
}, inner)) : inner), children);
|
356
1514
|
};
|
@@ -364,13 +1522,13 @@ var propTypes$e = {
|
|
364
1522
|
var defaultProps$d = {};
|
365
1523
|
var ResourceCreatePage = function ResourceCreatePage(_ref) {
|
366
1524
|
var resource = _ref.resource;
|
367
|
-
var _useLocation =
|
368
|
-
_useLocation2 =
|
1525
|
+
var _useLocation = useLocation(),
|
1526
|
+
_useLocation2 = _slicedToArray(_useLocation, 2),
|
369
1527
|
navigate = _useLocation2[1];
|
370
|
-
var search =
|
1528
|
+
var search = useSearch();
|
371
1529
|
var resourceRoute = hooks.useResourceUrlGenerator(resource);
|
372
1530
|
var _useMemo = React.useMemo(function () {
|
373
|
-
return
|
1531
|
+
return queryString.parse(search, {
|
374
1532
|
arrayFormat: 'bracket'
|
375
1533
|
});
|
376
1534
|
}, [search]),
|
@@ -381,10 +1539,10 @@ var ResourceCreatePage = function ResourceCreatePage(_ref) {
|
|
381
1539
|
var onSuccess = React.useCallback(function () {
|
382
1540
|
navigate("".concat(resourceRoute('index'), "?created=true"));
|
383
1541
|
}, [navigate, resourceRoute]);
|
384
|
-
return /*#__PURE__*/
|
1542
|
+
return /*#__PURE__*/React.createElement(contexts.ResourceProvider, {
|
385
1543
|
resource: resource
|
386
|
-
}, /*#__PURE__*/
|
387
|
-
title: /*#__PURE__*/
|
1544
|
+
}, /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement(PageHeader$1, {
|
1545
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
388
1546
|
values: resourceValues,
|
389
1547
|
id: "6viUpq",
|
390
1548
|
defaultMessage: [{
|
@@ -394,17 +1552,17 @@ var ResourceCreatePage = function ResourceCreatePage(_ref) {
|
|
394
1552
|
"type": 1,
|
395
1553
|
"value": "a_singular"
|
396
1554
|
}]
|
397
|
-
}), typeName !== null ? /*#__PURE__*/
|
1555
|
+
}), typeName !== null ? /*#__PURE__*/React.createElement("span", {
|
398
1556
|
className: "text-body-secondary"
|
399
1557
|
}, " (", typeName, ")") : null),
|
400
1558
|
small: true
|
401
|
-
}), /*#__PURE__*/
|
1559
|
+
}), /*#__PURE__*/React.createElement("div", {
|
402
1560
|
className: "container-sm py-4"
|
403
|
-
}, /*#__PURE__*/
|
1561
|
+
}, /*#__PURE__*/React.createElement("div", {
|
404
1562
|
className: "row justify-content-center"
|
405
|
-
}, /*#__PURE__*/
|
1563
|
+
}, /*#__PURE__*/React.createElement("div", {
|
406
1564
|
className: "col-12 col-md-8 col-lg-7"
|
407
|
-
}, /*#__PURE__*/
|
1565
|
+
}, /*#__PURE__*/React.createElement(ResourceForm, {
|
408
1566
|
resource: resource,
|
409
1567
|
type: type,
|
410
1568
|
onSuccess: onSuccess
|
@@ -415,19 +1573,21 @@ ResourceCreatePage.defaultProps = defaultProps$d;
|
|
415
1573
|
var ResourceCreate = ResourceCreatePage;
|
416
1574
|
|
417
1575
|
var propTypes$d = {
|
418
|
-
itemId:
|
1576
|
+
itemId: PropTypes.string.isRequired,
|
419
1577
|
resource: core.PropTypes.resource.isRequired
|
420
1578
|
};
|
421
1579
|
var defaultProps$c = {};
|
422
1580
|
var ResourceDeletePage = function ResourceDeletePage(_ref) {
|
423
1581
|
var itemId = _ref.itemId,
|
424
1582
|
resource = _ref.resource;
|
425
|
-
var _useLocation =
|
426
|
-
_useLocation2 =
|
1583
|
+
var _useLocation = useLocation(),
|
1584
|
+
_useLocation2 = _slicedToArray(_useLocation, 2),
|
427
1585
|
navigate = _useLocation2[1];
|
428
1586
|
var resourceRoute = hooks.useResourceUrlGenerator(resource);
|
429
1587
|
var _useResourceItem = data.useResourceItem(resource, itemId),
|
430
|
-
item = _useResourceItem.item
|
1588
|
+
item = _useResourceItem.item,
|
1589
|
+
loading = _useResourceItem.loading,
|
1590
|
+
error = _useResourceItem.error;
|
431
1591
|
var _ref2 = item || {},
|
432
1592
|
_ref2$type = _ref2.type,
|
433
1593
|
type = _ref2$type === void 0 ? null : _ref2$type;
|
@@ -436,10 +1596,10 @@ var ResourceDeletePage = function ResourceDeletePage(_ref) {
|
|
436
1596
|
var onSuccess = React.useCallback(function () {
|
437
1597
|
return navigate("".concat(resourceRoute('index'), "?deleted=true"));
|
438
1598
|
}, [navigate, resourceRoute]);
|
439
|
-
return /*#__PURE__*/
|
1599
|
+
return /*#__PURE__*/React.createElement(contexts.ResourceProvider, {
|
440
1600
|
resource: resource
|
441
|
-
}, /*#__PURE__*/
|
442
|
-
title: /*#__PURE__*/
|
1601
|
+
}, /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement(PageHeader$1, {
|
1602
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
443
1603
|
values: resourceValues,
|
444
1604
|
id: "zN5N/Q",
|
445
1605
|
defaultMessage: [{
|
@@ -449,29 +1609,35 @@ var ResourceDeletePage = function ResourceDeletePage(_ref) {
|
|
449
1609
|
"type": 1,
|
450
1610
|
"value": "a_singular"
|
451
1611
|
}]
|
452
|
-
}), typeName !== null ? /*#__PURE__*/
|
1612
|
+
}), typeName !== null ? /*#__PURE__*/React.createElement("span", {
|
453
1613
|
className: "text-body-secondary"
|
454
1614
|
}, " (", typeName, ")") : null),
|
455
1615
|
small: true
|
456
|
-
}), /*#__PURE__*/
|
1616
|
+
}), /*#__PURE__*/React.createElement("div", {
|
457
1617
|
className: "container-sm py-4"
|
458
|
-
}, /*#__PURE__*/
|
1618
|
+
}, /*#__PURE__*/React.createElement("div", {
|
459
1619
|
className: "row justify-content-center"
|
460
|
-
}, /*#__PURE__*/
|
1620
|
+
}, /*#__PURE__*/React.createElement("div", {
|
461
1621
|
className: "col-12 col-md-8 col-lg-7"
|
462
|
-
}, item !== null ? /*#__PURE__*/
|
1622
|
+
}, item !== null ? /*#__PURE__*/React.createElement(ResourceForm, {
|
463
1623
|
resource: resource,
|
464
1624
|
item: item,
|
465
1625
|
onSuccess: onSuccess,
|
466
1626
|
isDelete: true
|
467
|
-
}) : null
|
1627
|
+
}) : null, item === null && loading && !error ? /*#__PURE__*/React.createElement(Loading, null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
1628
|
+
id: "TV3jir",
|
1629
|
+
defaultMessage: [{
|
1630
|
+
"type": 0,
|
1631
|
+
"value": "Loading"
|
1632
|
+
}]
|
1633
|
+
})) : null)))));
|
468
1634
|
};
|
469
1635
|
ResourceDeletePage.propTypes = propTypes$d;
|
470
1636
|
ResourceDeletePage.defaultProps = defaultProps$c;
|
471
1637
|
var ResourceDelete = ResourceDeletePage;
|
472
1638
|
|
473
1639
|
var propTypes$c = {
|
474
|
-
itemId:
|
1640
|
+
itemId: PropTypes.string.isRequired,
|
475
1641
|
resource: core.PropTypes.resource.isRequired
|
476
1642
|
};
|
477
1643
|
var defaultProps$b = {};
|
@@ -479,12 +1645,14 @@ var ResourceEditPage = function ResourceEditPage(_ref) {
|
|
479
1645
|
var itemId = _ref.itemId,
|
480
1646
|
resource = _ref.resource;
|
481
1647
|
var _useResourceItem = data.useResourceItem(resource, itemId),
|
482
|
-
item = _useResourceItem.item
|
1648
|
+
item = _useResourceItem.item,
|
1649
|
+
loading = _useResourceItem.loading,
|
1650
|
+
error = _useResourceItem.error;
|
483
1651
|
var _ref2 = item || {},
|
484
1652
|
_ref2$type = _ref2.type,
|
485
1653
|
type = _ref2$type === void 0 ? null : _ref2$type;
|
486
1654
|
var _useState = React.useState(item),
|
487
|
-
_useState2 =
|
1655
|
+
_useState2 = _slicedToArray(_useState, 2),
|
488
1656
|
editItem = _useState2[0],
|
489
1657
|
setEditItem = _useState2[1];
|
490
1658
|
var typeName = hooks.useResourceTypeName(resource, type);
|
@@ -495,10 +1663,10 @@ var ResourceEditPage = function ResourceEditPage(_ref) {
|
|
495
1663
|
setEditItem(item);
|
496
1664
|
}, [item, setEditItem]);
|
497
1665
|
var resourceValues = intl.useResourceValues(resource);
|
498
|
-
return /*#__PURE__*/
|
1666
|
+
return /*#__PURE__*/React.createElement(contexts.ResourceProvider, {
|
499
1667
|
resource: resource
|
500
|
-
}, /*#__PURE__*/
|
501
|
-
title: /*#__PURE__*/
|
1668
|
+
}, /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement(PageHeader$1, {
|
1669
|
+
title: /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
502
1670
|
values: resourceValues,
|
503
1671
|
id: "mCfzkJ",
|
504
1672
|
defaultMessage: [{
|
@@ -508,22 +1676,28 @@ var ResourceEditPage = function ResourceEditPage(_ref) {
|
|
508
1676
|
"type": 1,
|
509
1677
|
"value": "a_singular"
|
510
1678
|
}]
|
511
|
-
}), typeName !== null ? /*#__PURE__*/
|
1679
|
+
}), typeName !== null ? /*#__PURE__*/React.createElement("span", {
|
512
1680
|
className: "text-body-secondary"
|
513
1681
|
}, " (", typeName, ")") : null),
|
514
1682
|
small: true
|
515
|
-
}), /*#__PURE__*/
|
1683
|
+
}), /*#__PURE__*/React.createElement("div", {
|
516
1684
|
className: "container-sm py-4"
|
517
|
-
}, /*#__PURE__*/
|
1685
|
+
}, /*#__PURE__*/React.createElement("div", {
|
518
1686
|
className: "row justify-content-center"
|
519
|
-
}, /*#__PURE__*/
|
1687
|
+
}, /*#__PURE__*/React.createElement("div", {
|
520
1688
|
className: "col-12 col-md-8 col-lg-7"
|
521
|
-
}, editItem !== null ? /*#__PURE__*/
|
1689
|
+
}, editItem !== null ? /*#__PURE__*/React.createElement(ResourceForm, {
|
522
1690
|
resource: resource,
|
523
1691
|
item: editItem,
|
524
1692
|
type: type,
|
525
1693
|
onSuccess: onSuccess
|
526
|
-
}) : null
|
1694
|
+
}) : null, editItem === null && loading && !error ? /*#__PURE__*/React.createElement(Loading, null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
1695
|
+
id: "TV3jir",
|
1696
|
+
defaultMessage: [{
|
1697
|
+
"type": 0,
|
1698
|
+
"value": "Loading"
|
1699
|
+
}]
|
1700
|
+
})) : null)))));
|
527
1701
|
};
|
528
1702
|
ResourceEditPage.propTypes = propTypes$c;
|
529
1703
|
ResourceEditPage.defaultProps = defaultProps$b;
|
@@ -531,7 +1705,7 @@ var ResourceEdit = ResourceEditPage;
|
|
531
1705
|
|
532
1706
|
var propTypes$b = {
|
533
1707
|
resource: core.PropTypes.resource.isRequired,
|
534
|
-
className:
|
1708
|
+
className: PropTypes.string
|
535
1709
|
};
|
536
1710
|
var defaultProps$a = {
|
537
1711
|
className: null
|
@@ -545,7 +1719,7 @@ var ResourceCreateButtom = function ResourceCreateButtom(_ref) {
|
|
545
1719
|
var resourceRoute = hooks.useResourceUrlGenerator(resource);
|
546
1720
|
var resourceValues = intl.useResourceValues(resource);
|
547
1721
|
var _useState = React.useState(false),
|
548
|
-
_useState2 =
|
1722
|
+
_useState2 = _slicedToArray(_useState, 2),
|
549
1723
|
dropdownOpened = _useState2[0],
|
550
1724
|
setDropdownOpened = _useState2[1];
|
551
1725
|
var onClickDropdown = React.useCallback(function (e) {
|
@@ -566,15 +1740,15 @@ var ResourceCreateButtom = function ResourceCreateButtom(_ref) {
|
|
566
1740
|
setDropdownOpened(false);
|
567
1741
|
}
|
568
1742
|
}, [setDropdownOpened, dropdownOpened]);
|
569
|
-
var button = /*#__PURE__*/
|
1743
|
+
var button = /*#__PURE__*/React.createElement(Button, {
|
570
1744
|
href: !hasMultipleTypes ? "".concat(resourceRoute('create')).concat(finalTypes !== null && finalTypes.length === 1 ? "?type=".concat(finalTypes[0].id) : '') : '#',
|
571
1745
|
size: "lg",
|
572
1746
|
theme: "primary",
|
573
|
-
className:
|
1747
|
+
className: classNames([_defineProperty({
|
574
1748
|
'dropdown-toggle': hasMultipleTypes
|
575
1749
|
}, className, className !== null)]),
|
576
1750
|
onClick: hasMultipleTypes ? onClickDropdown : null
|
577
|
-
}, /*#__PURE__*/
|
1751
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
578
1752
|
values: resourceValues,
|
579
1753
|
id: "l+ddDH",
|
580
1754
|
defaultMessage: [{
|
@@ -585,11 +1759,11 @@ var ResourceCreateButtom = function ResourceCreateButtom(_ref) {
|
|
585
1759
|
"value": "a_singular"
|
586
1760
|
}]
|
587
1761
|
}));
|
588
|
-
return hasMultipleTypes ? /*#__PURE__*/
|
589
|
-
className:
|
1762
|
+
return hasMultipleTypes ? /*#__PURE__*/React.createElement("div", {
|
1763
|
+
className: classNames(['dropdown', {
|
590
1764
|
show: dropdownOpened
|
591
1765
|
}])
|
592
|
-
}, button, /*#__PURE__*/
|
1766
|
+
}, button, /*#__PURE__*/React.createElement(Dropdown, {
|
593
1767
|
items: finalTypes.map(function (it) {
|
594
1768
|
return {
|
595
1769
|
id: it.id,
|
@@ -608,21 +1782,21 @@ var ResourceCreateButton = ResourceCreateButtom;
|
|
608
1782
|
|
609
1783
|
var _excluded$3 = ["resource"];
|
610
1784
|
var propTypes$a = {
|
611
|
-
resource:
|
612
|
-
id:
|
1785
|
+
resource: PropTypes.oneOfType([PropTypes.string, PropTypes.shape({
|
1786
|
+
id: PropTypes.string
|
613
1787
|
})]).isRequired
|
614
1788
|
};
|
615
1789
|
|
616
1790
|
// Kept for backward compatibility with exports
|
617
1791
|
var ResourceItemsList = function ResourceItemsList(_ref) {
|
618
1792
|
var resource = _ref.resource,
|
619
|
-
props =
|
620
|
-
var _ref2 =
|
1793
|
+
props = _objectWithoutProperties(_ref, _excluded$3);
|
1794
|
+
var _ref2 = isObject(resource) ? resource : {
|
621
1795
|
id: resource
|
622
1796
|
},
|
623
1797
|
_ref2$id = _ref2.id,
|
624
1798
|
finalResource = _ref2$id === void 0 ? null : _ref2$id;
|
625
|
-
return /*#__PURE__*/
|
1799
|
+
return /*#__PURE__*/React.createElement(ResourceList, Object.assign({
|
626
1800
|
resource: finalResource
|
627
1801
|
}, props));
|
628
1802
|
};
|
@@ -632,7 +1806,7 @@ var ResourceItemsList$1 = ResourceItemsList;
|
|
632
1806
|
var _excluded$2 = ["id", "component"];
|
633
1807
|
var propTypes$9 = {
|
634
1808
|
resource: core.PropTypes.resource.isRequired,
|
635
|
-
defaultActions:
|
1809
|
+
defaultActions: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.object])) // eslint-disable-line react/forbid-prop-types
|
636
1810
|
};
|
637
1811
|
var defaultProps$9 = {
|
638
1812
|
defaultActions: ['create']
|
@@ -670,12 +1844,12 @@ var ResourceIndexPage = function ResourceIndexPage(_ref) {
|
|
670
1844
|
}, [canCreate, actions]);
|
671
1845
|
var resourceValues = intl.useResourceValues(resource);
|
672
1846
|
var componentsManager = contexts.useComponentsManager();
|
673
|
-
var _useLocation =
|
674
|
-
_useLocation2 =
|
1847
|
+
var _useLocation = useLocation(),
|
1848
|
+
_useLocation2 = _slicedToArray(_useLocation, 2),
|
675
1849
|
navigate = _useLocation2[1];
|
676
|
-
var search =
|
1850
|
+
var search = useSearch();
|
677
1851
|
var query = React.useMemo(function () {
|
678
|
-
return
|
1852
|
+
return queryString.parse(search, {
|
679
1853
|
arrayFormat: 'bracket'
|
680
1854
|
});
|
681
1855
|
}, [search]);
|
@@ -692,14 +1866,14 @@ var ResourceIndexPage = function ResourceIndexPage(_ref) {
|
|
692
1866
|
var onQueryChange = React.useCallback(function (submitQuery) {
|
693
1867
|
var newQuery = submitQuery !== null ? Object.keys(submitQuery).reduce(function (currentQuery, key) {
|
694
1868
|
var value = submitQuery[key];
|
695
|
-
return value !== null ?
|
1869
|
+
return value !== null ? _objectSpread(_objectSpread({}, currentQuery), {}, _defineProperty({}, key, value)) : currentQuery;
|
696
1870
|
}, null) : null;
|
697
|
-
navigate("".concat(url).concat(newQuery !== null ? "?".concat(
|
1871
|
+
navigate("".concat(url).concat(newQuery !== null ? "?".concat(queryString.stringify(newQuery, {
|
698
1872
|
arrayFormat: 'bracket'
|
699
1873
|
})) : ''));
|
700
1874
|
}, [navigate, url, query, paginated]);
|
701
1875
|
var onQueryReset = React.useCallback(function () {
|
702
|
-
var resetQuery =
|
1876
|
+
var resetQuery = queryString.stringify(null, {
|
703
1877
|
arrayFormat: 'bracket'
|
704
1878
|
});
|
705
1879
|
navigate("".concat(url, "?").concat(resetQuery));
|
@@ -709,32 +1883,32 @@ var ResourceIndexPage = function ResourceIndexPage(_ref) {
|
|
709
1883
|
replace: true
|
710
1884
|
});
|
711
1885
|
}, [navigate, url]);
|
712
|
-
return /*#__PURE__*/
|
1886
|
+
return /*#__PURE__*/React.createElement(contexts.ResourceProvider, {
|
713
1887
|
resource: resource
|
714
|
-
}, /*#__PURE__*/
|
1888
|
+
}, /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement(PageHeader$1, {
|
715
1889
|
title: name,
|
716
|
-
actions: finalActions.length > 0 ? /*#__PURE__*/
|
1890
|
+
actions: finalActions.length > 0 ? /*#__PURE__*/React.createElement("div", {
|
717
1891
|
className: "d-flex align-items-center"
|
718
1892
|
}, finalActions.map(function (_ref5) {
|
719
1893
|
var id = _ref5.id,
|
720
1894
|
_ref5$component = _ref5.component,
|
721
|
-
component = _ref5$component === void 0 ?
|
722
|
-
actionProps =
|
723
|
-
var ActionComponent =
|
724
|
-
return ActionComponent !== null ? /*#__PURE__*/
|
1895
|
+
component = _ref5$component === void 0 ? Button : _ref5$component,
|
1896
|
+
actionProps = _objectWithoutProperties(_ref5, _excluded$2);
|
1897
|
+
var ActionComponent = isString(component) ? componentsManager.getComponent(component) : component;
|
1898
|
+
return ActionComponent !== null ? /*#__PURE__*/React.createElement(ActionComponent, Object.assign({
|
725
1899
|
key: "action-".concat(id)
|
726
|
-
}, actionProps, ActionComponent !==
|
1900
|
+
}, actionProps, ActionComponent !== Button ? {
|
727
1901
|
resource: resource,
|
728
1902
|
query: query,
|
729
1903
|
onQueryChange: onQueryChange
|
730
1904
|
} : {})) : null;
|
731
1905
|
})) : null
|
732
|
-
}), /*#__PURE__*/
|
733
|
-
className:
|
734
|
-
}, created ? /*#__PURE__*/
|
1906
|
+
}), /*#__PURE__*/React.createElement("div", {
|
1907
|
+
className: classNames(['container-sm py-4'])
|
1908
|
+
}, created ? /*#__PURE__*/React.createElement(Alert, {
|
735
1909
|
className: "mb-4",
|
736
1910
|
onClose: onClickCloseAlert
|
737
|
-
}, /*#__PURE__*/
|
1911
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
738
1912
|
values: resourceValues,
|
739
1913
|
id: "bfP/d8",
|
740
1914
|
defaultMessage: [{
|
@@ -744,10 +1918,10 @@ var ResourceIndexPage = function ResourceIndexPage(_ref) {
|
|
744
1918
|
"type": 0,
|
745
1919
|
"value": " has been created."
|
746
1920
|
}]
|
747
|
-
})) : null, deleted ? /*#__PURE__*/
|
1921
|
+
})) : null, deleted ? /*#__PURE__*/React.createElement(Alert, {
|
748
1922
|
className: "mb-4",
|
749
1923
|
onClose: onClickCloseAlert
|
750
|
-
}, /*#__PURE__*/
|
1924
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
751
1925
|
values: resourceValues,
|
752
1926
|
id: "dkRdks",
|
753
1927
|
defaultMessage: [{
|
@@ -757,7 +1931,7 @@ var ResourceIndexPage = function ResourceIndexPage(_ref) {
|
|
757
1931
|
"type": 0,
|
758
1932
|
"value": " has been deleted."
|
759
1933
|
}]
|
760
|
-
})) : null, /*#__PURE__*/
|
1934
|
+
})) : null, /*#__PURE__*/React.createElement(ResourceItemsList$1, {
|
761
1935
|
resource: resource,
|
762
1936
|
baseUrl: url,
|
763
1937
|
query: listQuery,
|
@@ -773,7 +1947,7 @@ var ResourceIndex = ResourceIndexPage;
|
|
773
1947
|
|
774
1948
|
var propTypes$8 = {
|
775
1949
|
resource: core.PropTypes.resource.isRequired,
|
776
|
-
itemId:
|
1950
|
+
itemId: PropTypes.string.isRequired
|
777
1951
|
};
|
778
1952
|
var defaultProps$8 = {};
|
779
1953
|
var ResourceShowPage = function ResourceShowPage(_ref) {
|
@@ -781,27 +1955,35 @@ var ResourceShowPage = function ResourceShowPage(_ref) {
|
|
781
1955
|
itemId = _ref.itemId;
|
782
1956
|
var name = resource.name;
|
783
1957
|
var _useResourceItem = data.useResourceItem(resource, itemId),
|
784
|
-
item = _useResourceItem.item
|
1958
|
+
item = _useResourceItem.item,
|
1959
|
+
loading = _useResourceItem.loading,
|
1960
|
+
error = _useResourceItem.error;
|
785
1961
|
var _ref2 = item || {},
|
786
1962
|
_ref2$type = _ref2.type,
|
787
1963
|
type = _ref2$type === void 0 ? null : _ref2$type;
|
788
|
-
return /*#__PURE__*/
|
1964
|
+
return /*#__PURE__*/React.createElement(contexts.ResourceProvider, {
|
789
1965
|
resource: resource
|
790
|
-
}, /*#__PURE__*/
|
1966
|
+
}, /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement(PageHeader$1, {
|
791
1967
|
title: "".concat(name, " #").concat(itemId),
|
792
1968
|
small: true
|
793
|
-
}), /*#__PURE__*/
|
1969
|
+
}), /*#__PURE__*/React.createElement("div", {
|
794
1970
|
className: "container-sm py-4"
|
795
|
-
}, /*#__PURE__*/
|
1971
|
+
}, /*#__PURE__*/React.createElement("div", {
|
796
1972
|
className: "row justify-content-center"
|
797
|
-
}, /*#__PURE__*/
|
1973
|
+
}, /*#__PURE__*/React.createElement("div", {
|
798
1974
|
className: "col-12 col-md-8 col-lg-7"
|
799
|
-
}, /*#__PURE__*/
|
1975
|
+
}, item !== null ? /*#__PURE__*/React.createElement(ResourceForm, {
|
800
1976
|
resource: resource,
|
801
1977
|
item: item,
|
802
1978
|
type: type,
|
803
1979
|
disabled: true
|
804
|
-
})
|
1980
|
+
}) : null, item === null && loading && !error ? /*#__PURE__*/React.createElement(Loading, null, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
1981
|
+
id: "TV3jir",
|
1982
|
+
defaultMessage: [{
|
1983
|
+
"type": 0,
|
1984
|
+
"value": "Loading"
|
1985
|
+
}]
|
1986
|
+
})) : null)))));
|
805
1987
|
};
|
806
1988
|
ResourceShowPage.propTypes = propTypes$8;
|
807
1989
|
ResourceShowPage.defaultProps = defaultProps$8;
|
@@ -820,19 +2002,19 @@ var HomePage = function HomePage() {
|
|
820
2002
|
hideInNavbar = _ref$settings2$hideIn === void 0 ? false : _ref$settings2$hideIn;
|
821
2003
|
return !hideInNavbar;
|
822
2004
|
});
|
823
|
-
return /*#__PURE__*/
|
2005
|
+
return /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement("div", {
|
824
2006
|
className: "container-sm py-4"
|
825
2007
|
}, visibleResources.map(function (resource) {
|
826
2008
|
var _ref2 = resource || {},
|
827
2009
|
resourceId = _ref2.id;
|
828
2010
|
var resourceValues = intl.useResourceValues(resource);
|
829
|
-
return /*#__PURE__*/
|
2011
|
+
return /*#__PURE__*/React.createElement(Link, {
|
830
2012
|
className: "d-block my-2",
|
831
2013
|
key: "resource-link-".concat(resourceId),
|
832
2014
|
href: route('resources.index', {
|
833
2015
|
resource: resourceId
|
834
2016
|
})
|
835
|
-
}, /*#__PURE__*/
|
2017
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
836
2018
|
values: resourceValues,
|
837
2019
|
id: "FntHPK",
|
838
2020
|
defaultMessage: [{
|
@@ -852,7 +2034,7 @@ var HomePage$1 = HomePage;
|
|
852
2034
|
var propTypes$6 = {};
|
853
2035
|
var defaultProps$6 = {};
|
854
2036
|
var AccountPage = function AccountPage() {
|
855
|
-
return /*#__PURE__*/
|
2037
|
+
return /*#__PURE__*/React.createElement(MainLayout$1, null, /*#__PURE__*/React.createElement("div", {
|
856
2038
|
className: "container-sm py-4"
|
857
2039
|
}, "Account page"));
|
858
2040
|
};
|
@@ -862,8 +2044,8 @@ var AccountPage$1 = AccountPage;
|
|
862
2044
|
|
863
2045
|
/* eslint-disable react/jsx-props-no-spreading */
|
864
2046
|
var propTypes$5 = {
|
865
|
-
className:
|
866
|
-
onSuccess:
|
2047
|
+
className: PropTypes.string,
|
2048
|
+
onSuccess: PropTypes.func
|
867
2049
|
};
|
868
2050
|
var defaultProps$5 = {
|
869
2051
|
className: null,
|
@@ -882,12 +2064,12 @@ var LoginForm = function LoginForm(_ref) {
|
|
882
2064
|
}, [login]);
|
883
2065
|
var FormComponents = contexts.useFormsComponents();
|
884
2066
|
var FormComponent = utils.getComponentFromName('login', FormComponents);
|
885
|
-
return FormComponent !== null ? /*#__PURE__*/
|
2067
|
+
return FormComponent !== null ? /*#__PURE__*/React.createElement(FormComponent, {
|
886
2068
|
action: url('auth.login'),
|
887
2069
|
postForm: postForm,
|
888
2070
|
onComplete: onSuccess,
|
889
2071
|
className: className,
|
890
|
-
submitButtonLabel: /*#__PURE__*/
|
2072
|
+
submitButtonLabel: /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
891
2073
|
id: "g6qbbX",
|
892
2074
|
defaultMessage: [{
|
893
2075
|
"type": 0,
|
@@ -903,8 +2085,8 @@ var LoginForm$1 = LoginForm;
|
|
903
2085
|
var styles = {};
|
904
2086
|
|
905
2087
|
var propTypes$4 = {
|
906
|
-
children:
|
907
|
-
fullscreen:
|
2088
|
+
children: PropTypes.node.isRequired,
|
2089
|
+
fullscreen: PropTypes.bool
|
908
2090
|
};
|
909
2091
|
var defaultProps$4 = {
|
910
2092
|
fullscreen: false
|
@@ -919,19 +2101,19 @@ var GuestLayout = function GuestLayout(_ref) {
|
|
919
2101
|
background = _usePanneauColorSchem3 === void 0 ? null : _usePanneauColorSchem3,
|
920
2102
|
_usePanneauColorSchem4 = _usePanneauColorSchem.text,
|
921
2103
|
text = _usePanneauColorSchem4 === void 0 ? null : _usePanneauColorSchem4;
|
922
|
-
return /*#__PURE__*/
|
923
|
-
className:
|
2104
|
+
return /*#__PURE__*/React.createElement("div", {
|
2105
|
+
className: classNames([styles.container, {
|
924
2106
|
'd-flex flex-column min-vh-100': fullscreen
|
925
2107
|
}]),
|
926
2108
|
"data-bs-theme": theme !== null ? theme : null
|
927
|
-
}, /*#__PURE__*/
|
928
|
-
className:
|
929
|
-
}), /*#__PURE__*/
|
930
|
-
className:
|
2109
|
+
}, /*#__PURE__*/React.createElement(MainNavbar$1, {
|
2110
|
+
className: classNames(['sticky-top', 'px-3'])
|
2111
|
+
}), /*#__PURE__*/React.createElement("div", {
|
2112
|
+
className: classNames(_defineProperty(_defineProperty({
|
931
2113
|
'd-flex flex-column flex-grow-1': fullscreen
|
932
2114
|
}, "bg-".concat(background), background !== null), "text-".concat(text), text !== null))
|
933
|
-
}, /*#__PURE__*/
|
934
|
-
className:
|
2115
|
+
}, /*#__PURE__*/React.createElement("div", {
|
2116
|
+
className: classNames({
|
935
2117
|
'w-100 my-auto': fullscreen
|
936
2118
|
})
|
937
2119
|
}, children)));
|
@@ -950,23 +2132,23 @@ var LoginPage = function LoginPage() {
|
|
950
2132
|
var onSuccess = React.useCallback(function () {
|
951
2133
|
window.location.href = route('home');
|
952
2134
|
}, [route]);
|
953
|
-
return /*#__PURE__*/
|
2135
|
+
return /*#__PURE__*/React.createElement(GuestLayout$1, {
|
954
2136
|
fullscreen: true
|
955
|
-
}, /*#__PURE__*/
|
2137
|
+
}, /*#__PURE__*/React.createElement("div", {
|
956
2138
|
className: "container-sm py-4"
|
957
|
-
}, /*#__PURE__*/
|
2139
|
+
}, /*#__PURE__*/React.createElement("div", {
|
958
2140
|
className: "row justify-content-center"
|
959
|
-
}, /*#__PURE__*/
|
2141
|
+
}, /*#__PURE__*/React.createElement("div", {
|
960
2142
|
className: "col-12 col-sm-8 col-md-6"
|
961
|
-
}, /*#__PURE__*/
|
2143
|
+
}, /*#__PURE__*/React.createElement("h1", {
|
962
2144
|
className: "mb-4"
|
963
|
-
}, /*#__PURE__*/
|
2145
|
+
}, /*#__PURE__*/React.createElement(reactIntl.FormattedMessage, {
|
964
2146
|
id: "AeOZq+",
|
965
2147
|
defaultMessage: [{
|
966
2148
|
"type": 0,
|
967
2149
|
"value": "Login"
|
968
2150
|
}]
|
969
|
-
})), /*#__PURE__*/
|
2151
|
+
})), /*#__PURE__*/React.createElement(LoginForm$1, {
|
970
2152
|
onSuccess: onSuccess
|
971
2153
|
})))));
|
972
2154
|
};
|
@@ -1075,15 +2257,15 @@ var defaultProps$2 = {
|
|
1075
2257
|
};
|
1076
2258
|
var ErrorPage = function ErrorPage(_ref) {
|
1077
2259
|
var statusCode = _ref.statusCode;
|
1078
|
-
return /*#__PURE__*/
|
2260
|
+
return /*#__PURE__*/React.createElement(GuestLayout$1, {
|
1079
2261
|
fullscreen: true
|
1080
|
-
}, /*#__PURE__*/
|
2262
|
+
}, /*#__PURE__*/React.createElement("div", {
|
1081
2263
|
className: "container-sm py-4"
|
1082
|
-
}, /*#__PURE__*/
|
2264
|
+
}, /*#__PURE__*/React.createElement("div", {
|
1083
2265
|
className: "row justify-content-center"
|
1084
|
-
}, /*#__PURE__*/
|
2266
|
+
}, /*#__PURE__*/React.createElement("div", {
|
1085
2267
|
className: "col-12 col-sm-8 col-md-6"
|
1086
|
-
}, /*#__PURE__*/
|
2268
|
+
}, /*#__PURE__*/React.createElement("h1", null, /*#__PURE__*/React.createElement(Label, null, messages["title".concat(statusCode || 404)])), /*#__PURE__*/React.createElement("p", null, /*#__PURE__*/React.createElement(Label, null, messages["description".concat(statusCode || 404)]))))));
|
1087
2269
|
};
|
1088
2270
|
ErrorPage.propTypes = propTypes$2;
|
1089
2271
|
ErrorPage.defaultProps = defaultProps$2;
|
@@ -1129,17 +2311,17 @@ var createResourceRoutes = function createResourceRoutes(resource, _ref) {
|
|
1129
2311
|
var ResourceCreateComponent = componentsManager.getComponent(resourceCreatePage === null || resourceCreatePage === void 0 ? void 0 : resourceCreatePage.component) || componentsManager.getComponent(createPage === null || createPage === void 0 ? void 0 : createPage.component) || ResourceCreate;
|
1130
2312
|
var ResourceEditComponent = componentsManager.getComponent(resourceEditPage === null || resourceEditPage === void 0 ? void 0 : resourceEditPage.component) || componentsManager.getComponent(editPage === null || editPage === void 0 ? void 0 : editPage.component) || ResourceEdit;
|
1131
2313
|
var ResourceDeleteComponent = componentsManager.getComponent(resourceDeletePage === null || resourceDeletePage === void 0 ? void 0 : resourceDeletePage.component) || componentsManager.getComponent(deletePage === null || deletePage === void 0 ? void 0 : deletePage.component) || ResourceDelete;
|
1132
|
-
return [/*#__PURE__*/
|
2314
|
+
return [/*#__PURE__*/React.createElement(Route, {
|
1133
2315
|
key: "".concat(resourceId, "-create"),
|
1134
2316
|
path: route('resources.create', {
|
1135
2317
|
resource: resourceId
|
1136
2318
|
}),
|
1137
2319
|
exact: true
|
1138
2320
|
}, function () {
|
1139
|
-
return /*#__PURE__*/
|
2321
|
+
return /*#__PURE__*/React.createElement(ResourceCreateComponent, {
|
1140
2322
|
resource: resource
|
1141
2323
|
});
|
1142
|
-
}), /*#__PURE__*/
|
2324
|
+
}), /*#__PURE__*/React.createElement(Route, {
|
1143
2325
|
key: "".concat(resourceId, "-show"),
|
1144
2326
|
path: route('resources.show', {
|
1145
2327
|
resource: resourceId,
|
@@ -1148,11 +2330,11 @@ var createResourceRoutes = function createResourceRoutes(resource, _ref) {
|
|
1148
2330
|
}, function (_ref4) {
|
1149
2331
|
var _ref4$id = _ref4.id,
|
1150
2332
|
id = _ref4$id === void 0 ? null : _ref4$id;
|
1151
|
-
return /*#__PURE__*/
|
2333
|
+
return /*#__PURE__*/React.createElement(ResourceShowComponent, {
|
1152
2334
|
itemId: id,
|
1153
2335
|
resource: resource
|
1154
2336
|
});
|
1155
|
-
}), /*#__PURE__*/
|
2337
|
+
}), /*#__PURE__*/React.createElement(Route, {
|
1156
2338
|
key: "".concat(resourceId, "-edit"),
|
1157
2339
|
path: route('resources.edit', {
|
1158
2340
|
resource: resourceId,
|
@@ -1161,11 +2343,11 @@ var createResourceRoutes = function createResourceRoutes(resource, _ref) {
|
|
1161
2343
|
}, function (_ref5) {
|
1162
2344
|
var _ref5$id = _ref5.id,
|
1163
2345
|
id = _ref5$id === void 0 ? null : _ref5$id;
|
1164
|
-
return /*#__PURE__*/
|
2346
|
+
return /*#__PURE__*/React.createElement(ResourceEditComponent, {
|
1165
2347
|
itemId: id,
|
1166
2348
|
resource: resource
|
1167
2349
|
});
|
1168
|
-
}), /*#__PURE__*/
|
2350
|
+
}), /*#__PURE__*/React.createElement(Route, {
|
1169
2351
|
key: "".concat(resourceId, "-delete"),
|
1170
2352
|
path: route('resources.delete', {
|
1171
2353
|
resource: resourceId,
|
@@ -1174,35 +2356,34 @@ var createResourceRoutes = function createResourceRoutes(resource, _ref) {
|
|
1174
2356
|
}, function (_ref6) {
|
1175
2357
|
var _ref6$id = _ref6.id,
|
1176
2358
|
id = _ref6$id === void 0 ? null : _ref6$id;
|
1177
|
-
return /*#__PURE__*/
|
2359
|
+
return /*#__PURE__*/React.createElement(ResourceDeleteComponent, {
|
1178
2360
|
itemId: id,
|
1179
2361
|
resource: resource
|
1180
2362
|
});
|
1181
|
-
})].concat(
|
2363
|
+
})].concat(_toConsumableArray(extraRoutes.map(function (_ref7) {
|
1182
2364
|
var path = _ref7.path,
|
1183
2365
|
component = _ref7.component,
|
1184
|
-
pageProps =
|
2366
|
+
pageProps = _objectWithoutProperties(_ref7, _excluded$1);
|
1185
2367
|
var RouteComponent = componentsManager.getComponent(component);
|
1186
|
-
return RouteComponent !== null ? /*#__PURE__*/
|
2368
|
+
return RouteComponent !== null ? /*#__PURE__*/React.createElement(Route, {
|
1187
2369
|
key: "route-".concat(path),
|
1188
2370
|
path: path
|
1189
2371
|
}, function () {
|
1190
|
-
return /*#__PURE__*/
|
2372
|
+
return /*#__PURE__*/React.createElement(RouteComponent, Object.assign({
|
1191
2373
|
resource: resource
|
1192
2374
|
}, pageProps));
|
1193
2375
|
}) : null;
|
1194
|
-
})), [/*#__PURE__*/
|
2376
|
+
})), [/*#__PURE__*/React.createElement(Route, {
|
1195
2377
|
key: "".concat(resourceId, "-index"),
|
1196
2378
|
path: route('resources.index', {
|
1197
2379
|
resource: resourceId
|
1198
2380
|
})
|
1199
2381
|
}, function () {
|
1200
|
-
return /*#__PURE__*/
|
2382
|
+
return /*#__PURE__*/React.createElement(ResourceIndexComponent, {
|
1201
2383
|
resource: resource
|
1202
2384
|
});
|
1203
2385
|
})]);
|
1204
2386
|
};
|
1205
|
-
var createResourceRoutes$1 = createResourceRoutes;
|
1206
2387
|
|
1207
2388
|
var _excluded = ["home", "login", "account", "error", "index", "show", "create", "edit", "delete"],
|
1208
2389
|
_excluded2 = ["path", "route", "component"];
|
@@ -1215,14 +2396,14 @@ var defaultProps$1 = {
|
|
1215
2396
|
var PanneauRoutes = function PanneauRoutes(_ref) {
|
1216
2397
|
var initialStatusCode = _ref.statusCode;
|
1217
2398
|
var routes = contexts.useRoutes();
|
1218
|
-
var _useLocation =
|
1219
|
-
_useLocation2 =
|
2399
|
+
var _useLocation = useLocation(),
|
2400
|
+
_useLocation2 = _slicedToArray(_useLocation, 1),
|
1220
2401
|
pathname = _useLocation2[0];
|
1221
2402
|
var _useState = React.useState({
|
1222
2403
|
statusCode: initialStatusCode,
|
1223
2404
|
pathname: pathname
|
1224
2405
|
}),
|
1225
|
-
_useState2 =
|
2406
|
+
_useState2 = _slicedToArray(_useState, 2),
|
1226
2407
|
_useState2$ = _useState2[0],
|
1227
2408
|
statusCode = _useState2$.statusCode,
|
1228
2409
|
lastPathname = _useState2$.pathname,
|
@@ -1259,16 +2440,16 @@ var PanneauRoutes = function PanneauRoutes(_ref) {
|
|
1259
2440
|
_ref2.create;
|
1260
2441
|
_ref2.edit;
|
1261
2442
|
_ref2["delete"];
|
1262
|
-
var otherPages =
|
2443
|
+
var otherPages = _objectWithoutProperties(_ref2, _excluded);
|
1263
2444
|
var customRoutes = React.useMemo(function () {
|
1264
|
-
return [].concat(
|
2445
|
+
return [].concat(_toConsumableArray(Object.keys(routesDefinition).filter(function (key) {
|
1265
2446
|
return key.match(/^(resources\.|auth\.)/) === null && key !== 'home' && key !== 'account';
|
1266
2447
|
}).filter(function (key) {
|
1267
2448
|
var routeDef = routesDefinition[key];
|
1268
|
-
return
|
2449
|
+
return isObject(routeDef) && typeof routeDef.component !== 'undefined' && typeof routeDef.path !== 'undefined';
|
1269
2450
|
}).map(function (key) {
|
1270
2451
|
return routesDefinition[key];
|
1271
|
-
})),
|
2452
|
+
})), _toConsumableArray(Object.keys(otherPages).map(function (key) {
|
1272
2453
|
return otherPages[key];
|
1273
2454
|
}).filter(function (_ref3) {
|
1274
2455
|
var _ref3$path = _ref3.path,
|
@@ -1285,66 +2466,66 @@ var PanneauRoutes = function PanneauRoutes(_ref) {
|
|
1285
2466
|
|
1286
2467
|
// If there is an error status code
|
1287
2468
|
if (statusCode !== null) {
|
1288
|
-
return /*#__PURE__*/
|
2469
|
+
return /*#__PURE__*/React.createElement(ErrorComponent, Object.assign({
|
1289
2470
|
statusCode: statusCode
|
1290
2471
|
}, errorPage));
|
1291
2472
|
}
|
1292
2473
|
|
1293
2474
|
// If user is unauthenticated
|
1294
2475
|
if (user === null) {
|
1295
|
-
return /*#__PURE__*/
|
2476
|
+
return /*#__PURE__*/React.createElement(Switch, null, /*#__PURE__*/React.createElement(Route, {
|
1296
2477
|
path: routes['auth.login']
|
1297
|
-
}, /*#__PURE__*/
|
2478
|
+
}, /*#__PURE__*/React.createElement(LoginComponent, loginPage)), /*#__PURE__*/React.createElement(Route, null, /*#__PURE__*/React.createElement(Redirect, {
|
1298
2479
|
to: "".concat(route('auth.login'), "?next=").concat(encodeURIComponent(pathname))
|
1299
2480
|
})));
|
1300
2481
|
}
|
1301
2482
|
|
1302
2483
|
// Normal routes
|
1303
|
-
return /*#__PURE__*/
|
2484
|
+
return /*#__PURE__*/React.createElement(Switch, null, user !== null ? /*#__PURE__*/React.createElement(Route, {
|
1304
2485
|
path: routes['auth.login']
|
1305
|
-
}, /*#__PURE__*/
|
2486
|
+
}, /*#__PURE__*/React.createElement(Redirect, {
|
1306
2487
|
to: routes.home,
|
1307
2488
|
replace: true
|
1308
2489
|
})) : null, resources.map(function (resource) {
|
1309
2490
|
var _ref4 = resource || {},
|
1310
2491
|
resourceId = _ref4.id;
|
1311
|
-
return /*#__PURE__*/
|
2492
|
+
return /*#__PURE__*/React.createElement(React.Fragment, {
|
1312
2493
|
key: "resource-".concat(resourceId)
|
1313
|
-
}, createResourceRoutes
|
2494
|
+
}, createResourceRoutes(resource, {
|
1314
2495
|
route: route,
|
1315
2496
|
componentsManager: componentsManager,
|
1316
2497
|
pages: pages
|
1317
2498
|
}));
|
1318
|
-
}), /*#__PURE__*/
|
2499
|
+
}), /*#__PURE__*/React.createElement(Route, {
|
1319
2500
|
path: routes.account
|
1320
|
-
}, /*#__PURE__*/
|
2501
|
+
}, /*#__PURE__*/React.createElement(AccountComponent, accountPage)), customRoutes.map(function (_ref5) {
|
1321
2502
|
var _ref5$path = _ref5.path,
|
1322
2503
|
path = _ref5$path === void 0 ? null : _ref5$path,
|
1323
2504
|
_ref5$route = _ref5.route,
|
1324
2505
|
pageRoute = _ref5$route === void 0 ? null : _ref5$route,
|
1325
2506
|
component = _ref5.component,
|
1326
|
-
props =
|
2507
|
+
props = _objectWithoutProperties(_ref5, _excluded2);
|
1327
2508
|
var PageComponent = componentsManager.getComponent(component);
|
1328
2509
|
var finalPath = path || routes[pageRoute];
|
1329
|
-
return PageComponent !== null ? /*#__PURE__*/
|
2510
|
+
return PageComponent !== null ? /*#__PURE__*/React.createElement(Route, {
|
1330
2511
|
key: "custom-route-".concat(finalPath),
|
1331
2512
|
path: path || routes[pageRoute]
|
1332
|
-
}, /*#__PURE__*/
|
1333
|
-
}), /*#__PURE__*/
|
2513
|
+
}, /*#__PURE__*/React.createElement(PageComponent, props)) : null;
|
2514
|
+
}), /*#__PURE__*/React.createElement(Route, {
|
1334
2515
|
path: routes.home
|
1335
|
-
}, /*#__PURE__*/
|
2516
|
+
}, /*#__PURE__*/React.createElement(HomeComponent, homePage)), /*#__PURE__*/React.createElement(Route, null, /*#__PURE__*/React.createElement(ErrorComponent, null)));
|
1336
2517
|
};
|
1337
2518
|
PanneauRoutes.propTypes = propTypes$1;
|
1338
2519
|
PanneauRoutes.defaultProps = defaultProps$1;
|
1339
2520
|
var Routes = PanneauRoutes;
|
1340
2521
|
|
1341
|
-
var pathToRegexpParser =
|
2522
|
+
var pathToRegexpParser = createPathToRegexpParser();
|
1342
2523
|
var propTypes = {
|
1343
2524
|
definition: core.PropTypes.panneauDefinition.isRequired,
|
1344
|
-
components:
|
2525
|
+
components: PropTypes.oneOfType([PropTypes.objectOf(PropTypes.elementType), PropTypes.objectOf(PropTypes.objectOf(PropTypes.elementType))]),
|
1345
2526
|
user: core.PropTypes.user,
|
1346
|
-
memoryRouter:
|
1347
|
-
baseUrl:
|
2527
|
+
memoryRouter: PropTypes.bool,
|
2528
|
+
baseUrl: PropTypes.string,
|
1348
2529
|
uppy: core.PropTypes.uppy,
|
1349
2530
|
statusCode: core.PropTypes.statusCode
|
1350
2531
|
};
|
@@ -1371,7 +2552,7 @@ var Container = function Container(_ref) {
|
|
1371
2552
|
_definition$intl2$loc2 = _definition$intl2.locales,
|
1372
2553
|
locales = _definition$intl2$loc2 === void 0 ? [] : _definition$intl2$loc2,
|
1373
2554
|
_definition$routes = definition.routes,
|
1374
|
-
routes
|
2555
|
+
routes = _definition$routes === void 0 ? {} : _definition$routes,
|
1375
2556
|
_definition$settings = definition.settings,
|
1376
2557
|
_definition$settings2 = _definition$settings === void 0 ? {} : _definition$settings,
|
1377
2558
|
_definition$settings3 = _definition$settings2.memoryRouter,
|
@@ -1384,14 +2565,14 @@ var Container = function Container(_ref) {
|
|
1384
2565
|
messages = _definition$intl4$mes === void 0 ? null : _definition$intl4$mes,
|
1385
2566
|
_definition$resources = definition.resources,
|
1386
2567
|
resources = _definition$resources === void 0 ? [] : _definition$resources;
|
1387
|
-
return
|
2568
|
+
return _objectSpread(_objectSpread({}, messages), resources.reduce(function (allMessages, _ref2) {
|
1388
2569
|
var id = _ref2.id,
|
1389
2570
|
_ref2$intl = _ref2.intl,
|
1390
2571
|
_ref2$intl2 = _ref2$intl === void 0 ? {} : _ref2$intl,
|
1391
2572
|
_ref2$intl2$messages = _ref2$intl2.messages,
|
1392
2573
|
resourceMessages = _ref2$intl2$messages === void 0 ? {} : _ref2$intl2$messages;
|
1393
|
-
return
|
1394
|
-
return
|
2574
|
+
return _objectSpread(_objectSpread({}, allMessages), Object.keys(resourceMessages).reduce(function (allResourceMessages, key) {
|
2575
|
+
return _objectSpread(_objectSpread({}, allResourceMessages), {}, _defineProperty({}, "resources.".concat(id, ".").concat(key), resourceMessages[key]));
|
1395
2576
|
}, {}));
|
1396
2577
|
}, {}));
|
1397
2578
|
}, [definition]);
|
@@ -1401,30 +2582,30 @@ var Container = function Container(_ref) {
|
|
1401
2582
|
var onLogout = React.useCallback(function () {
|
1402
2583
|
window.location.reload();
|
1403
2584
|
}, [baseUrl]);
|
1404
|
-
var _useMemoryRouter =
|
2585
|
+
var _useMemoryRouter = useMemoryRouter(),
|
1405
2586
|
memoryLocationHook = _useMemoryRouter.hook,
|
1406
2587
|
memorySearchHook = _useMemoryRouter.searchHook;
|
1407
|
-
return /*#__PURE__*/
|
2588
|
+
return /*#__PURE__*/React.createElement(Router, {
|
1408
2589
|
hook: isMemoryRouter ? memoryLocationHook : null,
|
1409
2590
|
searchHook: isMemoryRouter ? memorySearchHook : null,
|
1410
2591
|
parser: pathToRegexpParser
|
1411
|
-
}, /*#__PURE__*/
|
2592
|
+
}, /*#__PURE__*/React.createElement(intl.IntlProvider, {
|
1412
2593
|
locale: locale,
|
1413
2594
|
locales: locales,
|
1414
2595
|
extraMessages: extraMessages
|
1415
|
-
}, /*#__PURE__*/
|
2596
|
+
}, /*#__PURE__*/React.createElement(contexts.PanneauProvider, {
|
1416
2597
|
definition: definition
|
1417
|
-
}, /*#__PURE__*/
|
1418
|
-
routes: routes
|
1419
|
-
}, /*#__PURE__*/
|
2598
|
+
}, /*#__PURE__*/React.createElement(uppy.UppyProvider, uppy$1, /*#__PURE__*/React.createElement(contexts.RoutesProvider, {
|
2599
|
+
routes: routes
|
2600
|
+
}, /*#__PURE__*/React.createElement(FieldsProvider, null, /*#__PURE__*/React.createElement(FormsProvider, null, /*#__PURE__*/React.createElement(ListsProvider, null, /*#__PURE__*/React.createElement(DisplaysProvider, null, /*#__PURE__*/React.createElement(FiltersProvider, null, /*#__PURE__*/React.createElement(contexts.ModalProvider, null, /*#__PURE__*/React.createElement(ModalsProvider, null, /*#__PURE__*/React.createElement(data.ApiProvider, {
|
1420
2601
|
baseUrl: baseUrl,
|
1421
2602
|
onUnauthorized: onUnauthorized
|
1422
|
-
}, /*#__PURE__*/
|
2603
|
+
}, /*#__PURE__*/React.createElement(auth.AuthProvider, {
|
1423
2604
|
user: user,
|
1424
2605
|
onLogout: onLogout
|
1425
|
-
}, /*#__PURE__*/
|
2606
|
+
}, /*#__PURE__*/React.createElement(contexts.ComponentsProvider, {
|
1426
2607
|
components: components
|
1427
|
-
}, /*#__PURE__*/
|
2608
|
+
}, /*#__PURE__*/React.createElement(Routes, {
|
1428
2609
|
statusCode: statusCode
|
1429
2610
|
}))))))))))))))));
|
1430
2611
|
};
|
@@ -1433,10 +2614,11 @@ Container.defaultProps = defaultProps;
|
|
1433
2614
|
var PanneauContainer = Container;
|
1434
2615
|
|
1435
2616
|
/* eslint-disable react/jsx-props-no-spreading */
|
2617
|
+
// import PropTypes from 'prop-types';
|
1436
2618
|
|
1437
2619
|
// Kept for backward compatibility with exports
|
1438
2620
|
var ResourceFilters = function ResourceFilters(props) {
|
1439
|
-
return /*#__PURE__*/
|
2621
|
+
return /*#__PURE__*/React.createElement(Filters, props);
|
1440
2622
|
};
|
1441
2623
|
var ResourceFilters$1 = ResourceFilters;
|
1442
2624
|
|
@@ -1446,4 +2628,4 @@ exports.PageHeader = PageHeader$1;
|
|
1446
2628
|
exports.ResourceFilters = ResourceFilters$1;
|
1447
2629
|
exports.ResourceForm = ResourceForm;
|
1448
2630
|
exports.ResourceItemsList = ResourceItemsList$1;
|
1449
|
-
exports
|
2631
|
+
exports.default = PanneauContainer;
|