@redhat-cloud-services/frontend-components-utilities 3.3.12 → 3.3.14
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/RouterParams/RouterParams.d.ts +7 -23
- package/RouterParams/RouterParams.js +21 -76
- package/RouterParams/RouterParams.js.map +1 -1
- package/RouterParams/index.d.ts +2 -2
- package/RouterParams/index.js.map +1 -1
- package/esm/RouterParams/RouterParams.js +23 -75
- package/esm/RouterParams/RouterParams.js.map +1 -1
- package/esm/RouterParams/index.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
}, unknown>>, import("react-redux").Omit<import("react-redux").Matching<{
|
|
10
|
-
routerData: any;
|
|
11
|
-
} & {
|
|
12
|
-
onPathChange: (data: any) => {
|
|
13
|
-
type: string;
|
|
14
|
-
payload: any;
|
|
15
|
-
};
|
|
16
|
-
}, unknown>, never> | import("react-redux").Omit<import("react").ClassAttributes<import("react").Component<any, any, any>> & import("react-redux").Matching<{
|
|
17
|
-
routerData: any;
|
|
18
|
-
} & {
|
|
19
|
-
onPathChange: (data: any) => {
|
|
20
|
-
type: string;
|
|
21
|
-
payload: any;
|
|
22
|
-
};
|
|
23
|
-
}, unknown>, never>>>;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare type RouterParamsProps = {
|
|
3
|
+
[key: string]: any;
|
|
4
|
+
Component: React.ComponentType;
|
|
5
|
+
};
|
|
6
|
+
declare const _default: (Component: React.ComponentType) => (props: Record<string, any>) => JSX.Element;
|
|
7
|
+
export default _default;
|
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
2
|
var __assign = (this && this.__assign) || function () {
|
|
18
3
|
__assign = Object.assign || function(t) {
|
|
19
4
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -36,72 +21,32 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
36
21
|
}
|
|
37
22
|
return t;
|
|
38
23
|
};
|
|
39
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
-
};
|
|
42
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
25
|
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
44
|
-
var react_1 =
|
|
45
|
-
var prop_types_1 = __importDefault(require("prop-types"));
|
|
26
|
+
var react_1 = require("react");
|
|
46
27
|
var react_router_dom_1 = require("react-router-dom");
|
|
47
28
|
var react_redux_1 = require("react-redux");
|
|
48
|
-
var
|
|
49
|
-
var
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
onPathChange &&
|
|
58
|
-
onPathChange({
|
|
59
|
-
params: params,
|
|
60
|
-
path: path,
|
|
61
|
-
});
|
|
62
|
-
}
|
|
29
|
+
var RouterParams = function (props) {
|
|
30
|
+
var dispatch = (0, react_redux_1.useDispatch)();
|
|
31
|
+
var pathname = (0, react_router_dom_1.useLocation)().pathname;
|
|
32
|
+
var params = (0, react_router_dom_1.useParams)();
|
|
33
|
+
var onPathChange = function (data) {
|
|
34
|
+
return dispatch({
|
|
35
|
+
type: '@@INSIGHTS-CORE/NAVIGATION',
|
|
36
|
+
payload: data,
|
|
37
|
+
});
|
|
63
38
|
};
|
|
64
|
-
|
|
65
|
-
var _a
|
|
66
|
-
if (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
params: params,
|
|
71
|
-
path: path,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
};
|
|
76
|
-
RouterParams.prototype.render = function () {
|
|
77
|
-
var _a = this.props, onPathChange = _a.onPathChange, routerData = _a.routerData, staticContext = _a.staticContext, Component = _a.Component, props = __rest(_a, ["onPathChange", "routerData", "staticContext", "Component"]);
|
|
78
|
-
return (0, jsx_runtime_1.jsx)(Component, __assign({}, props));
|
|
79
|
-
};
|
|
80
|
-
return RouterParams;
|
|
81
|
-
}(react_1.default.Component));
|
|
82
|
-
RouterParams.propTypes = {
|
|
83
|
-
match: prop_types_1.default.shape({ params: prop_types_1.default.object, path: prop_types_1.default.string, url: prop_types_1.default.string }).isRequired,
|
|
84
|
-
onPathChange: prop_types_1.default.func,
|
|
85
|
-
location: prop_types_1.default.shape({ pathname: prop_types_1.default.string.isRequired }).isRequired,
|
|
86
|
-
routerData: prop_types_1.default.shape({
|
|
87
|
-
params: prop_types_1.default.object,
|
|
88
|
-
path: prop_types_1.default.string,
|
|
89
|
-
}).isRequired,
|
|
90
|
-
staticContext: prop_types_1.default.any,
|
|
91
|
-
Component: prop_types_1.default.any,
|
|
92
|
-
};
|
|
93
|
-
var routerParams = function (Component) {
|
|
94
|
-
return (0, react_router_dom_1.withRouter)((0, react_redux_1.connect)(function (_a) {
|
|
95
|
-
var routerData = _a.routerData;
|
|
96
|
-
return ({ routerData: routerData });
|
|
97
|
-
}, function (dispatch) { return ({
|
|
98
|
-
onPathChange: function (data) {
|
|
99
|
-
return dispatch({
|
|
100
|
-
type: '@@INSIGHTS-CORE/NAVIGATION',
|
|
101
|
-
payload: data,
|
|
39
|
+
(0, react_1.useEffect)(function () {
|
|
40
|
+
var _a;
|
|
41
|
+
if ((0, react_router_dom_1.matchPath)(pathname, { path: (_a = props === null || props === void 0 ? void 0 : props.match) === null || _a === void 0 ? void 0 : _a.path, exact: true })) {
|
|
42
|
+
onPathChange({
|
|
43
|
+
params: params,
|
|
44
|
+
path: pathname,
|
|
102
45
|
});
|
|
103
|
-
}
|
|
104
|
-
}
|
|
46
|
+
}
|
|
47
|
+
}, [pathname, JSON.stringify(params)]);
|
|
48
|
+
var Component = props.Component, rest = __rest(props, ["Component"]);
|
|
49
|
+
return (0, jsx_runtime_1.jsx)(Component, __assign({}, rest));
|
|
105
50
|
};
|
|
106
|
-
exports.default =
|
|
51
|
+
exports.default = (function (Component) { return function (props) { return (0, jsx_runtime_1.jsx)(RouterParams, __assign({ Component: Component }, props)); }; });
|
|
107
52
|
//# sourceMappingURL=RouterParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterParams.js","sourceRoot":"","sources":["../src/RouterParams/RouterParams.
|
|
1
|
+
{"version":3,"file":"RouterParams.js","sourceRoot":"","sources":["../src/RouterParams/RouterParams.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAAyC;AACzC,qDAAqE;AACrE,2CAA0C;AAO1C,IAAM,YAAY,GAAG,UAAC,KAAwB;IAC5C,IAAM,QAAQ,GAAG,IAAA,yBAAW,GAAE,CAAC;IACvB,IAAA,QAAQ,GAAK,IAAA,8BAAW,GAAE,SAAlB,CAAmB;IACnC,IAAM,MAAM,GAAG,IAAA,4BAAS,GAAE,CAAC;IAE3B,IAAM,YAAY,GAAG,UAAC,IAAS;QAC7B,OAAA,QAAQ,CAAC;YACP,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE,IAAI;SACd,CAAC;IAHF,CAGE,CAAC;IAEL,IAAA,iBAAS,EAAC;;QAER,IAAI,IAAA,4BAAS,EAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,0CAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;YAClE,YAAY,CAAC;gBACX,MAAM,QAAA;gBACN,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/B,IAAA,SAAS,GAAc,KAAK,UAAnB,EAAK,IAAI,UAAK,KAAK,EAA9B,aAAsB,CAAF,CAAW;IACrC,OAAO,uBAAC,SAAS,eAAK,IAAI,EAAI,CAAC;AACjC,CAAC,CAAC;AAGF,mBAAe,UAAC,SAA8B,IAAK,OAAA,UAAC,KAA0B,IAAK,OAAA,uBAAC,YAAY,aAAC,SAAS,EAAE,SAAS,IAAM,KAAK,EAAI,EAAjD,CAAiD,EAAjF,CAAiF,EAAC"}
|
package/RouterParams/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { default } from
|
|
2
|
-
export * from
|
|
1
|
+
export { default } from './RouterParams';
|
|
2
|
+
export * from './RouterParams';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/RouterParams/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/RouterParams/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,+CAAyC;AAAhC,wHAAA,OAAO,OAAA;AAChB,iDAA+B"}
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
var __extends = (this && this.__extends) || (function () {
|
|
2
|
-
var extendStatics = function (d, b) {
|
|
3
|
-
extendStatics = Object.setPrototypeOf ||
|
|
4
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
-
return extendStatics(d, b);
|
|
7
|
-
};
|
|
8
|
-
return function (d, b) {
|
|
9
|
-
if (typeof b !== "function" && b !== null)
|
|
10
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
-
extendStatics(d, b);
|
|
12
|
-
function __() { this.constructor = d; }
|
|
13
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
-
};
|
|
15
|
-
})();
|
|
16
1
|
var __assign = (this && this.__assign) || function () {
|
|
17
2
|
__assign = Object.assign || function(t) {
|
|
18
3
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -36,67 +21,30 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
36
21
|
return t;
|
|
37
22
|
};
|
|
38
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
39
|
-
import
|
|
40
|
-
import
|
|
41
|
-
import {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
var
|
|
45
|
-
|
|
46
|
-
function
|
|
47
|
-
return
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (matchPath(location.pathname, { path: url, exact: true })) {
|
|
52
|
-
onPathChange &&
|
|
53
|
-
onPathChange({
|
|
54
|
-
params: params,
|
|
55
|
-
path: path,
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
RouterParams.prototype.componentDidUpdate = function () {
|
|
60
|
-
var _a = this.props, _b = _a.match, params = _b.params, path = _b.path, url = _b.url, onPathChange = _a.onPathChange, location = _a.location, routerData = _a.routerData;
|
|
61
|
-
if (routerData && (!isEqual(params, routerData.params) || path !== routerData.path)) {
|
|
62
|
-
if (matchPath(location.pathname, { path: url, exact: true })) {
|
|
63
|
-
onPathChange &&
|
|
64
|
-
onPathChange({
|
|
65
|
-
params: params,
|
|
66
|
-
path: path,
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
RouterParams.prototype.render = function () {
|
|
72
|
-
var _a = this.props, onPathChange = _a.onPathChange, routerData = _a.routerData, staticContext = _a.staticContext, Component = _a.Component, props = __rest(_a, ["onPathChange", "routerData", "staticContext", "Component"]);
|
|
73
|
-
return _jsx(Component, __assign({}, props));
|
|
24
|
+
import { useEffect } from 'react';
|
|
25
|
+
import { matchPath, useLocation, useParams } from 'react-router-dom';
|
|
26
|
+
import { useDispatch } from 'react-redux';
|
|
27
|
+
var RouterParams = function (props) {
|
|
28
|
+
var dispatch = useDispatch();
|
|
29
|
+
var pathname = useLocation().pathname;
|
|
30
|
+
var params = useParams();
|
|
31
|
+
var onPathChange = function (data) {
|
|
32
|
+
return dispatch({
|
|
33
|
+
type: '@@INSIGHTS-CORE/NAVIGATION',
|
|
34
|
+
payload: data,
|
|
35
|
+
});
|
|
74
36
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
routerData: PropTypes.shape({
|
|
82
|
-
params: PropTypes.object,
|
|
83
|
-
path: PropTypes.string,
|
|
84
|
-
}).isRequired,
|
|
85
|
-
staticContext: PropTypes.any,
|
|
86
|
-
Component: PropTypes.any,
|
|
87
|
-
};
|
|
88
|
-
var routerParams = function (Component) {
|
|
89
|
-
return withRouter(connect(function (_a) {
|
|
90
|
-
var routerData = _a.routerData;
|
|
91
|
-
return ({ routerData: routerData });
|
|
92
|
-
}, function (dispatch) { return ({
|
|
93
|
-
onPathChange: function (data) {
|
|
94
|
-
return dispatch({
|
|
95
|
-
type: '@@INSIGHTS-CORE/NAVIGATION',
|
|
96
|
-
payload: data,
|
|
37
|
+
useEffect(function () {
|
|
38
|
+
var _a;
|
|
39
|
+
if (matchPath(pathname, { path: (_a = props === null || props === void 0 ? void 0 : props.match) === null || _a === void 0 ? void 0 : _a.path, exact: true })) {
|
|
40
|
+
onPathChange({
|
|
41
|
+
params: params,
|
|
42
|
+
path: pathname,
|
|
97
43
|
});
|
|
98
|
-
}
|
|
99
|
-
}
|
|
44
|
+
}
|
|
45
|
+
}, [pathname, JSON.stringify(params)]);
|
|
46
|
+
var Component = props.Component, rest = __rest(props, ["Component"]);
|
|
47
|
+
return _jsx(Component, __assign({}, rest));
|
|
100
48
|
};
|
|
101
|
-
export default
|
|
49
|
+
export default (function (Component) { return function (props) { return _jsx(RouterParams, __assign({ Component: Component }, props)); }; });
|
|
102
50
|
//# sourceMappingURL=RouterParams.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterParams.js","sourceRoot":"","sources":["../../src/RouterParams/RouterParams.
|
|
1
|
+
{"version":3,"file":"RouterParams.js","sourceRoot":"","sources":["../../src/RouterParams/RouterParams.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAO1C,IAAM,YAAY,GAAG,UAAC,KAAwB;IAC5C,IAAM,QAAQ,GAAG,WAAW,EAAE,CAAC;IACvB,IAAA,QAAQ,GAAK,WAAW,EAAE,SAAlB,CAAmB;IACnC,IAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAE3B,IAAM,YAAY,GAAG,UAAC,IAAS;QAC7B,OAAA,QAAQ,CAAC;YACP,IAAI,EAAE,4BAA4B;YAClC,OAAO,EAAE,IAAI;SACd,CAAC;IAHF,CAGE,CAAC;IAEL,SAAS,CAAC;;QAER,IAAI,SAAS,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,KAAK,0CAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,EAAE;YAClE,YAAY,CAAC;gBACX,MAAM,QAAA;gBACN,IAAI,EAAE,QAAQ;aACf,CAAC,CAAC;SACJ;IACH,CAAC,EAAE,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAE/B,IAAA,SAAS,GAAc,KAAK,UAAnB,EAAK,IAAI,UAAK,KAAK,EAA9B,aAAsB,CAAF,CAAW;IACrC,OAAO,KAAC,SAAS,eAAK,IAAI,EAAI,CAAC;AACjC,CAAC,CAAC;AAGF,gBAAe,UAAC,SAA8B,IAAK,OAAA,UAAC,KAA0B,IAAK,OAAA,KAAC,YAAY,aAAC,SAAS,EAAE,SAAS,IAAM,KAAK,EAAI,EAAjD,CAAiD,EAAjF,CAAiF,EAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/RouterParams/index.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/RouterParams/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@redhat-cloud-services/frontend-components-utilities",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.14",
|
|
4
4
|
"description": "Util functions for RedHat Cloud Services project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "esm/index.js",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@patternfly/react-core": "^4.239.0",
|
|
31
31
|
"@patternfly/react-table": "^4.108.0",
|
|
32
32
|
"@redhat-cloud-services/rbac-client": "^1.0.100",
|
|
33
|
-
"react": "^16.14.0 || ^17.0.0",
|
|
34
|
-
"react-dom": "^16.14.0 || ^17.0.0",
|
|
33
|
+
"react": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
|
34
|
+
"react-dom": "^16.14.0 || ^17.0.0 || ^18.0.0",
|
|
35
35
|
"react-redux": ">=7.0.0",
|
|
36
36
|
"react-router-dom": "^5.0.0 || ^6.0.0",
|
|
37
37
|
"cypress": ">=10.0.0 < 13.0.0"
|