@panneau/app 3.0.140 → 3.0.142
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/lib/index.js +48 -29
- package/package.json +40 -40
package/lib/index.js
CHANGED
@@ -202,7 +202,7 @@ if (typeof history !== "undefined" && typeof window[patchKey] === "undefined") {
|
|
202
202
|
|
203
203
|
var _excluded$5 = ["children"],
|
204
204
|
_excluded2$1 = ["path", "nest", "match"],
|
205
|
-
_excluded3 = ["to", "href", "onClick", "asChild", "children", "replace", "state"];
|
205
|
+
_excluded3 = ["to", "href", "onClick", "asChild", "children", "className", "replace", "state"];
|
206
206
|
|
207
207
|
/*
|
208
208
|
* Transforms `path` into its relative `base` version
|
@@ -252,7 +252,11 @@ var defaultRouter = {
|
|
252
252
|
base: "",
|
253
253
|
// this option is used to override the current location during SSR
|
254
254
|
ssrPath: undefined,
|
255
|
-
ssrSearch: undefined
|
255
|
+
ssrSearch: undefined,
|
256
|
+
// customizes how `href` props are transformed for <Link />
|
257
|
+
hrefs: function hrefs(x) {
|
258
|
+
return x;
|
259
|
+
}
|
256
260
|
};
|
257
261
|
var RouterCtx = React.createContext(defaultRouter);
|
258
262
|
|
@@ -320,6 +324,7 @@ var matchRoute = function matchRoute(parser, route, path, loose) {
|
|
320
324
|
*/
|
321
325
|
|
322
326
|
var Router = function Router(_ref3) {
|
327
|
+
var _props$ssrPath$split, _props$ssrPath, _props$hrefs, _props$hook;
|
323
328
|
var children = _ref3.children,
|
324
329
|
props = _objectWithoutProperties(_ref3, _excluded$5);
|
325
330
|
// the router we will inherit from - it is the closest router in the tree,
|
@@ -330,6 +335,16 @@ var Router = function Router(_ref3) {
|
|
330
335
|
// holds to the context value: the router object
|
331
336
|
var value = parent;
|
332
337
|
|
338
|
+
// when `ssrPath` contains a `?` character, we can extract the search from it
|
339
|
+
var _ref4 = (_props$ssrPath$split = (_props$ssrPath = props.ssrPath) === null || _props$ssrPath === void 0 ? void 0 : _props$ssrPath.split("?")) !== null && _props$ssrPath$split !== void 0 ? _props$ssrPath$split : [],
|
340
|
+
_ref5 = _slicedToArray(_ref4, 2),
|
341
|
+
path = _ref5[0],
|
342
|
+
search = _ref5[1];
|
343
|
+
if (search) props.ssrSearch = search, props.ssrPath = path;
|
344
|
+
|
345
|
+
// hooks can define their own `href` formatter (e.g. for hash location)
|
346
|
+
props.hrefs = (_props$hrefs = props.hrefs) !== null && _props$hrefs !== void 0 ? _props$hrefs : (_props$hook = props.hook) === null || _props$hook === void 0 ? void 0 : _props$hook.hrefs;
|
347
|
+
|
333
348
|
// what is happening below: to avoid unnecessary rerenders in child components,
|
334
349
|
// we ensure that the router object reference is stable, unless there are any
|
335
350
|
// changes that require reload (e.g. `base` prop changes -> all components that
|
@@ -359,9 +374,9 @@ var Router = function Router(_ref3) {
|
|
359
374
|
children: children
|
360
375
|
});
|
361
376
|
};
|
362
|
-
var h_route = function h_route(
|
363
|
-
var children =
|
364
|
-
component =
|
377
|
+
var h_route = function h_route(_ref6, params) {
|
378
|
+
var children = _ref6.children,
|
379
|
+
component = _ref6.component;
|
365
380
|
// React-Router style `component` prop
|
366
381
|
if (component) return React.createElement(component, {
|
367
382
|
params: params
|
@@ -370,22 +385,22 @@ var h_route = function h_route(_ref4, params) {
|
|
370
385
|
// support render prop or plain children
|
371
386
|
return typeof children === "function" ? children(params) : children;
|
372
387
|
};
|
373
|
-
var Route = function Route(
|
374
|
-
var path =
|
375
|
-
nest =
|
376
|
-
match =
|
377
|
-
renderProps = _objectWithoutProperties(
|
388
|
+
var Route = function Route(_ref7) {
|
389
|
+
var path = _ref7.path,
|
390
|
+
nest = _ref7.nest,
|
391
|
+
match = _ref7.match,
|
392
|
+
renderProps = _objectWithoutProperties(_ref7, _excluded2$1);
|
378
393
|
var router = useRouter();
|
379
394
|
var _useLocationFromRoute = useLocationFromRouter(router),
|
380
395
|
_useLocationFromRoute2 = _slicedToArray(_useLocationFromRoute, 1),
|
381
396
|
location = _useLocationFromRoute2[0];
|
382
|
-
var
|
397
|
+
var _ref8 = // `match` is a special prop to give up control to the parent,
|
383
398
|
// it is used by the `Switch` to avoid double matching
|
384
399
|
match !== null && match !== void 0 ? match : matchRoute(router.parser, path, location, nest),
|
385
|
-
|
386
|
-
matches =
|
387
|
-
params =
|
388
|
-
base =
|
400
|
+
_ref9 = _slicedToArray(_ref8, 3),
|
401
|
+
matches = _ref9[0],
|
402
|
+
params = _ref9[1],
|
403
|
+
base = _ref9[2];
|
389
404
|
if (!matches) return null;
|
390
405
|
var children = base ? React.createElement(Router, {
|
391
406
|
base: base
|
@@ -399,13 +414,15 @@ React.forwardRef(function (props, ref) {
|
|
399
414
|
var router = useRouter();
|
400
415
|
var _useLocationFromRoute3 = useLocationFromRouter(router),
|
401
416
|
_useLocationFromRoute4 = _slicedToArray(_useLocationFromRoute3, 2),
|
417
|
+
path = _useLocationFromRoute4[0],
|
402
418
|
navigate = _useLocationFromRoute4[1];
|
403
419
|
var to = props.to,
|
404
420
|
_props$href = props.href,
|
405
421
|
_href = _props$href === void 0 ? to : _props$href,
|
406
422
|
_onClick = props.onClick,
|
407
423
|
asChild = props.asChild,
|
408
|
-
children = props.children
|
424
|
+
children = props.children,
|
425
|
+
cls = props.className;
|
409
426
|
props.replace;
|
410
427
|
props.state;
|
411
428
|
var restProps = _objectWithoutProperties(props, _excluded3);
|
@@ -413,7 +430,7 @@ React.forwardRef(function (props, ref) {
|
|
413
430
|
// ignores the navigation when clicked using right mouse button or
|
414
431
|
// by holding a special modifier key: ctrl, command, win, alt, shift
|
415
432
|
if (event.ctrlKey || event.metaKey || event.altKey || event.shiftKey || event.button !== 0) return;
|
416
|
-
_onClick
|
433
|
+
_onClick === null || _onClick === void 0 || _onClick(event);
|
417
434
|
if (!event.defaultPrevented) {
|
418
435
|
event.preventDefault();
|
419
436
|
navigate(_href, props);
|
@@ -421,26 +438,28 @@ React.forwardRef(function (props, ref) {
|
|
421
438
|
});
|
422
439
|
|
423
440
|
// handle nested routers and absolute paths
|
424
|
-
var href = _href[0] === "~" ? _href.slice(1) : router.base + _href
|
441
|
+
var href = router.hrefs(_href[0] === "~" ? _href.slice(1) : router.base + _href, router // pass router as a second argument for convinience
|
442
|
+
);
|
425
443
|
return asChild && React.isValidElement(children) ? React.cloneElement(children, {
|
426
|
-
|
427
|
-
|
444
|
+
onClick: onClick,
|
445
|
+
href: href
|
428
446
|
}) : React.createElement("a", _objectSpread(_objectSpread({}, restProps), {}, {
|
429
|
-
href: href,
|
430
447
|
onClick: onClick,
|
448
|
+
href: href,
|
449
|
+
// `className` can be a function to apply the class if this link is active
|
450
|
+
className: cls !== null && cls !== void 0 && cls.call ? cls(path === href) : cls,
|
431
451
|
children: children,
|
432
452
|
ref: ref
|
433
453
|
}));
|
434
454
|
});
|
435
455
|
var flattenChildren = function flattenChildren(children) {
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
var
|
442
|
-
|
443
|
-
location = _ref9.location;
|
456
|
+
return Array.isArray(children) ? children.flatMap(function (c) {
|
457
|
+
return flattenChildren(c && c.type === React.Fragment ? c.props.children : c);
|
458
|
+
}) : [children];
|
459
|
+
};
|
460
|
+
var Switch = function Switch(_ref10) {
|
461
|
+
var children = _ref10.children,
|
462
|
+
location = _ref10.location;
|
444
463
|
var router = useRouter();
|
445
464
|
var _useLocationFromRoute5 = useLocationFromRouter(router),
|
446
465
|
_useLocationFromRoute6 = _slicedToArray(_useLocationFromRoute5, 1),
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@panneau/app",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.142",
|
4
4
|
"description": "",
|
5
5
|
"keywords": [
|
6
6
|
"javascript"
|
@@ -68,52 +68,52 @@
|
|
68
68
|
"@fortawesome/fontawesome-svg-core": "^6.5.1",
|
69
69
|
"@fortawesome/free-solid-svg-icons": "^6.5.1",
|
70
70
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
71
|
-
"@panneau/actions": "^3.0.
|
72
|
-
"@panneau/auth": "^3.0.
|
73
|
-
"@panneau/core": "^3.0.
|
74
|
-
"@panneau/data": "^3.0.
|
75
|
-
"@panneau/displays": "^3.0.
|
76
|
-
"@panneau/element-accordion": "^3.0.
|
77
|
-
"@panneau/element-alert": "^3.0.
|
78
|
-
"@panneau/element-avatar": "^3.0.
|
79
|
-
"@panneau/element-breadcrumbs": "^3.0.
|
80
|
-
"@panneau/element-button": "^3.0.
|
81
|
-
"@panneau/element-buttons": "^3.0.
|
82
|
-
"@panneau/element-dropdown": "^3.0.
|
83
|
-
"@panneau/element-form": "^3.0.
|
84
|
-
"@panneau/element-form-group": "^3.0.
|
85
|
-
"@panneau/element-form-row": "^3.0.
|
86
|
-
"@panneau/element-icon": "^3.0.
|
87
|
-
"@panneau/element-label": "^3.0.
|
88
|
-
"@panneau/element-link": "^3.0.
|
89
|
-
"@panneau/element-loading": "^3.0.
|
90
|
-
"@panneau/element-media-card": "^3.0.
|
91
|
-
"@panneau/element-menu": "^3.0.
|
92
|
-
"@panneau/element-modal": "^3.0.
|
93
|
-
"@panneau/element-navbar": "^3.0.
|
94
|
-
"@panneau/element-pagination": "^3.0.
|
95
|
-
"@panneau/element-radios": "^3.0.
|
96
|
-
"@panneau/element-range": "^3.0.
|
97
|
-
"@panneau/fields": "^3.0.
|
98
|
-
"@panneau/filter-filters": "^3.0.
|
99
|
-
"@panneau/filters": "^3.0.
|
100
|
-
"@panneau/form-resource": "^3.0.
|
101
|
-
"@panneau/forms": "^3.0.
|
102
|
-
"@panneau/intl": "^3.0.
|
103
|
-
"@panneau/list-resource-items": "^3.0.
|
104
|
-
"@panneau/lists": "^3.0.
|
105
|
-
"@panneau/modals": "^3.0.
|
106
|
-
"@panneau/themes": "^3.0.
|
107
|
-
"@panneau/uppy": "^3.0.
|
71
|
+
"@panneau/actions": "^3.0.142",
|
72
|
+
"@panneau/auth": "^3.0.142",
|
73
|
+
"@panneau/core": "^3.0.142",
|
74
|
+
"@panneau/data": "^3.0.142",
|
75
|
+
"@panneau/displays": "^3.0.142",
|
76
|
+
"@panneau/element-accordion": "^3.0.142",
|
77
|
+
"@panneau/element-alert": "^3.0.142",
|
78
|
+
"@panneau/element-avatar": "^3.0.142",
|
79
|
+
"@panneau/element-breadcrumbs": "^3.0.142",
|
80
|
+
"@panneau/element-button": "^3.0.142",
|
81
|
+
"@panneau/element-buttons": "^3.0.142",
|
82
|
+
"@panneau/element-dropdown": "^3.0.142",
|
83
|
+
"@panneau/element-form": "^3.0.142",
|
84
|
+
"@panneau/element-form-group": "^3.0.142",
|
85
|
+
"@panneau/element-form-row": "^3.0.142",
|
86
|
+
"@panneau/element-icon": "^3.0.142",
|
87
|
+
"@panneau/element-label": "^3.0.142",
|
88
|
+
"@panneau/element-link": "^3.0.142",
|
89
|
+
"@panneau/element-loading": "^3.0.142",
|
90
|
+
"@panneau/element-media-card": "^3.0.142",
|
91
|
+
"@panneau/element-menu": "^3.0.142",
|
92
|
+
"@panneau/element-modal": "^3.0.142",
|
93
|
+
"@panneau/element-navbar": "^3.0.142",
|
94
|
+
"@panneau/element-pagination": "^3.0.142",
|
95
|
+
"@panneau/element-radios": "^3.0.142",
|
96
|
+
"@panneau/element-range": "^3.0.142",
|
97
|
+
"@panneau/fields": "^3.0.142",
|
98
|
+
"@panneau/filter-filters": "^3.0.142",
|
99
|
+
"@panneau/filters": "^3.0.142",
|
100
|
+
"@panneau/form-resource": "^3.0.142",
|
101
|
+
"@panneau/forms": "^3.0.142",
|
102
|
+
"@panneau/intl": "^3.0.142",
|
103
|
+
"@panneau/list-resource-items": "^3.0.142",
|
104
|
+
"@panneau/lists": "^3.0.142",
|
105
|
+
"@panneau/modals": "^3.0.142",
|
106
|
+
"@panneau/themes": "^3.0.142",
|
107
|
+
"@panneau/uppy": "^3.0.142",
|
108
108
|
"classnames": "^2.5.1",
|
109
109
|
"lodash": "^4.17.21",
|
110
110
|
"prop-types": "^15.7.2",
|
111
111
|
"query-string": "^9.0.0",
|
112
112
|
"react-intl": "^5.15.8||^6.0.0",
|
113
|
-
"wouter": "^3.
|
113
|
+
"wouter": "^3.1.0"
|
114
114
|
},
|
115
115
|
"publishConfig": {
|
116
116
|
"access": "public"
|
117
117
|
},
|
118
|
-
"gitHead": "
|
118
|
+
"gitHead": "293308a0e1b7175dcc56128f6dbc1416845d0b15"
|
119
119
|
}
|