@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.
Files changed (147) hide show
  1. package/dist/cjs/components/blur-text/BlurText.d.ts +16 -0
  2. package/dist/cjs/components/blur-text/BlurText.js +1 -0
  3. package/dist/cjs/components/blur-text/index.d.ts +2 -0
  4. package/dist/cjs/components/button/Button.css +1 -0
  5. package/dist/cjs/components/button/Button.js +1 -1
  6. package/dist/cjs/components/comic-text/ComicText.css +1 -0
  7. package/dist/cjs/components/comic-text/ComicText.js +2 -2
  8. package/dist/cjs/components/dock/Duck.css +1 -0
  9. package/dist/cjs/components/dock/Duck.d.ts +2 -4
  10. package/dist/cjs/components/dock/Duck.js +1 -1
  11. package/dist/cjs/components/flip-text/FlipText.css +1 -0
  12. package/dist/cjs/components/flip-text/FlipText.js +1 -1
  13. package/dist/cjs/components/gradient-text/index.css +1 -0
  14. package/dist/cjs/components/gradient-text/index.js +1 -1
  15. package/dist/cjs/components/hyper-text/HyperText.css +1 -0
  16. package/dist/cjs/components/hyper-text/index.js +1 -1
  17. package/dist/cjs/components/image-compare/ImageCompare.css +1 -0
  18. package/dist/cjs/components/image-compare/ImageCompare.d.ts +4 -2
  19. package/dist/cjs/components/image-compare/ImageCompare.js +1 -1
  20. package/dist/cjs/components/image-viewer/ImageThumbnails.css +1 -0
  21. package/dist/cjs/components/image-viewer/ImageThumbnails.js +1 -1
  22. package/dist/cjs/components/image-viewer/ImageViewer.css +1 -0
  23. package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
  24. package/dist/cjs/components/message/Message.css +1 -0
  25. package/dist/cjs/components/message/Message.js +1 -1
  26. package/dist/cjs/components/pointer/Pointer.css +1 -0
  27. package/dist/cjs/components/pointer/Pointer.js +1 -1
  28. package/dist/cjs/components/scratch-to-reveal/ScratchToReveal.css +1 -0
  29. package/dist/cjs/components/scratch-to-reveal/ScratchToReveal.js +1 -1
  30. package/dist/cjs/components/shimmer-button/ShimmerButton.css +1 -0
  31. package/dist/cjs/components/shimmer-button/ShimmerButton.js +1 -1
  32. package/dist/cjs/components/shiny-button/ShinyButton.css +1 -0
  33. package/dist/cjs/components/shiny-button/ShinyButton.js +1 -1
  34. package/dist/cjs/components/shiny-text/ShinyText.css +1 -0
  35. package/dist/cjs/components/shiny-text/ShinyText.d.ts +16 -0
  36. package/dist/cjs/components/shiny-text/ShinyText.js +1 -0
  37. package/dist/cjs/components/shiny-text/index.d.ts +2 -0
  38. package/dist/cjs/components/sparkles-text/SparklesText.css +1 -0
  39. package/dist/cjs/components/sparkles-text/SparklesText.js +1 -1
  40. package/dist/cjs/components/split-text/SplitText.css +1 -0
  41. package/dist/cjs/components/split-text/SplitText.js +1 -1
  42. package/dist/cjs/components/subtitle-player/CurrentMode.css +1 -0
  43. package/dist/cjs/components/subtitle-player/CurrentMode.d.ts +2 -0
  44. package/dist/cjs/components/subtitle-player/CurrentMode.js +2 -2
  45. package/dist/cjs/components/subtitle-player/LyricsMode.css +1 -0
  46. package/dist/cjs/components/subtitle-player/LyricsMode.d.ts +2 -0
  47. package/dist/cjs/components/subtitle-player/LyricsMode.js +2 -2
  48. package/dist/cjs/components/subtitle-player/SubtitlePlayer.css +1 -0
  49. package/dist/cjs/components/subtitle-player/SubtitlePlayer.d.ts +2 -0
  50. package/dist/cjs/components/subtitle-player/SubtitlePlayer.js +1 -1
  51. package/dist/cjs/components/text-animate/TextAnimate.css +1 -0
  52. package/dist/cjs/components/text-animate/TextAnimate.js +2 -2
  53. package/dist/cjs/components/text-type/TextType.css +1 -0
  54. package/dist/cjs/components/text-type/TextType.js +1 -1
  55. package/dist/cjs/components/txt-reader/index.module.css +1 -0
  56. package/dist/cjs/components/txt-reader/index.module.css.js +1 -1
  57. package/dist/cjs/components/typing-animation/index.css +1 -0
  58. package/dist/cjs/components/typing-animation/index.js +1 -1
  59. package/dist/cjs/components/variable-proximity/index.css +1 -0
  60. package/dist/cjs/components/variable-proximity/index.js +1 -1
  61. package/dist/cjs/components/video-dialog/VideoDialog.css +1 -0
  62. package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
  63. package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.css +1 -0
  64. package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.js +1 -1
  65. package/dist/cjs/index.d.ts +2 -1
  66. package/dist/cjs/index.js +1 -1
  67. package/dist/cjs/llms.txt +2 -13
  68. package/dist/cjs/node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css +1 -0
  69. package/dist/es/components/blur-text/BlurText.d.ts +16 -0
  70. package/dist/es/components/blur-text/BlurText.js +77 -0
  71. package/dist/es/components/blur-text/index.d.ts +2 -0
  72. package/dist/es/components/button/Button.css +1 -0
  73. package/dist/es/components/button/Button.js +35 -46
  74. package/dist/es/components/comic-text/ComicText.css +1 -0
  75. package/dist/es/components/comic-text/ComicText.js +13 -12
  76. package/dist/es/components/dock/Duck.css +1 -0
  77. package/dist/es/components/dock/Duck.d.ts +2 -4
  78. package/dist/es/components/dock/Duck.js +60 -64
  79. package/dist/es/components/flip-text/FlipText.css +1 -0
  80. package/dist/es/components/flip-text/FlipText.js +8 -8
  81. package/dist/es/components/gradient-text/index.css +1 -0
  82. package/dist/es/components/gradient-text/index.js +9 -8
  83. package/dist/es/components/hyper-text/HyperText.css +1 -0
  84. package/dist/es/components/hyper-text/index.js +16 -13
  85. package/dist/es/components/image-compare/ImageCompare.css +1 -0
  86. package/dist/es/components/image-compare/ImageCompare.d.ts +4 -2
  87. package/dist/es/components/image-compare/ImageCompare.js +55 -48
  88. package/dist/es/components/image-viewer/ImageThumbnails.css +1 -0
  89. package/dist/es/components/image-viewer/ImageThumbnails.js +41 -42
  90. package/dist/es/components/image-viewer/ImageViewer.css +1 -0
  91. package/dist/es/components/image-viewer/ImageViewer.js +34 -35
  92. package/dist/es/components/message/Message.css +1 -0
  93. package/dist/es/components/message/Message.js +65 -54
  94. package/dist/es/components/pointer/Pointer.css +1 -0
  95. package/dist/es/components/pointer/Pointer.js +23 -25
  96. package/dist/es/components/scratch-to-reveal/ScratchToReveal.css +1 -0
  97. package/dist/es/components/scratch-to-reveal/ScratchToReveal.js +17 -16
  98. package/dist/es/components/shimmer-button/ShimmerButton.css +1 -0
  99. package/dist/es/components/shimmer-button/ShimmerButton.js +8 -8
  100. package/dist/es/components/shiny-button/ShinyButton.css +1 -0
  101. package/dist/es/components/shiny-button/ShinyButton.js +13 -13
  102. package/dist/es/components/shiny-text/ShinyText.css +1 -0
  103. package/dist/es/components/shiny-text/ShinyText.d.ts +16 -0
  104. package/dist/es/components/shiny-text/ShinyText.js +76 -0
  105. package/dist/es/components/shiny-text/index.d.ts +2 -0
  106. package/dist/es/components/sparkles-text/SparklesText.css +1 -0
  107. package/dist/es/components/sparkles-text/SparklesText.js +14 -14
  108. package/dist/es/components/split-text/SplitText.css +1 -0
  109. package/dist/es/components/split-text/SplitText.js +1 -1
  110. package/dist/es/components/subtitle-player/CurrentMode.css +1 -0
  111. package/dist/es/components/subtitle-player/CurrentMode.d.ts +2 -0
  112. package/dist/es/components/subtitle-player/CurrentMode.js +75 -40
  113. package/dist/es/components/subtitle-player/LyricsMode.css +1 -0
  114. package/dist/es/components/subtitle-player/LyricsMode.d.ts +2 -0
  115. package/dist/es/components/subtitle-player/LyricsMode.js +139 -68
  116. package/dist/es/components/subtitle-player/SubtitlePlayer.css +1 -0
  117. package/dist/es/components/subtitle-player/SubtitlePlayer.d.ts +2 -0
  118. package/dist/es/components/subtitle-player/SubtitlePlayer.js +63 -60
  119. package/dist/es/components/text-animate/TextAnimate.css +1 -0
  120. package/dist/es/components/text-animate/TextAnimate.js +57 -55
  121. package/dist/es/components/text-type/TextType.css +1 -0
  122. package/dist/es/components/text-type/TextType.js +24 -19
  123. package/dist/es/components/txt-reader/index.module.css +1 -0
  124. package/dist/es/components/txt-reader/index.module.css.js +1 -1
  125. package/dist/es/components/typing-animation/index.css +1 -0
  126. package/dist/es/components/typing-animation/index.js +12 -12
  127. package/dist/es/components/variable-proximity/index.css +1 -0
  128. package/dist/es/components/variable-proximity/index.js +19 -18
  129. package/dist/es/components/video-dialog/VideoDialog.css +1 -0
  130. package/dist/es/components/video-dialog/VideoDialog.js +1 -1
  131. package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.css +1 -0
  132. package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.js +100 -93
  133. package/dist/es/index.d.ts +2 -1
  134. package/dist/es/index.js +59 -60
  135. package/dist/es/llms.txt +2 -13
  136. package/dist/es/node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css +1 -0
  137. package/package.json +14 -12
  138. package/dist/cjs/components/animated-list/AnimatedList.d.ts +0 -9
  139. package/dist/cjs/components/animated-list/AnimatedList.js +0 -1
  140. package/dist/cjs/components/animated-list/index.d.ts +0 -1
  141. package/dist/cjs/react-components.css +0 -1
  142. package/dist/cjs/utils/utils.js +0 -1
  143. package/dist/es/components/animated-list/AnimatedList.d.ts +0 -9
  144. package/dist/es/components/animated-list/AnimatedList.js +0 -44
  145. package/dist/es/components/animated-list/index.d.ts +0 -1
  146. package/dist/es/react-components.css +0 -1
  147. 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 extends VariantProps<typeof dockVariants> {
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, dockVariants };
25
+ export { Dock, DockIcon };
@@ -1,84 +1,80 @@
1
1
  "use client";
