@julseb-lib/react 0.0.87 → 0.0.89
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 +640 -640
- package/dist/index.es.js +3890 -3345
- package/dist/index.umd.js +612 -612
- package/dist/lib/Mixins.tsx +970 -970
- 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/Image/Image.tsx +77 -73
- package/dist/lib/components/Image/ImageFunction.tsx +39 -37
- package/dist/lib/components/Main/Main.tsx +19 -19
- package/dist/lib/components/TextIcon/TextIcon.tsx +58 -58
- package/dist/lib/components/Timepicker/Timepicker.tsx +234 -235
- package/dist/lib/components/Tooltip/types.ts +15 -14
- package/dist/lib/components/Youtube/types.ts +5 -4
- package/dist/lib/index.ts +56 -55
- package/dist/lib/types/global.ts +129 -128
- package/dist/lib/types/index.ts +0 -1
- package/license.md +21 -0
- package/package.json +1 -1
- /package/dist/lib/{types/design-tokens.ts → design-tokens.ts} +0 -0
|
@@ -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
|
|
@@ -40,81 +40,85 @@ import type { ILibImage } from "./types"
|
|
|
40
40
|
* />
|
|
41
41
|
*/
|
|
42
42
|
export const Image: FC<ILibImage> = ({
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
43
|
+
"data-testid": testid,
|
|
44
|
+
ref,
|
|
45
|
+
role = "img",
|
|
46
|
+
className,
|
|
47
|
+
src,
|
|
48
|
+
alt,
|
|
49
|
+
caption,
|
|
50
|
+
width = "100%",
|
|
51
|
+
height = "auto",
|
|
52
|
+
aspectRatio,
|
|
53
|
+
borderRadius,
|
|
54
|
+
fit,
|
|
55
|
+
fallback = (
|
|
56
|
+
<Fallback
|
|
57
|
+
$aspectRatio={aspectRatio}
|
|
58
|
+
$width={width}
|
|
59
|
+
$height={height}
|
|
60
|
+
$borderRadius={borderRadius}
|
|
61
|
+
/>
|
|
62
|
+
),
|
|
63
|
+
containerStyle,
|
|
64
|
+
containerAs,
|
|
65
|
+
...rest
|
|
65
66
|
}) => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
67
|
+
const imageProps = {
|
|
68
|
+
"data-testid": testid,
|
|
69
|
+
ref,
|
|
70
|
+
role,
|
|
71
|
+
fallback,
|
|
72
|
+
caption,
|
|
73
|
+
className,
|
|
74
|
+
src,
|
|
75
|
+
alt,
|
|
76
|
+
aspectRatio,
|
|
77
|
+
width,
|
|
78
|
+
height,
|
|
79
|
+
borderRadius,
|
|
80
|
+
fit,
|
|
81
|
+
...rest,
|
|
82
|
+
}
|
|
81
83
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
84
|
+
if (caption)
|
|
85
|
+
return (
|
|
86
|
+
<ImgContainer
|
|
87
|
+
data-testid={testid}
|
|
88
|
+
className={className}
|
|
89
|
+
style={containerStyle}
|
|
90
|
+
as={containerAs}
|
|
91
|
+
role="figure"
|
|
92
|
+
$width={width}
|
|
93
|
+
$height={height}
|
|
94
|
+
$borderRadius={borderRadius}
|
|
95
|
+
>
|
|
96
|
+
<ImageFunction {...imageProps} />
|
|
94
97
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
98
|
+
<Caption
|
|
99
|
+
data-testid={testid && `${testid}.Caption`}
|
|
100
|
+
className={className && "Caption"}
|
|
101
|
+
role="contentinfo"
|
|
102
|
+
as={
|
|
103
|
+
typeof caption === "object" && caption.as
|
|
104
|
+
? caption.as
|
|
105
|
+
: "figcaption"
|
|
106
|
+
}
|
|
107
|
+
$backgroundColor={
|
|
108
|
+
typeof caption === "object" && caption.background
|
|
109
|
+
? caption?.background
|
|
110
|
+
: "black-50"
|
|
111
|
+
}
|
|
112
|
+
$textColor={
|
|
113
|
+
typeof caption === "object" && caption.textColor
|
|
114
|
+
? caption.textColor
|
|
115
|
+
: "white"
|
|
116
|
+
}
|
|
117
|
+
>
|
|
118
|
+
{typeof caption === "object" ? caption.text : caption}
|
|
119
|
+
</Caption>
|
|
120
|
+
</ImgContainer>
|
|
121
|
+
)
|
|
118
122
|
|
|
119
|
-
|
|
123
|
+
return <ImageFunction {...imageProps} />
|
|
120
124
|
}
|
|
@@ -4,42 +4,44 @@ import type { ILibImage } from "./types"
|
|
|
4
4
|
const StyledImage = lazy(() => import("./styles"))
|
|
5
5
|
|
|
6
6
|
export const ImageFunction: FC<ILibImage> = ({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
7
|
+
"data-testid": testid,
|
|
8
|
+
ref,
|
|
9
|
+
role = "img",
|
|
10
|
+
fallback,
|
|
11
|
+
caption,
|
|
12
|
+
className,
|
|
13
|
+
src,
|
|
14
|
+
alt,
|
|
15
|
+
aspectRatio,
|
|
16
|
+
width = "100%",
|
|
17
|
+
height = "auto",
|
|
18
|
+
borderRadius,
|
|
19
|
+
fit,
|
|
20
|
+
loading = "lazy",
|
|
21
|
+
imgFallback,
|
|
22
|
+
...rest
|
|
22
23
|
}) => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
return (
|
|
25
|
+
<Suspense fallback={fallback}>
|
|
26
|
+
<StyledImage
|
|
27
|
+
data-testid={!caption ? testid : testid && `${testid}.Image`}
|
|
28
|
+
className={!caption ? className : className && "Image"}
|
|
29
|
+
role={role}
|
|
30
|
+
ref={ref}
|
|
31
|
+
src={src}
|
|
32
|
+
alt={alt}
|
|
33
|
+
loading={loading}
|
|
34
|
+
data-fallback={imgFallback?.text}
|
|
35
|
+
$aspectRatio={aspectRatio}
|
|
36
|
+
$width={width}
|
|
37
|
+
$height={height}
|
|
38
|
+
$borderRadius={borderRadius}
|
|
39
|
+
$fit={fit}
|
|
40
|
+
$fallbackBackground={imgFallback?.background ?? "primary"}
|
|
41
|
+
$fallbackTextColor={imgFallback?.textColor ?? "background"}
|
|
42
|
+
$fallbackFontSize={imgFallback?.fontSize ?? "body"}
|
|
43
|
+
{...rest}
|
|
44
|
+
/>
|
|
45
|
+
</Suspense>
|
|
46
|
+
)
|
|
45
47
|
}
|
|
@@ -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
|
}
|