m3-ripple 0.0.0
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/.github/FUNDING.yaml +1 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/ci.yml +29 -0
- package/.github/workflows/publish.yml +47 -0
- package/LICENSE +7 -0
- package/README.md +121 -0
- package/dist/demo.d.ts +9 -0
- package/dist/demo.d.ts.map +1 -0
- package/dist/index.cjs.js +22 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +465 -0
- package/dist/ripple.css +107 -0
- package/package.json +59 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
github: SaltyAom
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: Build
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
pull_request:
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
build:
|
|
9
|
+
name: Build and test code
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
|
|
16
|
+
- name: Setup bun
|
|
17
|
+
uses: oven-sh/setup-bun@v1
|
|
18
|
+
with:
|
|
19
|
+
bun-version: latest
|
|
20
|
+
|
|
21
|
+
- name: Install packages
|
|
22
|
+
run: bun install
|
|
23
|
+
|
|
24
|
+
- name: Build code
|
|
25
|
+
run: bun run build
|
|
26
|
+
|
|
27
|
+
- name: Publish Preview
|
|
28
|
+
if: github.event_name == 'pull_request'
|
|
29
|
+
run: bunx pkg-pr-new publish
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
defaults:
|
|
8
|
+
run:
|
|
9
|
+
shell: bash
|
|
10
|
+
|
|
11
|
+
permissions:
|
|
12
|
+
id-token: write
|
|
13
|
+
|
|
14
|
+
env:
|
|
15
|
+
# Enable debug logging for actions
|
|
16
|
+
ACTIONS_RUNNER_DEBUG: true
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
publish-npm:
|
|
20
|
+
name: 'Publish: npm Registry'
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
steps:
|
|
23
|
+
- name: 'Checkout'
|
|
24
|
+
uses: actions/checkout@v4
|
|
25
|
+
|
|
26
|
+
- name: 'Setup Bun'
|
|
27
|
+
uses: oven-sh/setup-bun@v1
|
|
28
|
+
with:
|
|
29
|
+
bun-version: latest
|
|
30
|
+
registry-url: "https://registry.npmjs.org"
|
|
31
|
+
|
|
32
|
+
- uses: actions/setup-node@v4
|
|
33
|
+
with:
|
|
34
|
+
node-version: '20.x'
|
|
35
|
+
registry-url: 'https://registry.npmjs.org'
|
|
36
|
+
|
|
37
|
+
- name: Install packages
|
|
38
|
+
run: bun install
|
|
39
|
+
|
|
40
|
+
- name: Build code
|
|
41
|
+
run: bun run build
|
|
42
|
+
|
|
43
|
+
- name: 'Publish'
|
|
44
|
+
env:
|
|
45
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
46
|
+
run: |
|
|
47
|
+
npm publish --provenance --access=public
|
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2025 saltyAom
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
# m3-ripple
|
|
2
|
+
|
|
3
|
+
Material Design 3 ripple effect for React ([demo](https://m3-ripple.saltyaom.com))
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install m3-ripple
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
Put `Ripple` component inside any element, and set `position: relative`.
|
|
14
|
+
|
|
15
|
+
The ripple effect will automatically be applied when the element is pressed.
|
|
16
|
+
|
|
17
|
+
```jsx
|
|
18
|
+
import { Ripple } from 'm3-ripple'
|
|
19
|
+
import 'm3-ripple/ripple.css'
|
|
20
|
+
|
|
21
|
+
function Demo() {
|
|
22
|
+
return (
|
|
23
|
+
<button
|
|
24
|
+
style={{
|
|
25
|
+
position: 'relative',
|
|
26
|
+
color: 'white',
|
|
27
|
+
padding: '1rem 2rem',
|
|
28
|
+
backgroundColor: '#6200ee'
|
|
29
|
+
}}
|
|
30
|
+
>
|
|
31
|
+
<Ripple />
|
|
32
|
+
Click Me
|
|
33
|
+
</button>
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Customization
|
|
39
|
+
Ripple color will inherits the color of the parent element using `currentColor`. You can customize the ripple color by setting the `color` property on the parent element.
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
import { Ripple } from 'm3-ripple'
|
|
43
|
+
import 'm3-ripple/ripple.css'
|
|
44
|
+
|
|
45
|
+
function Demo() {
|
|
46
|
+
return (
|
|
47
|
+
<button
|
|
48
|
+
style={{
|
|
49
|
+
position: 'relative',
|
|
50
|
+
color: 'red'
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<Ripple />
|
|
54
|
+
Click Me
|
|
55
|
+
</button>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Props
|
|
61
|
+
Here's a type definition of the props you can use with the `Ripple` component:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
export interface RippleProps {
|
|
65
|
+
/**
|
|
66
|
+
* Disables the ripple.
|
|
67
|
+
*/
|
|
68
|
+
disabled?: boolean
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* hoverOpacity: The opacity of the ripple when hovered.
|
|
72
|
+
*
|
|
73
|
+
* @default 0.08
|
|
74
|
+
*/
|
|
75
|
+
hoverOpacity?: number
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* pressedOpacity: The opacity of the ripple when pressed.
|
|
79
|
+
*
|
|
80
|
+
* @default 0.12
|
|
81
|
+
*/
|
|
82
|
+
pressedOpacity?: number
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Additional CSS classes to apply to the ripple container.
|
|
86
|
+
*/
|
|
87
|
+
className?: string
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Additional styles to apply to the ripple container.
|
|
91
|
+
*/
|
|
92
|
+
style?: React.CSSProperties
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Easing function for the ripple animation.
|
|
96
|
+
*/
|
|
97
|
+
easing?: 'cubic-bezier(0.2, 0, 0, 1)'
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The duration in milliseconds for the ripple to grow when pressed.
|
|
101
|
+
*
|
|
102
|
+
* @default 150
|
|
103
|
+
*/
|
|
104
|
+
duration?: number
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The minimum duration in milliseconds for the ripple to be considered a
|
|
108
|
+
* valid press.
|
|
109
|
+
*
|
|
110
|
+
* @default 225
|
|
111
|
+
*/
|
|
112
|
+
minimumPressDuration?: number
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* * The duration in milliseconds for the ripple to wait before starting the
|
|
116
|
+
*
|
|
117
|
+
* @default 150
|
|
118
|
+
*/
|
|
119
|
+
touchDelay?: number
|
|
120
|
+
}
|
|
121
|
+
```
|
package/dist/demo.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"demo.d.ts","sourceRoot":"","sources":["../src/demo.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAOH,OAAO,cAAc,CAAA;AA2IrB,QAAA,MAAM,IAAI,+CAsNT,CAAA;AAMD,eAAe,IAAI,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react");var V={exports:{}},D={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var Q;function te(){if(Q)return D;Q=1;var b=Symbol.for("react.transitional.element"),h=Symbol.for("react.fragment");function u(S,i,f){var C=null;if(f!==void 0&&(C=""+f),i.key!==void 0&&(C=""+i.key),"key"in i){f={};for(var _ in i)_!=="key"&&(f[_]=i[_])}else f=i;return i=f.ref,{$$typeof:b,type:S,key:C,ref:i!==void 0?i:null,props:f}}return D.Fragment=h,D.jsx=u,D.jsxs=u,D}var F={};/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.development.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var K;function ne(){return K||(K=1,process.env.NODE_ENV!=="production"&&function(){function b(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===B?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case k:return"Fragment";case N:return"Profiler";case U:return"StrictMode";case I:return"Suspense";case g:return"SuspenseList";case H:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case y:return"Portal";case l:return(e.displayName||"Context")+".Provider";case w:return(e._context.displayName||"Context")+".Consumer";case x:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case E:return t=e.displayName||null,t!==null?t:b(e.type)||"Memo";case $:t=e._payload,e=e._init;try{return b(e(t))}catch{}}return null}function h(e){return""+e}function u(e){try{h(e);var t=!1}catch{t=!0}if(t){t=console;var r=t.error,n=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r.call(t,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",n),h(e)}}function S(e){if(e===k)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===$)return"<...>";try{var t=b(e);return t?"<"+t+">":"<...>"}catch{return"<...>"}}function i(){var e=O.A;return e===null?null:e.getOwner()}function f(){return Error("react-stack-top-frame")}function C(e){if(M.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function _(e,t){function r(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",t))}r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}function L(){var e=b(this.type);return q[e]||(q[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function z(e,t,r,n,c,a,m,R){return r=a.ref,e={$$typeof:p,type:e,key:t,props:a,_owner:c},(r!==void 0?r:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:L}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:m}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:R}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function A(e,t,r,n,c,a,m,R){var s=t.children;if(s!==void 0)if(n)if(P(s)){for(n=0;n<s.length;n++)j(s[n]);Object.freeze&&Object.freeze(s)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(s);if(M.call(t,"key")){s=b(e);var T=Object.keys(t).filter(function(Z){return Z!=="key"});n=0<T.length?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}",X[s+n]||(T=0<T.length?"{"+T.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,n,s,T,s),X[s+n]=!0)}if(s=null,r!==void 0&&(u(r),s=""+r),C(t)&&(u(t.key),s=""+t.key),"key"in t){r={};for(var Y in t)Y!=="key"&&(r[Y]=t[Y])}else r=t;return s&&_(r,typeof e=="function"?e.displayName||e.name||"Unknown":e),z(e,s,a,c,i(),r,m,R)}function j(e){typeof e=="object"&&e!==null&&e.$$typeof===p&&e._store&&(e._store.validated=1)}var v=o,p=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),w=Symbol.for("react.consumer"),l=Symbol.for("react.context"),x=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),g=Symbol.for("react.suspense_list"),E=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),H=Symbol.for("react.activity"),B=Symbol.for("react.client.reference"),O=v.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,M=Object.prototype.hasOwnProperty,P=Array.isArray,d=console.createTask?console.createTask:function(){return null};v={"react-stack-bottom-frame":function(e){return e()}};var W,q={},G=v["react-stack-bottom-frame"].bind(v,f)(),J=d(S(f)),X={};F.Fragment=k,F.jsx=function(e,t,r,n,c){var a=1e4>O.recentlyCreatedOwnerStacks++;return A(e,t,r,!1,n,c,a?Error("react-stack-top-frame"):G,a?d(S(e)):J)},F.jsxs=function(e,t,r,n,c){var a=1e4>O.recentlyCreatedOwnerStacks++;return A(e,t,r,!0,n,c,a?Error("react-stack-top-frame"):G,a?d(S(e)):J)}}()),F}var ee;function oe(){return ee||(ee=1,process.env.NODE_ENV==="production"?V.exports=te():V.exports=ne()),V.exports}var re=oe();const se=.2,ae=12,ce=75,ue=.35,le="forwards",ie=({hoverOpacity:b,pressedOpacity:h,disabled:u=!1,className:S="",style:i,easing:f,duration:C=150,minimumPressDuration:_=225,touchDelay:L=150})=>{const[z,A]=o.useState(!1),[j,v]=o.useState(!1),p=o.useRef(null),y=o.useRef(null),k=o.useRef(""),U=o.useRef(""),N=o.useRef(0),w=o.useRef(void 0),l=o.useRef(0),x=o.useRef(void 0),I=o.useRef(!1);o.useEffect(()=>{if(!y.current)return;const r=y.current.style;b!==void 0&&r.setProperty("--ripple-hover-opacity",b+""),h!==void 0&&r.setProperty("--ripple-pressed-opacity",h+"")},[b,h]);const g=o.useCallback(({pointerType:r})=>r==="touch",[]),E=o.useCallback(r=>{if(u||!r.isPrimary||x.current&&x.current.pointerId!==r.pointerId)return!1;if(r.type==="pointerenter"||r.type==="pointerleave")return!g(r);const n=r.buttons===1;return g(r)||n},[u,g]),$=o.useCallback(({x:r,y:n})=>{const c=p.current;if(!c)return!1;const{top:a,left:m,bottom:R,right:s}=c.getBoundingClientRect();return r>=m&&r<=s&&n>=a&&n<=R},[p]),H=o.useCallback(r=>{E(r)&&A(!0)},[E]),B=o.useCallback(()=>{const r=p.current;if(!r)return;const{height:n,width:c}=r.getBoundingClientRect(),a=Math.max(n,c),m=Math.max(ue*a,ce),R=Math.floor(a*se),T=Math.sqrt(c**2+n**2)+ae;N.current=R,U.current=`${(T+m)/R}`,k.current=`${R}px`},[p]),O=o.useCallback(r=>{const n=p.current;if(!n)return{x:0,y:0};const{scrollX:c,scrollY:a}=window,{left:m,top:R}=n.getBoundingClientRect(),s=c+m,T=a+R,{pageX:Y,pageY:Z}=r;return{x:Y-s,y:Z-T}},[p]),M=o.useCallback(r=>{const n=p.current.parentElement;if(!n)return{startPoint:{x:0,y:0},endPoint:{x:0,y:0}};const{height:c,width:a}=n.getBoundingClientRect(),m={x:(a-N.current)/2,y:(c-N.current)/2};return{startPoint:O(r),endPoint:m}},[p,O]),P=o.useCallback(r=>{var s;const n=y.current;if(!n)return;v(!0),(s=w.current)==null||s.cancel(),B();const{startPoint:c,endPoint:a}=M(r),m=`${c.x}px, ${c.y}px`,R=`${a.x}px, ${a.y}px`;w.current=n.animate({height:[k.current,k.current],width:[k.current,k.current],transform:[`translate(${m}) scale(1)`,`translate(${R}) scale(${U.current})`]},{pseudoElement:"::after",duration:C,easing:f,fill:le})},[B,C,f,M]),d=o.useCallback(()=>{x.current=void 0,l.current=0;const r=w.current;let n=1/0;if(typeof(r==null?void 0:r.currentTime)=="number"?n=r.currentTime:r!=null&&r.currentTime&&(n=r.currentTime.to("ms").value),n>=_)return void v(!1);setTimeout(()=>{w.current===r&&v(!1)},_-n)},[_]),W=o.useCallback(r=>{E(r)&&(A(!1),l.current!==0&&d())},[d,E]),q=o.useCallback(r=>{if(E(r)){if(l.current===2){l.current=3;return}if(l.current===1){l.current=3,P(x.current);return}}},[E,P]),G=o.useCallback(async r=>{if(E(r)){if(x.current=r,!g(r)){l.current=3,P(r);return}I.current&&!$(r)||(I.current=!1,l.current=1,await new Promise(n=>{setTimeout(n,L)}),l.current===1&&(l.current=2,P(r)))}},[E,g,$,P,L]),J=o.useCallback(()=>{if(!u){if(l.current===3){d();return}l.current===0&&(P(),d())}},[u,d,P]),X=o.useCallback(r=>{E(r)&&d()},[d,E]),e=o.useCallback(()=>{u||(I.current=!0,d())},[u,d]);o.useEffect(()=>{u&&(A(!1),v(!1))},[u]);const t=o.useMemo(()=>["salty-ripple-surface",[z&&"hovered",j&&"pressed"].filter(Boolean).join(" ")].filter(Boolean).join(" "),[z,j]);return re.jsx("div",{ref:p,className:`salty-ripple${S?` ${S}`:""}`,style:i,"aria-hidden":"true",onClick:J,onContextMenu:e,onPointerCancel:X,onPointerDown:G,onPointerEnter:H,onPointerLeave:W,onPointerUp:q,children:re.jsx("div",{ref:y,className:t})})};exports.Ripple=ie;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
export interface RippleProps {
|
|
2
|
+
/**
|
|
3
|
+
* Disables the ripple.
|
|
4
|
+
*/
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* hoverOpacity: The opacity of the ripple when hovered.
|
|
8
|
+
*
|
|
9
|
+
* @default 0.08
|
|
10
|
+
*/
|
|
11
|
+
hoverOpacity?: number;
|
|
12
|
+
/**
|
|
13
|
+
* pressedOpacity: The opacity of the ripple when pressed.
|
|
14
|
+
*
|
|
15
|
+
* @default 0.12
|
|
16
|
+
*/
|
|
17
|
+
pressedOpacity?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Additional CSS classes to apply to the ripple container.
|
|
20
|
+
*/
|
|
21
|
+
className?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Additional styles to apply to the ripple container.
|
|
24
|
+
*/
|
|
25
|
+
style?: React.CSSProperties;
|
|
26
|
+
/**
|
|
27
|
+
* Easing function for the ripple animation.
|
|
28
|
+
*/
|
|
29
|
+
easing?: 'cubic-bezier(0.2, 0, 0, 1)';
|
|
30
|
+
/**
|
|
31
|
+
* The duration in milliseconds for the ripple to grow when pressed.
|
|
32
|
+
*
|
|
33
|
+
* @default 150
|
|
34
|
+
*/
|
|
35
|
+
duration?: number;
|
|
36
|
+
/**
|
|
37
|
+
* The minimum duration in milliseconds for the ripple to be considered a
|
|
38
|
+
* valid press.
|
|
39
|
+
*
|
|
40
|
+
* @default 225
|
|
41
|
+
*/
|
|
42
|
+
minimumPressDuration?: number;
|
|
43
|
+
/**
|
|
44
|
+
* * The duration in milliseconds for the ripple to wait before starting the
|
|
45
|
+
*
|
|
46
|
+
* @default 150
|
|
47
|
+
*/
|
|
48
|
+
touchDelay?: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* A ripple component.
|
|
52
|
+
*/
|
|
53
|
+
export declare const Ripple: ({ hoverOpacity, pressedOpacity, disabled, className, style, easing, duration, minimumPressDuration, touchDelay }: RippleProps) => import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAeA,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,4CAuUb,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,465 @@
|
|
|
1
|
+
import se, { useState as K, useRef as x, useEffect as ee, useCallback as c, useMemo as ae } from "react";
|
|
2
|
+
var H = { exports: {} }, F = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var re;
|
|
13
|
+
function ce() {
|
|
14
|
+
if (re) return F;
|
|
15
|
+
re = 1;
|
|
16
|
+
var T = Symbol.for("react.transitional.element"), S = Symbol.for("react.fragment");
|
|
17
|
+
function u(A, l, f) {
|
|
18
|
+
var g = null;
|
|
19
|
+
if (f !== void 0 && (g = "" + f), l.key !== void 0 && (g = "" + l.key), "key" in l) {
|
|
20
|
+
f = {};
|
|
21
|
+
for (var v in l)
|
|
22
|
+
v !== "key" && (f[v] = l[v]);
|
|
23
|
+
} else f = l;
|
|
24
|
+
return l = f.ref, {
|
|
25
|
+
$$typeof: T,
|
|
26
|
+
type: A,
|
|
27
|
+
key: g,
|
|
28
|
+
ref: l !== void 0 ? l : null,
|
|
29
|
+
props: f
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return F.Fragment = S, F.jsx = u, F.jsxs = u, F;
|
|
33
|
+
}
|
|
34
|
+
var L = {};
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
var te;
|
|
45
|
+
function ue() {
|
|
46
|
+
return te || (te = 1, process.env.NODE_ENV !== "production" && function() {
|
|
47
|
+
function T(e) {
|
|
48
|
+
if (e == null) return null;
|
|
49
|
+
if (typeof e == "function")
|
|
50
|
+
return e.$$typeof === W ? null : e.displayName || e.name || null;
|
|
51
|
+
if (typeof e == "string") return e;
|
|
52
|
+
switch (e) {
|
|
53
|
+
case b:
|
|
54
|
+
return "Fragment";
|
|
55
|
+
case I:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case B:
|
|
58
|
+
return "StrictMode";
|
|
59
|
+
case $:
|
|
60
|
+
return "Suspense";
|
|
61
|
+
case y:
|
|
62
|
+
return "SuspenseList";
|
|
63
|
+
case Z:
|
|
64
|
+
return "Activity";
|
|
65
|
+
}
|
|
66
|
+
if (typeof e == "object")
|
|
67
|
+
switch (typeof e.tag == "number" && console.error(
|
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
+
), e.$$typeof) {
|
|
70
|
+
case O:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case i:
|
|
73
|
+
return (e.displayName || "Context") + ".Provider";
|
|
74
|
+
case C:
|
|
75
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case k:
|
|
77
|
+
var t = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = t.displayName || t.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case R:
|
|
80
|
+
return t = e.displayName || null, t !== null ? t : T(e.type) || "Memo";
|
|
81
|
+
case M:
|
|
82
|
+
t = e._payload, e = e._init;
|
|
83
|
+
try {
|
|
84
|
+
return T(e(t));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function S(e) {
|
|
91
|
+
return "" + e;
|
|
92
|
+
}
|
|
93
|
+
function u(e) {
|
|
94
|
+
try {
|
|
95
|
+
S(e);
|
|
96
|
+
var t = !1;
|
|
97
|
+
} catch {
|
|
98
|
+
t = !0;
|
|
99
|
+
}
|
|
100
|
+
if (t) {
|
|
101
|
+
t = console;
|
|
102
|
+
var r = t.error, n = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return r.call(
|
|
104
|
+
t,
|
|
105
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
+
n
|
|
107
|
+
), S(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function A(e) {
|
|
111
|
+
if (e === b) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === M)
|
|
113
|
+
return "<...>";
|
|
114
|
+
try {
|
|
115
|
+
var t = T(e);
|
|
116
|
+
return t ? "<" + t + ">" : "<...>";
|
|
117
|
+
} catch {
|
|
118
|
+
return "<...>";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function l() {
|
|
122
|
+
var e = j.A;
|
|
123
|
+
return e === null ? null : e.getOwner();
|
|
124
|
+
}
|
|
125
|
+
function f() {
|
|
126
|
+
return Error("react-stack-top-frame");
|
|
127
|
+
}
|
|
128
|
+
function g(e) {
|
|
129
|
+
if (Y.call(e, "key")) {
|
|
130
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (t && t.isReactWarning) return !1;
|
|
132
|
+
}
|
|
133
|
+
return e.key !== void 0;
|
|
134
|
+
}
|
|
135
|
+
function v(e, t) {
|
|
136
|
+
function r() {
|
|
137
|
+
G || (G = !0, console.error(
|
|
138
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
+
t
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
r.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: r,
|
|
144
|
+
configurable: !0
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function z() {
|
|
148
|
+
var e = T(this.type);
|
|
149
|
+
return q[e] || (q[e] = !0, console.error(
|
|
150
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
|
+
}
|
|
153
|
+
function U(e, t, r, n, a, s, m, p) {
|
|
154
|
+
return r = s.ref, e = {
|
|
155
|
+
$$typeof: E,
|
|
156
|
+
type: e,
|
|
157
|
+
key: t,
|
|
158
|
+
props: s,
|
|
159
|
+
_owner: a
|
|
160
|
+
}, (r !== void 0 ? r : null) !== null ? Object.defineProperty(e, "ref", {
|
|
161
|
+
enumerable: !1,
|
|
162
|
+
get: z
|
|
163
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
164
|
+
configurable: !1,
|
|
165
|
+
enumerable: !1,
|
|
166
|
+
writable: !0,
|
|
167
|
+
value: 0
|
|
168
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
169
|
+
configurable: !1,
|
|
170
|
+
enumerable: !1,
|
|
171
|
+
writable: !0,
|
|
172
|
+
value: null
|
|
173
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
174
|
+
configurable: !1,
|
|
175
|
+
enumerable: !1,
|
|
176
|
+
writable: !0,
|
|
177
|
+
value: m
|
|
178
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
179
|
+
configurable: !1,
|
|
180
|
+
enumerable: !1,
|
|
181
|
+
writable: !0,
|
|
182
|
+
value: p
|
|
183
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
184
|
+
}
|
|
185
|
+
function w(e, t, r, n, a, s, m, p) {
|
|
186
|
+
var o = t.children;
|
|
187
|
+
if (o !== void 0)
|
|
188
|
+
if (n)
|
|
189
|
+
if (h(o)) {
|
|
190
|
+
for (n = 0; n < o.length; n++)
|
|
191
|
+
N(o[n]);
|
|
192
|
+
Object.freeze && Object.freeze(o);
|
|
193
|
+
} else
|
|
194
|
+
console.error(
|
|
195
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
196
|
+
);
|
|
197
|
+
else N(o);
|
|
198
|
+
if (Y.call(t, "key")) {
|
|
199
|
+
o = T(e);
|
|
200
|
+
var _ = Object.keys(t).filter(function(Q) {
|
|
201
|
+
return Q !== "key";
|
|
202
|
+
});
|
|
203
|
+
n = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", V[o + n] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
204
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
205
|
+
let props = %s;
|
|
206
|
+
<%s {...props} />
|
|
207
|
+
React keys must be passed directly to JSX without using spread:
|
|
208
|
+
let props = %s;
|
|
209
|
+
<%s key={someKey} {...props} />`,
|
|
210
|
+
n,
|
|
211
|
+
o,
|
|
212
|
+
_,
|
|
213
|
+
o
|
|
214
|
+
), V[o + n] = !0);
|
|
215
|
+
}
|
|
216
|
+
if (o = null, r !== void 0 && (u(r), o = "" + r), g(t) && (u(t.key), o = "" + t.key), "key" in t) {
|
|
217
|
+
r = {};
|
|
218
|
+
for (var D in t)
|
|
219
|
+
D !== "key" && (r[D] = t[D]);
|
|
220
|
+
} else r = t;
|
|
221
|
+
return o && v(
|
|
222
|
+
r,
|
|
223
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
224
|
+
), U(
|
|
225
|
+
e,
|
|
226
|
+
o,
|
|
227
|
+
s,
|
|
228
|
+
a,
|
|
229
|
+
l(),
|
|
230
|
+
r,
|
|
231
|
+
m,
|
|
232
|
+
p
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
function N(e) {
|
|
236
|
+
typeof e == "object" && e !== null && e.$$typeof === E && e._store && (e._store.validated = 1);
|
|
237
|
+
}
|
|
238
|
+
var P = se, E = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), b = Symbol.for("react.fragment"), B = Symbol.for("react.strict_mode"), I = Symbol.for("react.profiler"), C = Symbol.for("react.consumer"), i = Symbol.for("react.context"), k = Symbol.for("react.forward_ref"), $ = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), M = Symbol.for("react.lazy"), Z = Symbol.for("react.activity"), W = Symbol.for("react.client.reference"), j = P.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, Y = Object.prototype.hasOwnProperty, h = Array.isArray, d = console.createTask ? console.createTask : function() {
|
|
239
|
+
return null;
|
|
240
|
+
};
|
|
241
|
+
P = {
|
|
242
|
+
"react-stack-bottom-frame": function(e) {
|
|
243
|
+
return e();
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
var G, q = {}, J = P["react-stack-bottom-frame"].bind(
|
|
247
|
+
P,
|
|
248
|
+
f
|
|
249
|
+
)(), X = d(A(f)), V = {};
|
|
250
|
+
L.Fragment = b, L.jsx = function(e, t, r, n, a) {
|
|
251
|
+
var s = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
252
|
+
return w(
|
|
253
|
+
e,
|
|
254
|
+
t,
|
|
255
|
+
r,
|
|
256
|
+
!1,
|
|
257
|
+
n,
|
|
258
|
+
a,
|
|
259
|
+
s ? Error("react-stack-top-frame") : J,
|
|
260
|
+
s ? d(A(e)) : X
|
|
261
|
+
);
|
|
262
|
+
}, L.jsxs = function(e, t, r, n, a) {
|
|
263
|
+
var s = 1e4 > j.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return w(
|
|
265
|
+
e,
|
|
266
|
+
t,
|
|
267
|
+
r,
|
|
268
|
+
!0,
|
|
269
|
+
n,
|
|
270
|
+
a,
|
|
271
|
+
s ? Error("react-stack-top-frame") : J,
|
|
272
|
+
s ? d(A(e)) : X
|
|
273
|
+
);
|
|
274
|
+
};
|
|
275
|
+
}()), L;
|
|
276
|
+
}
|
|
277
|
+
var ne;
|
|
278
|
+
function ie() {
|
|
279
|
+
return ne || (ne = 1, process.env.NODE_ENV === "production" ? H.exports = ce() : H.exports = ue()), H.exports;
|
|
280
|
+
}
|
|
281
|
+
var oe = ie();
|
|
282
|
+
const le = 0.2, fe = 12, de = 75, me = 0.35, pe = "forwards", Re = ({
|
|
283
|
+
hoverOpacity: T,
|
|
284
|
+
pressedOpacity: S,
|
|
285
|
+
disabled: u = !1,
|
|
286
|
+
className: A = "",
|
|
287
|
+
style: l,
|
|
288
|
+
easing: f,
|
|
289
|
+
duration: g = 150,
|
|
290
|
+
minimumPressDuration: v = 225,
|
|
291
|
+
touchDelay: z = 150
|
|
292
|
+
}) => {
|
|
293
|
+
const [U, w] = K(!1), [N, P] = K(!1), E = x(null), O = x(null), b = x(""), B = x(""), I = x(0), C = x(void 0), i = x(
|
|
294
|
+
0
|
|
295
|
+
/* INACTIVE */
|
|
296
|
+
), k = x(void 0), $ = x(!1);
|
|
297
|
+
ee(() => {
|
|
298
|
+
if (!O.current) return;
|
|
299
|
+
const r = O.current.style;
|
|
300
|
+
T !== void 0 && r.setProperty("--ripple-hover-opacity", T + ""), S !== void 0 && r.setProperty("--ripple-pressed-opacity", S + "");
|
|
301
|
+
}, [T, S]);
|
|
302
|
+
const y = c(({ pointerType: r }) => r === "touch", []), R = c(
|
|
303
|
+
(r) => {
|
|
304
|
+
if (u || !r.isPrimary || k.current && k.current.pointerId !== r.pointerId)
|
|
305
|
+
return !1;
|
|
306
|
+
if (r.type === "pointerenter" || r.type === "pointerleave")
|
|
307
|
+
return !y(r);
|
|
308
|
+
const n = r.buttons === 1;
|
|
309
|
+
return y(r) || n;
|
|
310
|
+
},
|
|
311
|
+
[u, y]
|
|
312
|
+
), M = c(
|
|
313
|
+
// @ts-ignore
|
|
314
|
+
({ x: r, y: n }) => {
|
|
315
|
+
const a = E.current;
|
|
316
|
+
if (!a) return !1;
|
|
317
|
+
const { top: s, left: m, bottom: p, right: o } = a.getBoundingClientRect();
|
|
318
|
+
return r >= m && r <= o && n >= s && n <= p;
|
|
319
|
+
},
|
|
320
|
+
[E]
|
|
321
|
+
), Z = c(
|
|
322
|
+
(r) => {
|
|
323
|
+
R(r) && w(!0);
|
|
324
|
+
},
|
|
325
|
+
[R]
|
|
326
|
+
), W = c(() => {
|
|
327
|
+
const r = E.current;
|
|
328
|
+
if (!r) return;
|
|
329
|
+
const { height: n, width: a } = r.getBoundingClientRect(), s = Math.max(n, a), m = Math.max(
|
|
330
|
+
me * s,
|
|
331
|
+
de
|
|
332
|
+
), p = Math.floor(s * le), _ = Math.sqrt(a ** 2 + n ** 2) + fe;
|
|
333
|
+
I.current = p, B.current = `${(_ + m) / p}`, b.current = `${p}px`;
|
|
334
|
+
}, [E]), j = c(
|
|
335
|
+
(r) => {
|
|
336
|
+
const n = E.current;
|
|
337
|
+
if (!n) return { x: 0, y: 0 };
|
|
338
|
+
const { scrollX: a, scrollY: s } = window, { left: m, top: p } = n.getBoundingClientRect(), o = a + m, _ = s + p, { pageX: D, pageY: Q } = r;
|
|
339
|
+
return { x: D - o, y: Q - _ };
|
|
340
|
+
},
|
|
341
|
+
[E]
|
|
342
|
+
), Y = c(
|
|
343
|
+
(r) => {
|
|
344
|
+
const n = E.current.parentElement;
|
|
345
|
+
if (!n)
|
|
346
|
+
return { startPoint: { x: 0, y: 0 }, endPoint: { x: 0, y: 0 } };
|
|
347
|
+
const { height: a, width: s } = n.getBoundingClientRect(), m = {
|
|
348
|
+
x: (s - I.current) / 2,
|
|
349
|
+
y: (a - I.current) / 2
|
|
350
|
+
};
|
|
351
|
+
return {
|
|
352
|
+
startPoint: j(r),
|
|
353
|
+
endPoint: m
|
|
354
|
+
};
|
|
355
|
+
},
|
|
356
|
+
[E, j]
|
|
357
|
+
), h = c(
|
|
358
|
+
(r) => {
|
|
359
|
+
var o;
|
|
360
|
+
const n = O.current;
|
|
361
|
+
if (!n) return;
|
|
362
|
+
P(!0), (o = C.current) == null || o.cancel(), W();
|
|
363
|
+
const { startPoint: a, endPoint: s } = Y(r), m = `${a.x}px, ${a.y}px`, p = `${s.x}px, ${s.y}px`;
|
|
364
|
+
C.current = n.animate(
|
|
365
|
+
{
|
|
366
|
+
height: [b.current, b.current],
|
|
367
|
+
width: [b.current, b.current],
|
|
368
|
+
transform: [
|
|
369
|
+
`translate(${m}) scale(1)`,
|
|
370
|
+
`translate(${p}) scale(${B.current})`
|
|
371
|
+
]
|
|
372
|
+
},
|
|
373
|
+
{
|
|
374
|
+
pseudoElement: "::after",
|
|
375
|
+
duration: g,
|
|
376
|
+
easing: f,
|
|
377
|
+
fill: pe
|
|
378
|
+
}
|
|
379
|
+
);
|
|
380
|
+
},
|
|
381
|
+
[W, g, f, Y]
|
|
382
|
+
), d = c(() => {
|
|
383
|
+
k.current = void 0, i.current = 0;
|
|
384
|
+
const r = C.current;
|
|
385
|
+
let n = 1 / 0;
|
|
386
|
+
if (typeof (r == null ? void 0 : r.currentTime) == "number" ? n = r.currentTime : r != null && r.currentTime && (n = r.currentTime.to(
|
|
387
|
+
"ms"
|
|
388
|
+
).value), n >= v)
|
|
389
|
+
return void P(!1);
|
|
390
|
+
setTimeout(() => {
|
|
391
|
+
C.current === r && P(!1);
|
|
392
|
+
}, v - n);
|
|
393
|
+
}, [v]), G = c(
|
|
394
|
+
(r) => {
|
|
395
|
+
R(r) && (w(!1), i.current !== 0 && d());
|
|
396
|
+
},
|
|
397
|
+
[d, R]
|
|
398
|
+
), q = c(
|
|
399
|
+
(r) => {
|
|
400
|
+
if (R(r)) {
|
|
401
|
+
if (i.current === 2) {
|
|
402
|
+
i.current = 3;
|
|
403
|
+
return;
|
|
404
|
+
}
|
|
405
|
+
if (i.current === 1) {
|
|
406
|
+
i.current = 3, h(k.current);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
},
|
|
411
|
+
[R, h]
|
|
412
|
+
), J = c(
|
|
413
|
+
async (r) => {
|
|
414
|
+
if (R(r)) {
|
|
415
|
+
if (k.current = r, !y(r)) {
|
|
416
|
+
i.current = 3, h(r);
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
$.current && !M(r) || ($.current = !1, i.current = 1, await new Promise((n) => {
|
|
420
|
+
setTimeout(n, z);
|
|
421
|
+
}), i.current === 1 && (i.current = 2, h(r)));
|
|
422
|
+
}
|
|
423
|
+
},
|
|
424
|
+
[R, y, M, h, z]
|
|
425
|
+
), X = c(() => {
|
|
426
|
+
if (!u) {
|
|
427
|
+
if (i.current === 3) {
|
|
428
|
+
d();
|
|
429
|
+
return;
|
|
430
|
+
}
|
|
431
|
+
i.current === 0 && (h(), d());
|
|
432
|
+
}
|
|
433
|
+
}, [u, d, h]), V = c(
|
|
434
|
+
(r) => {
|
|
435
|
+
R(r) && d();
|
|
436
|
+
},
|
|
437
|
+
[d, R]
|
|
438
|
+
), e = c(() => {
|
|
439
|
+
u || ($.current = !0, d());
|
|
440
|
+
}, [u, d]);
|
|
441
|
+
ee(() => {
|
|
442
|
+
u && (w(!1), P(!1));
|
|
443
|
+
}, [u]);
|
|
444
|
+
const t = ae(() => ["salty-ripple-surface", [U && "hovered", N && "pressed"].filter(Boolean).join(" ")].filter(Boolean).join(" "), [U, N]);
|
|
445
|
+
return /* @__PURE__ */ oe.jsx(
|
|
446
|
+
"div",
|
|
447
|
+
{
|
|
448
|
+
ref: E,
|
|
449
|
+
className: `salty-ripple${A ? ` ${A}` : ""}`,
|
|
450
|
+
style: l,
|
|
451
|
+
"aria-hidden": "true",
|
|
452
|
+
onClick: X,
|
|
453
|
+
onContextMenu: e,
|
|
454
|
+
onPointerCancel: V,
|
|
455
|
+
onPointerDown: J,
|
|
456
|
+
onPointerEnter: Z,
|
|
457
|
+
onPointerLeave: G,
|
|
458
|
+
onPointerUp: q,
|
|
459
|
+
children: /* @__PURE__ */ oe.jsx("div", { ref: O, className: t })
|
|
460
|
+
}
|
|
461
|
+
);
|
|
462
|
+
};
|
|
463
|
+
export {
|
|
464
|
+
Re as Ripple
|
|
465
|
+
};
|
package/dist/ripple.css
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
.salty-ripple-surface {
|
|
2
|
+
position: absolute;
|
|
3
|
+
inset: 0;
|
|
4
|
+
pointer-events: none;
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.salty-ripple-surface::before,
|
|
9
|
+
.salty-ripple-surface::after {
|
|
10
|
+
content: '';
|
|
11
|
+
opacity: 0;
|
|
12
|
+
position: absolute;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.salty-ripple-surface::before {
|
|
16
|
+
background-color: currentColor;
|
|
17
|
+
inset: 0;
|
|
18
|
+
transition:
|
|
19
|
+
opacity 15ms linear,
|
|
20
|
+
background-color 15ms linear;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.salty-ripple-surface::after {
|
|
24
|
+
background: radial-gradient(
|
|
25
|
+
closest-side,
|
|
26
|
+
currentColor max(100% - 70px, 65%),
|
|
27
|
+
transparent 100%
|
|
28
|
+
);
|
|
29
|
+
transform-origin: center center;
|
|
30
|
+
transition: opacity 375ms linear;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.hovered::before {
|
|
34
|
+
background-color: currentColor;
|
|
35
|
+
opacity: 0.08;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.pressed::after {
|
|
39
|
+
opacity: 0.12;
|
|
40
|
+
transition-duration: 75ms;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/* React-specific styles */
|
|
44
|
+
.salty-ripple {
|
|
45
|
+
position: absolute;
|
|
46
|
+
top: 0;
|
|
47
|
+
left: 0;
|
|
48
|
+
width: 100%;
|
|
49
|
+
height: 100%;
|
|
50
|
+
display: block;
|
|
51
|
+
margin: auto;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
.salty-ripple[aria-disabled='true'] {
|
|
55
|
+
display: none;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@media (forced-colors: active) {
|
|
59
|
+
.salty-ripple {
|
|
60
|
+
display: none;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.salty-ripple .salty-ripple-surface {
|
|
65
|
+
inset: 0;
|
|
66
|
+
pointer-events: none;
|
|
67
|
+
overflow: hidden;
|
|
68
|
+
border-radius: inherit;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.salty-ripple .salty-ripple-surface::before,
|
|
72
|
+
.salty-ripple .salty-ripple-surface::after {
|
|
73
|
+
content: '';
|
|
74
|
+
opacity: 0;
|
|
75
|
+
position: absolute;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.salty-ripple .salty-ripple-surface::before {
|
|
79
|
+
width: 100%;
|
|
80
|
+
height: 100%;
|
|
81
|
+
background-color: currentColor;
|
|
82
|
+
inset: 0;
|
|
83
|
+
transition:
|
|
84
|
+
opacity 15ms linear,
|
|
85
|
+
background-color 15ms linear;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.salty-ripple .salty-ripple-surface::after {
|
|
89
|
+
inset: 0;
|
|
90
|
+
background: radial-gradient(
|
|
91
|
+
closest-side,
|
|
92
|
+
currentColor max(100% - 70px, 65%),
|
|
93
|
+
transparent 100%
|
|
94
|
+
);
|
|
95
|
+
transform-origin: center center;
|
|
96
|
+
transition: opacity 375ms linear;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.salty-ripple .salty-ripple-surface.hovered::before {
|
|
100
|
+
background-color: currentColor;
|
|
101
|
+
opacity: var(--ripple-hover-opacity, 0.08);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.salty-ripple .salty-ripple-surface.pressed::after {
|
|
105
|
+
opacity: var(--ripple-pressed-opacity, 0.12);
|
|
106
|
+
transition-duration: 75ms;
|
|
107
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "m3-ripple",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "React TypeScript implementation of Material Design 3 Ripple component",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "saltyAom",
|
|
8
|
+
"url": "https://github.com/SaltyAom",
|
|
9
|
+
"email": "saltyaom@gmail.com"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"dev": "vite --config vite.config.site",
|
|
13
|
+
"build": "vite build --config vite.config.lib && tsc && cp src/ripple.css dist/ripple.css && vite build --config vite.config.site && cp assets/* dist-web/assets",
|
|
14
|
+
"lint": "eslint .",
|
|
15
|
+
"preview": "serve -p 4173 dist-web"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js",
|
|
21
|
+
"require": "./dist/index.cjs",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./ripple.css": "./dist/ripple.css"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"react": ">= 18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@eslint/js": "^9.25.0",
|
|
31
|
+
"@types/node": "^24.0.3",
|
|
32
|
+
"@types/react": "^19.1.2",
|
|
33
|
+
"@types/react-dom": "^19.1.2",
|
|
34
|
+
"@vitejs/plugin-react": "^4.4.1",
|
|
35
|
+
"eslint": "^9.25.0",
|
|
36
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
37
|
+
"eslint-plugin-react-refresh": "^0.4.19",
|
|
38
|
+
"globals": "^16.0.0",
|
|
39
|
+
"react": "^19.1.0",
|
|
40
|
+
"react-dom": "^19.1.0",
|
|
41
|
+
"serve": "^14.2.4",
|
|
42
|
+
"typescript": "~5.8.3",
|
|
43
|
+
"typescript-eslint": "^8.30.1",
|
|
44
|
+
"vite": "^6.3.5"
|
|
45
|
+
},
|
|
46
|
+
"repository": {
|
|
47
|
+
"type": "git",
|
|
48
|
+
"url": "https://github.com/saltyaom/m3-ripple"
|
|
49
|
+
},
|
|
50
|
+
"bugs": "https://github.com/saltyaom/m3-ripple/issues",
|
|
51
|
+
"homepage": "https://github.com/saltyaom/m3-ripple",
|
|
52
|
+
"keywords": [
|
|
53
|
+
"react",
|
|
54
|
+
"ripple",
|
|
55
|
+
"material design",
|
|
56
|
+
"material you"
|
|
57
|
+
],
|
|
58
|
+
"license": "MIT"
|
|
59
|
+
}
|