@yamada-ui/ripple 1.0.40-next-20241005235555 → 1.0.40-next-20241008193728

Sign up to get free protection for your applications and to get access to all the features.
@@ -32,12 +32,12 @@ var useRipple = ({
32
32
  }, []);
33
33
  return {
34
34
  ripples,
35
- onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),
36
- onClear
35
+ onClear,
36
+ onPointerDown: handlerAll(onPointerDown, rest.onPointerDown)
37
37
  };
38
38
  };
39
39
 
40
40
  export {
41
41
  useRipple
42
42
  };
43
- //# sourceMappingURL=chunk-QSFNYWP4.mjs.map
43
+ //# sourceMappingURL=chunk-7NWWPF2L.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/use-ripple.ts"],"sourcesContent":["import type React from \"react\"\nimport type { Key, PointerEventHandler } from \"react\"\nimport { createId, handlerAll } from \"@yamada-ui/utils\"\nimport { useCallback, useState } from \"react\"\n\nexport interface RippleOptions {\n key: React.Key\n size: number\n x: number\n y: number\n}\n\nexport interface UseRippleProps<T = HTMLElement> {\n disabled?: boolean\n isDisabled?: boolean\n onPointerDown?: PointerEventHandler<T>\n}\n\nexport const useRipple = <T = HTMLElement>({\n disabled,\n isDisabled,\n ...rest\n}: UseRippleProps<T> = {}) => {\n const [ripples, setRipples] = useState<RippleOptions[]>([])\n\n const onPointerDown: PointerEventHandler<T> = useCallback(\n (ev) => {\n if (disabled || isDisabled) return setRipples([])\n\n const trigger = ev.currentTarget as unknown as Element\n\n const size = Math.max(trigger.clientWidth, trigger.clientHeight)\n const rect = trigger.getBoundingClientRect()\n\n setRipples((prev) => [\n ...prev,\n {\n key: createId(prev.length.toString()),\n size,\n x: ev.clientX - rect.x - size / 2,\n y: ev.clientY - rect.y - size / 2,\n },\n ])\n },\n [disabled, isDisabled],\n )\n\n const onClear = useCallback((key: Key) => {\n setRipples((prev) => prev.filter((item) => item.key !== key))\n }, [])\n\n return {\n ripples,\n onClear,\n onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),\n }\n}\n\nexport type UseRippleReturn = ReturnType<typeof useRipple>\n"],"mappings":";;;AAEA,SAAS,UAAU,kBAAkB;AACrC,SAAS,aAAa,gBAAgB;AAe/B,IAAM,YAAY,CAAkB;AAAA,EACzC;AAAA,EACA;AAAA,EACA,GAAG;AACL,IAAuB,CAAC,MAAM;AAC5B,QAAM,CAAC,SAAS,UAAU,IAAI,SAA0B,CAAC,CAAC;AAE1D,QAAM,gBAAwC;AAAA,IAC5C,CAAC,OAAO;AACN,UAAI,YAAY,WAAY,QAAO,WAAW,CAAC,CAAC;AAEhD,YAAM,UAAU,GAAG;AAEnB,YAAM,OAAO,KAAK,IAAI,QAAQ,aAAa,QAAQ,YAAY;AAC/D,YAAM,OAAO,QAAQ,sBAAsB;AAE3C,iBAAW,CAAC,SAAS;AAAA,QACnB,GAAG;AAAA,QACH;AAAA,UACE,KAAK,SAAS,KAAK,OAAO,SAAS,CAAC;AAAA,UACpC;AAAA,UACA,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,UAChC,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,UAAU,YAAY,CAAC,QAAa;AACxC,eAAW,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,QAAQ,GAAG,CAAC;AAAA,EAC9D,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe,WAAW,eAAe,KAAK,aAAa;AAAA,EAC7D;AACF;","names":[]}
@@ -7,12 +7,12 @@ import { Fragment, jsx } from "react/jsx-runtime";
7
7
  var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
