m3-ripple 1.1.1 → 1.1.3

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/CHANGELOG.md CHANGED
@@ -1,4 +1,15 @@
1
- # 1.1.1 - 30 Dec
1
+ # 1.1.3 - 3 Jan 2026
2
+ Fix:
3
+ - remove `overflow-hidden` from ripple to prevent missing ripple effect on Safari
4
+
5
+ # 1.1.2 - 2 Jan 2026
6
+ Improvement:
7
+ - add `--ripple-color` to set default ripple color
8
+
9
+ Fix:
10
+ - default ripple to center when using keyboard event
11
+
12
+ # 1.1.1 - 30 Dec 2025
2
13
  Fix:
3
14
  - ripple sharing element
4
15
 
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),r=require("react"),U=.2,Z=12,J=75,K=.35,Q="forwards",V=({hoverOpacity:P,pressedOpacity:E,disabled:a=!1,className:w="",style:X,easing:k,duration:f=150,minimumPressDuration:C=225,touchDelay:g=150})=>{const[Y,A]=r.useState(!1),[D,I]=r.useState(!1),o=r.useRef(null),x=r.useRef(null),m=r.useRef(""),v=r.useRef(""),S=r.useRef(0),y=r.useRef(void 0),s=r.useRef(0),R=r.useRef(void 0),T=r.useRef(!1);r.useEffect(()=>{if(!x.current)return;const e=x.current.style;P!==void 0&&e.setProperty("--ripple-hover-opacity",P+""),E!==void 0&&e.setProperty("--ripple-pressed-opacity",E+""),f!==void 0&&f!==150&&e.setProperty("--ripple-duration",f+"ms")},[P,E,f]),r.useEffect(()=>{var c;const e=(c=o.current)==null?void 0:c.parentElement;if(!e)return;const t=(n,l)=>e.addEventListener(n,l,!0);return t("click",G),t("contextmenu",F),t("pointercancel",q),t("pointerdown",j),t("pointerenter",$),t("pointerleave",B),t("pointerup",L),()=>{const n=(l,d)=>e.removeEventListener(l,d,!0);n("click",G),n("contextmenu",F),n("pointercancel",q),n("pointerdown",j),n("pointerenter",$),n("pointerleave",B),n("pointerup",L)}},[a,k,f,C,g]);const h=r.useCallback(({pointerType:e})=>e==="touch",[]),u=r.useCallback(e=>{var c,n;if(a||(n=(c=o.current)==null?void 0:c.parentElement)!=null&&n.disabled||!e.isPrimary||R.current&&R.current.pointerId!==e.pointerId)return!1;if(e.type==="pointerenter"||e.type==="pointerleave")return!h(e);const t=e.buttons===1;return h(e)||t},[a,h]),M=r.useCallback(({x:e,y:t})=>{const c=o.current;if(!c)return!1;const n=c.getBoundingClientRect();return e>=n.left&&e<=n.right&&t>=n.top&&t<=n.bottom},[o]),$=r.useCallback(e=>{u(e)&&A(!0)},[u]),N=r.useCallback(()=>{const e=o.current;if(!e)return;const{height:t,width:c}=e.getBoundingClientRect(),n=Math.max(t,c),l=Math.max(K*n,J),d=Math.floor(n*U),H=Math.sqrt(c**2+t**2)+Z;S.current=d,v.current=(H+l)/d+"",m.current=d+"px"},[o]),_=r.useCallback(e=>{const t=o.current;if(!t)return{x:0,y:0};const c=t.getBoundingClientRect(),n=window.scrollX+c.left,l=window.scrollY+c.top;return{x:e.pageX-n,y:e.pageY-l}},[o]),z=r.useCallback(e=>{const t=o.current.parentElement;if(!t)return{startPoint:{x:0,y:0},endPoint:{x:0,y:0}};const c=t.getBoundingClientRect(),n={x:(c.width-S.current)/2,y:(c.height-S.current)/2};return{startPoint:_(e),endPoint:n}},[o,_]),p=r.useCallback(e=>{var b;const t=x.current;if(!t)return;I(!0),(b=y.current)==null||b.cancel(),N();const{startPoint:c,endPoint:n}=z(e),l=`${c.x}px, ${c.y}px`,d=`${n.x}px, ${n.y}px`;y.current=t.animate({height:[m.current,m.current],width:[m.current,m.current],transform:[`translate(${l}) scale(1)`,`translate(${d}) scale(${v.current})`]},{pseudoElement:"::after",duration:f,easing:k,fill:Q})},[N,f,k,z]),i=r.useCallback(()=>{R.current=void 0,s.current=0;const e=y.current;let t=1/0;if(typeof(e==null?void 0:e.currentTime)=="number"?t=e.currentTime:e!=null&&e.currentTime&&(t=e.currentTime.to("ms").value),t>=C)return void I(!1);setTimeout(()=>{y.current===e&&I(!1)},C-t)},[C]),B=r.useCallback(e=>{u(e)&&(A(!1),s.current!==0&&i())},[i,u]),L=r.useCallback(e=>{if(u(e)){if(s.current===2){s.current=3;return}if(s.current===1){s.current=3,p(R.current);return}}},[u,p]),j=r.useCallback(async e=>{if(u(e)){if(R.current=e,!h(e)){s.current=3,p(e);return}T.current&&!M(e)||(T.current=!1,s.current=1,await new Promise(t=>{setTimeout(t,g)}),s.current===1&&(s.current=2,p(e)))}},[u,h,M,p,g]),G=r.useCallback(()=>{if(!a){if(s.current===3){i();return}s.current===0&&(p(),i())}},[a,i,p]),q=r.useCallback(e=>{u(e)&&i()},[i,u]),F=r.useCallback(()=>{a||(T.current=!0,i())},[a,i]);return O.jsx("div",{ref:o,className:`salty-ripple${w?` ${w}`:""}`,style:X,"aria-hidden":"true",children:O.jsx("div",{ref:x,className:`salty-ripple-surface${Y?" --hover":""}${D?" --press":""}`})})};exports.Ripple=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Y=require("react/jsx-runtime"),n=require("react"),j=.2,q=12,X=75,Z=.35,s={INACTIVE:0,TOUCH_DELAY:1,HOLDING:2,WAITING_FOR_CLICK:3},J=({hoverOpacity:A,pressedOpacity:x,disabled:f=!1,className:S="",style:K,easing:_,duration:p=150,minimumPressDuration:T=225,touchDelay:N=150})=>{const[U,L]=n.useState(!1),[V,y]=n.useState(!1),i=n.useRef(null),h=n.useRef(null),I=n.useRef(""),b=n.useRef(""),P=n.useRef(0),E=n.useRef(void 0),o=n.useRef(s.INACTIVE),R=n.useRef(void 0),k=n.useRef(!1);n.useEffect(()=>{if(!h.current)return;const e=h.current.style;A!==void 0&&e.setProperty("--ripple-hover-opacity",A+""),x!==void 0&&e.setProperty("--ripple-pressed-opacity",x+""),p!==void 0&&p!==150&&e.setProperty("--ripple-duration",p+"ms")},[A,x,p]),n.useEffect(()=>{var c;const e=(c=i.current)==null?void 0:c.parentElement;if(!e)return;const t=(r,u)=>e.addEventListener(r,u,!0);return t("click",z),t("contextmenu",F),t("pointercancel",B),t("pointerdown",H),t("pointerenter",w),t("pointerleave",M),t("pointerup",D),()=>{const r=(u,d)=>e.removeEventListener(u,d,!0);r("click",z),r("contextmenu",F),r("pointercancel",B),r("pointerdown",H),r("pointerenter",w),r("pointerleave",M),r("pointerup",D)}},[f,_,p,T,N]);const m=n.useCallback(({pointerType:e})=>e==="touch",[]),l=n.useCallback(e=>{var c,r;if(f||(r=(c=i.current)==null?void 0:c.parentElement)!=null&&r.disabled||!e.isPrimary||R.current&&R.current.pointerId!==e.pointerId)return!1;if(e.type==="pointerenter"||e.type==="pointerleave")return!m(e);const t=e.buttons===1;return m(e)||t},[f,m]),O=n.useCallback(({x:e,y:t})=>{const c=i.current;if(!c)return!1;const r=c.getBoundingClientRect();return e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom},[i]),w=n.useCallback(e=>{l(e)&&L(!0)},[l]),G=n.useCallback(()=>{const e=i.current;if(!e)return;const{height:t,width:c}=e.getBoundingClientRect(),r=Math.max(t,c),u=Math.max(Z*r,X),d=Math.floor(r*j),W=Math.sqrt(c**2+t**2)+q;P.current=d,b.current=(W+u)/d+"",I.current=d+"px"},[i]),$=n.useCallback(e=>{const t=i.current;if(!t)return{x:0,y:0};const c=t.getBoundingClientRect(),r=window.scrollX+c.left,u=window.scrollY+c.top;return{x:e.pageX-r,y:e.pageY-u}},[i]),v=n.useCallback(e=>{var u;const t=(u=i.current)==null?void 0:u.parentElement;if(!t)return{startPoint:{x:0,y:0},endPoint:{x:0,y:0}};const c=t.getBoundingClientRect(),r={x:(c.width-P.current)/2,y:(c.height-P.current)/2};return{startPoint:e?$(e):r,endPoint:r}},[i,$]),C=n.useCallback(e=>{var g;const t=h.current;if(!t)return;y(!0),(g=E.current)==null||g.cancel(),G();const{startPoint:c,endPoint:r}=v(e),u=`${c.x}px,${c.y}px`,d=`${r.x}px,${r.y}px`;E.current=t.animate({height:[I.current,I.current],width:[I.current,I.current],transform:[`translate(${u}) scale(1)`,`translate(${d}) scale(${b.current})`]},{pseudoElement:"::after",duration:p,easing:_,fill:"forwards"})},[G,p,_,v]),a=n.useCallback(()=>{R.current=void 0,o.current=s.INACTIVE;const e=E.current;let t=1/0;if(typeof(e==null?void 0:e.currentTime)=="number"?t=e.currentTime:e!=null&&e.currentTime&&(t=e.currentTime.to("ms").value),t>=T)return void y(!1);setTimeout(()=>{E.current===e&&y(!1)},T-t)},[T]),M=n.useCallback(e=>{l(e)&&(L(!1),o.current!==s.INACTIVE&&a())},[a,l]),D=n.useCallback(e=>{if(l(e)){if(o.current===s.HOLDING){o.current=s.WAITING_FOR_CLICK;return}if(o.current===s.TOUCH_DELAY){o.current=s.WAITING_FOR_CLICK,C(R.current);return}}},[l,C]),H=n.useCallback(e=>{if(l(e)){if(R.current=e,!m(e)){o.current=s.WAITING_FOR_CLICK,C(e);return}k.current&&!O(e)||(k.current=!1,o.current=s.TOUCH_DELAY,setTimeout(()=>{o.current===s.TOUCH_DELAY&&(o.current=s.HOLDING,C(e))},N))}},[l,m,O,C,N]),z=n.useCallback(e=>{if(!f){if(o.current===s.WAITING_FOR_CLICK){a();return}o.current===s.INACTIVE&&(C(e),a())}},[f,a,C]),B=n.useCallback(e=>{l(e)&&a()},[a,l]),F=n.useCallback(()=>{f||(k.current=!0,a())},[f,a]);return Y.jsx("div",{ref:i,className:`salty-ripple${S?` ${S}`:""}`,style:K,"aria-hidden":"true",children:Y.jsx("div",{ref:h,className:`salty-ripple-surface${U?" --hover":""}${V?" --press":""}`})})};exports.Ripple=J;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAQA,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAE3B;;OAEG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAA;IAErC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AA+CD;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,kHAUpB,WAAW,4CAqVb,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAOA,MAAM,WAAW,WAAW;IACxB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAA;IAE3B;;OAEG;IACH,MAAM,CAAC,EAAE,4BAA4B,CAAA;IAErC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAA;IAEjB;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAA;IAE7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB;AA+CD;;GAEG;AACH,eAAO,MAAM,MAAM,GAAI,kHAUpB,WAAW,4CAyVb,CAAA"}
package/dist/index.js CHANGED
@@ -1,196 +1,231 @@
1
- import { jsx as q } from "react/jsx-runtime";
2
- import { useState as D, useRef as f, useEffect as H, useCallback as o } from "react";
3
- const Q = 0.2, V = 12, W = 75, b = 0.35, ee = "forwards", ne = ({
4
- hoverOpacity: I,
5
- pressedOpacity: g,
6
- disabled: a = !1,
7
- className: v = "",
8
- style: U,
9
- easing: T,
10
- duration: p = 150,
11
- minimumPressDuration: P = 225,
12
- touchDelay: w = 150
1
+ import { jsx as U } from "react/jsx-runtime";
2
+ import { useState as V, useRef as a, useEffect as W, useCallback as o } from "react";
3
+ const J = 0.2, Q = 12, b = 75, tt = 0.35, c = {
4
+ /**
5
+ * Initial state of the control, no touch in progress.
6
+ *
7
+ * Transitions:
8
+ * - on touch down: transition to `TOUCH_DELAY`.
9
+ * - on mouse down: transition to `WAITING_FOR_CLICK`.
10
+ */
11
+ INACTIVE: 0,
12
+ /**
13
+ * Touch down has been received, waiting to determine if it's a swipe or
14
+ * scroll.
15
+ *
16
+ * Transitions:
17
+ * - on touch up: begin press; transition to `WAITING_FOR_CLICK`.
18
+ * - on cancel: transition to `INACTIVE`.
19
+ * - after `TOUCH_DELAY_MS`: begin press; transition to `HOLDING`.
20
+ */
21
+ TOUCH_DELAY: 1,
22
+ /**
23
+ * A touch has been deemed to be a press
24
+ *
25
+ * Transitions:
26
+ * - on up: transition to `WAITING_FOR_CLICK`.
27
+ */
28
+ HOLDING: 2,
29
+ /**
30
+ * The user touch has finished, transition into rest state.
31
+ *
32
+ * Transitions:
33
+ * - on click end press; transition to `INACTIVE`.
34
+ */
35
+ WAITING_FOR_CLICK: 3
36
+ }, nt = ({
37
+ hoverOpacity: _,
38
+ pressedOpacity: x,
39
+ disabled: p = !1,
40
+ className: O = "",
41
+ style: X,
42
+ easing: N,
43
+ duration: d = 150,
44
+ minimumPressDuration: E = 225,
45
+ touchDelay: P = 150
13
46
  }) => {
14
- const [Z, M] = D(!1), [J, S] = D(!1), s = f(null), y = f(null), h = f(""), N = f(""), C = f(0), E = f(void 0), c = f(
15
- 0
16
- /* INACTIVE */
17
- ), x = f(void 0), A = f(!1);
18
- H(() => {
19
- if (!y.current) return;
20
- const e = y.current.style;
21
- I !== void 0 && e.setProperty("--ripple-hover-opacity", I + ""), g !== void 0 && e.setProperty("--ripple-pressed-opacity", g + ""), p !== void 0 && p !== 150 && e.setProperty("--ripple-duration", p + "ms");
22
- }, [I, g, p]), H(() => {
47
+ const [j, w] = V(!1), [q, y] = V(!1), u = a(null), R = a(null), C = a(""), G = a(""), L = a(0), A = a(void 0), s = a(c.INACTIVE), h = a(void 0), g = a(!1);
48
+ W(() => {
49
+ if (!R.current) return;
50
+ const t = R.current.style;
51
+ _ !== void 0 && t.setProperty("--ripple-hover-opacity", _ + ""), x !== void 0 && t.setProperty("--ripple-pressed-opacity", x + ""), d !== void 0 && d !== 150 && t.setProperty("--ripple-duration", d + "ms");
52
+ }, [_, x, d]), W(() => {
23
53
  var n;
24
- const e = (n = s.current) == null ? void 0 : n.parentElement;
25
- if (!e) return;
26
- const t = (r, l) => e.addEventListener(r, l, !0);
27
- return t("click", Y), t("contextmenu", j), t("pointercancel", O), t("pointerdown", X), t("pointerenter", z), t("pointerleave", G), t("pointerup", F), () => {
28
- const r = (l, m) => e.removeEventListener(l, m, !0);
29
- r("click", Y), r("contextmenu", j), r("pointercancel", O), r("pointerdown", X), r("pointerenter", z), r("pointerleave", G), r("pointerup", F);
54
+ const t = (n = u.current) == null ? void 0 : n.parentElement;
55
+ if (!t) return;
56
+ const e = (r, i) => t.addEventListener(r, i, !0);
57
+ return e("click", Y), e("contextmenu", K), e("pointercancel", k), e("pointerdown", F), e("pointerenter", v), e("pointerleave", z), e("pointerup", B), () => {
58
+ const r = (i, m) => t.removeEventListener(i, m, !0);
59
+ r("click", Y), r("contextmenu", K), r("pointercancel", k), r("pointerdown", F), r("pointerenter", v), r("pointerleave", z), r("pointerup", B);
30
60
  };
31
- }, [a, T, p, P, w]);
32
- const R = o(
33
- ({ pointerType: e }) => e === "touch",
61
+ }, [p, N, d, E, P]);
62
+ const T = o(
63
+ ({ pointerType: t }) => t === "touch",
34
64
  []
35
- ), i = o(
36
- (e) => {
65
+ ), l = o(
66
+ (t) => {
37
67
  var n, r;
38
- if (a || // @ts-ignore
39
- (r = (n = s.current) == null ? void 0 : n.parentElement) != null && r.disabled || !e.isPrimary || x.current && x.current.pointerId !== e.pointerId)
68
+ if (p || // @ts-ignore
69
+ (r = (n = u.current) == null ? void 0 : n.parentElement) != null && r.disabled || !t.isPrimary || h.current && h.current.pointerId !== t.pointerId)
40
70
  return !1;
41
- if (e.type === "pointerenter" || e.type === "pointerleave")
42
- return !R(e);
43
- const t = e.buttons === 1;
44
- return R(e) || t;
71
+ if (t.type === "pointerenter" || t.type === "pointerleave")
72
+ return !T(t);
73
+ const e = t.buttons === 1;
74
+ return T(t) || e;
45
75
  },
46
- [a, R]
47
- ), _ = o(
76
+ [p, T]
77
+ ), $ = o(
48
78
  // @ts-ignore
49
- ({ x: e, y: t }) => {
50
- const n = s.current;
79
+ ({ x: t, y: e }) => {
80
+ const n = u.current;
51
81
  if (!n) return !1;
52
82
  const r = n.getBoundingClientRect();
53
- return e >= r.left && e <= r.right && t >= r.top && t <= r.bottom;
83
+ return t >= r.left && t <= r.right && e >= r.top && e <= r.bottom;
54
84
  },
55
- [s]
56
- ), z = o(
57
- (e) => {
58
- i(e) && M(!0);
85
+ [u]
86
+ ), v = o(
87
+ (t) => {
88
+ l(t) && w(!0);
59
89
  },
60
- [i]
61
- ), B = o(() => {
62
- const e = s.current;
63
- if (!e) return;
64
- const { height: t, width: n } = e.getBoundingClientRect(), r = Math.max(t, n), l = Math.max(
65
- b * r,
66
- W
67
- ), m = Math.floor(r * Q), K = Math.sqrt(n ** 2 + t ** 2) + V;
68
- C.current = m, N.current = (K + l) / m + "", h.current = m + "px";
69
- }, [s]), L = o(
70
- (e) => {
71
- const t = s.current;
72
- if (!t) return { x: 0, y: 0 };
73
- const n = t.getBoundingClientRect(), r = window.scrollX + n.left, l = window.scrollY + n.top;
90
+ [l]
91
+ ), M = o(() => {
92
+ const t = u.current;
93
+ if (!t) return;
94
+ const { height: e, width: n } = t.getBoundingClientRect(), r = Math.max(e, n), i = Math.max(
95
+ tt * r,
96
+ b
97
+ ), m = Math.floor(r * J), Z = Math.sqrt(n ** 2 + e ** 2) + Q;
98
+ L.current = m, G.current = (Z + i) / m + "", C.current = m + "px";
99
+ }, [u]), D = o(
100
+ (t) => {
101
+ const e = u.current;
102
+ if (!e) return { x: 0, y: 0 };
103
+ const n = e.getBoundingClientRect(), r = window.scrollX + n.left, i = window.scrollY + n.top;
74
104
  return {
75
- x: e.pageX - r,
76
- y: e.pageY - l
105
+ x: t.pageX - r,
106
+ y: t.pageY - i
77
107
  };
78
108
  },
79
- [s]
80
- ), k = o(
81
- (e) => {
82
- const t = s.current.parentElement;
83
- if (!t)
109
+ [u]
110
+ ), H = o(
111
+ (t) => {
112
+ var i;
113
+ const e = (i = u.current) == null ? void 0 : i.parentElement;
114
+ if (!e)
84
115
  return { startPoint: { x: 0, y: 0 }, endPoint: { x: 0, y: 0 } };
85
- const n = t.getBoundingClientRect(), r = {
86
- x: (n.width - C.current) / 2,
87
- y: (n.height - C.current) / 2
116
+ const n = e.getBoundingClientRect(), r = {
117
+ x: (n.width - L.current) / 2,
118
+ y: (n.height - L.current) / 2
88
119
  };
89
120
  return {
90
- startPoint: L(e),
121
+ // If using keyboard, start in the center
122
+ startPoint: t ? D(t) : r,
91
123
  endPoint: r
92
124
  };
93
125
  },
94
- [s, L]
95
- ), d = o(
96
- (e) => {
97
- var $;
98
- const t = y.current;
99
- if (!t) return;
100
- S(!0), ($ = E.current) == null || $.cancel(), B();
101
- const { startPoint: n, endPoint: r } = k(e), l = `${n.x}px, ${n.y}px`, m = `${r.x}px, ${r.y}px`;
102
- E.current = t.animate(
126
+ [u, D]
127
+ ), I = o(
128
+ (t) => {
129
+ var S;
130
+ const e = R.current;
131
+ if (!e) return;
132
+ y(!0), (S = A.current) == null || S.cancel(), M();
133
+ const { startPoint: n, endPoint: r } = H(t), i = `${n.x}px,${n.y}px`, m = `${r.x}px,${r.y}px`;
134
+ A.current = e.animate(
103
135
  {
104
- height: [h.current, h.current],
105
- width: [h.current, h.current],
136
+ height: [C.current, C.current],
137
+ width: [C.current, C.current],
106
138
  transform: [
107
- `translate(${l}) scale(1)`,
108
- `translate(${m}) scale(${N.current})`
139
+ `translate(${i}) scale(1)`,
140
+ `translate(${m}) scale(${G.current})`
109
141
  ]
110
142
  },
111
143
  {
112
144
  pseudoElement: "::after",
113
- duration: p,
114
- easing: T,
115
- fill: ee
145
+ duration: d,
146
+ easing: N,
147
+ fill: "forwards"
116
148
  }
117
149
  );
118
150
  },
119
- [B, p, T, k]
120
- ), u = o(() => {
121
- x.current = void 0, c.current = 0;
122
- const e = E.current;
123
- let t = 1 / 0;
124
- if (typeof (e == null ? void 0 : e.currentTime) == "number" ? t = e.currentTime : e != null && e.currentTime && (t = e.currentTime.to("ms").value), t >= P)
125
- return void S(!1);
151
+ [M, d, N, H]
152
+ ), f = o(() => {
153
+ h.current = void 0, s.current = c.INACTIVE;
154
+ const t = A.current;
155
+ let e = 1 / 0;
156
+ if (typeof (t == null ? void 0 : t.currentTime) == "number" ? e = t.currentTime : t != null && t.currentTime && (e = t.currentTime.to("ms").value), e >= E)
157
+ return void y(!1);
126
158
  setTimeout(() => {
127
- E.current === e && S(!1);
128
- }, P - t);
129
- }, [P]), G = o(
130
- (e) => {
131
- i(e) && (M(!1), c.current !== 0 && u());
159
+ A.current === t && y(!1);
160
+ }, E - e);
161
+ }, [E]), z = o(
162
+ (t) => {
163
+ l(t) && (w(!1), s.current !== c.INACTIVE && f());
132
164
  },
133
- [u, i]
134
- ), F = o(
135
- (e) => {
136
- if (i(e)) {
137
- if (c.current === 2) {
138
- c.current = 3;
165
+ [f, l]
166
+ ), B = o(
167
+ (t) => {
168
+ if (l(t)) {
169
+ if (s.current === c.HOLDING) {
170
+ s.current = c.WAITING_FOR_CLICK;
139
171
  return;
140
172
  }
141
- if (c.current === 1) {
142
- c.current = 3, d(x.current);
173
+ if (s.current === c.TOUCH_DELAY) {
174
+ s.current = c.WAITING_FOR_CLICK, I(h.current);
143
175
  return;
144
176
  }
145
177
  }
146
178
  },
147
- [i, d]
148
- ), X = o(
149
- async (e) => {
150
- if (i(e)) {
151
- if (x.current = e, !R(e)) {
152
- c.current = 3, d(e);
179
+ [l, I]
180
+ ), F = o(
181
+ (t) => {
182
+ if (l(t)) {
183
+ if (h.current = t, !T(t)) {
184
+ s.current = c.WAITING_FOR_CLICK, I(t);
153
185
  return;
154
186
  }
155
- A.current && !_(e) || (A.current = !1, c.current = 1, await new Promise((t) => {
156
- setTimeout(t, w);
157
- }), c.current === 1 && (c.current = 2, d(e)));
187
+ g.current && !$(t) || (g.current = !1, s.current = c.TOUCH_DELAY, setTimeout(() => {
188
+ s.current === c.TOUCH_DELAY && (s.current = c.HOLDING, I(t));
189
+ }, P));
158
190
  }
159
191
  },
160
- [i, R, _, d, w]
161
- ), Y = o(() => {
162
- if (!a) {
163
- if (c.current === 3) {
164
- u();
165
- return;
192
+ [l, T, $, I, P]
193
+ ), Y = o(
194
+ (t) => {
195
+ if (!p) {
196
+ if (s.current === c.WAITING_FOR_CLICK) {
197
+ f();
198
+ return;
199
+ }
200
+ s.current === c.INACTIVE && (I(t), f());
166
201
  }
167
- c.current === 0 && (d(), u());
168
- }
169
- }, [a, u, d]), O = o(
170
- (e) => {
171
- i(e) && u();
172
202
  },
173
- [u, i]
174
- ), j = o(() => {
175
- a || (A.current = !0, u());
176
- }, [a, u]);
177
- return /* @__PURE__ */ q(
203
+ [p, f, I]
204
+ ), k = o(
205
+ (t) => {
206
+ l(t) && f();
207
+ },
208
+ [f, l]
209
+ ), K = o(() => {
210
+ p || (g.current = !0, f());
211
+ }, [p, f]);
212
+ return /* @__PURE__ */ U(
178
213
  "div",
179
214
  {
180
- ref: s,
181
- className: `salty-ripple${v ? ` ${v}` : ""}`,
182
- style: U,
215
+ ref: u,
216
+ className: `salty-ripple${O ? ` ${O}` : ""}`,
217
+ style: X,
183
218
  "aria-hidden": "true",
184
- children: /* @__PURE__ */ q(
219
+ children: /* @__PURE__ */ U(
185
220
  "div",
186
221
  {
187
- ref: y,
188
- className: `salty-ripple-surface${Z ? " --hover" : ""}${J ? " --press" : ""}`
222
+ ref: R,
223
+ className: `salty-ripple-surface${j ? " --hover" : ""}${q ? " --press" : ""}`
189
224
  }
190
225
  )
191
226
  }
192
227
  );
193
228
  };
194
229
  export {
195
- ne as Ripple
230
+ nt as Ripple
196
231
  };
package/dist/ripple.css CHANGED
@@ -23,7 +23,7 @@
23
23
  .salty-ripple .salty-ripple-surface {
24
24
  inset: 0;
25
25
  pointer-events: none;
26
- overflow: hidden;
26
+ /*overflow: hidden;*/
27
27
  border-radius: inherit;
28
28
  }
29
29
 
@@ -37,7 +37,7 @@
37
37
  .salty-ripple .salty-ripple-surface::before {
38
38
  width: 100%;
39
39
  height: 100%;
40
- background-color: currentColor;
40
+ background-color: var(--ripple-color, currentColor);
41
41
  inset: 0;
42
42
  transition:
43
43
  opacity var(--ripple-duration, 150ms),
@@ -48,7 +48,7 @@
48
48
  inset: 0;
49
49
  background: radial-gradient(
50
50
  closest-side,
51
- currentColor max(100% - 70px, 65%),
51
+ var(--ripple-color, currentColor) max(100% - 70px, 65%),
52
52
  transparent 100%
53
53
  );
54
54
  transform-origin: center center;
@@ -56,7 +56,7 @@
56
56
  }
57
57
 
58
58
  .salty-ripple .salty-ripple-surface.--hover::before {
59
- background-color: currentColor;
59
+ background-color: var(--ripple-color, currentColor);
60
60
  opacity: var(--ripple-hover-opacity, 0.08);
61
61
  }
62
62
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3-ripple",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "React TypeScript implementation of Material Design 3 Ripple component",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",