m3-ripple 1.1.2 → 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,3 +1,7 @@
1
+ # 1.1.3 - 3 Jan 2026
2
+ Fix:
3
+ - remove `overflow-hidden` from ripple to prevent missing ripple effect on Safari
4
+
1
5
  # 1.1.2 - 2 Jan 2026
2
6
  Improvement:
3
7
  - add `--ripple-color` to set default ripple color
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("react/jsx-runtime"),n=require("react"),U=.2,Z=12,J=75,K=.35,Q="forwards",V=({hoverOpacity:P,pressedOpacity:k,disabled:a=!1,className:w="",style:X,easing:E,duration:f=150,minimumPressDuration:C=225,touchDelay:g=150})=>{const[Y,A]=n.useState(!1),[D,I]=n.useState(!1),u=n.useRef(null),x=n.useRef(null),m=n.useRef(""),M=n.useRef(""),S=n.useRef(0),y=n.useRef(void 0),s=n.useRef(0),R=n.useRef(void 0),T=n.useRef(!1);n.useEffect(()=>{if(!x.current)return;const e=x.current.style;P!==void 0&&e.setProperty("--ripple-hover-opacity",P+""),k!==void 0&&e.setProperty("--ripple-pressed-opacity",k+""),f!==void 0&&f!==150&&e.setProperty("--ripple-duration",f+"ms")},[P,k,f]),n.useEffect(()=>{var c;const e=(c=u.current)==null?void 0:c.parentElement;if(!e)return;const t=(r,o)=>e.addEventListener(r,o,!0);return t("click",G),t("contextmenu",F),t("pointercancel",q),t("pointerdown",j),t("pointerenter",v),t("pointerleave",B),t("pointerup",L),()=>{const r=(o,d)=>e.removeEventListener(o,d,!0);r("click",G),r("contextmenu",F),r("pointercancel",q),r("pointerdown",j),r("pointerenter",v),r("pointerleave",B),r("pointerup",L)}},[a,E,f,C,g]);const h=n.useCallback(({pointerType:e})=>e==="touch",[]),i=n.useCallback(e=>{var c,r;if(a||(r=(c=u.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!h(e);const t=e.buttons===1;return h(e)||t},[a,h]),$=n.useCallback(({x:e,y:t})=>{const c=u.current;if(!c)return!1;const r=c.getBoundingClientRect();return e>=r.left&&e<=r.right&&t>=r.top&&t<=r.bottom},[u]),v=n.useCallback(e=>{i(e)&&A(!0)},[i]),N=n.useCallback(()=>{const e=u.current;if(!e)return;const{height:t,width:c}=e.getBoundingClientRect(),r=Math.max(t,c),o=Math.max(K*r,J),d=Math.floor(r*U),H=Math.sqrt(c**2+t**2)+Z;S.current=d,M.current=(H+o)/d+"",m.current=d+"px"},[u]),_=n.useCallback(e=>{const t=u.current;if(!t)return{x:0,y:0};const c=t.getBoundingClientRect(),r=window.scrollX+c.left,o=window.scrollY+c.top;return{x:e.pageX-r,y:e.pageY-o}},[u]),z=n.useCallback(e=>{var o;const t=(o=u.current)==null?void 0:o.parentElement;if(!t)return{startPoint:{x:0,y:0},endPoint:{x:0,y:0}};const c=t.getBoundingClientRect(),r={x:(c.width-S.current)/2,y:(c.height-S.current)/2};return{startPoint:e?_(e):r,endPoint:r}},[u,_]),p=n.useCallback(e=>{var b;const t=x.current;if(!t)return;I(!0),(b=y.current)==null||b.cancel(),N();const{startPoint:c,endPoint:r}=z(e),o=`${c.x}px, ${c.y}px`,d=`${r.x}px, ${r.y}px`;y.current=t.animate({height:[m.current,m.current],width:[m.current,m.current],transform:[`translate(${o}) scale(1)`,`translate(${d}) scale(${M.current})`]},{pseudoElement:"::after",duration:f,easing:E,fill:Q})},[N,f,E,z]),l=n.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=n.useCallback(e=>{i(e)&&(A(!1),s.current!==0&&l())},[l,i]),L=n.useCallback(e=>{if(i(e)){if(s.current===2){s.current=3;return}if(s.current===1){s.current=3,p(R.current);return}}},[i,p]),j=n.useCallback(async e=>{if(i(e)){if(R.current=e,!h(e)){s.current=3,p(e);return}T.current&&!$(e)||(T.current=!1,s.current=1,await new Promise(t=>{setTimeout(t,g)}),s.current===1&&(s.current=2,p(e)))}},[i,h,$,p,g]),G=n.useCallback(()=>{if(!a){if(s.current===3){l();return}s.current===0&&(p(),l())}},[a,l,p]),q=n.useCallback(e=>{i(e)&&l()},[l,i]),F=n.useCallback(()=>{a||(T.current=!0,l())},[a,l]);return O.jsx("div",{ref:u,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,4CAwVb,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,198 +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: M = "",
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, N] = D(!1), [J, S] = D(!1), i = f(null), y = f(null), h = f(""), v = 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 = i.current) == null ? void 0 : n.parentElement;
25
- if (!e) return;
26
- const t = (r, s) => e.addEventListener(r, s, !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 = (s, m) => e.removeEventListener(s, 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
- ), u = o(
36
- (e) => {
65
+ ), l = o(
66
+ (t) => {
37
67
  var n, r;
38
- if (a || // @ts-ignore
39
- (r = (n = i.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 = i.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;
54
- },
55
- [i]
56
- ), z = o(
57
- (e) => {
58
- u(e) && N(!0);
83
+ return t >= r.left && t <= r.right && e >= r.top && e <= r.bottom;
59
84
  },
60
85
  [u]
61
- ), B = o(() => {
62
- const e = i.current;
63
- if (!e) return;
64
- const { height: t, width: n } = e.getBoundingClientRect(), r = Math.max(t, n), s = 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, v.current = (K + s) / m + "", h.current = m + "px";
69
- }, [i]), L = o(
70
- (e) => {
71
- const t = i.current;
72
- if (!t) return { x: 0, y: 0 };
73
- const n = t.getBoundingClientRect(), r = window.scrollX + n.left, s = window.scrollY + n.top;
86
+ ), v = o(
87
+ (t) => {
88
+ l(t) && w(!0);
89
+ },
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 - s
105
+ x: t.pageX - r,
106
+ y: t.pageY - i
77
107
  };
78
108
  },
79
- [i]
80
- ), k = o(
81
- (e) => {
82
- var s;
83
- const t = (s = i.current) == null ? void 0 : s.parentElement;
84
- 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)
85
115
  return { startPoint: { x: 0, y: 0 }, endPoint: { x: 0, y: 0 } };
86
- const n = t.getBoundingClientRect(), r = {
87
- x: (n.width - C.current) / 2,
88
- 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
89
119
  };
90
120
  return {
91
121
  // If using keyboard, start in the center
92
- startPoint: e ? L(e) : r,
122
+ startPoint: t ? D(t) : r,
93
123
  endPoint: r
94
124
  };
95
125
  },
96
- [i, L]
97
- ), d = o(
98
- (e) => {
99
- var $;
100
- const t = y.current;
101
- if (!t) return;
102
- S(!0), ($ = E.current) == null || $.cancel(), B();
103
- const { startPoint: n, endPoint: r } = k(e), s = `${n.x}px, ${n.y}px`, m = `${r.x}px, ${r.y}px`;
104
- 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(
105
135
  {
106
- height: [h.current, h.current],
107
- width: [h.current, h.current],
136
+ height: [C.current, C.current],
137
+ width: [C.current, C.current],
108
138
  transform: [
109
- `translate(${s}) scale(1)`,
110
- `translate(${m}) scale(${v.current})`
139
+ `translate(${i}) scale(1)`,
140
+ `translate(${m}) scale(${G.current})`
111
141
  ]
112
142
  },
113
143
  {
114
144
  pseudoElement: "::after",
115
- duration: p,
116
- easing: T,
117
- fill: ee
145
+ duration: d,
146
+ easing: N,
147
+ fill: "forwards"
118
148
  }
119
149
  );
120
150
  },
121
- [B, p, T, k]
122
- ), l = o(() => {
123
- x.current = void 0, c.current = 0;
124
- const e = E.current;
125
- let t = 1 / 0;
126
- if (typeof (e == null ? void 0 : e.currentTime) == "number" ? t = e.currentTime : e != null && e.currentTime && (t = e.currentTime.to("ms").value), t >= P)
127
- 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);
128
158
  setTimeout(() => {
129
- E.current === e && S(!1);
130
- }, P - t);
131
- }, [P]), G = o(
132
- (e) => {
133
- u(e) && (N(!1), c.current !== 0 && l());
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());
134
164
  },
135
- [l, u]
136
- ), F = o(
137
- (e) => {
138
- if (u(e)) {
139
- if (c.current === 2) {
140
- 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;
141
171
  return;
142
172
  }
143
- if (c.current === 1) {
144
- c.current = 3, d(x.current);
173
+ if (s.current === c.TOUCH_DELAY) {
174
+ s.current = c.WAITING_FOR_CLICK, I(h.current);
145
175
  return;
146
176
  }
147
177
  }
148
178
  },
149
- [u, d]
150
- ), X = o(
151
- async (e) => {
152
- if (u(e)) {
153
- if (x.current = e, !R(e)) {
154
- 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);
155
185
  return;
156
186
  }
157
- A.current && !_(e) || (A.current = !1, c.current = 1, await new Promise((t) => {
158
- setTimeout(t, w);
159
- }), 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));
160
190
  }
161
191
  },
162
- [u, R, _, d, w]
163
- ), Y = o(() => {
164
- if (!a) {
165
- if (c.current === 3) {
166
- l();
167
- 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());
168
201
  }
169
- c.current === 0 && (d(), l());
170
- }
171
- }, [a, l, d]), O = o(
172
- (e) => {
173
- u(e) && l();
174
202
  },
175
- [l, u]
176
- ), j = o(() => {
177
- a || (A.current = !0, l());
178
- }, [a, l]);
179
- 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(
180
213
  "div",
181
214
  {
182
- ref: i,
183
- className: `salty-ripple${M ? ` ${M}` : ""}`,
184
- style: U,
215
+ ref: u,
216
+ className: `salty-ripple${O ? ` ${O}` : ""}`,
217
+ style: X,
185
218
  "aria-hidden": "true",
186
- children: /* @__PURE__ */ q(
219
+ children: /* @__PURE__ */ U(
187
220
  "div",
188
221
  {
189
- ref: y,
190
- className: `salty-ripple-surface${Z ? " --hover" : ""}${J ? " --press" : ""}`
222
+ ref: R,
223
+ className: `salty-ripple-surface${j ? " --hover" : ""}${q ? " --press" : ""}`
191
224
  }
192
225
  )
193
226
  }
194
227
  );
195
228
  };
196
229
  export {
197
- ne as Ripple
230
+ nt as Ripple
198
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "m3-ripple",
3
- "version": "1.1.2",
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",