@etsoo/react 1.5.41 → 1.5.42

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.js CHANGED
@@ -8,19 +8,22 @@ import { globalApp } from '../app/ReactApp';
8
8
  */
9
9
  export const RLink = React.forwardRef((props, ref) => {
10
10
  // Destruct
11
- const { href, onClick, ...rest } = props;
11
+ const { href, target, onClick, ...rest } = props;
12
12
  // Click handler
13
13
  const onClickLocl = (event) => {
14
14
  if (onClick)
15
15
  onClick(event);
16
- if (!event.isDefaultPrevented && href && globalApp) {
17
- // Router push
18
- globalApp.history.push(href);
16
+ if (!event.isDefaultPrevented() &&
17
+ href &&
18
+ (!target || target === '_self') && // Let browser handle "target=_blank" etc
19
+ globalApp) {
19
20
  // Cancel further processing
20
21
  event.preventDefault();
21
22
  event.stopPropagation();
23
+ // Router push
24
+ globalApp.history.push(href);
22
25
  }
23
26
  };
24
27
  // Component
25
- return React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, ref: ref });
28
+ return (React.createElement(Link, { ...rest, onClick: onClickLocl, href: href, target: target, ref: ref }));
26
29
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/react",
3
- "version": "1.5.41",
3
+ "version": "1.5.42",
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
@@ -10,7 +10,7 @@ import { globalApp } from '../app/ReactApp';
10
10
  export const RLink = React.forwardRef<HTMLAnchorElement, LinkProps>(
11
11
  (props, ref) => {
12
12
  // Destruct
13
- const { href, onClick, ...rest } = props;
13
+ const { href, target, onClick, ...rest } = props;
14
14
 
15
15
  // Click handler
16
16
  const onClickLocl = (
@@ -18,17 +18,30 @@ export const RLink = React.forwardRef<HTMLAnchorElement, LinkProps>(
18
18
  ) => {
19
19
  if (onClick) onClick(event);
20
20
 
21
- if (!event.isDefaultPrevented && href && globalApp) {
22
- // Router push
23
- globalApp.history.push(href);
24
-
21
+ if (
22
+ !event.isDefaultPrevented() &&
23
+ href &&
24
+ (!target || target === '_self') && // Let browser handle "target=_blank" etc
25
+ globalApp
26
+ ) {
25
27
  // Cancel further processing
26
28
  event.preventDefault();
27
29
  event.stopPropagation();
30
+
31
+ // Router push
32
+ globalApp.history.push(href);
28
33
  }
29
34
  };
30
35
 
31
36
  // Component
32
- return <Link {...rest} onClick={onClickLocl} href={href} ref={ref} />;
37
+ return (
38
+ <Link
39
+ {...rest}
40
+ onClick={onClickLocl}
41
+ href={href}
42
+ target={target}
43
+ ref={ref}
44
+ />
45
+ );
33
46
  }
34
47
  );