@mbao01/next 0.0.30 → 0.0.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mbao01/next",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "author": "Ayomide Bakare",
@@ -42,7 +42,7 @@
42
42
  "test:coverage": "vitest run --coverage"
43
43
  },
44
44
  "dependencies": {
45
- "@mbao01/common": "^0.0.29",
45
+ "@mbao01/common": "^0.0.31",
46
46
  "@radix-ui/react-icons": "^1.3.0",
47
47
  "clsx": "^2.1.0"
48
48
  },
@@ -93,5 +93,5 @@
93
93
  "peerDependencies": {
94
94
  "next": "^14.1.0"
95
95
  },
96
- "gitHead": "1ccc8b44c98ab629a4ec708e3ee1bee6d9e13be8"
96
+ "gitHead": "06b3dabcfcd2694bf8d0701a392f6b7f01101e7a"
97
97
  }
@@ -1,5 +1,6 @@
1
1
  import NextLink from "next/link";
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,12 +13,30 @@ export const Link = <T,>({
12
13
  children,
13
14
  className,
14
15
  underline = false,
16
+ isExternal = false,
17
+ isInternal = true,
15
18
  ...props
16
19
  }: LinkProps<T>) => {
17
- const isExternal = target === "_blank";
20
+ if (isInternal === false) {
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
+ }
36
+
18
37
  return (
19
38
  <NextLink
20
- href={href}
39
+ href={href as Omit<LinkProps<T>["href"], string>}
21
40
  target={target}
22
41
  className={cn(getLinkClasses({ hover, variant, underline }), className)}
23
42
  {...props}
@@ -1,12 +1,32 @@
1
1
  import { type UrlObject } from "url";
2
- import type { LinkRestProps } from "next/link";
2
+ import { type LinkRestProps } from "next/link";
3
3
  import { type VariantProps } from "@mbao01/common/libs";
4
4
  import { getLinkClasses } from "./constant";
5
5
 
6
- export type LinkProps<T> = LinkRestProps & {
7
- /**
8
- * The path or URL to navigate to. This is the only required prop. It can also be an object.
9
- * @see https://nextjs.org/docs/api-reference/next/link
10
- */
11
- href: __next_route_internal_types__.RouteImpl<T> | UrlObject;
12
- } & VariantProps<typeof getLinkClasses>;
6
+ // export type LinkProps<
7
+ // T,
8
+ // I = boolean,
9
+ // H = I extends true
10
+ // ? /**
11
+ // * The path or URL to navigate to. This is the only required prop. It can also be an object.
12
+ // * @see https://nextjs.org/docs/api-reference/next/link
13
+ // */
14
+ // __next_route_internal_types__.RouteImpl<T> | UrlObject
15
+ // : string,
16
+ // > = LinkRestProps & {
17
+ // href: H;
18
+ // isInternal?: I;
19
+ // isExternal?: boolean;
20
+ // } & VariantProps<typeof getLinkClasses>;
21
+
22
+ export type LinkProps<T> = LinkRestProps & { isExternal?: boolean } & (
23
+ | {
24
+ href: __next_route_internal_types__.RouteImpl<T> | UrlObject;
25
+ isInternal?: true;
26
+ }
27
+ | {
28
+ href: string;
29
+ isInternal?: false;
30
+ }
31
+ ) &
32
+ VariantProps<typeof getLinkClasses>;