@xiping/react-components 1.0.55 → 1.0.57
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/components/blur-text/BlurText.d.ts +16 -0
- package/dist/cjs/components/blur-text/BlurText.js +1 -0
- package/dist/cjs/components/blur-text/index.d.ts +2 -0
- package/dist/cjs/components/button/Button.css +1 -0
- package/dist/cjs/components/button/Button.js +1 -1
- package/dist/cjs/components/comic-text/ComicText.css +1 -0
- package/dist/cjs/components/comic-text/ComicText.js +2 -2
- package/dist/cjs/components/dock/Duck.css +1 -0
- package/dist/cjs/components/dock/Duck.d.ts +2 -4
- package/dist/cjs/components/dock/Duck.js +1 -1
- package/dist/cjs/components/flip-text/FlipText.css +1 -0
- package/dist/cjs/components/flip-text/FlipText.js +1 -1
- package/dist/cjs/components/gradient-text/index.css +1 -0
- package/dist/cjs/components/gradient-text/index.js +1 -1
- package/dist/cjs/components/hyper-text/HyperText.css +1 -0
- package/dist/cjs/components/hyper-text/index.js +1 -1
- package/dist/cjs/components/image-compare/ImageCompare.css +1 -0
- package/dist/cjs/components/image-compare/ImageCompare.d.ts +4 -2
- package/dist/cjs/components/image-compare/ImageCompare.js +1 -1
- package/dist/cjs/components/image-viewer/ImageThumbnails.css +1 -0
- package/dist/cjs/components/image-viewer/ImageThumbnails.js +1 -1
- package/dist/cjs/components/image-viewer/ImageViewer.css +1 -0
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
- package/dist/cjs/components/message/Message.css +1 -0
- package/dist/cjs/components/message/Message.js +1 -1
- package/dist/cjs/components/pointer/Pointer.css +1 -0
- package/dist/cjs/components/pointer/Pointer.js +1 -1
- package/dist/cjs/components/scratch-to-reveal/ScratchToReveal.css +1 -0
- package/dist/cjs/components/scratch-to-reveal/ScratchToReveal.js +1 -1
- package/dist/cjs/components/shimmer-button/ShimmerButton.css +1 -0
- package/dist/cjs/components/shimmer-button/ShimmerButton.js +1 -1
- package/dist/cjs/components/shiny-button/ShinyButton.css +1 -0
- package/dist/cjs/components/shiny-button/ShinyButton.js +1 -1
- package/dist/cjs/components/shiny-text/ShinyText.css +1 -0
- package/dist/cjs/components/shiny-text/ShinyText.d.ts +16 -0
- package/dist/cjs/components/shiny-text/ShinyText.js +1 -0
- package/dist/cjs/components/shiny-text/index.d.ts +2 -0
- package/dist/cjs/components/sparkles-text/SparklesText.css +1 -0
- package/dist/cjs/components/sparkles-text/SparklesText.js +1 -1
- package/dist/cjs/components/split-text/SplitText.css +1 -0
- package/dist/cjs/components/split-text/SplitText.js +1 -1
- package/dist/cjs/components/subtitle-player/CurrentMode.css +1 -0
- package/dist/cjs/components/subtitle-player/CurrentMode.d.ts +2 -0
- package/dist/cjs/components/subtitle-player/CurrentMode.js +2 -2
- package/dist/cjs/components/subtitle-player/LyricsMode.css +1 -0
- package/dist/cjs/components/subtitle-player/LyricsMode.d.ts +2 -0
- package/dist/cjs/components/subtitle-player/LyricsMode.js +2 -2
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.css +1 -0
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.d.ts +2 -0
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.js +1 -1
- package/dist/cjs/components/text-animate/TextAnimate.css +1 -0
- package/dist/cjs/components/text-animate/TextAnimate.js +2 -2
- package/dist/cjs/components/text-type/TextType.css +1 -0
- package/dist/cjs/components/text-type/TextType.js +1 -1
- package/dist/cjs/components/txt-reader/index.module.css +1 -0
- package/dist/cjs/components/txt-reader/index.module.css.js +1 -1
- package/dist/cjs/components/typing-animation/index.css +1 -0
- package/dist/cjs/components/typing-animation/index.js +1 -1
- package/dist/cjs/components/variable-proximity/index.css +1 -0
- package/dist/cjs/components/variable-proximity/index.js +1 -1
- package/dist/cjs/components/video-dialog/VideoDialog.css +1 -0
- package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.css +1 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.js +1 -1
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/llms.txt +2 -13
- package/dist/cjs/node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css +1 -0
- package/dist/es/components/blur-text/BlurText.d.ts +16 -0
- package/dist/es/components/blur-text/BlurText.js +77 -0
- package/dist/es/components/blur-text/index.d.ts +2 -0
- package/dist/es/components/button/Button.css +1 -0
- package/dist/es/components/button/Button.js +35 -46
- package/dist/es/components/comic-text/ComicText.css +1 -0
- package/dist/es/components/comic-text/ComicText.js +13 -12
- package/dist/es/components/dock/Duck.css +1 -0
- package/dist/es/components/dock/Duck.d.ts +2 -4
- package/dist/es/components/dock/Duck.js +60 -64
- package/dist/es/components/flip-text/FlipText.css +1 -0
- package/dist/es/components/flip-text/FlipText.js +8 -8
- package/dist/es/components/gradient-text/index.css +1 -0
- package/dist/es/components/gradient-text/index.js +9 -8
- package/dist/es/components/hyper-text/HyperText.css +1 -0
- package/dist/es/components/hyper-text/index.js +16 -13
- package/dist/es/components/image-compare/ImageCompare.css +1 -0
- package/dist/es/components/image-compare/ImageCompare.d.ts +4 -2
- package/dist/es/components/image-compare/ImageCompare.js +55 -48
- package/dist/es/components/image-viewer/ImageThumbnails.css +1 -0
- package/dist/es/components/image-viewer/ImageThumbnails.js +41 -42
- package/dist/es/components/image-viewer/ImageViewer.css +1 -0
- package/dist/es/components/image-viewer/ImageViewer.js +34 -35
- package/dist/es/components/message/Message.css +1 -0
- package/dist/es/components/message/Message.js +65 -54
- package/dist/es/components/pointer/Pointer.css +1 -0
- package/dist/es/components/pointer/Pointer.js +23 -25
- package/dist/es/components/scratch-to-reveal/ScratchToReveal.css +1 -0
- package/dist/es/components/scratch-to-reveal/ScratchToReveal.js +17 -16
- package/dist/es/components/shimmer-button/ShimmerButton.css +1 -0
- package/dist/es/components/shimmer-button/ShimmerButton.js +8 -8
- package/dist/es/components/shiny-button/ShinyButton.css +1 -0
- package/dist/es/components/shiny-button/ShinyButton.js +13 -13
- package/dist/es/components/shiny-text/ShinyText.css +1 -0
- package/dist/es/components/shiny-text/ShinyText.d.ts +16 -0
- package/dist/es/components/shiny-text/ShinyText.js +76 -0
- package/dist/es/components/shiny-text/index.d.ts +2 -0
- package/dist/es/components/sparkles-text/SparklesText.css +1 -0
- package/dist/es/components/sparkles-text/SparklesText.js +14 -14
- package/dist/es/components/split-text/SplitText.css +1 -0
- package/dist/es/components/split-text/SplitText.js +1 -1
- package/dist/es/components/subtitle-player/CurrentMode.css +1 -0
- package/dist/es/components/subtitle-player/CurrentMode.d.ts +2 -0
- package/dist/es/components/subtitle-player/CurrentMode.js +75 -40
- package/dist/es/components/subtitle-player/LyricsMode.css +1 -0
- package/dist/es/components/subtitle-player/LyricsMode.d.ts +2 -0
- package/dist/es/components/subtitle-player/LyricsMode.js +139 -68
- package/dist/es/components/subtitle-player/SubtitlePlayer.css +1 -0
- package/dist/es/components/subtitle-player/SubtitlePlayer.d.ts +2 -0
- package/dist/es/components/subtitle-player/SubtitlePlayer.js +63 -60
- package/dist/es/components/text-animate/TextAnimate.css +1 -0
- package/dist/es/components/text-animate/TextAnimate.js +57 -55
- package/dist/es/components/text-type/TextType.css +1 -0
- package/dist/es/components/text-type/TextType.js +24 -19
- package/dist/es/components/txt-reader/index.module.css +1 -0
- package/dist/es/components/txt-reader/index.module.css.js +1 -1
- package/dist/es/components/typing-animation/index.css +1 -0
- package/dist/es/components/typing-animation/index.js +12 -12
- package/dist/es/components/variable-proximity/index.css +1 -0
- package/dist/es/components/variable-proximity/index.js +19 -18
- package/dist/es/components/video-dialog/VideoDialog.css +1 -0
- package/dist/es/components/video-dialog/VideoDialog.js +1 -1
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.css +1 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.js +100 -93
- package/dist/es/index.d.ts +2 -1
- package/dist/es/index.js +59 -60
- package/dist/es/llms.txt +2 -13
- package/dist/es/node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css +1 -0
- package/package.json +14 -12
- package/dist/cjs/components/animated-list/AnimatedList.d.ts +0 -9
- package/dist/cjs/components/animated-list/AnimatedList.js +0 -1
- package/dist/cjs/components/animated-list/index.d.ts +0 -1
- package/dist/cjs/react-components.css +0 -1
- package/dist/cjs/utils/utils.js +0 -1
- package/dist/es/components/animated-list/AnimatedList.d.ts +0 -9
- package/dist/es/components/animated-list/AnimatedList.js +0 -44
- package/dist/es/components/animated-list/index.d.ts +0 -1
- package/dist/es/react-components.css +0 -1
- package/dist/es/utils/utils.js +0 -8
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { VariantProps } from 'class-variance-authority';
|
|
2
1
|
import { MotionProps, MotionValue } from 'motion/react';
|
|
3
2
|
import { default as React, PropsWithChildren } from 'react';
|
|
4
|
-
export interface DockProps
|
|
3
|
+
export interface DockProps {
|
|
5
4
|
className?: string;
|
|
6
5
|
iconSize?: number;
|
|
7
6
|
iconMagnification?: number;
|
|
@@ -9,7 +8,6 @@ export interface DockProps extends VariantProps<typeof dockVariants> {
|
|
|
9
8
|
direction?: "top" | "middle" | "bottom";
|
|
10
9
|
children: React.ReactNode;
|
|
11
10
|
}
|
|
12
|
-
declare const dockVariants: (props?: import('class-variance-authority/types').ClassProp) => string;
|
|
13
11
|
declare const Dock: React.ForwardRefExoticComponent<DockProps & React.RefAttributes<HTMLDivElement>>;
|
|
14
12
|
export interface DockIconProps extends Omit<MotionProps & React.HTMLAttributes<HTMLDivElement>, "children"> {
|
|
15
13
|
size?: number;
|
|
@@ -24,4 +22,4 @@ declare const DockIcon: {
|
|
|
24
22
|
({ size, magnification, distance, mouseX, className, children, ...props }: DockIconProps): import("react/jsx-runtime").JSX.Element;
|
|
25
23
|
displayName: string;
|
|
26
24
|
};
|
|
27
|
-
export { Dock, DockIcon
|
|
25
|
+
export { Dock, DockIcon };
|
|
@@ -1,84 +1,80 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
const
|
|
8
|
-
"supports-backdrop-blur:bg-white/10 supports-backdrop-blur:dark:bg-black/10 mx-auto mt-8 flex h-[58px] w-max items-center justify-center gap-2 rounded-2xl border p-2 backdrop-blur-md"
|
|
9
|
-
), C = i.forwardRef(
|
|
2
|
+
import { jsx as g } from "react/jsx-runtime";
|
|
3
|
+
import { useMotionValue as x, motion as I, useTransform as f, useSpring as A } from "motion/react";
|
|
4
|
+
import r, { useRef as C } from "react";
|
|
5
|
+
import k from "clsx";
|
|
6
|
+
import './Duck.css';/* empty css */
|
|
7
|
+
const D = 40, y = 60, E = 140, h = r.forwardRef(
|
|
10
8
|
({
|
|
11
|
-
className:
|
|
12
|
-
children:
|
|
13
|
-
iconSize: s =
|
|
14
|
-
iconMagnification:
|
|
15
|
-
iconDistance:
|
|
16
|
-
direction:
|
|
17
|
-
...
|
|
18
|
-
},
|
|
19
|
-
const
|
|
20
|
-
...
|
|
21
|
-
mouseX:
|
|
9
|
+
className: o,
|
|
10
|
+
children: c,
|
|
11
|
+
iconSize: s = D,
|
|
12
|
+
iconMagnification: m = y,
|
|
13
|
+
iconDistance: a = E,
|
|
14
|
+
direction: t = "middle",
|
|
15
|
+
...d
|
|
16
|
+
}, i) => {
|
|
17
|
+
const e = x(1 / 0), p = () => r.Children.map(c, (n) => r.isValidElement(n) && n.type === M ? r.cloneElement(n, {
|
|
18
|
+
...n.props,
|
|
19
|
+
mouseX: e,
|
|
22
20
|
size: s,
|
|
23
|
-
magnification:
|
|
24
|
-
distance:
|
|
25
|
-
}) :
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
21
|
+
magnification: m,
|
|
22
|
+
distance: a
|
|
23
|
+
}) : n);
|
|
24
|
+
return /* @__PURE__ */ g(
|
|
25
|
+
I.div,
|
|
28
26
|
{
|
|
29
|
-
ref:
|
|
30
|
-
onMouseMove: (
|
|
31
|
-
onMouseLeave: () =>
|
|
32
|
-
...
|
|
33
|
-
className: k(
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
27
|
+
ref: i,
|
|
28
|
+
onMouseMove: (n) => e.set(n.pageX),
|
|
29
|
+
onMouseLeave: () => e.set(1 / 0),
|
|
30
|
+
...d,
|
|
31
|
+
className: k(
|
|
32
|
+
"xiping-dock",
|
|
33
|
+
t === "top" && "xiping-dock--top",
|
|
34
|
+
t === "bottom" && "xiping-dock--bottom",
|
|
35
|
+
t === "middle" && "xiping-dock--middle",
|
|
36
|
+
o
|
|
37
|
+
),
|
|
38
|
+
children: p()
|
|
39
39
|
}
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
);
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
size:
|
|
46
|
-
magnification:
|
|
47
|
-
distance: s =
|
|
48
|
-
mouseX:
|
|
49
|
-
className:
|
|
50
|
-
children:
|
|
51
|
-
...
|
|
43
|
+
h.displayName = "Dock";
|
|
44
|
+
const M = ({
|
|
45
|
+
size: o = D,
|
|
46
|
+
magnification: c = y,
|
|
47
|
+
distance: s = E,
|
|
48
|
+
mouseX: m,
|
|
49
|
+
className: a,
|
|
50
|
+
children: t,
|
|
51
|
+
...d
|
|
52
52
|
}) => {
|
|
53
|
-
const
|
|
54
|
-
const l =
|
|
55
|
-
return
|
|
56
|
-
}),
|
|
57
|
-
|
|
53
|
+
const i = C(null), e = Math.max(6, o * 0.2), p = x(1 / 0), n = f(m ?? p, (T) => {
|
|
54
|
+
const l = i.current?.getBoundingClientRect() ?? { x: 0, width: 0 };
|
|
55
|
+
return T - l.x - l.width / 2;
|
|
56
|
+
}), N = f(
|
|
57
|
+
n,
|
|
58
58
|
[-s, 0, s],
|
|
59
|
-
[
|
|
60
|
-
),
|
|
59
|
+
[o, c, o]
|
|
60
|
+
), u = A(N, {
|
|
61
61
|
mass: 0.1,
|
|
62
62
|
stiffness: 150,
|
|
63
63
|
damping: 12
|
|
64
64
|
});
|
|
65
|
-
return /* @__PURE__ */
|
|
66
|
-
|
|
65
|
+
return /* @__PURE__ */ g(
|
|
66
|
+
I.div,
|
|
67
67
|
{
|
|
68
|
-
ref:
|
|
69
|
-
style: { width:
|
|
70
|
-
className: k(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
),
|
|
74
|
-
...u,
|
|
75
|
-
children: n
|
|
68
|
+
ref: i,
|
|
69
|
+
style: { width: u, height: u, padding: e },
|
|
70
|
+
className: k("xiping-dock-icon", a),
|
|
71
|
+
...d,
|
|
72
|
+
children: t
|
|
76
73
|
}
|
|
77
74
|
);
|
|
78
75
|
};
|
|
79
|
-
|
|
76
|
+
M.displayName = "DockIcon";
|
|
80
77
|
export {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
A as dockVariants
|
|
78
|
+
h as Dock,
|
|
79
|
+
M as DockIcon
|
|
84
80
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-flip-container{display:flex;justify-content:center;gap:.5rem}.xiping-flip-char{transform-origin:center;filter:drop-shadow(0 1px 1px rgb(0 0 0 / .05))}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as i } from "react/jsx-runtime";
|
|
3
3
|
import { motion as d, AnimatePresence as h } from "motion/react";
|
|
4
|
-
import
|
|
5
|
-
import x from "
|
|
6
|
-
|
|
4
|
+
import f from "react";
|
|
5
|
+
import x from "clsx";
|
|
6
|
+
import './FlipText.css';/* empty css */
|
|
7
7
|
const u = {
|
|
8
8
|
hidden: { rotateX: -90, opacity: 0 },
|
|
9
9
|
visible: { rotateX: 0, opacity: 1 }
|
|
@@ -17,18 +17,18 @@ function A({
|
|
|
17
17
|
variants: c,
|
|
18
18
|
...s
|
|
19
19
|
}) {
|
|
20
|
-
const
|
|
21
|
-
return /* @__PURE__ */ i("div", { className: "xiping-flip-container", children: /* @__PURE__ */ i(h, { mode: "wait", children:
|
|
22
|
-
|
|
20
|
+
const l = d.create(r), m = f.Children.toArray(e).join("").split("");
|
|
21
|
+
return /* @__PURE__ */ i("div", { className: "xiping-flip-container", children: /* @__PURE__ */ i(h, { mode: "wait", children: m.map((p, t) => /* @__PURE__ */ i(
|
|
22
|
+
l,
|
|
23
23
|
{
|
|
24
24
|
initial: "hidden",
|
|
25
25
|
animate: "visible",
|
|
26
26
|
exit: "hidden",
|
|
27
27
|
variants: c || u,
|
|
28
28
|
transition: { duration: n, delay: t * a },
|
|
29
|
-
className:
|
|
29
|
+
className: x("xiping-flip-char", o),
|
|
30
30
|
...s,
|
|
31
|
-
children:
|
|
31
|
+
children: p
|
|
32
32
|
},
|
|
33
33
|
t
|
|
34
34
|
)) }) });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-gradient-text{position:relative;margin:0 auto;display:flex;max-width:-moz-fit-content;max-width:fit-content;flex-direction:row;align-items:center;justify-content:center;border-radius:1.25rem;font-weight:500;-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);transition:box-shadow .5s ease-out;overflow:hidden;cursor:pointer}.xiping-gradient-text__overlay{position:absolute;inset:0;background-size:300% 100%;animation:xiping-gradient linear infinite;border-radius:inherit;z-index:0;pointer-events:none}.xiping-gradient-text__overlay:before{content:"";position:absolute;border-radius:inherit;width:calc(100% - 2px);height:calc(100% - 2px);left:50%;top:50%;transform:translate(-50%,-50%);background-color:#060010;z-index:-1}@keyframes xiping-gradient{0%{background-position:0% 50%}50%{background-position:100% 50%}to{background-position:0% 50%}}.xiping-gradient-text__content{display:inline-block;position:relative;z-index:2;background-size:300% 100%;background-clip:text;-webkit-background-clip:text;color:transparent;animation:xiping-gradient linear infinite}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsxs as f, jsx as a } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import o from "clsx";
|
|
3
|
+
import './index.css';/* empty css */
|
|
4
|
+
function x({
|
|
5
|
+
children: i,
|
|
6
|
+
className: e = "",
|
|
6
7
|
colors: n = ["#40ffaa", "#4079ff", "#40ffaa", "#4079ff", "#40ffaa"],
|
|
7
8
|
animationSpeed: r = 8,
|
|
8
9
|
showBorder: s = !1
|
|
@@ -11,12 +12,12 @@ function g({
|
|
|
11
12
|
backgroundImage: `linear-gradient(to right, ${n.join(", ")})`,
|
|
12
13
|
animationDuration: `${r}s`
|
|
13
14
|
};
|
|
14
|
-
return /* @__PURE__ */ f("div", { className:
|
|
15
|
+
return /* @__PURE__ */ f("div", { className: o("xiping-gradient-text", e), children: [
|
|
15
16
|
s && /* @__PURE__ */ a("div", { className: "xiping-gradient-text__overlay", style: t }),
|
|
16
|
-
/* @__PURE__ */ a("div", { className: "xiping-gradient-text__content", style: t, children:
|
|
17
|
+
/* @__PURE__ */ a("div", { className: "xiping-gradient-text__content", style: t, children: i })
|
|
17
18
|
] });
|
|
18
19
|
}
|
|
19
20
|
export {
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
x as GradientText,
|
|
22
|
+
x as default
|
|
22
23
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-hyper-container{overflow:hidden;padding-top:.5rem;padding-bottom:.5rem;font-size:2.25rem;line-height:2.5rem;font-weight:700}.xiping-hyper-char{font-family:ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace}.xiping-hyper-space{width:.75rem}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as p } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
3
|
+
import { motion as A, AnimatePresence as U } from "motion/react";
|
|
4
|
+
import { useState as h, useRef as M, useEffect as d } from "react";
|
|
5
|
+
import I from "clsx";
|
|
6
|
+
import './HyperText.css';/* empty css */
|
|
7
7
|
const j = Object.freeze(
|
|
8
8
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("")
|
|
9
9
|
), q = (n) => Math.floor(Math.random() * n);
|
|
@@ -18,14 +18,14 @@ function B({
|
|
|
18
18
|
characterSet: s = j,
|
|
19
19
|
...R
|
|
20
20
|
}) {
|
|
21
|
-
const b =
|
|
21
|
+
const b = A.create(E, {
|
|
22
22
|
forwardMotionProps: !0
|
|
23
|
-
}), [v, y] =
|
|
23
|
+
}), [v, y] = h(
|
|
24
24
|
() => n.split("")
|
|
25
|
-
), [i, r] =
|
|
25
|
+
), [i, r] = h(!1), a = M(0), m = M(null), D = () => {
|
|
26
26
|
F && !i && (a.current = 0, r(!0));
|
|
27
27
|
};
|
|
28
|
-
return
|
|
28
|
+
return d(() => {
|
|
29
29
|
if (!f) {
|
|
30
30
|
const t = setTimeout(() => {
|
|
31
31
|
r(!0);
|
|
@@ -41,7 +41,7 @@ function B({
|
|
|
41
41
|
{ threshold: 0.1, rootMargin: "-30% 0px -30% 0px" }
|
|
42
42
|
);
|
|
43
43
|
return m.current && e.observe(m.current), () => e.disconnect();
|
|
44
|
-
}, [o, f]),
|
|
44
|
+
}, [o, f]), d(() => {
|
|
45
45
|
if (!i) return;
|
|
46
46
|
const e = n.length, t = performance.now();
|
|
47
47
|
let c;
|
|
@@ -49,7 +49,7 @@ function B({
|
|
|
49
49
|
const N = H - t, g = Math.min(N / u, 1);
|
|
50
50
|
a.current = g * e, y(
|
|
51
51
|
(P) => P.map(
|
|
52
|
-
(T,
|
|
52
|
+
(T, x) => T === " " ? T : x <= a.current ? n[x] : s[q(s.length)]
|
|
53
53
|
)
|
|
54
54
|
), g < 1 ? c = requestAnimationFrame(l) : r(!1);
|
|
55
55
|
};
|
|
@@ -59,13 +59,16 @@ function B({
|
|
|
59
59
|
b,
|
|
60
60
|
{
|
|
61
61
|
ref: m,
|
|
62
|
-
className:
|
|
62
|
+
className: I("xiping-hyper-container", C),
|
|
63
63
|
onMouseEnter: D,
|
|
64
64
|
...R,
|
|
65
65
|
children: /* @__PURE__ */ p(U, { children: v.map((e, t) => /* @__PURE__ */ p(
|
|
66
|
-
|
|
66
|
+
A.span,
|
|
67
67
|
{
|
|
68
|
-
className:
|
|
68
|
+
className: I(
|
|
69
|
+
"xiping-hyper-char",
|
|
70
|
+
e === " " && "xiping-hyper-space"
|
|
71
|
+
),
|
|
69
72
|
children: e.toUpperCase()
|
|
70
73
|
},
|
|
71
74
|
t
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-image-compare-container{position:relative;-webkit-user-select:none;-moz-user-select:none;user-select:none;overflow:hidden;width:100%}.xiping-image-compare-label{position:absolute;top:1rem;padding:.25rem .5rem;background-color:#0009;color:#fff;font-size:.75rem;font-weight:500;border-radius:.25rem;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px);z-index:10}.xiping-image-compare-label-original{right:1rem}.xiping-image-compare-label-modified{left:1rem}.xiping-image-compare-overlay{position:absolute;inset:0;height:100%;overflow:hidden}.xiping-image-compare-divider{position:absolute;top:0;bottom:0;background-color:#ffffffe6;cursor:ew-resize;box-shadow:0 0 0 1px #0000004d,0 0 0 1px #ffffff80 inset,0 0 8px #0003}.xiping-image-compare-divider-button{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);width:2rem;height:2rem;border-radius:50%;background-color:#fffffff2;border:2px solid rgba(0,0,0,.2);box-shadow:0 0 0 1px #fffc,0 4px 12px #0000004d,0 2px 4px #0003;display:flex;align-items:center;justify-content:center;transition:box-shadow .2s ease,transform .2s ease}.xiping-image-compare-divider-button:hover{box-shadow:0 0 0 1px #ffffffe6,0 6px 16px #0006,0 3px 6px #0000004d;transform:translate(-50%,-50%) scale(1.05)}.xiping-image-compare-divider-button:active{transform:translate(-50%,-50%) scale(.95)}.xiping-image-compare-divider-icon{width:1.5rem;height:1.5rem;color:#1f2937}.xiping-image-compare-divider-theme-dark{background-color:#000000e6;box-shadow:0 0 0 1px #ffffff4d,0 0 0 1px #00000080 inset,0 0 8px #fff3}.xiping-image-compare-divider-button-theme-dark{background-color:#000000f2;border:2px solid rgba(255,255,255,.2);box-shadow:0 0 0 1px #000c,0 4px 12px #ffffff4d,0 2px 4px #fff3}.xiping-image-compare-divider-button-theme-dark:hover{box-shadow:0 0 0 1px #000000e6,0 6px 16px #fff6,0 3px 6px #ffffff4d}.xiping-image-compare-divider-theme-dark .xiping-image-compare-divider-icon{color:#f3f4f6}
|
|
@@ -4,10 +4,12 @@ interface ImageCompareProps {
|
|
|
4
4
|
modifiedImage: string;
|
|
5
5
|
/** 中间分隔线的宽度,可以是数字(px)或字符串(如 '2px', '0.5px'),默认为 1px */
|
|
6
6
|
dividerWidth?: number | string;
|
|
7
|
-
/** 原图标签文本,默认为 "
|
|
7
|
+
/** 原图标签文本,默认为 "Original" */
|
|
8
8
|
originalLabel?: string;
|
|
9
|
-
/** 处理过的图标签文本,默认为 "
|
|
9
|
+
/** 处理过的图标签文本,默认为 "Modified" */
|
|
10
10
|
modifiedLabel?: string;
|
|
11
|
+
/** 主题模式,默认为 "light"(浅色主题) */
|
|
12
|
+
theme?: "light" | "dark";
|
|
11
13
|
}
|
|
12
14
|
declare const ImageCompare: (props: ImageCompareProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
15
|
export default ImageCompare;
|
|
@@ -1,66 +1,67 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import { useState as
|
|
4
|
-
|
|
5
|
-
const
|
|
1
|
+
import { jsxs as X, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import w from "clsx";
|
|
3
|
+
import { useState as N, useRef as r, useCallback as a, useEffect as S, useMemo as b } from "react";
|
|
4
|
+
import './ImageCompare.css';/* empty css */
|
|
5
|
+
const O = (I) => {
|
|
6
6
|
const {
|
|
7
7
|
originalImage: c,
|
|
8
|
-
modifiedImage:
|
|
9
|
-
className:
|
|
8
|
+
modifiedImage: x,
|
|
9
|
+
className: $,
|
|
10
10
|
dividerWidth: l = 1,
|
|
11
|
-
originalLabel:
|
|
12
|
-
modifiedLabel:
|
|
13
|
-
|
|
11
|
+
originalLabel: P = "Original",
|
|
12
|
+
modifiedLabel: A = "Modified",
|
|
13
|
+
theme: M = "light"
|
|
14
|
+
} = I, [s, C] = N(50), [k, D] = N(16 / 9), h = r(null), d = r(!1), o = r(null), u = r(null), n = r(null), R = a((e) => {
|
|
14
15
|
if (!h.current) return;
|
|
15
|
-
(!
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
(!u.current || !d.current) && (u.current = h.current.getBoundingClientRect());
|
|
17
|
+
const i = u.current, g = (e - i.left) / i.width * 100, p = Math.min(100, Math.max(0, g));
|
|
18
|
+
C(p);
|
|
18
19
|
}, []), m = a((e) => {
|
|
19
|
-
|
|
20
|
-
|
|
20
|
+
d.current && (o.current !== null && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
|
|
21
|
+
R(e);
|
|
21
22
|
}));
|
|
22
|
-
}, [
|
|
23
|
+
}, [R]), L = a((e) => {
|
|
23
24
|
m(e.clientX);
|
|
24
|
-
}, [m]),
|
|
25
|
+
}, [m]), E = a((e) => {
|
|
25
26
|
e.touches.length > 0 && m(e.touches[0].clientX);
|
|
26
|
-
}, [m]),
|
|
27
|
-
|
|
28
|
-
const e = (f) =>
|
|
29
|
-
|
|
27
|
+
}, [m]), y = a(() => {
|
|
28
|
+
d.current = !0, u.current = null;
|
|
29
|
+
const e = (f) => L(f), i = (f) => E(f), v = () => {
|
|
30
|
+
d.current = !1, o.current !== null && (cancelAnimationFrame(o.current), o.current = null), n.current && (n.current(), n.current = null);
|
|
30
31
|
}, g = () => v(), p = () => v();
|
|
31
|
-
window.addEventListener("mousemove", e), window.addEventListener("touchmove",
|
|
32
|
-
const
|
|
33
|
-
window.removeEventListener("mousemove", e), window.removeEventListener("touchmove",
|
|
32
|
+
window.addEventListener("mousemove", e), window.addEventListener("touchmove", i, { passive: !1 }), window.addEventListener("mouseup", g), window.addEventListener("touchend", p);
|
|
33
|
+
const F = () => {
|
|
34
|
+
window.removeEventListener("mousemove", e), window.removeEventListener("touchmove", i), window.removeEventListener("mouseup", g), window.removeEventListener("touchend", p);
|
|
34
35
|
};
|
|
35
|
-
n.current =
|
|
36
|
-
}, [
|
|
37
|
-
|
|
36
|
+
n.current = F;
|
|
37
|
+
}, [L, E]);
|
|
38
|
+
S(() => () => {
|
|
38
39
|
n.current && (n.current(), n.current = null);
|
|
39
|
-
}, []),
|
|
40
|
+
}, []), S(() => {
|
|
40
41
|
const e = new Image();
|
|
41
42
|
e.onload = () => {
|
|
42
|
-
|
|
43
|
+
D(e.width / e.height);
|
|
43
44
|
}, e.src = c;
|
|
44
45
|
}, [c]);
|
|
45
|
-
const
|
|
46
|
+
const G = b(
|
|
46
47
|
() => ({
|
|
47
48
|
backgroundRepeat: "no-repeat",
|
|
48
49
|
backgroundPosition: "top left",
|
|
49
50
|
backgroundImage: `url(${c})`,
|
|
50
51
|
backgroundSize: "contain",
|
|
51
|
-
aspectRatio:
|
|
52
|
+
aspectRatio: k
|
|
52
53
|
}),
|
|
53
|
-
[c,
|
|
54
|
-
),
|
|
54
|
+
[c, k]
|
|
55
|
+
), T = b(
|
|
55
56
|
() => ({
|
|
56
57
|
width: `${s}%`,
|
|
57
|
-
backgroundImage: `url(${
|
|
58
|
+
backgroundImage: `url(${x})`,
|
|
58
59
|
backgroundRepeat: "no-repeat",
|
|
59
60
|
backgroundPosition: "top left",
|
|
60
61
|
backgroundSize: "auto 100%"
|
|
61
62
|
}),
|
|
62
|
-
[s,
|
|
63
|
-
),
|
|
63
|
+
[s, x]
|
|
64
|
+
), j = b(
|
|
64
65
|
() => ({
|
|
65
66
|
left: `${s}%`,
|
|
66
67
|
transform: "translateX(-50%)",
|
|
@@ -68,30 +69,36 @@ const q = (N) => {
|
|
|
68
69
|
}),
|
|
69
70
|
[s, l]
|
|
70
71
|
);
|
|
71
|
-
return /* @__PURE__ */
|
|
72
|
+
return /* @__PURE__ */ X(
|
|
72
73
|
"div",
|
|
73
74
|
{
|
|
74
75
|
ref: h,
|
|
75
|
-
className:
|
|
76
|
-
style:
|
|
76
|
+
className: w("xiping-image-compare-container", $),
|
|
77
|
+
style: G,
|
|
77
78
|
children: [
|
|
78
|
-
/* @__PURE__ */ t("div", { className: "xiping-image-compare-label xiping-image-compare-label-original", children:
|
|
79
|
+
/* @__PURE__ */ t("div", { className: "xiping-image-compare-label xiping-image-compare-label-original", children: P }),
|
|
79
80
|
/* @__PURE__ */ t(
|
|
80
81
|
"div",
|
|
81
82
|
{
|
|
82
83
|
className: "xiping-image-compare-overlay",
|
|
83
|
-
style:
|
|
84
|
-
children: /* @__PURE__ */ t("div", { className: "xiping-image-compare-label xiping-image-compare-label-modified", children:
|
|
84
|
+
style: T,
|
|
85
|
+
children: /* @__PURE__ */ t("div", { className: "xiping-image-compare-label xiping-image-compare-label-modified", children: A })
|
|
85
86
|
}
|
|
86
87
|
),
|
|
87
88
|
/* @__PURE__ */ t(
|
|
88
89
|
"div",
|
|
89
90
|
{
|
|
90
|
-
className:
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
91
|
+
className: w(
|
|
92
|
+
"xiping-image-compare-divider",
|
|
93
|
+
`xiping-image-compare-divider-theme-${M}`
|
|
94
|
+
),
|
|
95
|
+
style: j,
|
|
96
|
+
onMouseDown: y,
|
|
97
|
+
onTouchStart: y,
|
|
98
|
+
children: /* @__PURE__ */ t("div", { className: w(
|
|
99
|
+
"xiping-image-compare-divider-button",
|
|
100
|
+
`xiping-image-compare-divider-button-theme-${M}`
|
|
101
|
+
), children: /* @__PURE__ */ t(
|
|
95
102
|
"svg",
|
|
96
103
|
{
|
|
97
104
|
className: "xiping-image-compare-divider-icon",
|
|
@@ -116,5 +123,5 @@ const q = (N) => {
|
|
|
116
123
|
);
|
|
117
124
|
};
|
|
118
125
|
export {
|
|
119
|
-
|
|
126
|
+
O as default
|
|
120
127
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-thumbnails-wrapper{height:6rem;background-color:#00000080;flex-shrink:0;z-index:10;padding-bottom:env(safe-area-inset-bottom);padding-left:env(safe-area-inset-left);padding-right:env(safe-area-inset-right)}.xiping-thumbnails-wrapper--hidden{display:none}.xiping-thumbnails-scroll{height:6rem;width:100vw;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:none;-ms-overflow-style:none}.xiping-thumbnails-scroll::-webkit-scrollbar{display:none}.xiping-thumbnails-container{display:flex;gap:.5rem;padding:.5rem;height:6rem;min-width:-moz-max-content;min-width:max-content}.xiping-thumbnail-item{height:100%;aspect-ratio:1 / 1;flex-shrink:0;cursor:pointer;border:2px solid transparent;transition:all .2s}.xiping-thumbnail-item--active{border-color:#fff}.xiping-thumbnail-image{width:100%;height:100%;-o-object-fit:contain;object-fit:contain}
|
|
@@ -1,68 +1,67 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useScroll as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useScroll as f, motion as h, useMotionValue as b, useMotionValueEvent as x, animate as r } from "motion/react";
|
|
3
|
+
import { size as v } from "lodash-es";
|
|
4
|
+
import { useRef as I } from "react";
|
|
5
|
+
import g from "clsx";
|
|
6
|
+
import './ImageThumbnails.css';/* empty css */
|
|
7
|
+
const $ = "0%", N = "100%", u = "20%", l = "80%", a = "#0000", e = "#000";
|
|
8
|
+
function k(i) {
|
|
9
|
+
const n = b(
|
|
10
|
+
`linear-gradient(90deg, ${e}, ${e} ${$}, ${e} ${l}, ${a})`
|
|
10
11
|
);
|
|
11
|
-
return
|
|
12
|
-
|
|
12
|
+
return x(i, "change", (s) => {
|
|
13
|
+
s === 0 ? r(
|
|
13
14
|
n,
|
|
14
|
-
`linear-gradient(90deg, ${e}, ${e} ${
|
|
15
|
-
) :
|
|
15
|
+
`linear-gradient(90deg, ${e}, ${e} ${$}, ${e} ${l}, ${a})`
|
|
16
|
+
) : s === 1 ? r(
|
|
16
17
|
n,
|
|
17
|
-
`linear-gradient(90deg, ${
|
|
18
|
-
) : (
|
|
18
|
+
`linear-gradient(90deg, ${a}, ${e} ${u}, ${e} ${N}, ${e})`
|
|
19
|
+
) : (i.getPrevious() === 0 || i.getPrevious() === 1) && r(
|
|
19
20
|
n,
|
|
20
|
-
`linear-gradient(90deg, ${
|
|
21
|
+
`linear-gradient(90deg, ${a}, ${e} ${u}, ${e} ${l}, ${a})`
|
|
21
22
|
);
|
|
22
23
|
}), n;
|
|
23
24
|
}
|
|
24
|
-
const
|
|
25
|
-
images:
|
|
25
|
+
const q = ({
|
|
26
|
+
images: i,
|
|
26
27
|
currentIndex: n,
|
|
27
|
-
onImageSelect:
|
|
28
|
+
onImageSelect: s
|
|
28
29
|
}) => {
|
|
29
|
-
const
|
|
30
|
-
return /* @__PURE__ */
|
|
30
|
+
const o = I(null), { scrollXProgress: p } = f({ container: o }), d = k(p);
|
|
31
|
+
return /* @__PURE__ */ t(
|
|
31
32
|
"div",
|
|
32
33
|
{
|
|
33
|
-
className:
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
hidden: w(r) <= 1
|
|
37
|
-
}
|
|
34
|
+
className: g(
|
|
35
|
+
"xiping-thumbnails-wrapper",
|
|
36
|
+
v(i) <= 1 && "xiping-thumbnails-wrapper--hidden"
|
|
38
37
|
),
|
|
39
|
-
children: /* @__PURE__ */
|
|
40
|
-
|
|
38
|
+
children: /* @__PURE__ */ t(
|
|
39
|
+
h.div,
|
|
41
40
|
{
|
|
42
|
-
ref:
|
|
41
|
+
ref: o,
|
|
43
42
|
style: {
|
|
44
|
-
maskImage:
|
|
45
|
-
WebkitOverflowScrolling: "touch",
|
|
46
|
-
scrollbarWidth: "none",
|
|
47
|
-
msOverflowStyle: "none"
|
|
43
|
+
maskImage: d
|
|
48
44
|
},
|
|
49
|
-
className: "
|
|
50
|
-
children: /* @__PURE__ */
|
|
45
|
+
className: "xiping-thumbnails-scroll",
|
|
46
|
+
children: /* @__PURE__ */ t("div", { className: "xiping-thumbnails-container", children: i.map((m, c) => /* @__PURE__ */ t(
|
|
51
47
|
"div",
|
|
52
48
|
{
|
|
53
|
-
className:
|
|
54
|
-
|
|
55
|
-
|
|
49
|
+
className: g(
|
|
50
|
+
"xiping-thumbnail-item",
|
|
51
|
+
c === n && "xiping-thumbnail-item--active"
|
|
52
|
+
),
|
|
53
|
+
onClick: () => s(c),
|
|
54
|
+
children: /* @__PURE__ */ t(
|
|
56
55
|
"img",
|
|
57
56
|
{
|
|
58
|
-
src:
|
|
57
|
+
src: m,
|
|
59
58
|
alt: "",
|
|
60
|
-
className: "
|
|
59
|
+
className: "xiping-thumbnail-image",
|
|
61
60
|
draggable: "false"
|
|
62
61
|
}
|
|
63
62
|
)
|
|
64
63
|
},
|
|
65
|
-
|
|
64
|
+
m
|
|
66
65
|
)) })
|
|
67
66
|
}
|
|
68
67
|
)
|
|
@@ -70,5 +69,5 @@ const j = ({
|
|
|
70
69
|
);
|
|
71
70
|
};
|
|
72
71
|
export {
|
|
73
|
-
|
|
72
|
+
q as default
|
|
74
73
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-wrapper{width:100vw;height:100vh;position:relative;display:flex;flex-direction:column;padding-top:env(safe-area-inset-top,0)}.xiping-tool-wrapper{position:absolute;top:16px;right:16px;display:flex;gap:16px;z-index:10}.xiping-close-icon,.xiping-download-icon{color:#fff;cursor:pointer}.xiping-main-content{flex:1;min-height:0;position:relative;display:flex;align-items:center;justify-content:center}.xiping-pinch-content{width:100%;height:100%}.xiping-image{width:100vw;height:100%;-o-object-fit:contain;object-fit:contain;pointer-events:none}.xiping-loading{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;background-color:#00000080}.xiping-modal-content{overflow:hidden}.xiping-modal-overlay{background-color:#000000b3}.scrollbar-hide{-ms-overflow-style:none;scrollbar-width:none}.scrollbar-hide::-webkit-scrollbar{display:none}
|