@dust-tt/sparkle 0.2.190-rc → 0.2.190
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/cjs/_index.d.ts +2 -2
- package/dist/cjs/components/DropzoneOverlay.d.ts +8 -0
- package/dist/cjs/index.js +630 -9
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/stories/DropzoneOverlay.stories.d.ts +8 -0
- package/dist/esm/_index.d.ts +2 -2
- package/dist/esm/components/DropzoneOverlay.d.ts +8 -0
- package/dist/esm/index.js +630 -9
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/stories/DropzoneOverlay.stories.d.ts +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/_index.ts +2 -2
- package/src/components/{DragArea.tsx → DropzoneOverlay.tsx} +31 -12
- package/src/lottie/dragArea.ts +605 -1
- package/src/lottie/src/dragArea.json +605 -1
- package/src/stories/DropzoneOverlay.stories.tsx +36 -0
- package/dist/cjs/components/DragArea.d.ts +0 -8
- package/dist/cjs/stories/Dragndrop.stories.d.ts +0 -7
- package/dist/esm/components/DragArea.d.ts +0 -8
- package/dist/esm/stories/Dragndrop.stories.d.ts +0 -7
- package/src/stories/Dragndrop.stories.tsx +0 -20
package/package.json
CHANGED
package/src/_index.ts
CHANGED
|
@@ -103,8 +103,8 @@ export { Avatar };
|
|
|
103
103
|
import Spinner from "./components/Spinner";
|
|
104
104
|
export { Spinner };
|
|
105
105
|
|
|
106
|
-
import
|
|
107
|
-
export {
|
|
106
|
+
import DropzoneOverlay from "./components/DropzoneOverlay";
|
|
107
|
+
export { DropzoneOverlay };
|
|
108
108
|
|
|
109
109
|
import CollapseButton from "./components/CollapseButton";
|
|
110
110
|
export { CollapseButton };
|
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
import Lottie, { LottieRefCurrentProps } from "lottie-react";
|
|
2
|
-
import React, { useRef } from "react";
|
|
2
|
+
import React, { useEffect, useRef, useState } from "react";
|
|
3
3
|
|
|
4
4
|
import { ArrowUpOnSquareIcon, Icon } from "@sparkle/_index";
|
|
5
5
|
import anim from "@sparkle/lottie/dragArea";
|
|
6
6
|
|
|
7
|
-
export interface
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export interface DropzoneOverlayProps {
|
|
8
|
+
description: string;
|
|
9
|
+
isDragActive: boolean;
|
|
10
|
+
title: string;
|
|
10
11
|
visual?: React.ReactNode;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
export default function DropzoneOverlay({
|
|
15
|
+
description,
|
|
16
|
+
isDragActive,
|
|
17
|
+
title,
|
|
16
18
|
visual = (
|
|
17
19
|
<Icon visual={ArrowUpOnSquareIcon} size="lg" className="s-text-white" />
|
|
18
20
|
),
|
|
19
|
-
})
|
|
21
|
+
}: DropzoneOverlayProps) {
|
|
20
22
|
const lottieRef = useRef<LottieRefCurrentProps | null>(null);
|
|
21
23
|
|
|
24
|
+
const [isActiveDelayed, setIsActiveDelayed] = useState(false);
|
|
25
|
+
|
|
26
|
+
// This is used to delay the removal of the overlay when the user stops dragging.
|
|
27
|
+
useEffect(() => {
|
|
28
|
+
if (isDragActive) {
|
|
29
|
+
setIsActiveDelayed(true);
|
|
30
|
+
} else {
|
|
31
|
+
const timeoutId = setTimeout(() => {
|
|
32
|
+
setIsActiveDelayed(false);
|
|
33
|
+
}, 400);
|
|
34
|
+
return () => clearTimeout(timeoutId);
|
|
35
|
+
}
|
|
36
|
+
}, [isDragActive]);
|
|
37
|
+
|
|
38
|
+
if (!isActiveDelayed) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
22
42
|
return (
|
|
23
43
|
<div
|
|
24
|
-
className="s-flex s-h-full s-w-full s-flex-col s-items-center s-justify-center s-gap-0 s-bg-white/80 s-text-element-800"
|
|
44
|
+
className="s-absolute s-inset-0 s-z-50 s-flex s-h-full s-w-full s-flex-col s-items-center s-justify-center s-gap-0 s-bg-white/80 s-text-element-800"
|
|
25
45
|
onMouseLeave={() => {
|
|
26
46
|
lottieRef.current?.setDirection(-1);
|
|
47
|
+
lottieRef.current?.setSpeed(2);
|
|
27
48
|
lottieRef.current?.play();
|
|
28
49
|
}}
|
|
29
50
|
onDrop={() => {
|
|
@@ -47,6 +68,4 @@ const DragArea: React.FC<DragZoneProps> = ({
|
|
|
47
68
|
<div className="s-font-base s-text-base">{description}</div>
|
|
48
69
|
</div>
|
|
49
70
|
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export default DragArea;
|
|
71
|
+
}
|