motioncss-ui 0.1.4 → 0.1.6
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 +286 -15
- package/dist/motioncss-ui.css +1 -0
- package/dist/motioncss-ui.js +648 -473
- package/dist/motioncss-ui.umd.cjs +27 -23
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(j,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],m):(j=typeof globalThis<"u"?globalThis:j||self,m(j.MotionCSSUI={},j.React))})(this,(function(j,m){"use strict";var ee={exports:{}},K={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var pe;function Je(){if(pe)return K;pe=1;var l=m,n=Symbol.for("react.element"),i=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,v=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,c={key:!0,ref:!0,__self:!0,__source:!0};function u(p,a,f){var s,h={},y=null,E=null;f!==void 0&&(y=""+f),a.key!==void 0&&(y=""+a.key),a.ref!==void 0&&(E=a.ref);for(s in a)o.call(a,s)&&!c.hasOwnProperty(s)&&(h[s]=a[s]);if(p&&p.defaultProps)for(s in a=p.defaultProps,a)h[s]===void 0&&(h[s]=a[s]);return{$$typeof:n,type:p,key:y,ref:E,props:h,_owner:v.current}}return K.Fragment=i,K.jsx=u,K.jsxs=u,K}var H={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,30 +14,34 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+ie+e}}var
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+
|
|
17
|
+
*/var ye;function Ge(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&(function(){var l=m,n=Symbol.for("react.element"),i=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),c=Symbol.for("react.profiler"),u=Symbol.for("react.provider"),p=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),s=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),E=Symbol.for("react.offscreen"),x=Symbol.iterator,S="@@iterator";function M(e){if(e===null||typeof e!="object")return null;var t=x&&e[x]||e[S];return typeof t=="function"?t:null}var O=l.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function w(e){{for(var t=arguments.length,r=new Array(t>1?t-1:0),d=1;d<t;d++)r[d-1]=arguments[d];A("error",e,r)}}function A(e,t,r){{var d=O.ReactDebugCurrentFrame,R=d.getStackAddendum();R!==""&&(t+="%s",r=r.concat([R]));var _=r.map(function(b){return String(b)});_.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,_)}}var I=!1,W=!1,$=!1,L=!1,V=!1,J;J=Symbol.for("react.module.reference");function N(e){return!!(typeof e=="string"||typeof e=="function"||e===o||e===c||V||e===v||e===f||e===s||L||e===E||I||W||$||typeof e=="object"&&e!==null&&(e.$$typeof===y||e.$$typeof===h||e.$$typeof===u||e.$$typeof===p||e.$$typeof===a||e.$$typeof===J||e.getModuleId!==void 0))}function Z(e,t,r){var d=e.displayName;if(d)return d;var R=t.displayName||t.name||"";return R!==""?r+"("+R+")":r}function xe(e){return e.displayName||"Context"}function Y(e){if(e==null)return null;if(typeof e.tag=="number"&&w("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case o:return"Fragment";case i:return"Portal";case c:return"Profiler";case v:return"StrictMode";case f:return"Suspense";case s:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case p:var t=e;return xe(t)+".Consumer";case u:var r=e;return xe(r._context)+".Provider";case a:return Z(e,e.render,"ForwardRef");case h:var d=e.displayName||null;return d!==null?d:Y(e.type)||"Memo";case y:{var R=e,_=R._payload,b=R._init;try{return Y(b(_))}catch{return null}}}return null}var B=Object.assign,Q=0,_e,Se,we,Pe,Te,je,Ce;function Oe(){}Oe.__reactDisabledLog=!0;function lt(){{if(Q===0){_e=console.log,Se=console.info,we=console.warn,Pe=console.error,Te=console.group,je=console.groupCollapsed,Ce=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Oe,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Q++}}function ut(){{if(Q--,Q===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},e,{value:_e}),info:B({},e,{value:Se}),warn:B({},e,{value:we}),error:B({},e,{value:Pe}),group:B({},e,{value:Te}),groupCollapsed:B({},e,{value:je}),groupEnd:B({},e,{value:Ce})})}Q<0&&w("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var se=O.ReactCurrentDispatcher,ie;function te(e,t,r){{if(ie===void 0)try{throw Error()}catch(R){var d=R.stack.trim().match(/\n( *(at )?)/);ie=d&&d[1]||""}return`
|
|
18
|
+
`+ie+e}}var ce=!1,re;{var ft=typeof WeakMap=="function"?WeakMap:Map;re=new ft}function ke(e,t){if(!e||ce)return"";{var r=re.get(e);if(r!==void 0)return r}var d;ce=!0;var R=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var _;_=se.current,se.current=null,lt();try{if(t){var b=function(){throw Error()};if(Object.defineProperty(b.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(b,[])}catch(F){d=F}Reflect.construct(e,[],b)}else{try{b.call()}catch(F){d=F}e.call(b.prototype)}}else{try{throw Error()}catch(F){d=F}e()}}catch(F){if(F&&d&&typeof F.stack=="string"){for(var g=F.stack.split(`
|
|
19
|
+
`),k=d.stack.split(`
|
|
20
|
+
`),P=g.length-1,T=k.length-1;P>=1&&T>=0&&g[P]!==k[T];)T--;for(;P>=1&&T>=0;P--,T--)if(g[P]!==k[T]){if(P!==1||T!==1)do if(P--,T--,T<0||g[P]!==k[T]){var D=`
|
|
21
|
+
`+g[P].replace(" at new "," at ");return e.displayName&&D.includes("<anonymous>")&&(D=D.replace("<anonymous>",e.displayName)),typeof e=="function"&&re.set(e,D),D}while(P>=1&&T>=0);break}}}finally{ce=!1,se.current=_,ut(),Error.prepareStackTrace=R}var z=e?e.displayName||e.name:"",U=z?te(z):"";return typeof e=="function"&&re.set(e,U),U}function dt(e,t,r){return ke(e,!1)}function vt(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function ne(e,t,r){if(e==null)return"";if(typeof e=="function")return ke(e,vt(e));if(typeof e=="string")return te(e);switch(e){case f:return te("Suspense");case s:return te("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case a:return dt(e.render);case h:return ne(e.type,t,r);case y:{var d=e,R=d._payload,_=d._init;try{return ne(_(R),t,r)}catch{}}}return""}var q=Object.prototype.hasOwnProperty,Fe={},Me=O.ReactDebugCurrentFrame;function ae(e){if(e){var t=e._owner,r=ne(e.type,e._source,t?t.type:null);Me.setExtraStackFrame(r)}else Me.setExtraStackFrame(null)}function pt(e,t,r,d,R){{var _=Function.call.bind(q);for(var b in e)if(_(e,b)){var g=void 0;try{if(typeof e[b]!="function"){var k=Error((d||"React class")+": "+r+" type `"+b+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[b]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw k.name="Invariant Violation",k}g=e[b](t,b,d,r,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(P){g=P}g&&!(g instanceof Error)&&(ae(R),w("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",d||"React class",r,b,typeof g),ae(null)),g instanceof Error&&!(g.message in Fe)&&(Fe[g.message]=!0,ae(R),w("Failed %s type: %s",r,g.message),ae(null))}}}var yt=Array.isArray;function le(e){return yt(e)}function ht(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,r=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return r}}function gt(e){try{return Ae(e),!1}catch{return!0}}function Ae(e){return""+e}function Ie(e){if(gt(e))return w("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ht(e)),Ae(e)}var De=O.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},$e,Le;function bt(e){if(q.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Rt(e){if(q.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function Et(e,t){typeof e.ref=="string"&&De.current}function xt(e,t){{var r=function(){$e||($e=!0,w("%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://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"key",{get:r,configurable:!0})}}function _t(e,t){{var r=function(){Le||(Le=!0,w("%s: `ref` 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://reactjs.org/link/special-props)",t))};r.isReactWarning=!0,Object.defineProperty(e,"ref",{get:r,configurable:!0})}}var St=function(e,t,r,d,R,_,b){var g={$$typeof:n,type:e,key:t,ref:r,props:b,_owner:_};return g._store={},Object.defineProperty(g._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(g,"_self",{configurable:!1,enumerable:!1,writable:!1,value:d}),Object.defineProperty(g,"_source",{configurable:!1,enumerable:!1,writable:!1,value:R}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g};function wt(e,t,r,d,R){{var _,b={},g=null,k=null;r!==void 0&&(Ie(r),g=""+r),Rt(t)&&(Ie(t.key),g=""+t.key),bt(t)&&(k=t.ref,Et(t,R));for(_ in t)q.call(t,_)&&!mt.hasOwnProperty(_)&&(b[_]=t[_]);if(e&&e.defaultProps){var P=e.defaultProps;for(_ in P)b[_]===void 0&&(b[_]=P[_])}if(g||k){var T=typeof e=="function"?e.displayName||e.name||"Unknown":e;g&&xt(b,T),k&&_t(b,T)}return St(e,g,k,R,d,De.current,b)}}var ue=O.ReactCurrentOwner,Ye=O.ReactDebugCurrentFrame;function G(e){if(e){var t=e._owner,r=ne(e.type,e._source,t?t.type:null);Ye.setExtraStackFrame(r)}else Ye.setExtraStackFrame(null)}var fe;fe=!1;function de(e){return typeof e=="object"&&e!==null&&e.$$typeof===n}function We(){{if(ue.current){var e=Y(ue.current.type);if(e)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+e+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+e+"`."}return""}}function Pt(e){return""}var Ve={};function Tt(e){{var t=We();if(!t){var r=typeof e=="string"?e:e.displayName||e.name;r&&(t=`
|
|
24
24
|
|
|
25
|
-
Check the top-level render call using <`+r+">.")}return t}}function
|
|
25
|
+
Check the top-level render call using <`+r+">.")}return t}}function Ne(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var r=Tt(t);if(Ve[r])return;Ve[r]=!0;var d="";e&&e._owner&&e._owner!==ue.current&&(d=" It was passed a child from "+Y(e._owner.type)+"."),G(e),w('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',r,d),G(null)}}function Be(e,t){{if(typeof e!="object")return;if(le(e))for(var r=0;r<e.length;r++){var d=e[r];de(d)&&Ne(d,t)}else if(de(e))e._store&&(e._store.validated=!0);else if(e){var R=M(e);if(typeof R=="function"&&R!==e.entries)for(var _=R.call(e),b;!(b=_.next()).done;)de(b.value)&&Ne(b.value,t)}}}function jt(e){{var t=e.type;if(t==null||typeof t=="string")return;var r;if(typeof t=="function")r=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===a||t.$$typeof===h))r=t.propTypes;else return;if(r){var d=Y(t);pt(r,e.props,"prop",d,e)}else if(t.PropTypes!==void 0&&!fe){fe=!0;var R=Y(t);w("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",R||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&w("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ct(e){{for(var t=Object.keys(e.props),r=0;r<t.length;r++){var d=t[r];if(d!=="children"&&d!=="key"){G(e),w("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",d),G(null);break}}e.ref!==null&&(G(e),w("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var Ue={};function Xe(e,t,r,d,R,_){{var b=N(e);if(!b){var g="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(g+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var k=Pt();k?g+=k:g+=We();var P;e===null?P="null":le(e)?P="array":e!==void 0&&e.$$typeof===n?(P="<"+(Y(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):P=typeof e,w("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",P,g)}var T=wt(e,t,r,R,_);if(T==null)return T;if(b){var D=t.children;if(D!==void 0)if(d)if(le(D)){for(var z=0;z<D.length;z++)Be(D[z],e);Object.freeze&&Object.freeze(D)}else w("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 Be(D,e)}if(q.call(t,"key")){var U=Y(e),F=Object.keys(t).filter(function(It){return It!=="key"}),ve=F.length>0?"{key: someKey, "+F.join(": ..., ")+": ...}":"{key: someKey}";if(!Ue[U+ve]){var At=F.length>0?"{"+F.join(": ..., ")+": ...}":"{}";w(`A props object containing a "key" prop is being spread into JSX:
|
|
26
26
|
let props = %s;
|
|
27
27
|
<%s {...props} />
|
|
28
28
|
React keys must be passed directly to JSX without using spread:
|
|
29
29
|
let props = %s;
|
|
30
|
-
<%s key={someKey} {...props} />`,
|
|
31
|
-
translate(${
|
|
32
|
-
scale(${
|
|
33
|
-
`},p=()=>{const a=
|
|
34
|
-
${
|
|
35
|
-
${
|
|
36
|
-
${
|
|
37
|
-
transparent 75%)`:
|
|
38
|
-
${
|
|
39
|
-
${
|
|
40
|
-
transparent 100%)`:`radial-gradient(${n*
|
|
41
|
-
${
|
|
42
|
-
${
|
|
43
|
-
transparent 100%)`),[n,
|
|
30
|
+
<%s key={someKey} {...props} />`,ve,U,At,U),Ue[U+ve]=!0}}return e===o?Ct(T):jt(T),T}}function Ot(e,t,r){return Xe(e,t,r,!0)}function kt(e,t,r){return Xe(e,t,r,!1)}var Ft=kt,Mt=Ot;H.Fragment=o,H.jsx=Ft,H.jsxs=Mt})()),H}var he;function ze(){return he||(he=1,process.env.NODE_ENV==="production"?ee.exports=Je():ee.exports=Ge()),ee.exports}var C=ze();function Ke({children:l,strength:n=.3,speed:i=.25,scale:o=1,className:v=""}){const c=m.useRef(null),u=a=>{const f=c.current;if(!f)return;const s=f.getBoundingClientRect(),h=a.clientX-(s.left+s.width/2),y=a.clientY-(s.top+s.height/2);f.style.transform=`
|
|
31
|
+
translate(${h*n}px, ${y*n}px)
|
|
32
|
+
scale(${o})
|
|
33
|
+
`},p=()=>{const a=c.current;a&&(a.style.transform="translate(0, 0) scale(1)")};return C.jsx("div",{ref:c,className:v,onMouseMove:u,onMouseLeave:p,style:{display:"inline-block",transition:`transform ${i}s ease-out`,willChange:"transform"},children:l})}function oe(){const[l,n]=m.useState(!1);return m.useEffect(()=>{if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia("(prefers-reduced-motion: reduce)");n(i.matches);const o=v=>n(v.matches);return i.addEventListener("change",o),()=>i.removeEventListener("change",o)},[]),l}function He({children:l,tilt:n=15,scale:i=1.03,glare:o=!0,perspective:v=1e3,className:c="",style:u}){const p=m.useRef(null),a=m.useRef(null),f=oe(),s=y=>{const E=p.current;if(!E||f)return;const x=E.getBoundingClientRect(),S=(y.clientX-x.left)/x.width,M=(y.clientY-x.top)/x.height,O=(S-.5)*2*n,w=(.5-M)*2*n;E.style.transition="transform 0.08s linear",E.style.transform=`perspective(${v}px) rotateX(${w}deg) rotateY(${O}deg) scale(${i})`;const A=a.current;A&&(A.style.opacity="1",A.style.background=`radial-gradient(circle at ${S*100}% ${M*100}%, rgba(255,255,255,0.35), transparent 55%)`)},h=()=>{const y=p.current;y&&(y.style.transition="transform 0.4s ease-out",y.style.transform=`perspective(${v}px) rotateX(0deg) rotateY(0deg) scale(1)`,a.current&&(a.current.style.opacity="0"))};return C.jsxs("div",{ref:p,className:c,onMouseMove:s,onMouseLeave:h,style:{position:"relative",transformStyle:"preserve-3d",willChange:"transform",...u},children:[l,o&&C.jsx("div",{ref:a,"aria-hidden":"true",style:{position:"absolute",inset:0,borderRadius:"inherit",pointerEvents:"none",opacity:0,transition:"opacity 0.3s ease-out"}})]})}const Ze={radial:{opacity:1,blurScale:1,gradient:"radial"},glow:{opacity:.9,blurScale:1.5,gradient:"radial"},soft:{opacity:.7,blurScale:2,gradient:"radial"},sharp:{opacity:1,blurScale:.3,gradient:"radial"},neon:{opacity:1,blurScale:1.2,gradient:"radial"}};function Qe({children:l,size:n=320,intensity:i=.85,color:o="#ffffff",blur:v=60,mode:c="radial",enabled:u=!0,className:p="",style:a}){const f=m.useRef(null),s=m.useRef(null),h=m.useRef(!1),y=Ze[c],E=m.useCallback((x,S)=>(n/2*y.blurScale,v*y.blurScale,c==="neon"?`radial-gradient(${n*y.blurScale}px circle at ${x}px ${S}px,
|
|
34
|
+
${o}33 0%,
|
|
35
|
+
${o}22 25%,
|
|
36
|
+
${o}11 50%,
|
|
37
|
+
transparent 75%)`:c==="sharp"?`radial-gradient(${n*.4}px circle at ${x}px ${S}px,
|
|
38
|
+
${o}dd 0%,
|
|
39
|
+
${o}99 30%,
|
|
40
|
+
transparent 100%)`:`radial-gradient(${n*y.blurScale}px circle at ${x}px ${S}px,
|
|
41
|
+
${o}${Math.round(i*255).toString(16).padStart(2,"0")} 0%,
|
|
42
|
+
${o}${Math.round(i*.5*255).toString(16).padStart(2,"0")} 40%,
|
|
43
|
+
transparent 100%)`),[n,i,o,v,c,y]);return m.useEffect(()=>{if(!u)return;const x=f.current,S=s.current;if(!x||!S)return;const M=A=>{const I=x.getBoundingClientRect(),W=A.clientX-I.left,$=A.clientY-I.top;S.style.background=E(W,$),S.style.opacity=String(y.opacity)},O=()=>{h.current=!0,S.style.transition="opacity 300ms ease",S.style.opacity=String(y.opacity)},w=()=>{h.current=!1,S.style.transition="opacity 600ms ease",S.style.opacity="0"};return x.addEventListener("mousemove",M),x.addEventListener("mouseenter",O),x.addEventListener("mouseleave",w),()=>{x.removeEventListener("mousemove",M),x.removeEventListener("mouseenter",O),x.removeEventListener("mouseleave",w)}},[u,E,y]),C.jsxs("div",{ref:f,className:`motioncss-spotlight ${p}`,style:{position:"relative",overflow:"hidden",...a},children:[l,C.jsx("div",{ref:s,"aria-hidden":"true",style:{position:"absolute",inset:0,pointerEvents:"none",opacity:0,zIndex:10,filter:v>0?`blur(${v*.15}px)`:void 0,mixBlendMode:c==="neon"?"screen":"normal"}})]})}function ge({threshold:l=.2,rootMargin:n="0px",once:i=!0}={}){const o=m.useRef(null),[v,c]=m.useState(!1);return m.useEffect(()=>{const u=o.current;if(!u)return;if(typeof IntersectionObserver>"u"){c(!0);return}const p=new IntersectionObserver(([a])=>{a.isIntersecting?(c(!0),i&&p.disconnect()):i||c(!1)},{threshold:l,rootMargin:n});return p.observe(u),()=>p.disconnect()},[l,n,i]),{ref:o,inView:v}}function qe({children:l,stagger:n=70,duration:i=700,delay:o=0,once:v=!0,as:c="div",className:u="",style:p}){const{ref:a,inView:f}=ge({once:v}),s=oe(),h=c,y=l.split(/\s+/).filter(Boolean),E=f||s;return C.jsx(h,{ref:a,className:u,style:p,"aria-label":l,children:y.map((x,S)=>C.jsx("span",{"aria-hidden":"true",style:{display:"inline-block",overflow:"hidden",verticalAlign:"top",paddingBottom:"0.15em",marginRight:"0.25em"},children:C.jsx("span",{style:{display:"inline-block",transform:E?"translateY(0)":"translateY(110%)",opacity:E?1:0,transition:s?"none":`transform ${i}ms cubic-bezier(0.22, 1, 0.36, 1) ${o+S*n}ms, opacity ${i}ms ease ${o+S*n}ms`},children:x})},S))})}function et(l,n){switch(l){case"fade-up":return`translateY(${n}px)`;case"fade-down":return`translateY(${-n}px)`;case"fade-left":return`translateX(${n}px)`;case"fade-right":return`translateX(${-n}px)`;case"zoom":return"scale(0.92)";default:return"none"}}function tt({children:l,animation:n="fade-up",duration:i=700,delay:o=0,distance:v=32,threshold:c=.2,once:u=!0,className:p="",style:a}){const{ref:f,inView:s}=ge({threshold:c,once:u}),h=oe(),y=s||h;return C.jsx("div",{ref:f,className:p,style:{opacity:y?1:0,transform:y?"none":et(n,v),transition:h?"none":`opacity ${i}ms ease ${o}ms, transform ${i}ms cubic-bezier(0.22, 1, 0.36, 1) ${o}ms`,willChange:"opacity, transform",...a},children:l})}function rt({children:l,colors:n=["#6366f1","#ec4899","#f59e0b","#06b6d4"],angle:i=120,duration:o=12,className:v="",style:c}){const u=[...n,n[0]].join(", ");return C.jsx("div",{className:`mcss-gradient-flow ${v}`.trim(),style:{backgroundImage:`linear-gradient(${i}deg, ${u})`,animationDuration:`${o}s`,...c},children:l})}function nt(l,n,i,o){const v=[],c=i;if(l==="left"||l==="right"){const u=l==="left",p=u?n*100:100-n*100,a=u?p-100:p+100;v.push(`${a}% 0%`),v.push(`${a}% 100%`);for(let f=o;f>=0;f--){const s=f/o,h=s*100,y=Math.sin(s*Math.PI)*c,E=p+(u?y:-y);v.push(`${E}% ${h}%`)}}else{const u=l==="top",p=u?n*100:100-n*100,a=u?p-100:p+100;v.push(`0% ${a}%`),v.push(`100% ${a}%`);for(let f=o;f>=0;f--){const s=f/o,h=s*100,y=Math.sin(s*Math.PI)*c,E=p+(u?y:-y);v.push(`${h}% ${E}%`)}}return`polygon(${v.join(", ")})`}function at({origin:l="left",duration:n=900,color:i="#111111",curve:o=8,resolution:v=20,blur:c=0,onComplete:u,style:p}){const a=m.useRef(null),f=m.useRef(null),s=m.useRef(null);return m.useEffect(()=>{const h=a.current;if(!h)return;const y=E=>{s.current||(s.current=E);const x=E-s.current,S=Math.min(x/n,1)*2;h.style.clipPath=nt(l,S,o,v),S<2?f.current=requestAnimationFrame(y):(h.style.clipPath="polygon(200% 0%, 200% 100%, 100% 100%, 100% 0%)",u==null||u())};return f.current=requestAnimationFrame(y),()=>{f.current&&cancelAnimationFrame(f.current)}},[l,n,o,v,u]),C.jsx("div",{ref:a,"aria-hidden":"true",style:{position:"fixed",inset:0,zIndex:9999,pointerEvents:"none",background:i,backdropFilter:c>0?`blur(${c}px)`:void 0,WebkitBackdropFilter:c>0?`blur(${c}px)`:void 0,...p}})}function ot({children:l,origin:n="left",duration:i=900,color:o="#111111",curve:v=8,blur:c=0,className:u="",style:p}){const a=m.useRef(null),f=m.useRef(null),s=m.useRef(null),[h,y]=m.useState(!1);return m.useEffect(()=>{const E=a.current;if(!E)return;const x=S=>{s.current||(s.current=S);const M=Math.min((S-s.current)/i,1),O=[],w=v,A=20;if(n==="left"||n==="right"){const I=n==="left",W=I?M*100:100-M*100,$=I?150:-50;for(let L=0;L<=A;L++){const V=L/A,J=V*100,N=Math.sin(V*Math.PI)*w,Z=W+(I?N:-N);O.push(`${Z}% ${J}%`)}O.push(`${$}% 100%`),O.push(`${$}% 0%`)}else{const I=n==="top",W=I?M*100:100-M*100,$=I?150:-50;for(let L=0;L<=A;L++){const V=L/A,J=V*100,N=Math.sin(V*Math.PI)*w,Z=W+(I?N:-N);O.push(`${J}% ${Z}%`)}O.push(`100% ${$}%`),O.push(`0% ${$}%`)}E.style.clipPath=`polygon(${O.join(", ")})`,M<1?f.current=requestAnimationFrame(x):(E.style.clipPath="none",E.style.display="none",y(!0))};return f.current=requestAnimationFrame(x),()=>{f.current&&cancelAnimationFrame(f.current)}},[n,i,o,v]),C.jsxs("div",{className:`motioncss-wave-reveal ${u}`,style:{position:"relative",overflow:"hidden",...p},children:[l,!h&&C.jsx("div",{ref:a,"aria-hidden":"true",style:{position:"absolute",inset:0,background:o,backdropFilter:c>0?`blur(${c}px)`:void 0,WebkitBackdropFilter:c>0?`blur(${c}px)`:void 0,zIndex:10,pointerEvents:"none"}})]})}const me=m.createContext(null);function be(){const l=m.useContext(me);if(!l)throw new Error("useScrollytelling must be used inside <Scrollytelling>");return l}function st({children:l,height:n="400vh",className:i="",style:o}){const v=m.useRef(null),[c,u]=m.useState(0);return m.useEffect(()=>{let p=0;const a=()=>{p||(p=requestAnimationFrame(()=>{p=0;const f=v.current;if(!f)return;const s=f.getBoundingClientRect(),h=s.height-window.innerHeight;if(h<=0){u(0);return}const y=-s.top/h,E=Math.min(1,Math.max(0,y));u(E)}))};return a(),window.addEventListener("scroll",a,{passive:!0}),window.addEventListener("resize",a),()=>{window.removeEventListener("scroll",a),window.removeEventListener("resize",a),p&&cancelAnimationFrame(p)}},[]),C.jsx(me.Provider,{value:{progress:c},children:C.jsx("section",{ref:v,className:`motioncss-scrollytelling ${i}`,style:{height:n,position:"relative",...o},children:C.jsx("div",{className:"motioncss-scrollytelling__stage",style:{position:"sticky",top:0,width:"100%",height:"100vh",overflow:"hidden"},children:l})})})}const Re=m.createContext(null);function Ee(){const l=m.useContext(Re);if(!l)throw new Error("useSceneProgress must be used inside <Scene>");return l}function it({children:l,start:n,end:i,fadeOutRange:o=.05,className:v="",style:c}){const{progress:u}=be(),p=Math.max(i-n,1e-4),a=(u-n)/p,f=Math.min(1,Math.max(0,a));let s=1;if(o>0&&u>i){const h=u-i;s=1-Math.min(1,h/o)}else o===0&&u>i&&(s=0);return C.jsx(Re.Provider,{value:{progress:f},children:C.jsx("div",{className:`motioncss-scene ${v}`,style:{position:"absolute",inset:0,opacity:s,pointerEvents:f>0&&f<1?"auto":"none",...c},children:l})})}function X(l=0,n=0,i){return l+(n-l)*i}function ct({children:l,from:n={},to:i={},className:o="",style:v}){const{progress:c}=Ee(),u=X(n.opacity??1,i.opacity??1,c),p=X(n.scale??1,i.scale??1,c),a=X(n.x??0,i.x??0,c),f=X(n.y??0,i.y??0,c),s=X(n.rotate??0,i.rotate??0,c),h=X(n.blur??0,i.blur??0,c);return C.jsx("div",{className:`motioncss-scroll-layer ${o}`,style:{opacity:u,transform:`
|
|
44
|
+
translate3d(${a}px, ${f}px, 0)
|
|
45
|
+
scale(${p})
|
|
46
|
+
rotate(${s}deg)
|
|
47
|
+
`,filter:h>0?`blur(${h}px)`:"none",willChange:"transform, opacity, filter",...v},children:l})}j.EdgeWave=at,j.GradientFlow=rt,j.Magnetic=Ke,j.RevealText=qe,j.Scene=it,j.ScrollLayer=ct,j.ScrollReveal=tt,j.Scrollytelling=st,j.Spotlight=Qe,j.TiltCard=He,j.WaveReveal=ot,j.useSceneProgress=Ee,j.useScrollytelling=be,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motioncss-ui",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Zero-dependency React motion components: Magnetic, TiltCard, Spotlight, ScrollReveal, GradientFlow, EdgeWave.",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "Zero-dependency React motion components: Magnetic, TiltCard, Spotlight, ScrollReveal, ScrollReveal, AmbientBackground, RevealText, GradientFlow, EdgeWave, WaveReveal, Scrollytelling.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/motioncss-ui.umd.cjs",
|
|
7
7
|
"module": "./dist/motioncss-ui.js",
|