8
8
  var Ripple = ({
9
9
  className,
10
+ style,
11
+ color = "currentColor",
12
+ isDisabled,
10
13
  ripples,
11
14
  onAnimationComplete,
12
15
  onClear,
13
- color = "currentColor",
14
- style,
15
- isDisabled,
16
16
  ...rest
17
17
  }) => {
18
18
  if (isDisabled) return null;
@@ -20,27 +20,27 @@ var Ripple = ({
20
20
  rounded: "fallback(full, 9999px)",
21
21
  zIndex: "fallback(kurillin, 9)"
22
22
  };
23
- return /* @__PURE__ */ jsx(Fragment, { children: ripples.map(({ key, x, y, size }) => {
23
+ return /* @__PURE__ */ jsx(Fragment, { children: ripples.map(({ key, size, x, y }) => {
24
24
  const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5);
25
25
  return /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ jsx(
26
26
  motion.span,
27
27
  {
28
28
  className: cx("ui-ripple", className),
29
- initial: { transform: "scale(0)", opacity: 0.35 },
30
- animate: { transform: "scale(2)", opacity: 0 },
31
- exit: { opacity: 0 },
32
- transition: { duration },
33
- bgColor: color,
34
29
  style: {
35
- position: "absolute",
36
- transformOrigin: "center",
37
- pointerEvents: "none",
30
+ height: `${size}px`,
38
31
  left: x,
32
+ pointerEvents: "none",
33
+ position: "absolute",
39
34
  top: y,
35
+ transformOrigin: "center",
40
36
  width: `${size}px`,
41
- height: `${size}px`,
42
37
  ...style
43
38
  },
39
+ animate: { opacity: 0, transform: "scale(2)" },
40
+ bgColor: color,
41
+ exit: { opacity: 0 },
42
+ initial: { opacity: 0.35, transform: "scale(0)" },
43
+ transition: { duration },
44
44
  __css: css,
45
45
  ...rest,
46
46
  onAnimationComplete: handlerAll(
@@ -57,4 +57,4 @@ Ripple.__ui__ = "Ripple";
57
57
  export {
58
58
  Ripple
59
59
  };
60
- //# sourceMappingURL=chunk-N2WO662B.mjs.map
60
+ //# sourceMappingURL=chunk-YH24ZFF2.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/ripple.tsx"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport type { Key } from \"react\"\nimport type { RippleOptions } from \"./use-ripple\"\nimport { AnimatePresence, motion } from \"@yamada-ui/motion\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max)\n\nexport interface RippleProps extends MotionProps<\"span\"> {\n ripples: RippleOptions[]\n onClear: (key: Key) => void\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\n/**\n * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.\n *\n * @see Docs https://yamada-ui.com/components/other/ripple\n */\nexport const Ripple: FC<RippleProps> = ({\n className,\n style,\n color = \"currentColor\",\n isDisabled,\n ripples,\n onAnimationComplete,\n onClear,\n ...rest\n}) => {\n if (isDisabled) return null\n\n const css: CSSUIObject = {\n rounded: \"fallback(full, 9999px)\",\n zIndex: \"fallback(kurillin, 9)\",\n }\n\n return (\n <>\n {ripples.map(({ key, size, x, y }) => {\n const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5)\n\n return (\n <AnimatePresence key={key} mode=\"popLayout\">\n <motion.span\n className={cx(\"ui-ripple\", className)}\n style={{\n height: `${size}px`,\n left: x,\n pointerEvents: \"none\",\n position: \"absolute\",\n top: y,\n transformOrigin: \"center\",\n width: `${size}px`,\n ...style,\n }}\n animate={{ opacity: 0, transform: \"scale(2)\" }}\n bgColor={color}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0.35, transform: \"scale(0)\" }}\n transition={{ duration }}\n __css={css}\n {...rest}\n onAnimationComplete={handlerAll(onAnimationComplete, () =>\n onClear(key),\n )}\n />\n </AnimatePresence>\n )\n })}\n </>\n )\n}\n\nRipple.displayName = \"Ripple\"\nRipple.__ui__ = \"Ripple\"\n"],"mappings":";;;AAIA,SAAS,iBAAiB,cAAc;AACxC,SAAS,IAAI,kBAAkB;AAuC3B,mBAMQ,WANR;AArCJ,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAkB7B,IAAM,SAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAY,QAAO;AAEvB,QAAM,MAAmB;AAAA,IACvB,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAEA,SACE,gCACG,kBAAQ,IAAI,CAAC,EAAE,KAAK,MAAM,GAAG,EAAE,MAAM;AACpC,UAAM,WAAW,MAAM,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,GAAG;AAEhE,WACE,oBAAC,mBAA0B,MAAK,aAC9B;AAAA,MAAC,OAAO;AAAA,MAAP;AAAA,QACC,WAAW,GAAG,aAAa,SAAS;AAAA,QACpC,OAAO;AAAA,UACL,QAAQ,GAAG,IAAI;AAAA,UACf,MAAM;AAAA,UACN,eAAe;AAAA,UACf,UAAU;AAAA,UACV,KAAK;AAAA,UACL,iBAAiB;AAAA,UACjB,OAAO,GAAG,IAAI;AAAA,UACd,GAAG;AAAA,QACL;AAAA,QACA,SAAS,EAAE,SAAS,GAAG,WAAW,WAAW;AAAA,QAC7C,SAAS;AAAA,QACT,MAAM,EAAE,SAAS,EAAE;AAAA,QACnB,SAAS,EAAE,SAAS,MAAM,WAAW,WAAW;AAAA,QAChD,YAAY,EAAE,SAAS;AAAA,QACvB,OAAO;AAAA,QACN,GAAG;AAAA,QACJ,qBAAqB;AAAA,UAAW;AAAA,UAAqB,MACnD,QAAQ,GAAG;AAAA,QACb;AAAA;AAAA,IACF,KAvBoB,GAwBtB;AAAA,EAEJ,CAAC,GACH;AAEJ;AAEA,OAAO,cAAc;AACrB,OAAO,SAAS;","names":[]}
package/dist/index.js CHANGED
@@ -33,12 +33,12 @@ var import_jsx_runtime = require("react/jsx-runtime");
33
33
  var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
34
34
  var Ripple = ({
35
35
  className,
36
+ style,
37
+ color = "currentColor",
38
+ isDisabled,
36
39
  ripples,
37
40
  onAnimationComplete,
38
41
  onClear,
39
- color = "currentColor",
40
- style,
41
- isDisabled,
42
42
  ...rest
43
43
  }) => {
44
44
  if (isDisabled) return null;
@@ -46,27 +46,27 @@ var Ripple = ({
46
46
  rounded: "fallback(full, 9999px)",
47
47
  zIndex: "fallback(kurillin, 9)"
48
48
  };
49
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ripples.map(({ key, x, y, size }) => {
49
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ripples.map(({ key, size, x, y }) => {
50
50
  const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5);
51
51
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion.AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
52
52
  import_motion.motion.span,
53
53
  {
54
54
  className: (0, import_utils.cx)("ui-ripple", className),
55
- initial: { transform: "scale(0)", opacity: 0.35 },
56
- animate: { transform: "scale(2)", opacity: 0 },
57
- exit: { opacity: 0 },
58
- transition: { duration },
59
- bgColor: color,
60
55
  style: {
61
- position: "absolute",
62
- transformOrigin: "center",
63
- pointerEvents: "none",
56
+ height: `${size}px`,
64
57
  left: x,
58
+ pointerEvents: "none",
59
+ position: "absolute",
65
60
  top: y,
61
+ transformOrigin: "center",
66
62
  width: `${size}px`,
67
- height: `${size}px`,
68
63
  ...style
69
64
  },
65
+ animate: { opacity: 0, transform: "scale(2)" },
66
+ bgColor: color,
67
+ exit: { opacity: 0 },
68
+ initial: { opacity: 0.35, transform: "scale(0)" },
69
+ transition: { duration },
70
70
  __css: css,
71
71
  ...rest,
72
72
  onAnimationComplete: (0, import_utils.handlerAll)(
@@ -112,8 +112,8 @@ var useRipple = ({
112
112
  }, []);
113
113
  return {
114
114
  ripples,
115
- onPointerDown: (0, import_utils2.handlerAll)(onPointerDown, rest.onPointerDown),
116
- onClear
115
+ onClear,
116
+ onPointerDown: (0, import_utils2.handlerAll)(onPointerDown, rest.onPointerDown)
117
117
  };
118
118
  };
119
119
  // Annotate the CommonJS export names for ESM import in node:
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/ripple.tsx","../src/use-ripple.ts"],"sourcesContent":["export { Ripple } from \"./ripple\"\nexport type { RippleProps } from \"./ripple\"\nexport { useRipple } from \"./use-ripple\"\nexport type {\n RippleOptions,\n UseRippleProps,\n UseRippleReturn,\n} from \"./use-ripple\"\n","import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport { AnimatePresence, motion } from \"@yamada-ui/motion\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport type { Key } from \"react\"\nimport type { RippleOptions } from \"./use-ripple\"\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max)\n\nexport interface RippleProps extends MotionProps<\"span\"> {\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n isDisabled?: boolean\n ripples: RippleOptions[]\n onClear: (key: Key) => void\n}\n\n/**\n * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.\n *\n * @see Docs https://yamada-ui.com/components/other/ripple\n */\nexport const Ripple: FC<RippleProps> = ({\n className,\n ripples,\n onAnimationComplete,\n onClear,\n color = \"currentColor\",\n style,\n isDisabled,\n ...rest\n}) => {\n if (isDisabled) return null\n\n const css: CSSUIObject = {\n rounded: \"fallback(full, 9999px)\",\n zIndex: \"fallback(kurillin, 9)\",\n }\n\n return (\n <>\n {ripples.map(({ key, x, y, size }) => {\n const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5)\n\n return (\n <AnimatePresence key={key} mode=\"popLayout\">\n <motion.span\n className={cx(\"ui-ripple\", className)}\n initial={{ transform: \"scale(0)\", opacity: 0.35 }}\n animate={{ transform: \"scale(2)\", opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration }}\n bgColor={color}\n style={{\n position: \"absolute\",\n transformOrigin: \"center\",\n pointerEvents: \"none\",\n left: x,\n top: y,\n width: `${size}px`,\n height: `${size}px`,\n ...style,\n }}\n __css={css}\n {...rest}\n onAnimationComplete={handlerAll(onAnimationComplete, () =>\n onClear(key),\n )}\n />\n </AnimatePresence>\n )\n })}\n </>\n )\n}\n\nRipple.displayName = \"Ripple\"\nRipple.__ui__ = \"Ripple\"\n","import { createId, handlerAll } from \"@yamada-ui/utils\"\nimport type React from \"react\"\nimport type { Key, PointerEventHandler } from \"react\"\nimport { useCallback, useState } from \"react\"\n\nexport interface RippleOptions {\n key: React.Key\n x: number\n y: number\n size: number\n}\n\nexport interface UseRippleProps<T extends any = HTMLElement> {\n disabled?: boolean\n isDisabled?: boolean\n onPointerDown?: PointerEventHandler<T>\n}\n\nexport const useRipple = <T extends any = HTMLElement>({\n disabled,\n isDisabled,\n ...rest\n}: UseRippleProps<T> = {}) => {\n const [ripples, setRipples] = useState<RippleOptions[]>([])\n\n const onPointerDown: PointerEventHandler<T> = useCallback(\n (ev) => {\n if (disabled || isDisabled) return setRipples([])\n\n const trigger = ev.currentTarget as unknown as Element\n\n const size = Math.max(trigger.clientWidth, trigger.clientHeight)\n const rect = trigger.getBoundingClientRect()\n\n setRipples((prev) => [\n ...prev,\n {\n key: createId(prev.length.toString()),\n size,\n x: ev.clientX - rect.x - size / 2,\n y: ev.clientY - rect.y - size / 2,\n },\n ])\n },\n [disabled, isDisabled],\n )\n\n const onClear = useCallback((key: Key) => {\n setRipples((prev) => prev.filter((item) => item.key !== key))\n }, [])\n\n return {\n ripples,\n onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),\n onClear,\n }\n}\n\nexport type UseRippleReturn = ReturnType<typeof useRipple>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,oBAAwC;AAExC,mBAA+B;AAyC3B;AArCJ,IAAM,QAA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AA,EACA,GAAG;AACL,IAAuB,CAAC,MAAM;AAC5B,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA0B,CAAC,CAAC;AAE1D,QAAM,oBAAwC;AAAA,IAC5C,CAAC,OAAO;AACN,UAAI,YAAY,WAAY,QAAO,WAAW,CAAC,CAAC;AAEhD,YAAM,UAAU,GAAG;AAEnB,YAAM,OAAO,KAAK,IAAI,QAAQ,aAAa,QAAQ,YAAY;AAC/D,YAAM,OAAO,QAAQ,sBAAsB;AAE3C,iBAAW,CAAC,SAAS;AAAA,QACnB,GAAG;AAAA,QACH;AAAA,UACE,SAAK,wBAAS,KAAK,OAAO,SAAS,CAAC;AAAA,UACpC;AAAA,UACA,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,UAChC,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,cAAU,0BAAY,CAAC,QAAa;AACxC,eAAW,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,QAAQ,GAAG,CAAC;AAAA,EAC9D,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA,mBAAe,0BAAW,eAAe,KAAK,aAAa;AAAA,IAC3D;AAAA,EACF;AACF;","names":["import_utils"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/ripple.tsx","../src/use-ripple.ts"],"sourcesContent":["export { Ripple } from \"./ripple\"\nexport type { RippleProps } from \"./ripple\"\nexport { useRipple } from \"./use-ripple\"\nexport type {\n RippleOptions,\n UseRippleProps,\n UseRippleReturn,\n} from \"./use-ripple\"\n","import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport type { Key } from \"react\"\nimport type { RippleOptions } from \"./use-ripple\"\nimport { AnimatePresence, motion } from \"@yamada-ui/motion\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max)\n\nexport interface RippleProps extends MotionProps<\"span\"> {\n ripples: RippleOptions[]\n onClear: (key: Key) => void\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\n/**\n * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.\n *\n * @see Docs https://yamada-ui.com/components/other/ripple\n */\nexport const Ripple: FC<RippleProps> = ({\n className,\n style,\n color = \"currentColor\",\n isDisabled,\n ripples,\n onAnimationComplete,\n onClear,\n ...rest\n}) => {\n if (isDisabled) return null\n\n const css: CSSUIObject = {\n rounded: \"fallback(full, 9999px)\",\n zIndex: \"fallback(kurillin, 9)\",\n }\n\n return (\n <>\n {ripples.map(({ key, size, x, y }) => {\n const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5)\n\n return (\n <AnimatePresence key={key} mode=\"popLayout\">\n <motion.span\n className={cx(\"ui-ripple\", className)}\n style={{\n height: `${size}px`,\n left: x,\n pointerEvents: \"none\",\n position: \"absolute\",\n top: y,\n transformOrigin: \"center\",\n width: `${size}px`,\n ...style,\n }}\n animate={{ opacity: 0, transform: \"scale(2)\" }}\n bgColor={color}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0.35, transform: \"scale(0)\" }}\n transition={{ duration }}\n __css={css}\n {...rest}\n onAnimationComplete={handlerAll(onAnimationComplete, () =>\n onClear(key),\n )}\n />\n </AnimatePresence>\n )\n })}\n </>\n )\n}\n\nRipple.displayName = \"Ripple\"\nRipple.__ui__ = \"Ripple\"\n","import type React from \"react\"\nimport type { Key, PointerEventHandler } from \"react\"\nimport { createId, handlerAll } from \"@yamada-ui/utils\"\nimport { useCallback, useState } from \"react\"\n\nexport interface RippleOptions {\n key: React.Key\n size: number\n x: number\n y: number\n}\n\nexport interface UseRippleProps<T = HTMLElement> {\n disabled?: boolean\n isDisabled?: boolean\n onPointerDown?: PointerEventHandler<T>\n}\n\nexport const useRipple = <T = HTMLElement>({\n disabled,\n isDisabled,\n ...rest\n}: UseRippleProps<T> = {}) => {\n const [ripples, setRipples] = useState<RippleOptions[]>([])\n\n const onPointerDown: PointerEventHandler<T> = useCallback(\n (ev) => {\n if (disabled || isDisabled) return setRipples([])\n\n const trigger = ev.currentTarget as unknown as Element\n\n const size = Math.max(trigger.clientWidth, trigger.clientHeight)\n const rect = trigger.getBoundingClientRect()\n\n setRipples((prev) => [\n ...prev,\n {\n key: createId(prev.length.toString()),\n size,\n x: ev.clientX - rect.x - size / 2,\n y: ev.clientY - rect.y - size / 2,\n },\n ])\n },\n [disabled, isDisabled],\n )\n\n const onClear = useCallback((key: Key) => {\n setRipples((prev) => prev.filter((item) => item.key !== key))\n }, [])\n\n return {\n ripples,\n onClear,\n onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),\n }\n}\n\nexport type UseRippleReturn = ReturnType<typeof useRipple>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACIA,oBAAwC;AACxC,mBAA+B;AAuC3B;AArCJ,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAkB7B,IAAM,SAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAY,QAAO;AAEvB,QAAM,MAAmB;AAAA,IACvB,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAEA,SACE,2EACG,kBAAQ,IAAI,CAAC,EAAE,KAAK,MAAM,GAAG,EAAE,MAAM;AACpC,UAAM,WAAW,MAAM,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,GAAG;AAEhE,WACE,4CAAC,iCAA0B,MAAK,aAC9B;AAAA,MAAC,qBAAO;AAAA,MAAP;AAAA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QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,cAAU,0BAAY,CAAC,QAAa;AACxC,eAAW,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,QAAQ,GAAG,CAAC;AAAA,EAC9D,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,mBAAe,0BAAW,eAAe,KAAK,aAAa;AAAA,EAC7D;AACF;","names":["import_utils"]}
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
1
  "use client"
2
2
  import {
3
3
  Ripple
4
- } from "./chunk-N2WO662B.mjs";
4
+ } from "./chunk-YH24ZFF2.mjs";
5
5
  import {
6
6
  useRipple
7
- } from "./chunk-QSFNYWP4.mjs";
7
+ } from "./chunk-7NWWPF2L.mjs";
8
8
  export {
9
9
  Ripple,
10
10
  useRipple
package/dist/ripple.d.mts CHANGED
@@ -4,14 +4,14 @@ import { Key } from 'react';
4
4
  import { RippleOptions } from './use-ripple.mjs';
5
5
 
6
6
  interface RippleProps extends MotionProps<"span"> {
7
+ ripples: RippleOptions[];
8
+ onClear: (key: Key) => void;
7
9
  /**
8
10
  * If `true`, disable ripple effects when pressing a element.
9
11
  *
10
12
  * @default false
11
13
  */
12
14
  isDisabled?: boolean;
13
- ripples: RippleOptions[];
14
- onClear: (key: Key) => void;
15
15
  }
16
16
  /**
17
17
  * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.
package/dist/ripple.d.ts CHANGED
@@ -4,14 +4,14 @@ import { Key } from 'react';
4
4
  import { RippleOptions } from './use-ripple.js';
5
5
 
6
6
  interface RippleProps extends MotionProps<"span"> {
7
+ ripples: RippleOptions[];
8
+ onClear: (key: Key) => void;
7
9
  /**
8
10
  * If `true`, disable ripple effects when pressing a element.
9
11
  *
10
12
  * @default false
11
13
  */
12
14
  isDisabled?: boolean;
13
- ripples: RippleOptions[];
14
- onClear: (key: Key) => void;
15
15
  }
16
16
  /**
17
17
  * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.
package/dist/ripple.js CHANGED
@@ -30,12 +30,12 @@ var import_jsx_runtime = require("react/jsx-runtime");
30
30
  var clamp = (value, min, max) => Math.min(Math.max(value, min), max);
31
31
  var Ripple = ({
32
32
  className,
33
+ style,
34
+ color = "currentColor",
35
+ isDisabled,
33
36
  ripples,
34
37
  onAnimationComplete,
35
38
  onClear,
36
- color = "currentColor",
37
- style,
38
- isDisabled,
39
39
  ...rest
40
40
  }) => {
41
41
  if (isDisabled) return null;
@@ -43,27 +43,27 @@ var Ripple = ({
43
43
  rounded: "fallback(full, 9999px)",
44
44
  zIndex: "fallback(kurillin, 9)"
45
45
  };
46
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ripples.map(({ key, x, y, size }) => {
46
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ripples.map(({ key, size, x, y }) => {
47
47
  const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5);
48
48
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_motion.AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
49
49
  import_motion.motion.span,
50
50
  {
51
51
  className: (0, import_utils.cx)("ui-ripple", className),
52
- initial: { transform: "scale(0)", opacity: 0.35 },
53
- animate: { transform: "scale(2)", opacity: 0 },
54
- exit: { opacity: 0 },
55
- transition: { duration },
56
- bgColor: color,
57
52
  style: {
58
- position: "absolute",
59
- transformOrigin: "center",
60
- pointerEvents: "none",
53
+ height: `${size}px`,
61
54
  left: x,
55
+ pointerEvents: "none",
56
+ position: "absolute",
62
57
  top: y,
58
+ transformOrigin: "center",
63
59
  width: `${size}px`,
64
- height: `${size}px`,
65
60
  ...style
66
61
  },
62
+ animate: { opacity: 0, transform: "scale(2)" },
63
+ bgColor: color,
64
+ exit: { opacity: 0 },
65
+ initial: { opacity: 0.35, transform: "scale(0)" },
66
+ transition: { duration },
67
67
  __css: css,
68
68
  ...rest,
69
69
  onAnimationComplete: (0, import_utils.handlerAll)(
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/ripple.tsx"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport { AnimatePresence, motion } from \"@yamada-ui/motion\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport type { Key } from \"react\"\nimport type { RippleOptions } from \"./use-ripple\"\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max)\n\nexport interface RippleProps extends MotionProps<\"span\"> {\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n isDisabled?: boolean\n ripples: RippleOptions[]\n onClear: (key: Key) => void\n}\n\n/**\n * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.\n *\n * @see Docs https://yamada-ui.com/components/other/ripple\n */\nexport const Ripple: FC<RippleProps> = ({\n className,\n ripples,\n onAnimationComplete,\n onClear,\n color = \"currentColor\",\n style,\n isDisabled,\n ...rest\n}) => {\n if (isDisabled) return null\n\n const css: CSSUIObject = {\n rounded: \"fallback(full, 9999px)\",\n zIndex: \"fallback(kurillin, 9)\",\n }\n\n return (\n <>\n {ripples.map(({ key, x, y, size }) => {\n const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5)\n\n return (\n <AnimatePresence key={key} mode=\"popLayout\">\n <motion.span\n className={cx(\"ui-ripple\", className)}\n initial={{ transform: \"scale(0)\", opacity: 0.35 }}\n animate={{ transform: \"scale(2)\", opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration }}\n bgColor={color}\n style={{\n position: \"absolute\",\n transformOrigin: \"center\",\n pointerEvents: \"none\",\n left: x,\n top: y,\n width: `${size}px`,\n height: `${size}px`,\n ...style,\n }}\n __css={css}\n {...rest}\n onAnimationComplete={handlerAll(onAnimationComplete, () =>\n onClear(key),\n )}\n />\n </AnimatePresence>\n )\n })}\n </>\n )\n}\n\nRipple.displayName = \"Ripple\"\nRipple.__ui__ = \"Ripple\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAwC;AAExC,mBAA+B;AAyC3B;AArCJ,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAkB7B,IAAM,SAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAY,QAAO;AAEvB,QAAM,MAAmB;AAAA,IACvB,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAEA,SACE,2EACG,kBAAQ,IAAI,CAAC,EAAE,KAAK,GAAG,GAAG,KAAK,MAAM;AACpC,UAAM,WAAW,MAAM,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,GAAG;AAEhE,WACE,4CAAC,iCAA0B,MAAK,aAC9B;AAAA,MAAC,qBAAO;AAAA,MAAP;AAAA,QACC,eAAW,iBAAG,aAAa,SAAS;AAAA,QACpC,SAAS,EAAE,WAAW,YAAY,SAAS,KAAK;AAAA,QAChD,SAAS,EAAE,WAAW,YAAY,SAAS,EAAE;AAAA,QAC7C,MAAM,EAAE,SAAS,EAAE;AAAA,QACnB,YAAY,EAAE,SAAS;AAAA,QACvB,SAAS;AAAA,QACT,OAAO;AAAA,UACL,UAAU;AAAA,UACV,iBAAiB;AAAA,UACjB,eAAe;AAAA,UACf,MAAM;AAAA,UACN,KAAK;AAAA,UACL,OAAO,GAAG,IAAI;AAAA,UACd,QAAQ,GAAG,IAAI;AAAA,UACf,GAAG;AAAA,QACL;AAAA,QACA,OAAO;AAAA,QACN,GAAG;AAAA,QACJ,yBAAqB;AAAA,UAAW;AAAA,UAAqB,MACnD,QAAQ,GAAG;AAAA,QACb;AAAA;AAAA,IACF,KAvBoB,GAwBtB;AAAA,EAEJ,CAAC,GACH;AAEJ;AAEA,OAAO,cAAc;AACrB,OAAO,SAAS;","names":[]}
1
+ {"version":3,"sources":["../src/ripple.tsx"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport type { Key } from \"react\"\nimport type { RippleOptions } from \"./use-ripple\"\nimport { AnimatePresence, motion } from \"@yamada-ui/motion\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max)\n\nexport interface RippleProps extends MotionProps<\"span\"> {\n ripples: RippleOptions[]\n onClear: (key: Key) => void\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n isDisabled?: boolean\n}\n\n/**\n * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.\n *\n * @see Docs https://yamada-ui.com/components/other/ripple\n */\nexport const Ripple: FC<RippleProps> = ({\n className,\n style,\n color = \"currentColor\",\n isDisabled,\n ripples,\n onAnimationComplete,\n onClear,\n ...rest\n}) => {\n if (isDisabled) return null\n\n const css: CSSUIObject = {\n rounded: \"fallback(full, 9999px)\",\n zIndex: \"fallback(kurillin, 9)\",\n }\n\n return (\n <>\n {ripples.map(({ key, size, x, y }) => {\n const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5)\n\n return (\n <AnimatePresence key={key} mode=\"popLayout\">\n <motion.span\n className={cx(\"ui-ripple\", className)}\n style={{\n height: `${size}px`,\n left: x,\n pointerEvents: \"none\",\n position: \"absolute\",\n top: y,\n transformOrigin: \"center\",\n width: `${size}px`,\n ...style,\n }}\n animate={{ opacity: 0, transform: \"scale(2)\" }}\n bgColor={color}\n exit={{ opacity: 0 }}\n initial={{ opacity: 0.35, transform: \"scale(0)\" }}\n transition={{ duration }}\n __css={css}\n {...rest}\n onAnimationComplete={handlerAll(onAnimationComplete, () =>\n onClear(key),\n )}\n />\n </AnimatePresence>\n )\n })}\n </>\n )\n}\n\nRipple.displayName = \"Ripple\"\nRipple.__ui__ = \"Ripple\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,oBAAwC;AACxC,mBAA+B;AAuC3B;AArCJ,IAAM,QAAQ,CAAC,OAAe,KAAa,QACzC,KAAK,IAAI,KAAK,IAAI,OAAO,GAAG,GAAG,GAAG;AAkB7B,IAAM,SAA0B,CAAC;AAAA,EACtC;AAAA,EACA;AAAA,EACA,QAAQ;AAAA,EACR;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,GAAG;AACL,MAAM;AACJ,MAAI,WAAY,QAAO;AAEvB,QAAM,MAAmB;AAAA,IACvB,SAAS;AAAA,IACT,QAAQ;AAAA,EACV;AAEA,SACE,2EACG,kBAAQ,IAAI,CAAC,EAAE,KAAK,MAAM,GAAG,EAAE,MAAM;AACpC,UAAM,WAAW,MAAM,OAAO,MAAM,KAAK,OAAO,MAAM,OAAO,GAAG;AAEhE,WACE,4CAAC,iCAA0B,MAAK,aAC9B;AAAA,MAAC,qBAAO;AAAA,MAAP;AAAA,QACC,eAAW,iBAAG,aAAa,SAAS;AAAA,QACpC,OAAO;AAAA,UACL,QAAQ,GAAG,IAAI;AAAA,UACf,MAAM;AAAA,UACN,eAAe;AAAA,UACf,UAAU;AAAA,UACV,KAAK;AAAA,UACL,iBAAiB;AAAA,UACjB,OAAO,GAAG,IAAI;AAAA,UACd,GAAG;AAAA,QACL;AAAA,QACA,SAAS,EAAE,SAAS,GAAG,WAAW,WAAW;AAAA,QAC7C,SAAS;AAAA,QACT,MAAM,EAAE,SAAS,EAAE;AAAA,QACnB,SAAS,EAAE,SAAS,MAAM,WAAW,WAAW;AAAA,QAChD,YAAY,EAAE,SAAS;AAAA,QACvB,OAAO;AAAA,QACN,GAAG;AAAA,QACJ,yBAAqB;AAAA,UAAW;AAAA,UAAqB,MACnD,QAAQ,GAAG;AAAA,QACb;AAAA;AAAA,IACF,KAvBoB,GAwBtB;AAAA,EAEJ,CAAC,GACH;AAEJ;AAEA,OAAO,cAAc;AACrB,OAAO,SAAS;","names":[]}
package/dist/ripple.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  Ripple
4
- } from "./chunk-N2WO662B.mjs";
4
+ } from "./chunk-YH24ZFF2.mjs";
5
5
  export {
6
6
  Ripple
7
7
  };
@@ -2,19 +2,19 @@ import React, { PointerEventHandler, Key } from 'react';
2
2
 
3
3
  interface RippleOptions {
4
4
  key: React.Key;
5
+ size: number;
5
6
  x: number;
6
7
  y: number;
7
- size: number;
8
8
  }
9
- interface UseRippleProps<T extends any = HTMLElement> {
9
+ interface UseRippleProps<T = HTMLElement> {
10
10
  disabled?: boolean;
11
11
  isDisabled?: boolean;
12
12
  onPointerDown?: PointerEventHandler<T>;
13
13
  }
14
- declare const useRipple: <T extends unknown = HTMLElement>({ disabled, isDisabled, ...rest }?: UseRippleProps<T>) => {
14
+ declare const useRipple: <T = HTMLElement>({ disabled, isDisabled, ...rest }?: UseRippleProps<T>) => {
15
15
  ripples: RippleOptions[];
16
- onPointerDown: (event: React.PointerEvent<T>) => void;
17
16
  onClear: (key: Key) => void;
17
+ onPointerDown: (event: React.PointerEvent<T>) => void;
18
18
  };
19
19
  type UseRippleReturn = ReturnType<typeof useRipple>;
20
20
 
@@ -2,19 +2,19 @@ import React, { PointerEventHandler, Key } from 'react';
2
2
 
3
3
  interface RippleOptions {
4
4
  key: React.Key;
5
+ size: number;
5
6
  x: number;
6
7
  y: number;
7
- size: number;
8
8
  }
9
- interface UseRippleProps<T extends any = HTMLElement> {
9
+ interface UseRippleProps<T = HTMLElement> {
10
10
  disabled?: boolean;
11
11
  isDisabled?: boolean;
12
12
  onPointerDown?: PointerEventHandler<T>;
13
13
  }
14
- declare const useRipple: <T extends unknown = HTMLElement>({ disabled, isDisabled, ...rest }?: UseRippleProps<T>) => {
14
+ declare const useRipple: <T = HTMLElement>({ disabled, isDisabled, ...rest }?: UseRippleProps<T>) => {
15
15
  ripples: RippleOptions[];
16
- onPointerDown: (event: React.PointerEvent<T>) => void;
17
16
  onClear: (key: Key) => void;
17
+ onPointerDown: (event: React.PointerEvent<T>) => void;
18
18
  };
19
19
  type UseRippleReturn = ReturnType<typeof useRipple>;
20
20
 
@@ -55,8 +55,8 @@ var useRipple = ({
55
55
  }, []);
56
56
  return {
57
57
  ripples,
58
- onPointerDown: (0, import_utils.handlerAll)(onPointerDown, rest.onPointerDown),
59
- onClear
58
+ onClear,
59
+ onPointerDown: (0, import_utils.handlerAll)(onPointerDown, rest.onPointerDown)
60
60
  };
61
61
  };
62
62
  // Annotate the CommonJS export names for ESM import in node:
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/use-ripple.ts"],"sourcesContent":["import { createId, handlerAll } from \"@yamada-ui/utils\"\nimport type React from \"react\"\nimport type { Key, PointerEventHandler } from \"react\"\nimport { useCallback, useState } from \"react\"\n\nexport interface RippleOptions {\n key: React.Key\n x: number\n y: number\n size: number\n}\n\nexport interface UseRippleProps<T extends any = HTMLElement> {\n disabled?: boolean\n isDisabled?: boolean\n onPointerDown?: PointerEventHandler<T>\n}\n\nexport const useRipple = <T extends any = HTMLElement>({\n disabled,\n isDisabled,\n ...rest\n}: UseRippleProps<T> = {}) => {\n const [ripples, setRipples] = useState<RippleOptions[]>([])\n\n const onPointerDown: PointerEventHandler<T> = useCallback(\n (ev) => {\n if (disabled || isDisabled) return setRipples([])\n\n const trigger = ev.currentTarget as unknown as Element\n\n const size = Math.max(trigger.clientWidth, trigger.clientHeight)\n const rect = trigger.getBoundingClientRect()\n\n setRipples((prev) => [\n ...prev,\n {\n key: createId(prev.length.toString()),\n size,\n x: ev.clientX - rect.x - size / 2,\n y: ev.clientY - rect.y - size / 2,\n },\n ])\n },\n [disabled, isDisabled],\n )\n\n const onClear = useCallback((key: Key) => {\n setRipples((prev) => prev.filter((item) => item.key !== key))\n }, [])\n\n return {\n ripples,\n onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),\n onClear,\n }\n}\n\nexport type UseRippleReturn = ReturnType<typeof useRipple>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAqC;AAGrC,mBAAsC;AAe/B,IAAM,YAAY,CAA8B;AAAA,EACrD;AAAA,EACA;AAAA,EACA,GAAG;AACL,IAAuB,CAAC,MAAM;AAC5B,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA0B,CAAC,CAAC;AAE1D,QAAM,oBAAwC;AAAA,IAC5C,CAAC,OAAO;AACN,UAAI,YAAY,WAAY,QAAO,WAAW,CAAC,CAAC;AAEhD,YAAM,UAAU,GAAG;AAEnB,YAAM,OAAO,KAAK,IAAI,QAAQ,aAAa,QAAQ,YAAY;AAC/D,YAAM,OAAO,QAAQ,sBAAsB;AAE3C,iBAAW,CAAC,SAAS;AAAA,QACnB,GAAG;AAAA,QACH;AAAA,UACE,SAAK,uBAAS,KAAK,OAAO,SAAS,CAAC;AAAA,UACpC;AAAA,UACA,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,UAChC,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,cAAU,0BAAY,CAAC,QAAa;AACxC,eAAW,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,QAAQ,GAAG,CAAC;AAAA,EAC9D,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA,mBAAe,yBAAW,eAAe,KAAK,aAAa;AAAA,IAC3D;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/use-ripple.ts"],"sourcesContent":["import type React from \"react\"\nimport type { Key, PointerEventHandler } from \"react\"\nimport { createId, handlerAll } from \"@yamada-ui/utils\"\nimport { useCallback, useState } from \"react\"\n\nexport interface RippleOptions {\n key: React.Key\n size: number\n x: number\n y: number\n}\n\nexport interface UseRippleProps<T = HTMLElement> {\n disabled?: boolean\n isDisabled?: boolean\n onPointerDown?: PointerEventHandler<T>\n}\n\nexport const useRipple = <T = HTMLElement>({\n disabled,\n isDisabled,\n ...rest\n}: UseRippleProps<T> = {}) => {\n const [ripples, setRipples] = useState<RippleOptions[]>([])\n\n const onPointerDown: PointerEventHandler<T> = useCallback(\n (ev) => {\n if (disabled || isDisabled) return setRipples([])\n\n const trigger = ev.currentTarget as unknown as Element\n\n const size = Math.max(trigger.clientWidth, trigger.clientHeight)\n const rect = trigger.getBoundingClientRect()\n\n setRipples((prev) => [\n ...prev,\n {\n key: createId(prev.length.toString()),\n size,\n x: ev.clientX - rect.x - size / 2,\n y: ev.clientY - rect.y - size / 2,\n },\n ])\n },\n [disabled, isDisabled],\n )\n\n const onClear = useCallback((key: Key) => {\n setRipples((prev) => prev.filter((item) => item.key !== key))\n }, [])\n\n return {\n ripples,\n onClear,\n onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),\n }\n}\n\nexport type UseRippleReturn = ReturnType<typeof useRipple>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAqC;AACrC,mBAAsC;AAe/B,IAAM,YAAY,CAAkB;AAAA,EACzC;AAAA,EACA;AAAA,EACA,GAAG;AACL,IAAuB,CAAC,MAAM;AAC5B,QAAM,CAAC,SAAS,UAAU,QAAI,uBAA0B,CAAC,CAAC;AAE1D,QAAM,oBAAwC;AAAA,IAC5C,CAAC,OAAO;AACN,UAAI,YAAY,WAAY,QAAO,WAAW,CAAC,CAAC;AAEhD,YAAM,UAAU,GAAG;AAEnB,YAAM,OAAO,KAAK,IAAI,QAAQ,aAAa,QAAQ,YAAY;AAC/D,YAAM,OAAO,QAAQ,sBAAsB;AAE3C,iBAAW,CAAC,SAAS;AAAA,QACnB,GAAG;AAAA,QACH;AAAA,UACE,SAAK,uBAAS,KAAK,OAAO,SAAS,CAAC;AAAA,UACpC;AAAA,UACA,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,UAChC,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,cAAU,0BAAY,CAAC,QAAa;AACxC,eAAW,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,QAAQ,GAAG,CAAC;AAAA,EAC9D,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,mBAAe,yBAAW,eAAe,KAAK,aAAa;AAAA,EAC7D;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  "use client"
2
2
  import {
3
3
  useRipple
4
- } from "./chunk-QSFNYWP4.mjs";
4
+ } from "./chunk-7NWWPF2L.mjs";
5
5
  export {
6
6
  useRipple
7
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamada-ui/ripple",
3
- "version": "1.0.40-next-20241005235555",
3
+ "version": "1.0.40-next-20241008193728",
4
4
  "description": "Yamada UI ripple component",
5
5
  "keywords": [],
6
6
  "author": "Hirotomo Yamada <hirotomo.yamada@avap.co.jp>",
@@ -23,9 +23,9 @@
23
23
  "url": "https://github.com/yamada-ui/yamada-ui/issues"
24
24
  },
25
25
  "dependencies": {
26
- "@yamada-ui/core": "1.15.2-next-20241005235555",
27
- "@yamada-ui/motion": "2.2.4-next-20241005235555",
28
- "@yamada-ui/utils": "1.5.2"
26
+ "@yamada-ui/core": "1.15.2-next-20241008193728",
27
+ "@yamada-ui/motion": "2.2.4-next-20241008193728",
28
+ "@yamada-ui/utils": "1.5.3-next-20241008193728"
29
29
  },
30
30
  "devDependencies": {
31
31
  "clean-package": "2.2.0",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/ripple.tsx"],"sourcesContent":["import type { CSSUIObject, FC } from \"@yamada-ui/core\"\nimport { AnimatePresence, motion } from \"@yamada-ui/motion\"\nimport type { MotionProps } from \"@yamada-ui/motion\"\nimport { cx, handlerAll } from \"@yamada-ui/utils\"\nimport type { Key } from \"react\"\nimport type { RippleOptions } from \"./use-ripple\"\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max)\n\nexport interface RippleProps extends MotionProps<\"span\"> {\n /**\n * If `true`, disable ripple effects when pressing a element.\n *\n * @default false\n */\n isDisabled?: boolean\n ripples: RippleOptions[]\n onClear: (key: Key) => void\n}\n\n/**\n * `Ripple` is a component that adds a ripple effect to elements, allowing users to recognize when they have clicked.\n *\n * @see Docs https://yamada-ui.com/components/other/ripple\n */\nexport const Ripple: FC<RippleProps> = ({\n className,\n ripples,\n onAnimationComplete,\n onClear,\n color = \"currentColor\",\n style,\n isDisabled,\n ...rest\n}) => {\n if (isDisabled) return null\n\n const css: CSSUIObject = {\n rounded: \"fallback(full, 9999px)\",\n zIndex: \"fallback(kurillin, 9)\",\n }\n\n return (\n <>\n {ripples.map(({ key, x, y, size }) => {\n const duration = clamp(0.01 * size, 0.2, size > 100 ? 0.75 : 0.5)\n\n return (\n <AnimatePresence key={key} mode=\"popLayout\">\n <motion.span\n className={cx(\"ui-ripple\", className)}\n initial={{ transform: \"scale(0)\", opacity: 0.35 }}\n animate={{ transform: \"scale(2)\", opacity: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration }}\n bgColor={color}\n style={{\n position: \"absolute\",\n transformOrigin: \"center\",\n pointerEvents: \"none\",\n left: x,\n top: y,\n width: `${size}px`,\n height: `${size}px`,\n ...style,\n }}\n __css={css}\n {...rest}\n onAnimationComplete={handlerAll(onAnimationComplete, () =>\n onClear(key),\n )}\n />\n </AnimatePresence>\n )\n })}\n </>\n )\n}\n\nRipple.displayName = \"Ripple\"\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,OAAO,cAAc;AACrB,OAAO,SAAS;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/use-ripple.ts"],"sourcesContent":["import { createId, handlerAll } from \"@yamada-ui/utils\"\nimport type React from \"react\"\nimport type { Key, PointerEventHandler } from \"react\"\nimport { useCallback, useState } from \"react\"\n\nexport interface RippleOptions {\n key: React.Key\n x: number\n y: number\n size: number\n}\n\nexport interface UseRippleProps<T extends any = HTMLElement> {\n disabled?: boolean\n isDisabled?: boolean\n onPointerDown?: PointerEventHandler<T>\n}\n\nexport const useRipple = <T extends any = HTMLElement>({\n disabled,\n isDisabled,\n ...rest\n}: UseRippleProps<T> = {}) => {\n const [ripples, setRipples] = useState<RippleOptions[]>([])\n\n const onPointerDown: PointerEventHandler<T> = useCallback(\n (ev) => {\n if (disabled || isDisabled) return setRipples([])\n\n const trigger = ev.currentTarget as unknown as Element\n\n const size = Math.max(trigger.clientWidth, trigger.clientHeight)\n const rect = trigger.getBoundingClientRect()\n\n setRipples((prev) => [\n ...prev,\n {\n key: createId(prev.length.toString()),\n size,\n x: ev.clientX - rect.x - size / 2,\n y: ev.clientY - rect.y - size / 2,\n },\n ])\n },\n [disabled, isDisabled],\n )\n\n const onClear = useCallback((key: Key) => {\n setRipples((prev) => prev.filter((item) => item.key !== key))\n }, [])\n\n return {\n ripples,\n onPointerDown: handlerAll(onPointerDown, rest.onPointerDown),\n onClear,\n }\n}\n\nexport type UseRippleReturn = ReturnType<typeof useRipple>\n"],"mappings":";;;AAAA,SAAS,UAAU,kBAAkB;AAGrC,SAAS,aAAa,gBAAgB;AAe/B,IAAM,YAAY,CAA8B;AAAA,EACrD;AAAA,EACA;AAAA,EACA,GAAG;AACL,IAAuB,CAAC,MAAM;AAC5B,QAAM,CAAC,SAAS,UAAU,IAAI,SAA0B,CAAC,CAAC;AAE1D,QAAM,gBAAwC;AAAA,IAC5C,CAAC,OAAO;AACN,UAAI,YAAY,WAAY,QAAO,WAAW,CAAC,CAAC;AAEhD,YAAM,UAAU,GAAG;AAEnB,YAAM,OAAO,KAAK,IAAI,QAAQ,aAAa,QAAQ,YAAY;AAC/D,YAAM,OAAO,QAAQ,sBAAsB;AAE3C,iBAAW,CAAC,SAAS;AAAA,QACnB,GAAG;AAAA,QACH;AAAA,UACE,KAAK,SAAS,KAAK,OAAO,SAAS,CAAC;AAAA,UACpC;AAAA,UACA,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,UAChC,GAAG,GAAG,UAAU,KAAK,IAAI,OAAO;AAAA,QAClC;AAAA,MACF,CAAC;AAAA,IACH;AAAA,IACA,CAAC,UAAU,UAAU;AAAA,EACvB;AAEA,QAAM,UAAU,YAAY,CAAC,QAAa;AACxC,eAAW,CAAC,SAAS,KAAK,OAAO,CAAC,SAAS,KAAK,QAAQ,GAAG,CAAC;AAAA,EAC9D,GAAG,CAAC,CAAC;AAEL,SAAO;AAAA,IACL;AAAA,IACA,eAAe,WAAW,eAAe,KAAK,aAAa;AAAA,IAC3D;AAAA,EACF;AACF;","names":[]}