@etsoo/react 1.5.34 → 1.5.37
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/components/HRouter.d.ts +8 -0
- package/lib/components/HRouter.js +15 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/uses/useParamsEx.d.ts +6 -0
- package/lib/uses/useParamsEx.js +12 -0
- package/package.json +8 -8
- package/src/app/ReactApp.ts +0 -1
- package/src/components/HRouter.tsx +26 -0
- package/src/index.ts +2 -0
- package/src/uses/useParamsEx.ts +14 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { HistoryRouterProps } from 'react-router-dom';
|
|
3
|
+
/**
|
|
4
|
+
* Open to use HistoryRouter of react-router-dom
|
|
5
|
+
* @param History router properties
|
|
6
|
+
* @returns Component
|
|
7
|
+
*/
|
|
8
|
+
export declare function HRouter({ basename, children, history }: HistoryRouterProps): JSX.Element;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Router } from 'react-router-dom';
|
|
3
|
+
/**
|
|
4
|
+
* Open to use HistoryRouter of react-router-dom
|
|
5
|
+
* @param History router properties
|
|
6
|
+
* @returns Component
|
|
7
|
+
*/
|
|
8
|
+
export function HRouter({ basename, children, history }) {
|
|
9
|
+
const [state, setState] = React.useState({
|
|
10
|
+
action: history.action,
|
|
11
|
+
location: history.location
|
|
12
|
+
});
|
|
13
|
+
React.useLayoutEffect(() => history.listen(setState), [history]);
|
|
14
|
+
return (React.createElement(Router, { basename: basename, children: children, location: state.location, navigationType: state.action, navigator: history }));
|
|
15
|
+
}
|
package/lib/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export * from './app/RefreshTokenRQ';
|
|
|
11
11
|
export * from './app/ServiceApp';
|
|
12
12
|
export * from './components/GridColumn';
|
|
13
13
|
export * from './components/GridLoader';
|
|
14
|
+
export * from './components/HRouter';
|
|
14
15
|
export * from './components/ListItemReact';
|
|
15
16
|
export * from './components/ScrollerGrid';
|
|
16
17
|
export * from './components/ScrollerList';
|
|
@@ -89,5 +90,6 @@ export * from './states/UserState';
|
|
|
89
90
|
export * from './uses/useCombinedRefs';
|
|
90
91
|
export * from './uses/useDelayedExecutor';
|
|
91
92
|
export * from './uses/useDimensions';
|
|
93
|
+
export * from './uses/useParamsEx';
|
|
92
94
|
export * from './uses/useTimeout';
|
|
93
95
|
export * from './uses/useWindowSize';
|
package/lib/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from './app/ServiceApp';
|
|
|
13
13
|
// components
|
|
14
14
|
export * from './components/GridColumn';
|
|
15
15
|
export * from './components/GridLoader';
|
|
16
|
+
export * from './components/HRouter';
|
|
16
17
|
export * from './components/ListItemReact';
|
|
17
18
|
export * from './components/ScrollerGrid';
|
|
18
19
|
export * from './components/ScrollerList';
|
|
@@ -95,5 +96,6 @@ export * from './states/UserState';
|
|
|
95
96
|
export * from './uses/useCombinedRefs';
|
|
96
97
|
export * from './uses/useDelayedExecutor';
|
|
97
98
|
export * from './uses/useDimensions';
|
|
99
|
+
export * from './uses/useParamsEx';
|
|
98
100
|
export * from './uses/useTimeout';
|
|
99
101
|
export * from './uses/useWindowSize';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DomUtils } from '@etsoo/shared';
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
|
+
/**
|
|
4
|
+
* Extended useParams of react-router-dom
|
|
5
|
+
* Provide exact type data
|
|
6
|
+
*/
|
|
7
|
+
export function useParamsEx(template) {
|
|
8
|
+
// Get parameters
|
|
9
|
+
const params = useParams();
|
|
10
|
+
// Return
|
|
11
|
+
return DomUtils.dataAs(params, template, false);
|
|
12
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.37",
|
|
4
4
|
"description": "TypeScript ReactJs framework",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -50,9 +50,9 @@
|
|
|
50
50
|
"@emotion/react": "^11.9.0",
|
|
51
51
|
"@emotion/style": "^0.8.0",
|
|
52
52
|
"@emotion/styled": "^11.8.1",
|
|
53
|
-
"@etsoo/appscript": "^1.2.
|
|
54
|
-
"@etsoo/notificationbase": "^1.1.
|
|
55
|
-
"@etsoo/shared": "^1.1.
|
|
53
|
+
"@etsoo/appscript": "^1.2.61",
|
|
54
|
+
"@etsoo/notificationbase": "^1.1.4",
|
|
55
|
+
"@etsoo/shared": "^1.1.40",
|
|
56
56
|
"@mui/icons-material": "^5.8.0",
|
|
57
57
|
"@mui/material": "^5.8.1",
|
|
58
58
|
"@types/pica": "^9.0.0",
|
|
@@ -76,10 +76,10 @@
|
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@babel/cli": "^7.17.10",
|
|
79
|
-
"@babel/core": "^7.18.
|
|
80
|
-
"@babel/plugin-transform-runtime": "^7.18.
|
|
81
|
-
"@babel/preset-env": "^7.18.
|
|
82
|
-
"@babel/runtime-corejs3": "^7.18.
|
|
79
|
+
"@babel/core": "^7.18.2",
|
|
80
|
+
"@babel/plugin-transform-runtime": "^7.18.2",
|
|
81
|
+
"@babel/preset-env": "^7.18.2",
|
|
82
|
+
"@babel/runtime-corejs3": "^7.18.3",
|
|
83
83
|
"@types/jest": "^27.5.1",
|
|
84
84
|
"@types/react-test-renderer": "^18.0.0",
|
|
85
85
|
"@typescript-eslint/eslint-plugin": "^5.26.0",
|
package/src/app/ReactApp.ts
CHANGED
|
@@ -35,7 +35,6 @@ import {
|
|
|
35
35
|
} from '../states/UserState';
|
|
36
36
|
import { InputDialogProps } from './InputDialogProps';
|
|
37
37
|
import { Labels } from './Labels';
|
|
38
|
-
import { ReactUtils } from './ReactUtils';
|
|
39
38
|
import { createBrowserHistory, createMemoryHistory, History } from 'history';
|
|
40
39
|
|
|
41
40
|
/**
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { HistoryRouterProps, Router } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Open to use HistoryRouter of react-router-dom
|
|
6
|
+
* @param History router properties
|
|
7
|
+
* @returns Component
|
|
8
|
+
*/
|
|
9
|
+
export function HRouter({ basename, children, history }: HistoryRouterProps) {
|
|
10
|
+
const [state, setState] = React.useState({
|
|
11
|
+
action: history.action,
|
|
12
|
+
location: history.location
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
React.useLayoutEffect(() => history.listen(setState), [history]);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<Router
|
|
19
|
+
basename={basename}
|
|
20
|
+
children={children}
|
|
21
|
+
location={state.location}
|
|
22
|
+
navigationType={state.action}
|
|
23
|
+
navigator={history}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -14,6 +14,7 @@ export * from './app/ServiceApp';
|
|
|
14
14
|
// components
|
|
15
15
|
export * from './components/GridColumn';
|
|
16
16
|
export * from './components/GridLoader';
|
|
17
|
+
export * from './components/HRouter';
|
|
17
18
|
export * from './components/ListItemReact';
|
|
18
19
|
export * from './components/ScrollerGrid';
|
|
19
20
|
export * from './components/ScrollerList';
|
|
@@ -102,5 +103,6 @@ export * from './states/UserState';
|
|
|
102
103
|
export * from './uses/useCombinedRefs';
|
|
103
104
|
export * from './uses/useDelayedExecutor';
|
|
104
105
|
export * from './uses/useDimensions';
|
|
106
|
+
export * from './uses/useParamsEx';
|
|
105
107
|
export * from './uses/useTimeout';
|
|
106
108
|
export * from './uses/useWindowSize';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DataTypes, DomUtils } from '@etsoo/shared';
|
|
2
|
+
import { useParams } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Extended useParams of react-router-dom
|
|
6
|
+
* Provide exact type data
|
|
7
|
+
*/
|
|
8
|
+
export function useParamsEx<T extends DataTypes.BasicTemplate>(template: T) {
|
|
9
|
+
// Get parameters
|
|
10
|
+
const params = useParams<{ [K in keyof T]: string }>();
|
|
11
|
+
|
|
12
|
+
// Return
|
|
13
|
+
return DomUtils.dataAs(params, template, false);
|
|
14
|
+
}
|