2
- import { jsx as b } from "react/jsx-runtime";
3
- import { cva as N } from "class-variance-authority";
4
- import { useMotionValue as g, motion as x, useTransform as f, useSpring as T } from "motion/react";
5
- import i, { useRef as w } from "react";
6
- import { cn as k } from "../../utils/utils.js";
7
- const I = 40, y = 60, D = 140, A = N(
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: t,
12
- children: a,
13
- iconSize: s = I,
14
- iconMagnification: c = y,
15
- iconDistance: m = D,
16
- direction: n = "middle",
17
- ...u
18
- }, r) => {
19
- const o = g(1 / 0), d = () => i.Children.map(a, (e) => i.isValidElement(e) && e.type === h ? i.cloneElement(e, {
20
- ...e.props,
21
- mouseX: o,
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: c,
24
- distance: m
25
- }) : e);
26
- return /* @__PURE__ */ b(
27
- x.div,
21
+ magnification: m,
22
+ distance: a
23
+ }) : n);
24
+ return /* @__PURE__ */ g(
25
+ I.div,
28
26
  {
29
- ref: r,
30
- onMouseMove: (e) => o.set(e.pageX),
31
- onMouseLeave: () => o.set(1 / 0),
32
- ...u,
33
- className: k(A({ className: t }), {
34
- "items-start": n === "top",
35
- "items-center": n === "middle",
36
- "items-end": n === "bottom"
37
- }),
38
- children: d()
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
- C.displayName = "Dock";
44
- const h = ({
45
- size: t = I,
46
- magnification: a = y,
47
- distance: s = D,
48
- mouseX: c,
49
- className: m,
50
- children: n,
51
- ...u
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 r = w(null), o = Math.max(6, t * 0.2), d = g(1 / 0), e = f(c ?? d, (M) => {
54
- const l = r.current?.getBoundingClientRect() ?? { x: 0, width: 0 };
55
- return M - l.x - l.width / 2;
56
- }), E = f(
57
- e,
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
- [t, a, t]
60
- ), p = T(E, {
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__ */ b(
66
- x.div,
65
+ return /* @__PURE__ */ g(
66
+ I.div,
67
67
  {
68
- ref: r,
69
- style: { width: p, height: p, padding: o },
70
- className: k(
71
- "flex aspect-square cursor-pointer items-center justify-center rounded-full",
72
- m
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
- h.displayName = "DockIcon";
76
+ M.displayName = "DockIcon";
80
77
  export {
81
- C as Dock,
82
- h as DockIcon,
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 { cn as f } from "../../utils/utils.js";
5
- import x from "react";
6
- /* empty css */
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 m = d.create(r), p = x.Children.toArray(e).join("").split("");
21
- return /* @__PURE__ */ i("div", { className: "xiping-flip-container", children: /* @__PURE__ */ i(h, { mode: "wait", children: p.map((l, t) => /* @__PURE__ */ i(
22
- m,
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: f("xiping-flip-char", o),
29
+ className: x("xiping-flip-char", o),
30
30
  ...s,
31
- children: l
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
- /* empty css */
3
- function g({
4
- children: e,
5
- className: i = "",
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: `xiping-gradient-text ${i}`, children: [
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: e })
17
+ /* @__PURE__ */ a("div", { className: "xiping-gradient-text__content", style: t, children: i })
17
18
  ] });
18
19
  }
19
20
  export {
20
- g as GradientText,
21
- g as default
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 { cn as h } from "../../utils/utils.js";
4
- import { motion as x, AnimatePresence as U } from "motion/react";
5
- import { useState as M, useRef as d, useEffect as I } from "react";
6
- /* empty css */
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 = x.create(E, {
21
+ const b = A.create(E, {
22
22
  forwardMotionProps: !0
23
- }), [v, y] = M(
23
+ }), [v, y] = h(
24
24
  () => n.split("")
25
- ), [i, r] = M(!1), a = d(0), m = d(null), D = () => {
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 I(() => {
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]), I(() => {
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, A) => T === " " ? T : A <= a.current ? n[A] : s[q(s.length)]
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: h("xiping-hyper-container", C),
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
- x.span,
66
+ A.span,
67
67
  {
68
- className: h("xiping-hyper-char", e === " " ? "xiping-hyper-space" : ""),
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 j, jsx as t } from "react/jsx-runtime";
2
- import F from "clsx";
3
- import { useState as E, useRef as i, useCallback as a, useEffect as y, useMemo as w } from "react";
4
- /* empty css */
5
- const q = (N) => {
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: b,
9
- className: S,
8
+ modifiedImage: x,
9
+ className: $,
10
10
  dividerWidth: l = 1,
11
- originalLabel: I = "原图",
12
- modifiedLabel: P = "处理过的图"
13
- } = N, [s, $] = E(50), [x, A] = E(16 / 9), h = i(null), u = i(!1), o = i(null), d = i(null), n = i(null), k = a((e) => {
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
- (!d.current || !u.current) && (d.current = h.current.getBoundingClientRect());
16
- const r = d.current, g = (e - r.left) / r.width * 100, p = Math.min(100, Math.max(0, g));
17
- $(p);
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
- u.current && (o.current !== null && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
20
- k(e);
20
+ d.current && (o.current !== null && cancelAnimationFrame(o.current), o.current = requestAnimationFrame(() => {
21
+ R(e);
21
22
  }));
22
- }, [k]), M = a((e) => {
23
+ }, [R]), L = a((e) => {
23
24
  m(e.clientX);
24
- }, [m]), R = a((e) => {
25
+ }, [m]), E = a((e) => {
25
26
  e.touches.length > 0 && m(e.touches[0].clientX);
26
- }, [m]), L = a(() => {
27
- u.current = !0, d.current = null;
28
- const e = (f) => M(f), r = (f) => R(f), v = () => {
29
- u.current = !1, o.current !== null && (cancelAnimationFrame(o.current), o.current = null), n.current && (n.current(), n.current = null);
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", r, { passive: !1 }), window.addEventListener("mouseup", g), window.addEventListener("touchend", p);
32
- const T = () => {
33
- window.removeEventListener("mousemove", e), window.removeEventListener("touchmove", r), window.removeEventListener("mouseup", g), window.removeEventListener("touchend", p);
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 = T;
36
- }, [M, R]);
37
- y(() => () => {
36
+ n.current = F;
37
+ }, [L, E]);
38
+ S(() => () => {
38
39
  n.current && (n.current(), n.current = null);
39
- }, []), y(() => {
40
+ }, []), S(() => {
40
41
  const e = new Image();
41
42
  e.onload = () => {
42
- A(e.width / e.height);
43
+ D(e.width / e.height);
43
44
  }, e.src = c;
44
45
  }, [c]);
45
- const C = w(
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: x
52
+ aspectRatio: k
52
53
  }),
53
- [c, x]
54
- ), D = w(
54
+ [c, k]
55
+ ), T = b(
55
56
  () => ({
56
57
  width: `${s}%`,
57
- backgroundImage: `url(${b})`,
58
+ backgroundImage: `url(${x})`,
58
59
  backgroundRepeat: "no-repeat",
59
60
  backgroundPosition: "top left",
60
61
  backgroundSize: "auto 100%"
61
62
  }),
62
- [s, b]
63
- ), G = w(
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__ */ j(
72
+ return /* @__PURE__ */ X(
72
73
  "div",
73
74
  {
74
75
  ref: h,
75
- className: F("xiping-image-compare-container", S),
76
- style: C,
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: I }),
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: D,
84
- children: /* @__PURE__ */ t("div", { className: "xiping-image-compare-label xiping-image-compare-label-modified", children: P })
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: "xiping-image-compare-divider",
91
- style: G,
92
- onMouseDown: L,
93
- onTouchStart: L,
94
- children: /* @__PURE__ */ t("div", { className: "xiping-image-compare-divider-button", children: /* @__PURE__ */ t(
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
- q as default
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 o } from "react/jsx-runtime";
2
- import { useScroll as h, motion as g, useMotionValue as p, useMotionValueEvent as b, animate as l } from "motion/react";
3
- import { cn as v } from "../../utils/utils.js";
4
- import { size as w } from "lodash-es";
5
- import { useRef as k } from "react";
6
- const m = "0%", x = "100%", d = "20%", s = "80%", t = "#0000", e = "#000";
7
- function I(r) {
8
- const n = p(
9
- `linear-gradient(90deg, ${e}, ${e} ${m}, ${e} ${s}, ${t})`
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 b(r, "change", (a) => {
12
- a === 0 ? l(
12
+ return x(i, "change", (s) => {
13
+ s === 0 ? r(
13
14
  n,
14
- `linear-gradient(90deg, ${e}, ${e} ${m}, ${e} ${s}, ${t})`
15
- ) : a === 1 ? l(
15
+ `linear-gradient(90deg, ${e}, ${e} ${$}, ${e} ${l}, ${a})`
16
+ ) : s === 1 ? r(
16
17
  n,
17
- `linear-gradient(90deg, ${t}, ${e} ${d}, ${e} ${x}, ${e})`
18
- ) : (r.getPrevious() === 0 || r.getPrevious() === 1) && l(
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, ${t}, ${e} ${d}, ${e} ${s}, ${t})`
21
+ `linear-gradient(90deg, ${a}, ${e} ${u}, ${e} ${l}, ${a})`
21
22
  );
22
23
  }), n;
23
24
  }
24
- const j = ({
25
- images: r,
25
+ const q = ({
26
+ images: i,
26
27
  currentIndex: n,
27
- onImageSelect: a
28
+ onImageSelect: s
28
29
  }) => {
29
- const i = k(null), { scrollXProgress: $ } = h({ container: i }), u = I($);
30
- return /* @__PURE__ */ o(
30
+ const o = I(null), { scrollXProgress: p } = f({ container: o }), d = k(p);
31
+ return /* @__PURE__ */ t(
31
32
  "div",
32
33
  {
33
- className: v(
34
- "h-24 bg-black/50 shrink-0 z-10 pb-safe-offset-0 pl-safe-offset-0 pr-safe-offset-0",
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__ */ o(
40
- g.div,
38
+ children: /* @__PURE__ */ t(
39
+ h.div,
41
40
  {
42
- ref: i,
41
+ ref: o,
43
42
  style: {
44
- maskImage: u,
45
- WebkitOverflowScrolling: "touch",
46
- scrollbarWidth: "none",
47
- msOverflowStyle: "none"
43
+ maskImage: d
48
44
  },
49
- className: "h-24 w-screen overflow-x-auto overflow-y-hidden scrollbar-hide",
50
- children: /* @__PURE__ */ o("div", { className: "flex gap-2 p-2 h-24 min-w-max", children: r.map((c, f) => /* @__PURE__ */ o(
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: `h-full aspect-square flex-shrink-0 cursor-pointer border-2 transition-all ${f === n ? "border-white" : "border-transparent"}`,
54
- onClick: () => a(f),
55
- children: /* @__PURE__ */ o(
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: c,
57
+ src: m,
59
58
  alt: "",
60
- className: "w-full h-full object-contain",
59
+ className: "xiping-thumbnail-image",
61
60
  draggable: "false"
62
61
  }
63
62
  )
64
63
  },
65
- c
64
+ m
66
65
  )) })
67
66
  }
68
67
  )
@@ -70,5 +69,5 @@ const j = ({
70
69
  );
71
70
  };
72
71
  export {
73
- j as default
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}