@hilum/ui 3.6.0 → 3.6.1
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.js +10 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/dialog.tsx +33 -12
package/package.json
CHANGED
|
@@ -17,6 +17,11 @@ import { spring } from "../lib/springs";
|
|
|
17
17
|
import { useShape } from "../lib/shape-context";
|
|
18
18
|
import { SurfaceProvider, useSurface } from "../lib/surface-context";
|
|
19
19
|
import { surfaceClasses } from "../lib/surface-classes";
|
|
20
|
+
import {
|
|
21
|
+
desktopDialogContentClassName,
|
|
22
|
+
dialogSheetMotionClassName,
|
|
23
|
+
mobileDialogSheetContentClassName,
|
|
24
|
+
} from "../lib/mobile-popper-sheet";
|
|
20
25
|
import { Button } from "./button";
|
|
21
26
|
|
|
22
27
|
const DIALOG_OFFSET = 4;
|
|
@@ -75,6 +80,15 @@ const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
75
80
|
|
|
76
81
|
if (!mounted) return null;
|
|
77
82
|
|
|
83
|
+
const sizeClassName =
|
|
84
|
+
size === "sm"
|
|
85
|
+
? container
|
|
86
|
+
? "max-w-[400px]"
|
|
87
|
+
: "sm:max-w-[400px]"
|
|
88
|
+
: container
|
|
89
|
+
? "max-w-[540px]"
|
|
90
|
+
: "sm:max-w-[540px]";
|
|
91
|
+
|
|
78
92
|
return (
|
|
79
93
|
<DialogPrimitive.Portal forceMount container={container ?? undefined}>
|
|
80
94
|
<DialogPrimitive.Overlay asChild forceMount>
|
|
@@ -91,24 +105,31 @@ const DialogContent = forwardRef<HTMLDivElement, DialogContentProps>(
|
|
|
91
105
|
<DialogPrimitive.Content ref={ref} asChild forceMount {...props}>
|
|
92
106
|
<motion.div
|
|
93
107
|
className={cn(
|
|
94
|
-
container
|
|
95
|
-
|
|
108
|
+
container
|
|
109
|
+
? "absolute left-1/2 top-1/2 z-50 w-[calc(100%-2rem)]"
|
|
110
|
+
: [
|
|
111
|
+
mobileDialogSheetContentClassName,
|
|
112
|
+
desktopDialogContentClassName,
|
|
113
|
+
dialogSheetMotionClassName,
|
|
114
|
+
],
|
|
96
115
|
surfaceClasses(dialogLevel),
|
|
97
116
|
"p-6 focus:outline-none",
|
|
98
|
-
|
|
99
|
-
size === "sm" && "max-w-[400px]",
|
|
100
|
-
size === "lg" && "max-w-[540px]",
|
|
117
|
+
sizeClassName,
|
|
101
118
|
shape.container,
|
|
102
119
|
"rounded-t-2xl",
|
|
103
120
|
className,
|
|
104
121
|
)}
|
|
105
|
-
initial={{ opacity: 0, scale: 0.97, x: "-50%", y: "-50%" }}
|
|
106
|
-
animate={
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
122
|
+
initial={container ? { opacity: 0, scale: 0.97, x: "-50%", y: "-50%" } : { opacity: 0 }}
|
|
123
|
+
animate={
|
|
124
|
+
container
|
|
125
|
+
? {
|
|
126
|
+
opacity: open ? 1 : 0,
|
|
127
|
+
scale: open ? 1 : 0.97,
|
|
128
|
+
x: "-50%",
|
|
129
|
+
y: "-50%",
|
|
130
|
+
}
|
|
131
|
+
: { opacity: open ? 1 : 0 }
|
|
132
|
+
}
|
|
112
133
|
transition={open ? spring.slow : spring.slow.exit}
|
|
113
134
|
onAnimationComplete={handleExitComplete}
|
|
114
135
|
>
|