@etsoo/react 1.5.39 → 1.5.40
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/mu/RLink.d.ts +1 -6
- package/lib/mu/RLink.js +13 -2
- package/package.json +1 -1
- package/src/mu/RLink.tsx +18 -11
package/lib/mu/RLink.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { LinkProps } from '@mui/material';
|
|
3
|
-
import { LinkProps as RouterLinkProps } from 'react-router-dom';
|
|
4
|
-
/**
|
|
5
|
-
* Router Link props
|
|
6
|
-
*/
|
|
7
|
-
export declare type RLinkProps = LinkProps & RouterLinkProps;
|
|
8
3
|
/**
|
|
9
4
|
* Router Link
|
|
10
5
|
* @param props Props
|
|
11
6
|
* @returns Component
|
|
12
7
|
*/
|
|
13
|
-
export declare function RLink(props:
|
|
8
|
+
export declare function RLink(props: LinkProps): JSX.Element;
|
package/lib/mu/RLink.js
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { Link } from '@mui/material';
|
|
2
|
-
import { Link as RouterLink } from 'react-router-dom';
|
|
3
2
|
import React from 'react';
|
|
3
|
+
import { globalApp } from '../app/ReactApp';
|
|
4
4
|
/**
|
|
5
5
|
* Router Link
|
|
6
6
|
* @param props Props
|
|
7
7
|
* @returns Component
|
|
8
8
|
*/
|
|
9
9
|
export function RLink(props) {
|
|
10
|
-
|
|
10
|
+
// Destruct
|
|
11
|
+
const { href, onClick, ...rest } = props;
|
|
12
|
+
// Click handler
|
|
13
|
+
const onClickLocl = (event) => {
|
|
14
|
+
if (onClick)
|
|
15
|
+
onClick(event);
|
|
16
|
+
if (href && globalApp) {
|
|
17
|
+
globalApp.history.push(href);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
// Component
|
|
21
|
+
return React.createElement(Link, { ...rest, onClick: onClickLocl });
|
|
11
22
|
}
|
package/package.json
CHANGED
package/src/mu/RLink.tsx
CHANGED
|
@@ -1,20 +1,27 @@
|
|
|
1
1
|
import { Link, LinkProps } from '@mui/material';
|
|
2
|
-
import {
|
|
3
|
-
Link as RouterLink,
|
|
4
|
-
LinkProps as RouterLinkProps
|
|
5
|
-
} from 'react-router-dom';
|
|
6
2
|
import React from 'react';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Router Link props
|
|
10
|
-
*/
|
|
11
|
-
export type RLinkProps = LinkProps & RouterLinkProps;
|
|
3
|
+
import { globalApp } from '../app/ReactApp';
|
|
12
4
|
|
|
13
5
|
/**
|
|
14
6
|
* Router Link
|
|
15
7
|
* @param props Props
|
|
16
8
|
* @returns Component
|
|
17
9
|
*/
|
|
18
|
-
export function RLink(props:
|
|
19
|
-
|
|
10
|
+
export function RLink(props: LinkProps) {
|
|
11
|
+
// Destruct
|
|
12
|
+
const { href, onClick, ...rest } = props;
|
|
13
|
+
|
|
14
|
+
// Click handler
|
|
15
|
+
const onClickLocl = (
|
|
16
|
+
event: React.MouseEvent<HTMLAnchorElement, MouseEvent>
|
|
17
|
+
) => {
|
|
18
|
+
if (onClick) onClick(event);
|
|
19
|
+
|
|
20
|
+
if (href && globalApp) {
|
|
21
|
+
globalApp.history.push(href);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// Component
|
|
26
|
+
return <Link {...rest} onClick={onClickLocl} />;
|
|
20
27
|
}
|