@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.
- package/dist/index.cjs.js +260 -260
- package/dist/index.es.js +687 -665
- package/dist/index.umd.js +268 -268
- package/dist/lib/components/Footer/Footer.tsx +3 -1
- package/dist/lib/components/Header/HeaderNavLink.tsx +18 -53
- package/dist/lib/components/Link/Link.tsx +68 -0
- package/dist/lib/components/Link/index.ts +3 -0
- package/dist/lib/components/Link/types.ts +9 -0
- package/dist/lib/index.ts +1 -0
- package/dist/lib/types/components-props.ts +1 -0
- package/dist/lib/types/type-values.ts +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/*=============================================== HeaderNavLink ===============================================*/
|
|
3
3
|
|
|
4
4
|
import { isValidElement } from "react"
|
|
5
|
-
import {
|
|
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
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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,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"
|
|
@@ -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
|
|