@kopexa/ripple 0.0.0-canary-20250718183330

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/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @kopexa/ripple
2
+
3
+ A Quick description of the component
4
+
5
+ > This is an internal utility, not intended for public usage.
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ yarn add @kopexa/ripple
11
+ # or
12
+ npm i @kopexa/ripple
13
+ ```
14
+
15
+ ## Contribution
16
+
17
+ Yes please! See the
18
+ [contributing guidelines](https://github.com/kopexa-grc/sight/blob/master/CONTRIBUTING.md)
19
+ for details.
20
+
21
+ ## License
22
+
23
+ This project is licensed under the terms of the
24
+ [MIT license](https://github.com/kopexa-grc/sight/blob/master/LICENSE).
@@ -0,0 +1,32 @@
1
+ "use client";
2
+
3
+ // src/use-ripple.ts
4
+ import { getUniqueID } from "@kopexa/shared-utils";
5
+ import { useCallback, useState } from "react";
6
+ function useRipple() {
7
+ const [ripples, setRipples] = useState([]);
8
+ const onClick = useCallback((event) => {
9
+ const trigger = event.target;
10
+ const size = Math.max(trigger.clientWidth, trigger.clientHeight);
11
+ const rect = trigger.getBoundingClientRect();
12
+ const x = event.clientX - rect.left - size / 2;
13
+ const y = event.clientY - rect.top - size / 2;
14
+ setRipples((prevRipples) => [
15
+ ...prevRipples,
16
+ {
17
+ key: getUniqueID(prevRipples.length.toString()),
18
+ size,
19
+ x,
20
+ y
21
+ }
22
+ ]);
23
+ }, []);
24
+ const onClear = useCallback((key) => {
25
+ setRipples((prevState) => prevState.filter((ripple) => ripple.key !== key));
26
+ }, []);
27
+ return { ripples, onClick, onClear };
28
+ }
29
+
30
+ export {
31
+ useRipple
32
+ };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+
3
+ // src/ripple.tsx
4
+ import { clamp } from "@kopexa/shared-utils";
5
+ import {
6
+ AnimatePresence,
7
+ domAnimation,
8
+ LazyMotion,
9
+ m
10
+ } from "motion/react";
11
+ import { Fragment, jsx } from "react/jsx-runtime";
12
+ var Ripple = (props) => {
13
+ const {
14
+ ripples = [],
15
+ motionProps,
16
+ color = "currentColor",
17
+ style,
18
+ onClear
19
+ } = props;
20
+ return /* @__PURE__ */ jsx(Fragment, { children: ripples.map((ripple) => {
21
+ const duration = clamp(
22
+ 0.01 * ripple.size,
23
+ 0.2,
24
+ ripple.size > 100 ? 0.75 : 0.5
25
+ );
26
+ return /* @__PURE__ */ jsx(LazyMotion, { features: domAnimation, children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ jsx(
27
+ m.span,
28
+ {
29
+ animate: { transform: "scale(2)", opacity: 0 },
30
+ exit: { opacity: 0 },
31
+ initial: { transform: "scale(0)", opacity: 0.35 },
32
+ style: {
33
+ position: "absolute",
34
+ backgroundColor: color,
35
+ borderRadius: "100%",
36
+ transformOrigin: "center",
37
+ pointerEvents: "none",
38
+ overflow: "hidden",
39
+ inset: 0,
40
+ zIndex: 0,
41
+ top: ripple.y,
42
+ left: ripple.x,
43
+ width: `${ripple.size}px`,
44
+ height: `${ripple.size}px`,
45
+ ...style
46
+ },
47
+ transition: { duration },
48
+ onAnimationComplete: () => {
49
+ onClear(ripple.key);
50
+ },
51
+ ...motionProps
52
+ }
53
+ ) }) }, ripple.key);
54
+ }) });
55
+ };
56
+
57
+ export {
58
+ Ripple
59
+ };
@@ -0,0 +1,5 @@
1
+ export { Ripple, RippleProps } from './ripple.mjs';
2
+ export { useRipple } from './use-ripple.mjs';
3
+ import 'react/jsx-runtime';
4
+ import 'motion/react';
5
+ import 'react';
@@ -0,0 +1,5 @@
1
+ export { Ripple, RippleProps } from './ripple.js';
2
+ export { useRipple } from './use-ripple.js';
3
+ import 'react/jsx-runtime';
4
+ import 'motion/react';
5
+ import 'react';
package/dist/index.js ADDED
@@ -0,0 +1,108 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/index.ts
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
+ Ripple: () => Ripple,
25
+ useRipple: () => useRipple
26
+ });
27
+ module.exports = __toCommonJS(index_exports);
28
+
29
+ // src/ripple.tsx
30
+ var import_shared_utils = require("@kopexa/shared-utils");
31
+ var import_react = require("motion/react");
32
+ var import_jsx_runtime = require("react/jsx-runtime");
33
+ var Ripple = (props) => {
34
+ const {
35
+ ripples = [],
36
+ motionProps,
37
+ color = "currentColor",
38
+ style,
39
+ onClear
40
+ } = props;
41
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ripples.map((ripple) => {
42
+ const duration = (0, import_shared_utils.clamp)(
43
+ 0.01 * ripple.size,
44
+ 0.2,
45
+ ripple.size > 100 ? 0.75 : 0.5
46
+ );
47
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.LazyMotion, { features: import_react.domAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
48
+ import_react.m.span,
49
+ {
50
+ animate: { transform: "scale(2)", opacity: 0 },
51
+ exit: { opacity: 0 },
52
+ initial: { transform: "scale(0)", opacity: 0.35 },
53
+ style: {
54
+ position: "absolute",
55
+ backgroundColor: color,
56
+ borderRadius: "100%",
57
+ transformOrigin: "center",
58
+ pointerEvents: "none",
59
+ overflow: "hidden",
60
+ inset: 0,
61
+ zIndex: 0,
62
+ top: ripple.y,
63
+ left: ripple.x,
64
+ width: `${ripple.size}px`,
65
+ height: `${ripple.size}px`,
66
+ ...style
67
+ },
68
+ transition: { duration },
69
+ onAnimationComplete: () => {
70
+ onClear(ripple.key);
71
+ },
72
+ ...motionProps
73
+ }
74
+ ) }) }, ripple.key);
75
+ }) });
76
+ };
77
+
78
+ // src/use-ripple.ts
79
+ var import_shared_utils2 = require("@kopexa/shared-utils");
80
+ var import_react2 = require("react");
81
+ function useRipple() {
82
+ const [ripples, setRipples] = (0, import_react2.useState)([]);
83
+ const onClick = (0, import_react2.useCallback)((event) => {
84
+ const trigger = event.target;
85
+ const size = Math.max(trigger.clientWidth, trigger.clientHeight);
86
+ const rect = trigger.getBoundingClientRect();
87
+ const x = event.clientX - rect.left - size / 2;
88
+ const y = event.clientY - rect.top - size / 2;
89
+ setRipples((prevRipples) => [
90
+ ...prevRipples,
91
+ {
92
+ key: (0, import_shared_utils2.getUniqueID)(prevRipples.length.toString()),
93
+ size,
94
+ x,
95
+ y
96
+ }
97
+ ]);
98
+ }, []);
99
+ const onClear = (0, import_react2.useCallback)((key) => {
100
+ setRipples((prevState) => prevState.filter((ripple) => ripple.key !== key));
101
+ }, []);
102
+ return { ripples, onClick, onClear };
103
+ }
104
+ // Annotate the CommonJS export names for ESM import in node:
105
+ 0 && (module.exports = {
106
+ Ripple,
107
+ useRipple
108
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,11 @@
1
+ "use client";
2
+ import {
3
+ Ripple
4
+ } from "./chunk-FVH6YPZP.mjs";
5
+ import {
6
+ useRipple
7
+ } from "./chunk-B6V7GEJQ.mjs";
8
+ export {
9
+ Ripple,
10
+ useRipple
11
+ };
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { HTMLMotionProps } from 'motion/react';
3
+ import { RippleType } from './use-ripple.mjs';
4
+ import 'react';
5
+
6
+ type RippleProps = {
7
+ ripples: RippleType[];
8
+ color?: string;
9
+ style?: React.CSSProperties;
10
+ onClear: (key: React.Key) => void;
11
+ motionProps?: Omit<HTMLMotionProps<"span">, "ref">;
12
+ };
13
+ declare const Ripple: (props: RippleProps) => react_jsx_runtime.JSX.Element;
14
+
15
+ export { Ripple, type RippleProps };
@@ -0,0 +1,15 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { HTMLMotionProps } from 'motion/react';
3
+ import { RippleType } from './use-ripple.js';
4
+ import 'react';
5
+
6
+ type RippleProps = {
7
+ ripples: RippleType[];
8
+ color?: string;
9
+ style?: React.CSSProperties;
10
+ onClear: (key: React.Key) => void;
11
+ motionProps?: Omit<HTMLMotionProps<"span">, "ref">;
12
+ };
13
+ declare const Ripple: (props: RippleProps) => react_jsx_runtime.JSX.Element;
14
+
15
+ export { Ripple, type RippleProps };
package/dist/ripple.js ADDED
@@ -0,0 +1,77 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/ripple.tsx
22
+ var ripple_exports = {};
23
+ __export(ripple_exports, {
24
+ Ripple: () => Ripple
25
+ });
26
+ module.exports = __toCommonJS(ripple_exports);
27
+ var import_shared_utils = require("@kopexa/shared-utils");
28
+ var import_react = require("motion/react");
29
+ var import_jsx_runtime = require("react/jsx-runtime");
30
+ var Ripple = (props) => {
31
+ const {
32
+ ripples = [],
33
+ motionProps,
34
+ color = "currentColor",
35
+ style,
36
+ onClear
37
+ } = props;
38
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: ripples.map((ripple) => {
39
+ const duration = (0, import_shared_utils.clamp)(
40
+ 0.01 * ripple.size,
41
+ 0.2,
42
+ ripple.size > 100 ? 0.75 : 0.5
43
+ );
44
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.LazyMotion, { features: import_react.domAnimation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.AnimatePresence, { mode: "popLayout", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
+ import_react.m.span,
46
+ {
47
+ animate: { transform: "scale(2)", opacity: 0 },
48
+ exit: { opacity: 0 },
49
+ initial: { transform: "scale(0)", opacity: 0.35 },
50
+ style: {
51
+ position: "absolute",
52
+ backgroundColor: color,
53
+ borderRadius: "100%",
54
+ transformOrigin: "center",
55
+ pointerEvents: "none",
56
+ overflow: "hidden",
57
+ inset: 0,
58
+ zIndex: 0,
59
+ top: ripple.y,
60
+ left: ripple.x,
61
+ width: `${ripple.size}px`,
62
+ height: `${ripple.size}px`,
63
+ ...style
64
+ },
65
+ transition: { duration },
66
+ onAnimationComplete: () => {
67
+ onClear(ripple.key);
68
+ },
69
+ ...motionProps
70
+ }
71
+ ) }) }, ripple.key);
72
+ }) });
73
+ };
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ Ripple
77
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ Ripple
4
+ } from "./chunk-FVH6YPZP.mjs";
5
+ export {
6
+ Ripple
7
+ };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ type RippleType = {
4
+ key: React.Key;
5
+ x: number;
6
+ y: number;
7
+ size: number;
8
+ };
9
+ declare function useRipple(): {
10
+ ripples: RippleType[];
11
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
12
+ onClear: (key: React.Key) => void;
13
+ };
14
+
15
+ export { type RippleType, useRipple };
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+
3
+ type RippleType = {
4
+ key: React.Key;
5
+ x: number;
6
+ y: number;
7
+ size: number;
8
+ };
9
+ declare function useRipple(): {
10
+ ripples: RippleType[];
11
+ onClick: (event: React.MouseEvent<HTMLElement>) => void;
12
+ onClear: (key: React.Key) => void;
13
+ };
14
+
15
+ export { type RippleType, useRipple };
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/use-ripple.ts
22
+ var use_ripple_exports = {};
23
+ __export(use_ripple_exports, {
24
+ useRipple: () => useRipple
25
+ });
26
+ module.exports = __toCommonJS(use_ripple_exports);
27
+ var import_shared_utils = require("@kopexa/shared-utils");
28
+ var import_react = require("react");
29
+ function useRipple() {
30
+ const [ripples, setRipples] = (0, import_react.useState)([]);
31
+ const onClick = (0, import_react.useCallback)((event) => {
32
+ const trigger = event.target;
33
+ const size = Math.max(trigger.clientWidth, trigger.clientHeight);
34
+ const rect = trigger.getBoundingClientRect();
35
+ const x = event.clientX - rect.left - size / 2;
36
+ const y = event.clientY - rect.top - size / 2;
37
+ setRipples((prevRipples) => [
38
+ ...prevRipples,
39
+ {
40
+ key: (0, import_shared_utils.getUniqueID)(prevRipples.length.toString()),
41
+ size,
42
+ x,
43
+ y
44
+ }
45
+ ]);
46
+ }, []);
47
+ const onClear = (0, import_react.useCallback)((key) => {
48
+ setRipples((prevState) => prevState.filter((ripple) => ripple.key !== key));
49
+ }, []);
50
+ return { ripples, onClick, onClear };
51
+ }
52
+ // Annotate the CommonJS export names for ESM import in node:
53
+ 0 && (module.exports = {
54
+ useRipple
55
+ });
@@ -0,0 +1,7 @@
1
+ "use client";
2
+ import {
3
+ useRipple
4
+ } from "./chunk-B6V7GEJQ.mjs";
5
+ export {
6
+ useRipple
7
+ };
package/package.json ADDED
@@ -0,0 +1,55 @@
1
+ {
2
+ "name": "@kopexa/ripple",
3
+ "version": "0.0.0-canary-20250718183330",
4
+ "description": "",
5
+ "keywords": [
6
+ "ripple"
7
+ ],
8
+ "author": "Kopexa <hello@kopexa.com>",
9
+ "homepage": "https://kopexa.com",
10
+ "license": "MIT",
11
+ "main": "dist/index.js",
12
+ "sideEffects": false,
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/kopexa-grc/sight.git",
22
+ "directory": "packages/components/ripple"
23
+ },
24
+ "bugs": {
25
+ "url": "https://github.com/kopexa-grc/sight/issues"
26
+ },
27
+ "peerDependencies": {
28
+ "react": ">=19.0.0-rc.0",
29
+ "react-dom": ">=19.0.0-rc.0",
30
+ "motion": ">=12.23.6",
31
+ "@kopexa/theme": "0.0.0-canary-20250718183330"
32
+ },
33
+ "dependencies": {
34
+ "@kopexa/react-utils": "0.0.0-canary-20250718183330",
35
+ "@kopexa/shared-utils": "0.0.0-canary-20250718183330"
36
+ },
37
+ "clean-package": "../../../clean-package.config.json",
38
+ "module": "dist/index.mjs",
39
+ "types": "dist/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.mjs",
44
+ "require": "./dist/index.js"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "scripts": {
49
+ "build": "tsup src --dts",
50
+ "build:fast": "tsup src",
51
+ "dev": "pnpm build:fast --watch",
52
+ "clean": "rimraf dist .turbo",
53
+ "typecheck": "tsc --noEmit"
54
+ }
55
+ }