@syscore/ui-library 1.22.0 → 1.24.0
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/client/components/ui/dialog.tsx +12 -14
- package/client/components/ui/height-container.tsx +54 -0
- package/client/components/ui/tabs.tsx +3 -45
- package/client/components/ui/tooltip.tsx +1 -1
- package/client/global.css +15 -11
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js +43 -38
- package/package.json +1 -1
|
@@ -69,20 +69,18 @@ function DialogContent({
|
|
|
69
69
|
{children}
|
|
70
70
|
</div>
|
|
71
71
|
{showCloseButton && (
|
|
72
|
-
<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
</DialogPrimitive.Close>
|
|
85
|
-
</div>
|
|
72
|
+
<DialogPrimitive.Close
|
|
73
|
+
data-slot="dialog-close"
|
|
74
|
+
className="dialog-close"
|
|
75
|
+
>
|
|
76
|
+
<UtilityClose
|
|
77
|
+
className={cn(
|
|
78
|
+
"dialog-close-icon text-gray-400 hover:text-gray-600 transition-colors duration-200 ",
|
|
79
|
+
closeClassName,
|
|
80
|
+
)}
|
|
81
|
+
/>
|
|
82
|
+
<span className="sr-only">Close</span>
|
|
83
|
+
</DialogPrimitive.Close>
|
|
86
84
|
)}
|
|
87
85
|
</div>
|
|
88
86
|
</DialogPrimitive.Content>
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useLayoutEffect, useRef, ReactNode } from "react";
|
|
4
|
+
import { animate } from "motion/react";
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
export function HeightContainer({
|
|
8
|
+
children,
|
|
9
|
+
stateKey,
|
|
10
|
+
className,
|
|
11
|
+
}: {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
stateKey: string;
|
|
14
|
+
className?: string;
|
|
15
|
+
}) {
|
|
16
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
17
|
+
const innerRef = useRef<HTMLDivElement>(null);
|
|
18
|
+
const currentHeight = useRef(0);
|
|
19
|
+
|
|
20
|
+
useLayoutEffect(() => {
|
|
21
|
+
const container = containerRef.current;
|
|
22
|
+
const inner = innerRef.current;
|
|
23
|
+
if (!container || !inner) return;
|
|
24
|
+
|
|
25
|
+
// Set initial height without animation
|
|
26
|
+
const initialHeight = inner.offsetHeight;
|
|
27
|
+
if (currentHeight.current === 0 && initialHeight > 0) {
|
|
28
|
+
currentHeight.current = initialHeight;
|
|
29
|
+
container.style.height = `${initialHeight}px`;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Keep observing so we catch post-animation height changes
|
|
33
|
+
const ro = new ResizeObserver(() => {
|
|
34
|
+
const targetHeight = inner.offsetHeight;
|
|
35
|
+
if (targetHeight > 0 && targetHeight !== currentHeight.current) {
|
|
36
|
+
const shouldAnimate = currentHeight.current > 0;
|
|
37
|
+
currentHeight.current = targetHeight;
|
|
38
|
+
if (shouldAnimate) {
|
|
39
|
+
animate(container, { height: targetHeight }, { duration: 0.25, ease: "easeInOut" });
|
|
40
|
+
} else {
|
|
41
|
+
container.style.height = `${targetHeight}px`;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
ro.observe(inner);
|
|
46
|
+
return () => ro.disconnect();
|
|
47
|
+
}, [stateKey]);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<div ref={containerRef} className={cn("overflow-clip", className)}>
|
|
51
|
+
<div ref={innerRef}>{children}</div>
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
useMotionValue,
|
|
9
9
|
} from "motion/react";
|
|
10
10
|
import { cn } from "@/lib/utils";
|
|
11
|
+
import { HeightContainer } from "./height-container";
|
|
11
12
|
import {
|
|
12
13
|
Children,
|
|
13
14
|
cloneElement,
|
|
@@ -65,49 +66,6 @@ const contentVariants = {
|
|
|
65
66
|
exit: (dir: number) => ({ opacity: 0, x: dir * -20 }),
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
function AnimatedHeight({
|
|
69
|
-
children,
|
|
70
|
-
selectedValue,
|
|
71
|
-
}: {
|
|
72
|
-
children: ReactNode;
|
|
73
|
-
selectedValue: string;
|
|
74
|
-
}) {
|
|
75
|
-
const containerRef = useRef<HTMLDivElement>(null);
|
|
76
|
-
const innerRef = useRef<HTMLDivElement>(null);
|
|
77
|
-
const currentHeight = useRef(0);
|
|
78
|
-
|
|
79
|
-
useLayoutEffect(() => {
|
|
80
|
-
const container = containerRef.current;
|
|
81
|
-
const inner = innerRef.current;
|
|
82
|
-
if (!container || !inner) return;
|
|
83
|
-
|
|
84
|
-
const initialHeight = inner.offsetHeight;
|
|
85
|
-
if (currentHeight.current === 0) {
|
|
86
|
-
currentHeight.current = initialHeight;
|
|
87
|
-
container.style.height = `${initialHeight}px`;
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// Keep observing until the height differs from current (new content has mounted)
|
|
92
|
-
const ro = new ResizeObserver(() => {
|
|
93
|
-
const targetHeight = inner.offsetHeight;
|
|
94
|
-
if (targetHeight > 0 && targetHeight !== currentHeight.current) {
|
|
95
|
-
currentHeight.current = targetHeight;
|
|
96
|
-
ro.disconnect();
|
|
97
|
-
animate(container, { height: targetHeight }, { duration: 0.25, ease: "easeInOut" });
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
ro.observe(inner);
|
|
101
|
-
return () => ro.disconnect();
|
|
102
|
-
}, [selectedValue]);
|
|
103
|
-
|
|
104
|
-
return (
|
|
105
|
-
<div ref={containerRef} className="overflow-clip">
|
|
106
|
-
<div ref={innerRef}>{children}</div>
|
|
107
|
-
</div>
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
69
|
function Tabs({
|
|
112
70
|
children,
|
|
113
71
|
defaultValue,
|
|
@@ -156,12 +114,12 @@ function Tabs({
|
|
|
156
114
|
>
|
|
157
115
|
<div className={cn("tabs-container", className)}>
|
|
158
116
|
{nonContentChildren}
|
|
159
|
-
<
|
|
117
|
+
<HeightContainer stateKey={selectedValue}>
|
|
160
118
|
<AnimatePresence mode="wait" custom={direction}>
|
|
161
119
|
{activeContent &&
|
|
162
120
|
cloneElement(activeContent, { key: activeContent.props.value })}
|
|
163
121
|
</AnimatePresence>
|
|
164
|
-
</
|
|
122
|
+
</HeightContainer>
|
|
165
123
|
</div>
|
|
166
124
|
</TabsContext.Provider>
|
|
167
125
|
);
|
package/client/global.css
CHANGED
|
@@ -2054,7 +2054,7 @@ body {
|
|
|
2054
2054
|
.tooltip-content {
|
|
2055
2055
|
position: relative;
|
|
2056
2056
|
z-index: 50;
|
|
2057
|
-
border-radius:
|
|
2057
|
+
border-radius: 12px;
|
|
2058
2058
|
padding: 1.5rem;
|
|
2059
2059
|
padding-top: 2rem;
|
|
2060
2060
|
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
|
|
@@ -2177,6 +2177,12 @@ body {
|
|
|
2177
2177
|
top: 1rem;
|
|
2178
2178
|
right: 1rem;
|
|
2179
2179
|
cursor: pointer;
|
|
2180
|
+
color: var(--color-gray-500, #6b7280);
|
|
2181
|
+
transition: color 0.15s ease-in-out;
|
|
2182
|
+
}
|
|
2183
|
+
|
|
2184
|
+
[data-slot="tooltip-close"]:hover {
|
|
2185
|
+
color: var(--color-gray-300, #fff);
|
|
2180
2186
|
}
|
|
2181
2187
|
|
|
2182
2188
|
@media (max-width: 639px) {
|
|
@@ -2630,7 +2636,7 @@ body {
|
|
|
2630
2636
|
}
|
|
2631
2637
|
}
|
|
2632
2638
|
|
|
2633
|
-
|
|
2639
|
+
.dialog-close {
|
|
2634
2640
|
position: absolute;
|
|
2635
2641
|
top: 1rem;
|
|
2636
2642
|
right: 1rem;
|
|
@@ -2654,20 +2660,20 @@ body {
|
|
|
2654
2660
|
flex-shrink: 0;
|
|
2655
2661
|
color: var(--color-gray-400);
|
|
2656
2662
|
transition: color 0.2s ease-in-out;
|
|
2657
|
-
}
|
|
2663
|
+
}
|
|
2658
2664
|
|
|
2659
|
-
|
|
2665
|
+
.dialog-close:hover svg {
|
|
2660
2666
|
color: var(--color-gray-500);
|
|
2661
2667
|
}
|
|
2662
2668
|
|
|
2663
2669
|
.dialog-close-icon {
|
|
2664
2670
|
color: var(--color-gray-400);
|
|
2665
2671
|
transition: color 0.2s ease-in-out;
|
|
2666
|
-
}
|
|
2672
|
+
}
|
|
2667
2673
|
|
|
2668
|
-
|
|
2674
|
+
.dialog-close:hover .dialog-close-icon {
|
|
2669
2675
|
color: var(--color-gray-500);
|
|
2670
|
-
}
|
|
2676
|
+
}
|
|
2671
2677
|
|
|
2672
2678
|
.dialog-header {
|
|
2673
2679
|
display: flex;
|
|
@@ -7305,11 +7311,9 @@ body {
|
|
|
7305
7311
|
margin-bottom: 0;
|
|
7306
7312
|
}
|
|
7307
7313
|
|
|
7308
|
-
.page-header-description {
|
|
7309
|
-
/* Uses body-large utility */
|
|
7310
|
-
/* max-width: 680px; */
|
|
7314
|
+
/* .page-header-description {
|
|
7311
7315
|
padding-right: 10rem;
|
|
7312
|
-
}
|
|
7316
|
+
} */
|
|
7313
7317
|
|
|
7314
7318
|
@media (max-width: 640px) {
|
|
7315
7319
|
.page-header-description {
|