@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 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: RLinkProps): JSX.Element;
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
- return React.createElement(Link, { component: RouterLink, ...props });
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.39",
3
+ "version": "1.5.40",
4
4
  "description": "TypeScript ReactJs framework",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
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: RLinkProps) {
19
- return <Link component={RouterLink} {...props} />;
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
  }