@mbao01/ui 0.1.30 → 0.1.32

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.
@@ -1,2 +1,2 @@
1
1
  import { type LinkProps } from "./types";
2
- export declare const Link: ({ href, hover, target, variant, children, className, underline, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
2
+ export declare const Link: ({ href, hover, target, variant, children, className, underline, isExternal, isInternal, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
@@ -2,5 +2,11 @@ import type { To, LinkProps as RouterLinkProps } from "react-router-dom";
2
2
  import { type VariantProps } from "@mbao01/common/libs";
3
3
  import { getLinkClasses } from "./constant";
4
4
  export type LinkProps = Omit<RouterLinkProps, "to"> & {
5
+ isExternal?: boolean;
6
+ } & ({
7
+ isInternal?: false;
8
+ href: string;
9
+ } | {
10
+ isInternal?: true;
5
11
  href: To;
6
- } & VariantProps<typeof getLinkClasses>;
12
+ }) & VariantProps<typeof getLinkClasses>;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@mbao01/ui",
3
3
  "private": false,
4
- "version": "0.1.30",
4
+ "version": "0.1.32",
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
7
7
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "test:coverage": "vitest run --coverage"
41
41
  },
42
42
  "dependencies": {
43
- "@mbao01/common": "^0.0.29",
43
+ "@mbao01/common": "^0.0.31",
44
44
  "@radix-ui/react-icons": "^1.3.0",
45
45
  "clsx": "^2.1.0"
46
46
  },
@@ -87,5 +87,5 @@
87
87
  "peerDependencies": {
88
88
  "react-router-dom": "^6.22.0"
89
89
  },
90
- "gitHead": "1ccc8b44c98ab629a4ec708e3ee1bee6d9e13be8"
90
+ "gitHead": "06b3dabcfcd2694bf8d0701a392f6b7f01101e7a"
91
91
  }
@@ -1,5 +1,6 @@
1
1
  import { Link as RouterLink } from "react-router-dom";
2
2
  import { ExternalLinkIcon } from "@radix-ui/react-icons";
3
+ import { Anchor } from "@mbao01/common";
3
4
  import { cn } from "@mbao01/common/utilities";
4
5
  import { type LinkProps } from "./types";
5
6
  import { getLinkClasses } from "./constant";
@@ -12,9 +13,26 @@ export const Link = ({
12
13
  children,
13
14
  className,
14
15
  underline = false,
16
+ isExternal,
17
+ isInternal = true,
15
18
  ...props
16
19
  }: LinkProps) => {
17
- const isExternal = target === "_blank";
20
+ if (!isInternal)
21
+ return (
22
+ <Anchor
23
+ href={href as string}
24
+ target={target}
25
+ hover={hover}
26
+ variant={variant}
27
+ className={className}
28
+ underline={underline}
29
+ isExternal={isExternal}
30
+ {...props}
31
+ >
32
+ {children}
33
+ </Anchor>
34
+ );
35
+
18
36
  return (
19
37
  <RouterLink
20
38
  to={href}
@@ -3,5 +3,15 @@ import { type VariantProps } from "@mbao01/common/libs";
3
3
  import { getLinkClasses } from "./constant";
4
4
 
5
5
  export type LinkProps = Omit<RouterLinkProps, "to"> & {
6
- href: To;
7
- } & VariantProps<typeof getLinkClasses>;
6
+ isExternal?: boolean;
7
+ } & (
8
+ | {
9
+ isInternal?: false;
10
+ href: string;
11
+ }
12
+ | {
13
+ isInternal?: true;
14
+ href: To;
15
+ }
16
+ ) &
17
+ VariantProps<typeof getLinkClasses>;