@julseb-lib/react 0.0.42 → 0.0.44

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.
@@ -91,7 +91,9 @@ export const Footer = forwardRef<HTMLDivElement, ILibFooter>(
91
91
  <FooterLinkSeparatorContainer>
92
92
  {linksSeparator === "dash"
93
93
  ? "-"
94
- : ""}
94
+ : linksSeparator === "dot"
95
+ ? "•"
96
+ : ""}
95
97
  </FooterLinkSeparatorContainer>
96
98
  )}
97
99
  </Fragment>
@@ -2,7 +2,7 @@
2
2
  /*=============================================== HeaderNavLink ===============================================*/
3
3
 
4
4
  import { isValidElement } from "react"
5
- import { NavLink } from "react-router-dom"
5
+ import { Link } from "../../"
6
6
  import type { ILibHeaderNavLink } from "./subtypes"
7
7
 
8
8
  export const HeaderNavLink = ({
@@ -12,56 +12,21 @@ export const HeaderNavLink = ({
12
12
  }: ILibHeaderNavLink) => {
13
13
  if (isValidElement(link)) return link
14
14
 
15
- if (link.to)
16
- return (
17
- <NavLink
18
- data-testid={
19
- link["data-testid"] || (testid && `${testid}.NavLink`)
20
- }
21
- className={link.className || (className && "NavLink")}
22
- id={link.id}
23
- ref={link.ref}
24
- to={link.to}
25
- end={link.end}
26
- target={link.blank ? "_blank" : undefined}
27
- rel={link.blank ? "noreferrer noopener" : undefined}
28
- >
29
- {link.text}
30
- </NavLink>
31
- )
32
-
33
- if (link.href)
34
- return (
35
- <a
36
- data-testid={
37
- link["data-testid"] || (testid && `${testid}.NavLink`)
38
- }
39
- className={link.className || (className && "NavLink")}
40
- id={link.id}
41
- ref={link.ref}
42
- href={link.href}
43
- target={link.blank ? "_blank" : undefined}
44
- rel={link.blank ? "noreferrer noopener" : undefined}
45
- >
46
- {link.text}
47
- </a>
48
- )
49
-
50
- if (link.onClick)
51
- return (
52
- <button
53
- data-testid={
54
- link["data-testid"] || (testid && `${testid}.NavButton`)
55
- }
56
- className={link.className || (className && "NavButton")}
57
- id={link.id}
58
- ref={link.ref}
59
- onClick={link.onClick}
60
- disabled={link.disabled}
61
- >
62
- {link.text}
63
- </button>
64
- )
65
-
66
- return null
15
+ return (
16
+ <Link
17
+ data-testid={link["data-testid"] || (testid && `${testid}.NavLink`)}
18
+ className={link.className || (className && "NavLink")}
19
+ id={link.id}
20
+ ref={link.ref}
21
+ end={link.end}
22
+ blank={link.blank}
23
+ to={link.to}
24
+ href={link.href}
25
+ onClick={link.onClick}
26
+ disabled={link.disabled}
27
+ isNavLink
28
+ >
29
+ {link.text}
30
+ </Link>
31
+ )
67
32
  }
@@ -0,0 +1,68 @@
1
+ /*=============================================== Link component ===============================================*/
2
+
3
+ import { forwardRef, type RefObject } from "react"
4
+ import { Link as RouterLink, NavLink } from "react-router-dom"
5
+ import type { ILibLink } from "./types"
6
+
7
+ /**
8
+ * @description Returns a Link component
9
+ * @link https://documentation-components-react.vercel.app/components/link
10
+ * @extends HTMLDivElement
11
+ * @prop data-testid?: string
12
+ * @prop ref?: ForwardedRef<HTMLDivElement>
13
+ */
14
+ export const Link = forwardRef<HTMLAnchorElement | HTMLButtonElement, ILibLink>(
15
+ (
16
+ { "data-testid": testid, isNavLink, to, href, onClick, blank, end, ...rest },
17
+ ref
18
+ ) => {
19
+ if (onClick)
20
+ return (
21
+ <button
22
+ data-testid={testid}
23
+ ref={ref as RefObject<HTMLButtonElement>}
24
+ onClick={onClick}
25
+ {...rest}
26
+ />
27
+ )
28
+
29
+ if (href)
30
+ return (
31
+ <a
32
+ data-testid={testid}
33
+ ref={ref as RefObject<HTMLAnchorElement>}
34
+ href={href}
35
+ target={blank ? "_blank" : undefined}
36
+ rel={blank ? "noreferrer noopener" : undefined}
37
+ {...rest}
38
+ />
39
+ )
40
+
41
+ if (isNavLink && to)
42
+ return (
43
+ <NavLink
44
+ data-testid={testid}
45
+ ref={ref as RefObject<HTMLAnchorElement>}
46
+ to={to}
47
+ target={blank ? "_blank" : undefined}
48
+ rel={blank ? "noreferrer noopener" : undefined}
49
+ end={end}
50
+ {...rest}
51
+ />
52
+ )
53
+
54
+ if (to)
55
+ return (
56
+ <RouterLink
57
+ data-testid={testid}
58
+ ref={ref as RefObject<HTMLAnchorElement>}
59
+ to={to}
60
+ target={blank ? "_blank" : undefined}
61
+ rel={blank ? "noreferrer noopener" : undefined}
62
+ {...rest}
63
+ />
64
+ )
65
+
66
+ return null
67
+ }
68
+ )
@@ -0,0 +1,3 @@
1
+ /*=============================================== Link exports ===============================================*/
2
+
3
+ export * from "./Link"
@@ -0,0 +1,9 @@
1
+ /*=============================================== Link types ===============================================*/
2
+
3
+ import type { LibComponentBase, LibButtonLinkBlank } from "../../types"
4
+
5
+ export type ILibLink = LibComponentBase<HTMLAnchorElement | HTMLButtonElement> &
6
+ LibButtonLinkBlank & {
7
+ isNavLink?: boolean
8
+ end?: boolean
9
+ }
package/dist/lib/index.ts CHANGED
@@ -85,6 +85,7 @@ export * from "./components/Section"
85
85
  export * from "./components/Grid"
86
86
  export * from "./components/Flexbox"
87
87
  export * from "./components/Icon"
88
+ export * from "./components/Link"
88
89
  export * from "./components/Key"
89
90
  export * from "./components/TextIcon"
90
91
  export * from "./components/Highlight"
@@ -78,4 +78,5 @@ export * from "../components/DragList/types"
78
78
  export * from "../components/Fieldset/types"
79
79
  export * from "../components/Datepicker/types"
80
80
  export * from "../components/Timepicker/types"
81
+ export * from "../components/Link/types"
81
82
  // prependHere
@@ -260,7 +260,7 @@ export const typeValues = {
260
260
 
261
261
  footerDirections: { horizontal: "horizontal", vertical: "vertical" },
262
262
 
263
- footerSeparators: { dot: "dot", dash: "dash" },
263
+ footerSeparators: { dot: "dot", dash: "dash", none: "none" },
264
264
 
265
265
  buttonGroupToggleSelects: { single: "single", multi: "multi" },
266
266
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@julseb-lib/react",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "scripts": {