@julseb-lib/react 0.0.87 → 0.0.88
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/README.md +1 -1
- package/dist/index.cjs.js +52 -52
- package/dist/index.es.js +748 -733
- package/dist/index.umd.js +210 -210
- package/dist/lib/components/Alert/Alert.tsx +74 -72
- package/dist/lib/components/Aside/Aside.tsx +18 -18
- package/dist/lib/components/Button/Button.tsx +86 -84
- package/dist/lib/components/ButtonIcon/ButtonIcon.tsx +2 -0
- package/dist/lib/components/Grid/Grid.tsx +9 -9
- package/dist/lib/components/Header/Header.tsx +166 -164
- package/dist/lib/components/Header/HeaderBurger.tsx +40 -39
- package/dist/lib/components/Header/HeaderLogo.tsx +57 -53
- package/dist/lib/components/Header/HeaderNav.tsx +68 -59
- package/dist/lib/components/Header/subtypes.ts +52 -51
- package/dist/lib/components/Main/Main.tsx +19 -19
- package/dist/lib/components/TextIcon/TextIcon.tsx +58 -58
- package/dist/lib/components/Tooltip/types.ts +15 -14
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef, type FC, type ReactNode } from "react"
|
|
1
|
+
import { useRef, type FC, type ReactNode, type ReactElement } from "react"
|
|
2
2
|
import classNames from "classnames"
|
|
3
3
|
import { uuid } from "@julseb-lib/utils"
|
|
4
4
|
import { useMaxWidth, useClickOutside } from "../../"
|
|
@@ -9,72 +9,81 @@ import type { ILibHeaderNav } from "./subtypes"
|
|
|
9
9
|
import type { LibHeaderLink } from "../../types"
|
|
10
10
|
|
|
11
11
|
export const HeaderNav: FC<ILibHeaderNav> = ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
"data-testid": testid,
|
|
13
|
+
role = "navigation",
|
|
14
|
+
className,
|
|
15
|
+
search,
|
|
16
|
+
isOpen,
|
|
17
|
+
children,
|
|
18
|
+
links,
|
|
19
|
+
headerHeight,
|
|
20
|
+
variant,
|
|
21
|
+
navMobileVariant,
|
|
22
|
+
burgerPosition,
|
|
23
|
+
burgerRef,
|
|
24
|
+
handleClose,
|
|
25
|
+
nav,
|
|
25
26
|
}) => {
|
|
26
|
-
|
|
27
|
+
const isMobile = useMaxWidth(600)
|
|
27
28
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
29
|
+
const el = useRef<HTMLDivElement>(null as any)
|
|
30
|
+
useClickOutside(el, e => {
|
|
31
|
+
if (
|
|
32
|
+
!(
|
|
33
|
+
typeof burgerRef === "object" &&
|
|
34
|
+
burgerRef !== null &&
|
|
35
|
+
"current" in burgerRef &&
|
|
36
|
+
burgerRef.current?.contains(e.target as any)
|
|
37
|
+
)
|
|
38
|
+
) {
|
|
39
|
+
handleClose()
|
|
40
|
+
}
|
|
41
|
+
})
|
|
34
42
|
|
|
35
|
-
|
|
43
|
+
const valueArr = links ? links : (children as Array<ReactNode>)
|
|
36
44
|
|
|
37
|
-
|
|
45
|
+
const searchHeight = isMobile && !!search ? 32 : 0
|
|
38
46
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
const linksHeight = links
|
|
48
|
+
? links.length * 24 + ([...valueArr, searchHeight].length - 1) * 12
|
|
49
|
+
: 56
|
|
42
50
|
|
|
43
|
-
|
|
51
|
+
const navHeight = searchHeight + linksHeight
|
|
44
52
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
53
|
+
return (
|
|
54
|
+
<Nav
|
|
55
|
+
data-testid={testid && `${testid}.HeaderNav`}
|
|
56
|
+
ref={el}
|
|
57
|
+
className={classNames({ HeaderNav: className }, { Open: isOpen })}
|
|
58
|
+
role={role}
|
|
59
|
+
$headerHeight={headerHeight}
|
|
60
|
+
$variant={variant}
|
|
61
|
+
$burgerPosition={burgerPosition}
|
|
62
|
+
$navMobileVariant={navMobileVariant}
|
|
63
|
+
$navHeight={navHeight}
|
|
64
|
+
>
|
|
65
|
+
{isMobile && search && (
|
|
66
|
+
<HeaderSearch
|
|
67
|
+
{...search}
|
|
68
|
+
data-testid={testid}
|
|
69
|
+
className={className}
|
|
70
|
+
handleClose={handleClose}
|
|
71
|
+
/>
|
|
72
|
+
)}
|
|
64
73
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
{links &&
|
|
75
|
+
links.map(link => (
|
|
76
|
+
<HeaderNavLink
|
|
77
|
+
data-testid={testid}
|
|
78
|
+
className={className}
|
|
79
|
+
link={link as LibHeaderLink | ReactElement}
|
|
80
|
+
key={uuid()}
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
74
83
|
|
|
75
|
-
|
|
84
|
+
{children && children}
|
|
76
85
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
86
|
+
{nav && nav}
|
|
87
|
+
</Nav>
|
|
88
|
+
)
|
|
80
89
|
}
|
|
@@ -1,78 +1,79 @@
|
|
|
1
|
-
import type { FC, Ref } from "react"
|
|
1
|
+
import type { FC, ReactElement, Ref } from "react"
|
|
2
2
|
import type { LibHeaderLink, LibLink } from "../../types"
|
|
3
3
|
import type { ILibHeader } from "./types"
|
|
4
4
|
|
|
5
5
|
// ! DO NOT EXPORT THOSE TYPES, ONLY USE THEM IN THOSE COMPONENTS
|
|
6
6
|
|
|
7
7
|
export interface ILibHeaderNav
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
8
|
+
extends Pick<
|
|
9
|
+
ILibHeader,
|
|
10
|
+
| "data-testid"
|
|
11
|
+
| "className"
|
|
12
|
+
| "search"
|
|
13
|
+
| "children"
|
|
14
|
+
| "links"
|
|
15
|
+
| "variant"
|
|
16
|
+
| "navMobileVariant"
|
|
17
|
+
| "burgerPosition"
|
|
18
|
+
| "nav"
|
|
19
|
+
| "role"
|
|
20
|
+
> {
|
|
21
|
+
burgerRef: Ref<HTMLButtonElement>
|
|
22
|
+
isOpen: boolean
|
|
23
|
+
headerHeight: number
|
|
24
|
+
handleClose: () => void
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export interface ILibHeaderBurger
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
28
|
+
extends Pick<
|
|
29
|
+
ILibHeader,
|
|
30
|
+
| "data-testid"
|
|
31
|
+
| "className"
|
|
32
|
+
| "navMobileVariant"
|
|
33
|
+
| "variant"
|
|
34
|
+
| "burgerColor"
|
|
35
|
+
> {
|
|
36
|
+
isOpen: boolean
|
|
37
|
+
handleOpen: () => void
|
|
38
|
+
handleClose: () => void
|
|
39
|
+
ref?: Ref<HTMLButtonElement>
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export interface ILibHeaderLogo
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
extends Pick<
|
|
44
|
+
ILibHeader,
|
|
45
|
+
"data-testid" | "className" | "logo" | "children"
|
|
46
|
+
> {
|
|
47
|
+
isOpen: boolean
|
|
47
48
|
}
|
|
48
49
|
|
|
49
50
|
export interface ILibHeaderNavLink {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
"data-testid": string | undefined
|
|
52
|
+
className: string | undefined
|
|
53
|
+
link: LibHeaderLink | ReactElement | FC
|
|
53
54
|
}
|
|
54
55
|
|
|
55
56
|
export interface ILibHeaderSearch
|
|
56
|
-
|
|
57
|
-
|
|
57
|
+
extends Pick<ILibHeader, "data-testid" | "className" | "search"> {
|
|
58
|
+
handleClose: () => void
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
type HeaderLogoWithText = LibLink & {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
text: string
|
|
63
|
+
img?: never
|
|
64
|
+
imgOpen?: never
|
|
65
|
+
alt?: never
|
|
66
|
+
width?: never
|
|
67
|
+
height?: never
|
|
67
68
|
}
|
|
68
69
|
|
|
69
70
|
type HeaderLogoWithImg = LibLink & {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
text?: never
|
|
72
|
+
img: string
|
|
73
|
+
imgOpen?: string
|
|
74
|
+
alt?: string
|
|
75
|
+
width?: number
|
|
76
|
+
height?: number
|
|
76
77
|
}
|
|
77
78
|
|
|
78
79
|
export type LibHeaderLogo = string | HeaderLogoWithText | HeaderLogoWithImg
|
|
@@ -25,24 +25,24 @@ import type { ILibMain } from "./types"
|
|
|
25
25
|
* </Main>
|
|
26
26
|
*/
|
|
27
27
|
export const Main: FC<ILibMain> = ({
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
"data-testid": testid,
|
|
29
|
+
as,
|
|
30
|
+
ref,
|
|
31
|
+
children,
|
|
32
|
+
size = "default",
|
|
33
|
+
contentSize = "default",
|
|
34
|
+
...rest
|
|
35
35
|
}) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
36
|
+
return (
|
|
37
|
+
<StyledMain
|
|
38
|
+
data-testid={testid}
|
|
39
|
+
ref={ref}
|
|
40
|
+
as={as}
|
|
41
|
+
$size={size}
|
|
42
|
+
$contentSize={contentSize}
|
|
43
|
+
{...rest}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
</StyledMain>
|
|
47
|
+
)
|
|
48
48
|
}
|
|
@@ -36,65 +36,65 @@ import type { ILibTextIcon } from "./types"
|
|
|
36
36
|
* <TextIcon icon="star" tag="h2" color="primary">Featured</TextIcon>
|
|
37
37
|
*/
|
|
38
38
|
export const TextIcon: FC<ILibTextIcon> = ({
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
39
|
+
"data-testid": testid,
|
|
40
|
+
as,
|
|
41
|
+
ref,
|
|
42
|
+
textAs,
|
|
43
|
+
className,
|
|
44
|
+
children,
|
|
45
|
+
icon,
|
|
46
|
+
iconColor,
|
|
47
|
+
iconSize,
|
|
48
|
+
iconBaseUrl,
|
|
49
|
+
tag = "p",
|
|
50
|
+
display,
|
|
51
|
+
gap = "xs",
|
|
52
|
+
containerStyle,
|
|
53
|
+
...rest
|
|
54
54
|
}) => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
55
|
+
const textProps: Partial<Omit<ILibTextIcon, "tag" | "display">> = {
|
|
56
|
+
"data-testid": testid && `${testid}.Text`,
|
|
57
|
+
as: textAs,
|
|
58
|
+
className: "Text",
|
|
59
|
+
children,
|
|
60
|
+
...rest,
|
|
61
|
+
}
|
|
62
62
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
63
|
+
return (
|
|
64
|
+
<StyledTextIcon
|
|
65
|
+
data-testid={testid}
|
|
66
|
+
ref={ref}
|
|
67
|
+
as={as}
|
|
68
|
+
className={className}
|
|
69
|
+
style={containerStyle}
|
|
70
|
+
$gap={gap}
|
|
71
|
+
>
|
|
72
|
+
<IconContainer
|
|
73
|
+
data-testid={testid && `${testid}.IconContainer`}
|
|
74
|
+
className={className && "IconContainer"}
|
|
75
|
+
$tag={tag}
|
|
76
|
+
$display={display}
|
|
77
|
+
$iconSize={iconSize}
|
|
78
|
+
>
|
|
79
|
+
<LibIcon
|
|
80
|
+
data-testid={testid && `${testid}.IconContainer.Icon`}
|
|
81
|
+
className={className && "Icon"}
|
|
82
|
+
icon={icon}
|
|
83
|
+
size={iconSize || getIconHeight(tag, display)}
|
|
84
|
+
color={iconColor}
|
|
85
|
+
baseUrl={iconBaseUrl}
|
|
86
|
+
/>
|
|
87
|
+
</IconContainer>
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
89
|
+
{tag === "h1" ||
|
|
90
|
+
tag === "h2" ||
|
|
91
|
+
tag === "h3" ||
|
|
92
|
+
tag === "h4" ||
|
|
93
|
+
tag === "h5" ? (
|
|
94
|
+
<Text display={display} tag={tag} {...textProps} />
|
|
95
|
+
) : (
|
|
96
|
+
<Text tag={tag} {...textProps} />
|
|
97
|
+
)}
|
|
98
|
+
</StyledTextIcon>
|
|
99
|
+
)
|
|
100
100
|
}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import type { CSSProperties } from "react"
|
|
2
2
|
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
LibComponentBase,
|
|
4
|
+
LibAllColorsAndOverlays,
|
|
5
|
+
LibAllColors,
|
|
6
|
+
LibTooltipPosition,
|
|
7
|
+
LibSpacers,
|
|
8
|
+
LibTooltipTrigger,
|
|
9
|
+
ReactChildren,
|
|
9
10
|
} from "../../types"
|
|
10
11
|
|
|
11
12
|
export interface ILibTooltip extends LibComponentBase<HTMLDivElement> {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
tooltip: string | ReactChildren
|
|
14
|
+
position?: LibTooltipPosition
|
|
15
|
+
hideArrow?: boolean
|
|
16
|
+
trigger?: LibTooltipTrigger
|
|
17
|
+
backgroundColor?: LibAllColorsAndOverlays
|
|
18
|
+
textColor?: LibAllColors
|
|
19
|
+
offset?: LibSpacers
|
|
20
|
+
tooltipStyles?: CSSProperties
|
|
20
21
|
}
|