react-spring-carousel 3.0.0-beta090.42 → 3.0.0-beta090.44
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/dist/index.cjs.js +5 -5
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +84 -84
- package/dist/index.es.js.map +1 -1
- package/dist/types/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -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 ar;function mr(){if(ar)return Ae;ar=1;var n=l,p=Symbol.for("react.element"),m=Symbol.for("react.fragment"),$=Object.prototype.hasOwnProperty,U=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function w(f,d,v){var
|
|
9
|
+
*/var ar;function mr(){if(ar)return Ae;ar=1;var n=l,p=Symbol.for("react.element"),m=Symbol.for("react.fragment"),$=Object.prototype.hasOwnProperty,U=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,h={key:!0,ref:!0,__self:!0,__source:!0};function w(f,d,v){var N,A={},I=null,o=null;v!==void 0&&(I=""+v),d.key!==void 0&&(I=""+d.key),d.ref!==void 0&&(o=d.ref);for(N in d)$.call(d,N)&&!h.hasOwnProperty(N)&&(A[N]=d[N]);if(f&&f.defaultProps)for(N in d=f.defaultProps,d)A[N]===void 0&&(A[N]=d[N]);return{$$typeof:p,type:f,key:I,ref:o,props:A,_owner:U.current}}return Ae.Fragment=m,Ae.jsx=w,Ae.jsxs=w,Ae}var Le={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,15 +14,15 @@
|
|
|
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 or;function yr(){return or||(or=1,process.env.NODE_ENV!=="production"&&function(){var n=l,p=Symbol.for("react.element"),m=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),w=Symbol.for("react.provider"),f=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),
|
|
18
|
-
`+q+e}}var me=!1,ke;{var
|
|
17
|
+
*/var or;function yr(){return or||(or=1,process.env.NODE_ENV!=="production"&&function(){var n=l,p=Symbol.for("react.element"),m=Symbol.for("react.portal"),$=Symbol.for("react.fragment"),U=Symbol.for("react.strict_mode"),h=Symbol.for("react.profiler"),w=Symbol.for("react.provider"),f=Symbol.for("react.context"),d=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),A=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),o=Symbol.for("react.offscreen"),B=Symbol.iterator,b="@@iterator";function ae(e){if(e===null||typeof e!="object")return null;var t=B&&e[B]||e[b];return typeof t=="function"?t:null}var F=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function O(e){{for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];ne("error",e,i)}}function ne(e,t,i){{var s=F.ReactDebugCurrentFrame,E=s.getStackAddendum();E!==""&&(t+="%s",i=i.concat([E]));var _=i.map(function(y){return String(y)});_.unshift("Warning: "+t),Function.prototype.apply.call(console[e],console,_)}}var De=!1,ie=!1,Y=!1,ue=!1,oe=!1,z;z=Symbol.for("react.module.reference");function Ee(e){return!!(typeof e=="string"||typeof e=="function"||e===$||e===h||oe||e===U||e===v||e===N||ue||e===o||De||ie||Y||typeof e=="object"&&e!==null&&(e.$$typeof===I||e.$$typeof===A||e.$$typeof===w||e.$$typeof===f||e.$$typeof===d||e.$$typeof===z||e.getModuleId!==void 0))}function G(e,t,i){var s=e.displayName;if(s)return s;var E=t.displayName||t.name||"";return E!==""?i+"("+E+")":i}function M(e){return e.displayName||"Context"}function x(e){if(e==null)return null;if(typeof e.tag=="number"&&O("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 $:return"Fragment";case m:return"Portal";case h:return"Profiler";case U:return"StrictMode";case v:return"Suspense";case N:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case f:var t=e;return M(t)+".Consumer";case w:var i=e;return M(i._context)+".Provider";case d:return G(e,e.render,"ForwardRef");case A:var s=e.displayName||null;return s!==null?s:x(e.type)||"Memo";case I:{var E=e,_=E._payload,y=E._init;try{return x(y(_))}catch{return null}}}return null}var R=Object.assign,C=0,D,ge,pe,c,T,k,X;function H(){}H.__reactDisabledLog=!0;function He(){{if(C===0){D=console.log,ge=console.info,pe=console.warn,c=console.error,T=console.group,k=console.groupCollapsed,X=console.groupEnd;var e={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}C++}}function Ie(){{if(C--,C===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:R({},e,{value:D}),info:R({},e,{value:ge}),warn:R({},e,{value:pe}),error:R({},e,{value:c}),group:R({},e,{value:T}),groupCollapsed:R({},e,{value:k}),groupEnd:R({},e,{value:X})})}C<0&&O("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ee=F.ReactCurrentDispatcher,q;function ce(e,t,i){{if(q===void 0)try{throw Error()}catch(E){var s=E.stack.trim().match(/\n( *(at )?)/);q=s&&s[1]||""}return`
|
|
18
|
+
`+q+e}}var me=!1,ke;{var Ze=typeof WeakMap=="function"?WeakMap:Map;ke=new Ze}function We(e,t){if(!e||me)return"";{var i=ke.get(e);if(i!==void 0)return i}var s;me=!0;var E=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var _;_=ee.current,ee.current=null,He();try{if(t){var y=function(){throw Error()};if(Object.defineProperty(y.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(y,[])}catch(he){s=he}Reflect.construct(e,[],y)}else{try{y.call()}catch(he){s=he}e.call(y.prototype)}}else{try{throw Error()}catch(he){s=he}e()}}catch(he){if(he&&s&&typeof he.stack=="string"){for(var g=he.stack.split(`
|
|
19
19
|
`),J=s.stack.split(`
|
|
20
20
|
`),S=g.length-1,V=J.length-1;S>=1&&V>=0&&g[S]!==J[V];)V--;for(;S>=1&&V>=0;S--,V--)if(g[S]!==J[V]){if(S!==1||V!==1)do if(S--,V--,V<0||g[S]!==J[V]){var Z=`
|
|
21
|
-
`+g[S].replace(" at new "," at ");return e.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",e.displayName)),typeof e=="function"&&ke.set(e,Z),Z}while(S>=1&&V>=0);break}}}finally{me=!1,ee.current=_,Ie(),Error.prepareStackTrace=E}var $e=e?e.displayName||e.name:"",ur=$e?ce($e):"";return typeof e=="function"&&ke.set(e,ur),ur}function Je(e,t,i){return We(e,!1)}function ze(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function Pe(e,t,i){if(e==null)return"";if(typeof e=="function")return We(e,ze(e));if(typeof e=="string")return ce(e);switch(e){case v:return ce("Suspense");case
|
|
21
|
+
`+g[S].replace(" at new "," at ");return e.displayName&&Z.includes("<anonymous>")&&(Z=Z.replace("<anonymous>",e.displayName)),typeof e=="function"&&ke.set(e,Z),Z}while(S>=1&&V>=0);break}}}finally{me=!1,ee.current=_,Ie(),Error.prepareStackTrace=E}var $e=e?e.displayName||e.name:"",ur=$e?ce($e):"";return typeof e=="function"&&ke.set(e,ur),ur}function Je(e,t,i){return We(e,!1)}function ze(e){var t=e.prototype;return!!(t&&t.isReactComponent)}function Pe(e,t,i){if(e==null)return"";if(typeof e=="function")return We(e,ze(e));if(typeof e=="string")return ce(e);switch(e){case v:return ce("Suspense");case N:return ce("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case d:return Je(e.render);case A:return Pe(e.type,t,i);case I:{var s=e,E=s._payload,_=s._init;try{return Pe(_(E),t,i)}catch{}}}return""}var P=Object.prototype.hasOwnProperty,se={},W=F.ReactDebugCurrentFrame;function je(e){if(e){var t=e._owner,i=Pe(e.type,e._source,t?t.type:null);W.setExtraStackFrame(i)}else W.setExtraStackFrame(null)}function Te(e,t,i,s,E){{var _=Function.call.bind(P);for(var y in e)if(_(e,y)){var g=void 0;try{if(typeof e[y]!="function"){var J=Error((s||"React class")+": "+i+" type `"+y+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[y]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw J.name="Invariant Violation",J}g=e[y](t,y,s,i,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(S){g=S}g&&!(g instanceof Error)&&(je(E),O("%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).",s||"React class",i,y,typeof g),je(null)),g instanceof Error&&!(g.message in se)&&(se[g.message]=!0,je(E),O("Failed %s type: %s",i,g.message),je(null))}}}var we=Array.isArray;function ye(e){return we(e)}function re(e){{var t=typeof Symbol=="function"&&Symbol.toStringTag,i=t&&e[Symbol.toStringTag]||e.constructor.name||"Object";return i}}function Ce(e){try{return le(e),!1}catch{return!0}}function le(e){return""+e}function fe(e){if(Ce(e))return O("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",re(e)),le(e)}var _e=F.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},Xe,Ke,Ne;Ne={};function Fe(e){if(P.call(e,"ref")){var t=Object.getOwnPropertyDescriptor(e,"ref").get;if(t&&t.isReactWarning)return!1}return e.ref!==void 0}function Ge(e){if(P.call(e,"key")){var t=Object.getOwnPropertyDescriptor(e,"key").get;if(t&&t.isReactWarning)return!1}return e.key!==void 0}function be(e,t){if(typeof e.ref=="string"&&_e.current&&t&&_e.current.stateNode!==t){var i=x(_e.current.type);Ne[i]||(O('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',x(_e.current.type),e.ref),Ne[i]=!0)}}function Se(e,t){{var i=function(){Xe||(Xe=!0,O("%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))};i.isReactWarning=!0,Object.defineProperty(e,"key",{get:i,configurable:!0})}}function Ve(e,t){{var i=function(){Ke||(Ke=!0,O("%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))};i.isReactWarning=!0,Object.defineProperty(e,"ref",{get:i,configurable:!0})}}var Ye=function(e,t,i,s,E,_,y){var g={$$typeof:p,type:e,key:t,ref:i,props:y,_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:s}),Object.defineProperty(g,"_source",{configurable:!1,enumerable:!1,writable:!1,value:E}),Object.freeze&&(Object.freeze(g.props),Object.freeze(g)),g};function qe(e,t,i,s,E){{var _,y={},g=null,J=null;i!==void 0&&(fe(i),g=""+i),Ge(t)&&(fe(t.key),g=""+t.key),Fe(t)&&(J=t.ref,be(t,E));for(_ in t)P.call(t,_)&&!Qe.hasOwnProperty(_)&&(y[_]=t[_]);if(e&&e.defaultProps){var S=e.defaultProps;for(_ in S)y[_]===void 0&&(y[_]=S[_])}if(g||J){var V=typeof e=="function"?e.displayName||e.name||"Unknown":e;g&&Se(y,V),J&&Ve(y,V)}return Ye(e,g,J,E,s,_e.current,y)}}var Ue=F.ReactCurrentOwner,Oe=F.ReactDebugCurrentFrame;function xe(e){if(e){var t=e._owner,i=Pe(e.type,e._source,t?t.type:null);Oe.setExtraStackFrame(i)}else Oe.setExtraStackFrame(null)}var Be;Be=!1;function r(e){return typeof e=="object"&&e!==null&&e.$$typeof===p}function a(){{if(Ue.current){var e=x(Ue.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function u(e){{if(e!==void 0){var t=e.fileName.replace(/^.*[\\\/]/,""),i=e.lineNumber;return`
|
|
24
24
|
|
|
25
25
|
Check your code at `+t+":"+i+"."}return""}}var j={};function K(e){{var t=a();if(!t){var i=typeof e=="string"?e:e.displayName||e.name;i&&(t=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+i+">.")}return t}}function de(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var i=K(t);if(j[i])return;j[i]=!0;var s="";e&&e._owner&&e._owner!==Ue.current&&(s=" It was passed a child from "+x(e._owner.type)+"."),xe(e),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,s),xe(null)}}function ve(e,t){{if(typeof e!="object")return;if(ye(e))for(var i=0;i<e.length;i++){var s=e[i];r(s)&&de(s,t)}else if(r(e))e._store&&(e._store.validated=!0);else if(e){var E=ae(e);if(typeof E=="function"&&E!==e.entries)for(var _=E.call(e),y;!(y=_.next()).done;)r(y.value)&&de(y.value,t)}}}function er(e){{var t=e.type;if(t==null||typeof t=="string")return;var i;if(typeof t=="function")i=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===d||t.$$typeof===A))i=t.propTypes;else return;if(i){var s=x(t);Te(i,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!Be){Be=!0;var E=x(t);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function te(e){{for(var t=Object.keys(e.props),i=0;i<t.length;i++){var s=t[i];if(s!=="children"&&s!=="key"){xe(e),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),xe(null);break}}e.ref!==null&&(xe(e),O("Invalid attribute `ref` supplied to `React.Fragment`."),xe(null))}}function rr(e,t,i,s,E,_){{var y=Ee(e);if(!y){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 J=u(E);J?g+=J:g+=a();var S;e===null?S="null":ye(e)?S="array":e!==void 0&&e.$$typeof===p?(S="<"+(x(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):S=typeof e,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",S,g)}var V=qe(e,t,i,E,_);if(V==null)return V;if(y){var Z=t.children;if(Z!==void 0)if(s)if(ye(Z)){for(var $e=0;$e<Z.length;$e++)ve(Z[$e],e);Object.freeze&&Object.freeze(Z)}else O("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 ve(Z,e)}return e===$?te(V):er(V),V}}function fr(e,t,i){return rr(e,t,i,!0)}function dr(e,t,i){return rr(e,t,i,!1)}var vr=dr,hr=fr;Le.Fragment=$,Le.jsx=vr,Le.jsxs=hr}()),Le}(function(n){process.env.NODE_ENV==="production"?n.exports=mr():n.exports=yr()})(pr);const tr="RSC::Event";function sr(){const n=l.useRef(null);function p($){l.useEffect(()=>{n.current||(n.current=document.createElement("div"));function U(h){$(h.detail)}if(n.current)return n.current.addEventListener(tr,U,!1),()=>{var h;(h=n.current)==null||h.removeEventListener(tr,U,!1)}},[$])}function m($){if(n.current){const U=new CustomEvent(tr,{detail:$});n.current.dispatchEvent(U)}}return{useListenToCustomEvent:p,emitEvent:m}}function br({mainCarouselWrapperRef:n,onFullScreenChange:p,handleResize:m}){const $=l.useRef(!1);l.useEffect(()=>{function d(){document.fullscreenElement&&(U(!0),p(!0),m&&m()),document.fullscreenElement||(U(!1),p(!1),m&&m())}if(Re.isEnabled)return Re.on("change",d),()=>{Re.isEnabled&&Re.off("change",d)}},[]);function U(d){$.current=d}function h(){return $.current}function w(d){Re.isEnabled&&Re.request(d||n.current)}function f(){Re.isEnabled&&Re.exit()}return{enterFullscreen:w,exitFullscreen:f,getIsFullscreen:h}}function xr(n){const p=n.getBoundingClientRect();return p.top>=0&&p.left>=0&&p.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&p.right<=(window.innerWidth||document.documentElement.clientWidth)}function lr({thumbsSlideAxis:n="x",withThumbs:p=!1,prepareThumbsData:m,items:$,renderThumbFnProps:U}){const h=l.useRef(null),[w,f]=Q.useSpring(()=>({val:0}));function d(){var I;return h.current?Math.round(Number((I=h.current)==null?void 0:I[n==="x"?"scrollWidth":"scrollHeight"])-h.current.getBoundingClientRect()[n==="x"?"width":"height"]):0}function v(I){var b;function o(){return h.current?h.current.querySelector(`#thumb-item-${$[I].id}`):null}const B=o();if(B&&h.current&&!xr(B)){const ae=B.offsetLeft,F=ae>d()?d():ae;f.start({from:{val:((b=h.current)==null?void 0:b[n==="x"?"scrollLeft":"scrollTop"])??0},to:{val:F},onChange:({value:O})=>{h.current&&(h.current[n==="x"?"scrollLeft":"scrollTop"]=Math.abs(O.val))}})}}function W(){function I(o){return o.map(B=>({id:B.id,renderThumb:B.renderThumb}))}return m?m(I($)):I($)}return{thumbsFragment:p?L.jsx("div",{className:"use-spring-carousel-thumbs-wrapper",ref:h,onWheel:()=>w.val.stop(),style:{display:"flex",flex:"1",position:"relative",width:"100%",height:"100%",flexDirection:n==="x"?"row":"column",...n==="x"?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"}},children:W().map(({id:I,renderThumb:o})=>{const B=`thumb-item-${I}`;return L.jsx("div",{id:B,className:"thumb-item",children:typeof o=="function"?o(U):o},B)})}):null,handleScroll:v}}function Rr({items:n,init:p=!0,withThumbs:m,thumbsSlideAxis:$="x",itemsPerSlide:U=1,slideType:h="fixed",gutter:w=0,withLoop:f=!1,startEndGutter:d=0,carouselSlideAxis:v="x",disableGestures:W=!1,draggingSlideTreshold:A,slideWhenThresholdIsReached:I=!1,freeScroll:o,enableFreeScrollDrag:B,initialStartingPosition:b,prepareThumbsData:ae,initialActiveItem:F=0,animateWhenActiveItemChange:O=!0,slideGroupOfItems:ne=!1,__unstable_stretch_tems__:De=!0,slideAmount:ie}){const Y=U,ue=l.useRef(!1),oe=l.useRef(A??0),z=l.useRef("initial"),Ee=l.useRef("initial"),G=l.useRef("initial"),N=l.useRef(F),x=l.useRef(F===0),R=l.useRef(h==="fixed"&&F===n.length-1),C=l.useRef(null),M=l.useRef(null),ge=l.useRef(0),pe=l.useRef(0),c=l.useRef(0),T=l.useRef(f),k=l.useRef(h),X=l.useRef(o),H=l.useRef(!1),Ie=l.useCallback(()=>f?[...n.map(r=>({...r,id:`prev-repeated-item-${r.id}`})),...n,...n.map(r=>({...r,id:`next-repeated-item-${r.id}`}))]:[...n],[n,f])(),[ee,q]=Q.useSpring(()=>({val:0,pause:!p,onChange:({value:r})=>{o&&C.current?(v==="x"?C.current.scrollLeft=Math.abs(r.val):C.current.scrollTop=Math.abs(r.val),Fe()):M.current&&(v==="x"?M.current.style.transform=`translate3d(${r.val}px, 0px,0px)`:M.current.style.transform=`translate3d(0px,${r.val}px,0px)`)}}),[o]),{emitEvent:ce,useListenToCustomEvent:me}=sr(),{thumbsFragment:ke,handleScroll:Qe}=lr({withThumbs:!!m,thumbsSlideAxis:$,prepareThumbsData:ae,items:n,renderThumbFnProps:{getIsActiveItem:qe,getIsPrevItem:Ye,useListenToCustomEvent:me,getIsNextItem:Ve}}),{enterFullscreen:We,exitFullscreen:Je,getIsFullscreen:ze}=br({mainCarouselWrapperRef:C,handleResize:()=>ye(),onFullScreenChange:r=>{ce({eventName:"onFullscreenChange",isFullscreen:r})}});function Pe(r){return h==="fixed"&&!o?{marginRight:`${r?0:w}px`,flex:`${De?"1":"0"} 0 calc(100% / ${Y} - ${w*(Y-1)/Y}px)`}:{marginRight:`${r?0:w}px`}}const P=l.useCallback(()=>{var u;if(typeof ie=="number"&&ie>0&&(h==="fluid"||o))return ie;const r=ne?C.current:(u=C.current)==null?void 0:u.querySelector(".use-spring-carousel-item");if(!r)throw Error("No carousel items available!");let a=r.getBoundingClientRect()[v==="x"?"width":"height"];return ne||(a+=w),ne&&(a+=w-d*2),a},[v,o,w,ie,ne,h,d]);function se({from:r,to:a,nextActiveItem:u,immediate:j=!1,slideMode:K}){Ee.current=K,typeof u=="number"&&(o||(N.current=u),ce({eventName:"onSlideStartChange",slideActionType:z.current,slideMode:Ee.current,nextItem:{startReached:x.current,endReached:R.current,index:o?-1:N.current,id:o?"":n[N.current].id}})),c.current=a,q.start({immediate:j,from:{val:r},to:{val:a},config:{...Q.config.default,velocity:ee.val.velocity},onRest(de){!j&&de.finished&&ce({eventName:"onSlideChange",slideActionType:z.current,slideMode:Ee.current,currentItem:{startReached:x.current,endReached:R.current,index:o?-1:N.current,id:o?"":n[N.current].id}})}}),m&&!j&&Qe(N.current)}const D=l.useCallback(()=>{var r;return M.current?f?P()*n.length:Math.round(Number((r=M.current)==null?void 0:r[v==="x"?"scrollWidth":"scrollHeight"])-M.current.getBoundingClientRect()[v==="x"?"width":"height"]-d*2):0},[v,P,n.length,d,f]);function je(){const r=`calc(100% - ${d*2}px)`;return{width:v==="x"?r:"100%",height:v==="y"?r:"100%"}}const Te=l.useCallback(()=>{var a;const r=(a=M.current)==null?void 0:a.querySelector(".use-spring-carousel-item");if(!r)throw Error("No carousel items available!");return r.getBoundingClientRect()[v==="x"?"width":"height"]+w},[v,w]),we=l.useCallback(r=>{const a=v==="x"?"left":"top",u=M.current;u&&(f?(u.style.top="0px",u.style.left="0px",u.style[a]=`-${r-d}px`,x.current=!1,R.current=!1):(u.style.left="0px",u.style.top="0px"))},[v,d,f]),ye=l.useCallback((r=!1)=>{if(M.current&&r&&(M.current.style.transform="translate3d(0px, 0px,0px)",M.current.style.left="0",M.current.style.top="0"),h==="fixed"&&we(b==="center"?Te()*n.length-P()*Math.round((Y-1)/2):b==="end"?Te()*n.length-P()*Math.round(Y-1):Te()*n.length),h==="fluid"){if(we(Te()*n.length),R.current&&D()!==Math.abs(c.current)&&!f){const a=-D();c.current=a,q.start({immediate:!0,val:c.current});return}if(Math.abs(c.current)>0&&D()!==Math.abs(c.current)&&!f&&!o&&G.current==="backward"){const a=ge.current-D(),u=c.current+a;return q.start({immediate:!0,val:u}),()=>{c.current=u}}return}if(!o&&h==="fixed"){const a=-(P()*N.current);if(Math.abs(a)>D()&&!f){const u=-D();R.current=!0,c.current=u,q.start({immediate:!0,val:c.current})}else c.current=a,q.start({immediate:!0,val:a});setTimeout(()=>{ue.current=!1},0)}},[o,Te,P,D,b,n.length,Y,we,q,h,f]);function re(){return o&&C.current?C.current[v==="x"?"scrollLeft":"scrollTop"]:ee.val.get()}function Ce(r,a){if(o&&r==="next"){const u=c.current+P();return u>D()?D():u}if(o&&r==="prev"){const u=c.current-P();return u<0?0:u}return r==="next"?typeof a=="number"?-(a*P()):c.current-P():typeof a=="number"?-(a*P()):c.current+P()}function le({type:r,index:a,immediate:u}){if(!p||H.current||x.current&&!f)return;R.current&&(G.current="backward"),z.current="prev",R.current=!1;const j=typeof a=="number"?a:N.current-1;if(o&&Fe(),!f){const K=o?Ce("prev",a)-P()/3<0:Ce("prev",a)+P()/3>0;if(x.current)return;if(K){x.current=!0,R.current=!1,se({slideMode:r,from:re(),to:0,nextActiveItem:0,immediate:u});return}}if(f&&(x.current||j<0)){x.current=!1,R.current=!0,se({slideMode:r,from:re()-P()*n.length,to:-(P()*n.length)+P(),nextActiveItem:n.length-1,immediate:u});return}j===0&&(x.current=!0),(j===n.length-1||j===-1)&&(R.current=!0),se({slideMode:r,from:re(),to:Ce("prev",a),nextActiveItem:j,immediate:u})}function fe({type:r,index:a,immediate:u}){if(!p||H.current||R.current&&!f)return;x.current&&(G.current="forward"),z.current="next",x.current=!1;const j=a||N.current+1;if(o&&Fe(),!f){const K=Math.abs(Ce("next",a))>D()-P()/3;if(R.current)return;if(K){x.current=!1,R.current=!0,se({slideMode:r,from:re(),to:o?D():-D(),nextActiveItem:j,immediate:u});return}}if(f&&(R.current||j>n.length-1)){R.current=!1,x.current=!0,se({slideMode:r,from:re()+P()*n.length,to:0,nextActiveItem:0,immediate:u});return}j===0&&(x.current=!0),j===n.length-1&&(R.current=!0),se({slideMode:r,from:re(),to:Ce("next",a),nextActiveItem:j,immediate:u})}function _e(){A?oe.current=A:oe.current=Math.floor(P()/2/2)}function Xe(){M.current&&(ge.current=D(),T.current=f,k.current=h,X.current=o,pe.current=window.innerWidth,c.current=0,Se({id:0,immediate:!0,shouldReset:!0}),_e(),ye())}const Ke=p&&!W&&!o||!!o&&!!B,Ze=cr.useDrag(r=>{const a=r.dragging,u=r.offset[v==="x"?0:1],j=r.movement[v==="x"?0:1],K=r.direction[v==="x"?0:1],de=j>oe.current,ve=j<-oe.current,er=D(),te=r.velocity;if(a){if(K>0?z.current="prev":z.current="next",ce({...r,eventName:"onDrag",slideActionType:z.current}),o){if(u>0){q.start({from:{val:re()},to:{val:0},config:{velocity:te,friction:50,tension:1e3}}),r.cancel();return}q.start({from:{val:re()},to:{val:-u},config:{velocity:te,friction:50,tension:1e3}});return}q.start({val:u,config:{velocity:te,friction:50,tension:1e3}}),I&&ve?(fe({type:"drag"}),r.cancel()):I&&de&&(le({type:"drag"}),r.cancel()),er-Math.abs(u)<-(P()*2)&&r.cancel();return}if(r.last&&o&&u>0){q.start({from:{val:re()},to:{val:0},config:{velocity:te,friction:50,tension:1e3}});return}r.last&&!r.canceled&&o&&(z.current==="prev"&&le({type:"drag"}),z.current==="next"&&fe({type:"drag"})),r.last&&!r.canceled&&!o&&(Y===n.length?q.start({val:c.current,config:{...Q.config.default,velocity:te}}):ve?!f&&R.current?q.start({val:-D(),config:{...Q.config.default,velocity:te}}):fe({type:"drag"}):de?!f&&x.current?q.start({val:0,config:{...Q.config.default,velocity:te}}):le({type:"drag"}):q.start({val:c.current,config:{...Q.config.default,velocity:te}})),r.last&&r.canceled&&q.start({val:c.current,config:{...Q.config.default,velocity:te}})},{enabled:Ke,axis:v,from:()=>o&&C.current?[-C.current.scrollLeft,-C.current.scrollTop]:v==="x"?[ee.val.get(),ee.val.get()]:[ee.val.get(),ee.val.get()]});function Ne(){return o?v==="x"?{overflowX:"auto"}:{overflowY:"auto"}:{}}function Fe(){C.current&&(c.current=C.current[v==="x"?"scrollLeft":"scrollTop"],C.current[v==="x"?"scrollLeft":"scrollTop"]===0&&(x.current=!0,R.current=!1),C.current[v==="x"?"scrollLeft":"scrollTop"]>0&&C.current[v==="x"?"scrollLeft":"scrollTop"]<D()&&(x.current=!1,R.current=!1),C.current[v==="x"?"scrollLeft":"scrollTop"]===D()&&(x.current=!1,R.current=!0))}function Ge(){return o?{onWheel(){ee.val.stop(),Fe()}}:{}}function be(r,a){let u=0;if(typeof r=="string"?u=n.findIndex(j=>j.id===r):u=r,u<0||u>=n.length){if(a)throw new Error(a);console.error(`The item doesn't exist; check that the id provided - ${r} - is correct.`),u=-1}return u}function Se({id:r,immediate:a,shouldReset:u,type:j}){if(!p||H.current)return;x.current=!1,R.current=!1;const K=be(r,"The item you want to slide to doesn't exist; check the provided id.");if(K===N.current&&!u)return;const de=be(n[N.current].id),ve=be(n[K].id);ve>de?fe({type:j||u?"initial":"click",index:ve,immediate:a}):le({type:j||u?"initial":"click",index:ve,immediate:a})}function Ve(r){const a=be(r,"The item doesn't exist; check the provided id."),u=N.current;return f&&u===n.length-1?a===0:a===u+1}function Ye(r){const a=be(r,"The item doesn't exist; check the provided id."),u=N.current;return f&&u===0?a===n.length-1:a===u-1}function qe(r){return be(r,"The item you want to check doesn't exist; check the provided id.")===N.current}function Ue(){return W?"unset":v==="x"?"pan-y":"pan-x"}const Oe=o?{useListenToCustomEvent:me,enterFullscreen:We,exitFullscreen:Je,getIsFullscreen:ze,slideToPrevItem:(r=!0)=>{le({type:"click",immediate:!r})},slideToNextItem:(r=!0)=>{fe({type:"click",immediate:!r})}}:{useListenToCustomEvent:me,enterFullscreen:We,exitFullscreen:Je,getIsFullscreen:ze,slideToPrevItem:(r=!0)=>{le({type:"click",immediate:!r})},slideToNextItem:(r=!0)=>{fe({type:"click",immediate:!r})},slideToItem:(r,a=!0)=>{Se({id:r,immediate:!a})},getIsNextItem:Ve,getIsPrevItem:Ye,getIsActiveItem:qe};Q.useIsomorphicLayoutEffect(()=>{M.current&&p&&(ue.current=!0,Xe())},[p]),l.useEffect(()=>{N.current!==F&&(ue.current=!0,Se({id:F,immediate:!O}))},[F]),l.useEffect(()=>{if(p){if(F>n.length-1)throw new Error(`initialActiveItem (${F}) is greater than the total quantity available items (${n.length}).`);Y>n.length&&console.warn(`itemsPerSlide (${Y}) is greater than the total quantity available items (${n.length}). Fallback to ${n.length})`)}},[F,n.length,Y,p]),l.useEffect(()=>{pe.current=window.innerWidth},[]),l.useEffect(()=>{if(p){if(f&&o)throw new Error("`withLoop` and `freeScroll` can't be used together.");if(o&&h==="fixed")throw new Error("`freeScroll` can't be used when `scrollType: fixed`.");if(B&&(h!=="fluid"||!o))throw new Error("`enableFreeScrollDrag` must be used with `slideType: fluid` and `freeScroll=true`");if(ne&&o)throw new Error("`slideGroupOfItems` and `freeScroll` can't be used together.");if(typeof ie=="number"&&ie>0&&h==="fixed")throw new Error("`slideAmount` must be used with `slideType: fluid`");ue.current=!0,Xe()}},[b,Y,d,w,p,f,h,o,B,ne]),l.useEffect(()=>{if(!p)return;function r(){document.hidden?H.current=!0:H.current=!1}return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[p]),l.useEffect(()=>{if(C.current){let r;const a=new gr(()=>{if(!H.current&&!ue.current){pe.current=window.innerWidth;const u=ye();window.clearTimeout(r),r=setTimeout(()=>{ge.current=D(),typeof u=="function"&&u()},100)}});return a.observe(C.current),()=>{a.disconnect()}}},[ye,D]);const xe=L.jsx(nr.Provider,{value:Oe,children:ke}),Be=L.jsx(nr.Provider,{value:Oe,children:L.jsx("div",{className:"use-spring-carousel-main-wrapper",ref:C,...Ge(),style:{display:"flex",position:"relative",width:"100%",height:"100%",...Ne()},children:L.jsxs("div",{className:"use-spring-carousel-track-wrapper",ref:M,...Ze(),style:{position:"relative",display:"flex",flexDirection:v==="x"?"row":"column",touchAction:Ue(),...je()},children:[(o||!f)&&d?L.jsx("div",{style:{flexShrink:0,width:d}}):null,Ie.map((r,a)=>L.jsx(l.Fragment,{children:L.jsx("div",{className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:{display:"flex",position:"relative",...h==="fixed"?{flex:"1"}:{},...Pe(a===Ie.findIndex(u=>u.id===Ie[Ie.length-1].id))},children:typeof r.renderItem=="function"?r.renderItem({getIsActiveItem:qe,getIsNextItem:Ve,getIsPrevItem:Ye,useListenToCustomEvent:me}):r.renderItem})},`${r.id}-${a}`)),(o||!f)&&d?L.jsx("div",{style:{flexShrink:0,width:d}}):null]})})});return{...Oe,carouselFragment:Be,thumbsFragment:xe}}const nr=l.createContext(void 0);function Er(){const n=l.useContext(nr);if(!n)throw new Error("useSpringCarouselContext must be used within the carousel.");return n}const Me={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"relative"},enter:{position:"relative",opacity:1},leave:{opacity:1,position:"absolute"}};function Tr({init:n=!0,disableGestures:p=!1,items:m,springConfig:$=Q.config.default,exitBeforeEnter:U=!1,trail:h,withLoop:w=!1,activeItem:f,toPrevItemSpringProps:d=Me,toNextItemSpringProps:v=Me,draggingSlideTreshold:W=50,thumbsSlideAxis:A="x"}){const I=l.useRef("next"),o=l.useRef("initial"),B=l.useRef(null),[b,ae]=l.useState(f??0),{emitEvent:F,useListenToCustomEvent:O}=sr(),{handleScroll:ne,thumbsFragment:De}=lr({thumbsSlideAxis:A,items:m,renderThumbFnProps:{getIsNextItem:N,getIsPrevItem:x,useListenToCustomEvent:O,activeItem:{index:b,id:m[b].id}}});function ie(){return I.current==="prev"?{initial:{...d.initial},from:{...d.from},enter:{...d.enter},leave:{...d.leave}}:I.current==="next"?{initial:{...v.initial},from:{...v.from},enter:{...v.enter},leave:{...v.leave}}:{initial:{...Me.initial},from:{...Me.from},enter:{...Me.enter},leave:{...Me.leave}}}l.useEffect(()=>{typeof f=="number"&&f!==b&&ae(f)},[f]);function Y({to:c,slideType:T,slideMode:k}){I.current=T,o.current=k,F({eventName:"onSlideStartChange",slideActionType:I.current,slideMode:o.current,nextItem:{index:c,id:m[c].id,startReached:c===0,endReached:c===m.length-1}}),ae(c),ne(b)}function ue(c){if(!n)return;const T=b===0;!w&&T||Y(w&&T?{to:m.length-1,slideType:"prev",slideMode:c}:{to:b-1,slideType:"prev",slideMode:c})}function oe(c){if(!n)return;const T=b===m.length-1;!w&&T||Y(w&&T?{to:0,slideType:"next",slideMode:c}:{to:b+1,slideType:"next",slideMode:c})}const z=Q.useTransition(b,{config:$,key:null,trail:h,exitBeforeEnter:U,...ie(),onRest(c,T,k){c.finished&&k===b&&F({eventName:"onSlideChange",slideActionType:I.current,slideMode:o.current,currentItem:{index:b,id:m[b].id,startReached:b===0,endReached:b===m.length-1}})}}),Ee=cr.useDrag(({last:c,movement:[T]})=>{if(c){const k=T>W,X=T<-W,H=b===0,He=b===m.length-1;if(X){if(!w&&He)return;F({eventName:"onLeftSwipe"}),oe("swipe")}else if(k){if(!w&&H)return;F({eventName:"onRightSwipe"}),ue("swipe")}}},{enabled:!p});function G(c,T){let k=0;if(typeof c=="string"?k=m.findIndex(X=>X.id===c):k=c,k<0||k>=m.length){if(T)throw new Error(T);console.error(`The item doesn't exist; check that the id provided - ${c} - is correct.`),k=-1}return k}function N(c){const T=G(c,"The item doesn't exist; check the provided id."),k=b;return w&&k===m.length-1?T===0:T===k+1}function x(c){const T=G(c,"The item doesn't exist; check the provided id."),k=b;return w&&k===0?T===m.length-1:T===k-1}const R=z((c,T,k,X)=>{const H=m[T].renderItem;return L.jsx(Q.a.div,{id:`use-transition-carousel-item-${X}`,className:"use-transition-carousel-item",style:{...c,flex:"1 0 100%",width:"100%",height:"100%"},children:typeof H=="function"?H({useListenToCustomEvent:O,getIsNextItem:N,getIsPrevItem:x,activeItem:{index:b,id:m[b].id}}):H})});function C(){return p?"unset":"pan-y"}const M={useListenToCustomEvent:O,slideToPrevItem:()=>ue("click"),slideToNextItem:()=>oe("click"),activeItem:b,slideToItem:c=>{const T=G(c,"The item you want to slide to doesn't exist; check the provided id.");if(c===b)return;const k=G(m[b].id),X=G(m[T].id);Y({to:X,slideType:X>k?"next":"prev",slideMode:"click"})}},ge=L.jsx(ir.Provider,{value:M,children:De}),pe=L.jsx(ir.Provider,{value:M,children:L.jsx("div",{className:"use-transition-carousel-wrapper",ref:B,...Ee(),style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden",touchAction:C()},children:R})});return{...M,carouselFragment:pe,thumbsFragment:ge}}const ir=l.createContext(void 0);function wr(){const n=l.useContext(ir);if(!n)throw new Error("useTransitionCarouselContext must be used within the carousel.");return n}exports.useSpringCarousel=Rr;exports.useSpringCarouselContext=Er;exports.useTransitionCarousel=Tr;exports.useTransitionCarouselContext=wr;
|
|
27
|
+
Check the top-level render call using <`+i+">.")}return t}}function de(e,t){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var i=K(t);if(j[i])return;j[i]=!0;var s="";e&&e._owner&&e._owner!==Ue.current&&(s=" It was passed a child from "+x(e._owner.type)+"."),xe(e),O('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',i,s),xe(null)}}function ve(e,t){{if(typeof e!="object")return;if(ye(e))for(var i=0;i<e.length;i++){var s=e[i];r(s)&&de(s,t)}else if(r(e))e._store&&(e._store.validated=!0);else if(e){var E=ae(e);if(typeof E=="function"&&E!==e.entries)for(var _=E.call(e),y;!(y=_.next()).done;)r(y.value)&&de(y.value,t)}}}function er(e){{var t=e.type;if(t==null||typeof t=="string")return;var i;if(typeof t=="function")i=t.propTypes;else if(typeof t=="object"&&(t.$$typeof===d||t.$$typeof===A))i=t.propTypes;else return;if(i){var s=x(t);Te(i,e.props,"prop",s,e)}else if(t.PropTypes!==void 0&&!Be){Be=!0;var E=x(t);O("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",E||"Unknown")}typeof t.getDefaultProps=="function"&&!t.getDefaultProps.isReactClassApproved&&O("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function te(e){{for(var t=Object.keys(e.props),i=0;i<t.length;i++){var s=t[i];if(s!=="children"&&s!=="key"){xe(e),O("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",s),xe(null);break}}e.ref!==null&&(xe(e),O("Invalid attribute `ref` supplied to `React.Fragment`."),xe(null))}}function rr(e,t,i,s,E,_){{var y=Ee(e);if(!y){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 J=u(E);J?g+=J:g+=a();var S;e===null?S="null":ye(e)?S="array":e!==void 0&&e.$$typeof===p?(S="<"+(x(e.type)||"Unknown")+" />",g=" Did you accidentally export a JSX literal instead of a component?"):S=typeof e,O("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",S,g)}var V=qe(e,t,i,E,_);if(V==null)return V;if(y){var Z=t.children;if(Z!==void 0)if(s)if(ye(Z)){for(var $e=0;$e<Z.length;$e++)ve(Z[$e],e);Object.freeze&&Object.freeze(Z)}else O("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 ve(Z,e)}return e===$?te(V):er(V),V}}function fr(e,t,i){return rr(e,t,i,!0)}function dr(e,t,i){return rr(e,t,i,!1)}var vr=dr,hr=fr;Le.Fragment=$,Le.jsx=vr,Le.jsxs=hr}()),Le}(function(n){process.env.NODE_ENV==="production"?n.exports=mr():n.exports=yr()})(pr);const tr="RSC::Event";function sr(){const n=l.useRef(null);function p($){l.useEffect(()=>{n.current||(n.current=document.createElement("div"));function U(h){$(h.detail)}if(n.current)return n.current.addEventListener(tr,U,!1),()=>{var h;(h=n.current)==null||h.removeEventListener(tr,U,!1)}},[$])}function m($){if(n.current){const U=new CustomEvent(tr,{detail:$});n.current.dispatchEvent(U)}}return{useListenToCustomEvent:p,emitEvent:m}}function br({mainCarouselWrapperRef:n,onFullScreenChange:p,handleResize:m}){const $=l.useRef(!1);l.useEffect(()=>{function d(){document.fullscreenElement&&(U(!0),p(!0),m&&m()),document.fullscreenElement||(U(!1),p(!1),m&&m())}if(Re.isEnabled)return Re.on("change",d),()=>{Re.isEnabled&&Re.off("change",d)}},[]);function U(d){$.current=d}function h(){return $.current}function w(d){Re.isEnabled&&Re.request(d||n.current)}function f(){Re.isEnabled&&Re.exit()}return{enterFullscreen:w,exitFullscreen:f,getIsFullscreen:h}}function xr(n){const p=n.getBoundingClientRect();return p.top>=0&&p.left>=0&&p.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&p.right<=(window.innerWidth||document.documentElement.clientWidth)}function lr({thumbsSlideAxis:n="x",withThumbs:p=!1,prepareThumbsData:m,items:$,renderThumbFnProps:U}){const h=l.useRef(null),[w,f]=Q.useSpring(()=>({val:0}));function d(){var I;return h.current?Math.round(Number((I=h.current)==null?void 0:I[n==="x"?"scrollWidth":"scrollHeight"])-h.current.getBoundingClientRect()[n==="x"?"width":"height"]):0}function v(I){var b;function o(){return h.current?h.current.querySelector(`#thumb-item-${$[I].id}`):null}const B=o();if(B&&h.current&&!xr(B)){const ae=B.offsetLeft,F=ae>d()?d():ae;f.start({from:{val:((b=h.current)==null?void 0:b[n==="x"?"scrollLeft":"scrollTop"])??0},to:{val:F},onChange:({value:O})=>{h.current&&(h.current[n==="x"?"scrollLeft":"scrollTop"]=Math.abs(O.val))}})}}function N(){function I(o){return o.map(B=>({id:B.id,renderThumb:B.renderThumb}))}return m?m(I($)):I($)}return{thumbsFragment:p?L.jsx("div",{className:"use-spring-carousel-thumbs-wrapper",ref:h,onWheel:()=>w.val.stop(),style:{display:"flex",flex:"1",position:"relative",width:"100%",height:"100%",flexDirection:n==="x"?"row":"column",...n==="x"?{overflowX:"auto"}:{overflowY:"auto",maxHeight:"100%"}},children:N().map(({id:I,renderThumb:o})=>{const B=`thumb-item-${I}`;return L.jsx("div",{id:B,className:"thumb-item",children:typeof o=="function"?o(U):o},B)})}):null,handleScroll:v}}function Rr({items:n,init:p=!0,withThumbs:m,thumbsSlideAxis:$="x",itemsPerSlide:U=1,slideType:h="fixed",gutter:w=0,withLoop:f=!1,startEndGutter:d=0,carouselSlideAxis:v="x",disableGestures:N=!1,draggingSlideTreshold:A,slideWhenThresholdIsReached:I=!1,freeScroll:o,enableFreeScrollDrag:B,initialStartingPosition:b,prepareThumbsData:ae,initialActiveItem:F=0,animateWhenActiveItemChange:O=!0,slideGroupOfItems:ne=!1,__unstable_stretch_tems__:De=!0,slideAmount:ie}){const Y=U,ue=l.useRef(!1),oe=l.useRef(A??0),z=l.useRef("initial"),Ee=l.useRef("initial"),G=l.useRef("initial"),M=l.useRef(F),x=l.useRef(F===0),R=l.useRef(h==="fixed"&&F===n.length-1),C=l.useRef(null),D=l.useRef(null),ge=l.useRef(0),pe=l.useRef(0),c=l.useRef(0),T=l.useRef(f),k=l.useRef(h),X=l.useRef(o),H=l.useRef(!1),Ie=l.useCallback(()=>f?[...n.map(r=>({...r,id:`prev-repeated-item-${r.id}`})),...n,...n.map(r=>({...r,id:`next-repeated-item-${r.id}`}))]:[...n],[n,f])(),[ee,q]=Q.useSpring(()=>({val:0,pause:!p,onChange:({value:r})=>{o&&C.current?(v==="x"?C.current.scrollLeft=Math.abs(r.val):C.current.scrollTop=Math.abs(r.val),Fe()):D.current&&(v==="x"?D.current.style.transform=`translate3d(${r.val}px, 0px,0px)`:D.current.style.transform=`translate3d(0px,${r.val}px,0px)`)}}),[o]),{emitEvent:ce,useListenToCustomEvent:me}=sr(),{thumbsFragment:ke,handleScroll:Ze}=lr({withThumbs:!!m,thumbsSlideAxis:$,prepareThumbsData:ae,items:n,renderThumbFnProps:{getIsActiveItem:qe,getIsPrevItem:Ye,useListenToCustomEvent:me,getIsNextItem:Ve}}),{enterFullscreen:We,exitFullscreen:Je,getIsFullscreen:ze}=br({mainCarouselWrapperRef:C,handleResize:()=>ye(),onFullScreenChange:r=>{ce({eventName:"onFullscreenChange",isFullscreen:r})}});function Pe(r){return h==="fixed"&&!o?{marginRight:`${r?0:w}px`,flex:`${De?"1":"0"} 0 calc(100% / ${Y} - ${w*(Y-1)/Y}px)`}:{marginRight:`${r?0:w}px`}}const P=l.useCallback(()=>{var u;if(typeof ie=="number"&&ie>0&&(h==="fluid"||o))return ie;const r=ne?C.current:(u=C.current)==null?void 0:u.querySelector(".use-spring-carousel-item");if(!r)throw Error("No carousel items available!");let a=r.getBoundingClientRect()[v==="x"?"width":"height"];return ne||(a+=w),ne&&(a+=w-d*2),a},[v,o,w,ie,ne,h,d]);function se({from:r,to:a,nextActiveItem:u,immediate:j=!1,slideMode:K}){Ee.current=K,typeof u=="number"&&(o||(M.current=u),ce({eventName:"onSlideStartChange",slideActionType:z.current,slideMode:Ee.current,nextItem:{startReached:x.current,endReached:R.current,index:o?-1:M.current,id:o?"":n[M.current].id}})),c.current=a,q.start({immediate:j,from:{val:r},to:{val:a},config:{...Q.config.default,velocity:ee.val.velocity},onRest(de){!j&&de.finished&&ce({eventName:"onSlideChange",slideActionType:z.current,slideMode:Ee.current,currentItem:{startReached:x.current,endReached:R.current,index:o?-1:M.current,id:o?"":n[M.current].id}})}}),m&&!j&&Ze(M.current)}const W=l.useCallback(()=>{var r;return D.current?f?P()*n.length:Math.round(Number((r=D.current)==null?void 0:r[v==="x"?"scrollWidth":"scrollHeight"])-D.current.getBoundingClientRect()[v==="x"?"width":"height"]-d*2):0},[v,P,n.length,d,f]);function je(){const r=`calc(100% - ${d*2}px)`;return{width:v==="x"?r:"100%",height:v==="y"?r:"100%"}}const Te=l.useCallback(()=>{var a;const r=(a=D.current)==null?void 0:a.querySelector(".use-spring-carousel-item");if(!r)throw Error("No carousel items available!");return r.getBoundingClientRect()[v==="x"?"width":"height"]+w},[v,w]),we=l.useCallback(r=>{const a=v==="x"?"left":"top",u=D.current;u&&(f?(u.style.top="0px",u.style.left="0px",u.style[a]=`-${r-d}px`,x.current=!1,R.current=!1):(u.style.left="0px",u.style.top="0px"))},[v,d,f]),ye=l.useCallback((r=!1)=>{if(D.current&&r&&(D.current.style.transform="translate3d(0px, 0px,0px)",D.current.style.left="0",D.current.style.top="0"),h==="fixed"&&we(b==="center"?Te()*n.length-P()*Math.round((Y-1)/2):b==="end"?Te()*n.length-P()*Math.round(Y-1):Te()*n.length),h==="fluid"){if(we(Te()*n.length),R.current&&W()!==Math.abs(c.current)&&!f){const a=-W();c.current=a,q.start({immediate:!0,val:c.current});return}if(Math.abs(c.current)>0&&W()!==Math.abs(c.current)&&!f&&!o&&G.current==="backward"){const a=ge.current-W(),u=c.current+a;return q.start({immediate:!0,val:u}),()=>{c.current=u}}return}if(!o&&h==="fixed"){const a=-(P()*M.current);if(Math.abs(a)>W()&&!f){const u=-W();R.current=!0,c.current=u,q.start({immediate:!0,val:c.current})}else c.current=a,q.start({immediate:!0,val:a});setTimeout(()=>{ue.current=!1},0)}},[o,Te,P,W,b,n.length,Y,we,q,h,f]);function re(){return o&&C.current?C.current[v==="x"?"scrollLeft":"scrollTop"]:ee.val.get()}function Ce(r,a){if(o&&r==="next"){const u=c.current+P();return u>W()?W():u}if(o&&r==="prev"){const u=c.current-P();return u<0?0:u}return r==="next"?typeof a=="number"?-(a*P()):c.current-P():typeof a=="number"?-(a*P()):c.current+P()}function le({type:r,index:a,immediate:u}){if(!p||H.current||x.current&&!f)return;R.current&&(G.current="backward"),z.current="prev",R.current=!1;const j=typeof a=="number"?a:M.current-1;if(o&&Fe(),!f){const K=o?Ce("prev",a)-P()/3<0:Ce("prev",a)+P()/3>0;if(x.current)return;if(K){x.current=!0,R.current=!1,se({slideMode:r,from:re(),to:0,nextActiveItem:0,immediate:u});return}}if(f&&(x.current||j<0)){x.current=!1,R.current=!0,se({slideMode:r,from:re()-P()*n.length,to:-(P()*n.length)+P(),nextActiveItem:n.length-1,immediate:u});return}j===0&&(x.current=!0),(j===n.length-1||j===-1)&&(R.current=!0),se({slideMode:r,from:re(),to:Ce("prev",a),nextActiveItem:j,immediate:u})}function fe({type:r,index:a,immediate:u}){if(!p||H.current||R.current&&!f)return;x.current&&(G.current="forward"),z.current="next",x.current=!1;const j=a||M.current+1;if(o&&Fe(),!f){const K=Math.abs(Ce("next",a))>W()-P()/3;if(R.current)return;if(K){x.current=!1,R.current=!0,se({slideMode:r,from:re(),to:o?W():-W(),nextActiveItem:j,immediate:u});return}}if(f&&(R.current||j>n.length-1)){R.current=!1,x.current=!0,se({slideMode:r,from:re()+P()*n.length,to:0,nextActiveItem:0,immediate:u});return}j===0&&(x.current=!0),j===n.length-1&&(R.current=!0),se({slideMode:r,from:re(),to:Ce("next",a),nextActiveItem:j,immediate:u})}function _e(){A?oe.current=A:oe.current=Math.floor(P()/2/2)}function Qe(){D.current&&(ge.current=W(),T.current=f,k.current=h,X.current=o,pe.current=window.innerWidth,c.current=0,Se({id:M.current,immediate:!0,shouldReset:!0}),_e(),ye())}const Xe=p&&!N&&!o||!!o&&!!B,Ke=cr.useDrag(r=>{const a=r.dragging,u=r.offset[v==="x"?0:1],j=r.movement[v==="x"?0:1],K=r.direction[v==="x"?0:1],de=j>oe.current,ve=j<-oe.current,er=W(),te=r.velocity;if(a){if(K>0?z.current="prev":z.current="next",ce({...r,eventName:"onDrag",slideActionType:z.current}),o){if(u>0){q.start({from:{val:re()},to:{val:0},config:{velocity:te,friction:50,tension:1e3}}),r.cancel();return}q.start({from:{val:re()},to:{val:-u},config:{velocity:te,friction:50,tension:1e3}});return}q.start({val:u,config:{velocity:te,friction:50,tension:1e3}}),I&&ve?(fe({type:"drag"}),r.cancel()):I&&de&&(le({type:"drag"}),r.cancel()),er-Math.abs(u)<-(P()*2)&&r.cancel();return}if(r.last&&o&&u>0){q.start({from:{val:re()},to:{val:0},config:{velocity:te,friction:50,tension:1e3}});return}r.last&&!r.canceled&&o&&(z.current==="prev"&&le({type:"drag"}),z.current==="next"&&fe({type:"drag"})),r.last&&!r.canceled&&!o&&(Y===n.length?q.start({val:c.current,config:{...Q.config.default,velocity:te}}):ve?!f&&R.current?q.start({val:-W(),config:{...Q.config.default,velocity:te}}):fe({type:"drag"}):de?!f&&x.current?q.start({val:0,config:{...Q.config.default,velocity:te}}):le({type:"drag"}):q.start({val:c.current,config:{...Q.config.default,velocity:te}})),r.last&&r.canceled&&q.start({val:c.current,config:{...Q.config.default,velocity:te}})},{enabled:Xe,axis:v,from:()=>o&&C.current?[-C.current.scrollLeft,-C.current.scrollTop]:v==="x"?[ee.val.get(),ee.val.get()]:[ee.val.get(),ee.val.get()]});function Ne(){return o?v==="x"?{overflowX:"auto"}:{overflowY:"auto"}:{}}function Fe(){C.current&&(c.current=C.current[v==="x"?"scrollLeft":"scrollTop"],C.current[v==="x"?"scrollLeft":"scrollTop"]===0&&(x.current=!0,R.current=!1),C.current[v==="x"?"scrollLeft":"scrollTop"]>0&&C.current[v==="x"?"scrollLeft":"scrollTop"]<W()&&(x.current=!1,R.current=!1),C.current[v==="x"?"scrollLeft":"scrollTop"]===W()&&(x.current=!1,R.current=!0))}function Ge(){return o?{onWheel(){ee.val.stop(),Fe()}}:{}}function be(r,a){let u=0;if(typeof r=="string"?u=n.findIndex(j=>j.id===r):u=r,u<0||u>=n.length){if(a)throw new Error(a);console.error(`The item doesn't exist; check that the id provided - ${r} - is correct.`),u=-1}return u}function Se({id:r,immediate:a,shouldReset:u,type:j}){if(!p||H.current)return;x.current=!1,R.current=!1;const K=be(r,"The item you want to slide to doesn't exist; check the provided id.");if(K===M.current&&!u)return;const de=be(n[M.current].id),ve=be(n[K].id);ve>de?fe({type:j||u?"initial":"click",index:ve,immediate:a}):le({type:j||u?"initial":"click",index:ve,immediate:a})}function Ve(r){const a=be(r,"The item doesn't exist; check the provided id."),u=M.current;return f&&u===n.length-1?a===0:a===u+1}function Ye(r){const a=be(r,"The item doesn't exist; check the provided id."),u=M.current;return f&&u===0?a===n.length-1:a===u-1}function qe(r){return be(r,"The item you want to check doesn't exist; check the provided id.")===M.current}function Ue(){return N?"unset":v==="x"?"pan-y":"pan-x"}const Oe=o?{useListenToCustomEvent:me,enterFullscreen:We,exitFullscreen:Je,getIsFullscreen:ze,slideToPrevItem:(r=!0)=>{le({type:"click",immediate:!r})},slideToNextItem:(r=!0)=>{fe({type:"click",immediate:!r})}}:{useListenToCustomEvent:me,enterFullscreen:We,exitFullscreen:Je,getIsFullscreen:ze,slideToPrevItem:(r=!0)=>{le({type:"click",immediate:!r})},slideToNextItem:(r=!0)=>{fe({type:"click",immediate:!r})},slideToItem:(r,a=!0)=>{Se({id:r,immediate:!a})},getIsNextItem:Ve,getIsPrevItem:Ye,getIsActiveItem:qe};Q.useIsomorphicLayoutEffect(()=>{D.current&&p&&(ue.current=!0,Qe())},[p]),l.useEffect(()=>{M.current!==F&&(ue.current=!0,Se({id:F,immediate:!O}))},[F]),l.useEffect(()=>{if(p){if(F>n.length-1)throw new Error(`initialActiveItem (${F}) is greater than the total quantity available items (${n.length}).`);Y>n.length&&console.warn(`itemsPerSlide (${Y}) is greater than the total quantity available items (${n.length}). Fallback to ${n.length})`)}},[F,n.length,Y,p]),l.useEffect(()=>{pe.current=window.innerWidth},[]),l.useEffect(()=>{if(p){if(f&&o)throw new Error("`withLoop` and `freeScroll` can't be used together.");if(o&&h==="fixed")throw new Error("`freeScroll` can't be used when `scrollType: fixed`.");if(B&&(h!=="fluid"||!o))throw new Error("`enableFreeScrollDrag` must be used with `slideType: fluid` and `freeScroll=true`");if(ne&&o)throw new Error("`slideGroupOfItems` and `freeScroll` can't be used together.");if(typeof ie=="number"&&ie>0&&h==="fixed")throw new Error("`slideAmount` must be used with `slideType: fluid`");ue.current=!0}},[b,Y,d,w,p,f,h,o,B,ne]),l.useEffect(()=>{if(!p)return;function r(){document.hidden?H.current=!0:H.current=!1}return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[p]),l.useEffect(()=>{if(C.current){let r;const a=new gr(()=>{if(!H.current&&!ue.current){pe.current=window.innerWidth;const u=ye();window.clearTimeout(r),r=setTimeout(()=>{ge.current=W(),typeof u=="function"&&u()},100)}});return a.observe(C.current),()=>{a.disconnect()}}},[ye,W]);const xe=L.jsx(nr.Provider,{value:Oe,children:ke}),Be=L.jsx(nr.Provider,{value:Oe,children:L.jsx("div",{className:"use-spring-carousel-main-wrapper",ref:C,...Ge(),style:{display:"flex",position:"relative",width:"100%",height:"100%",...Ne()},children:L.jsxs("div",{className:"use-spring-carousel-track-wrapper",ref:D,...Ke(),style:{position:"relative",display:"flex",flexDirection:v==="x"?"row":"column",touchAction:Ue(),...je()},children:[(o||!f)&&d?L.jsx("div",{style:{flexShrink:0,width:d}}):null,Ie.map((r,a)=>L.jsx(l.Fragment,{children:L.jsx("div",{className:"use-spring-carousel-item","data-testid":"use-spring-carousel-item-wrapper",style:{display:"flex",position:"relative",...h==="fixed"?{flex:"1"}:{},...Pe(a===Ie.findIndex(u=>u.id===Ie[Ie.length-1].id))},children:typeof r.renderItem=="function"?r.renderItem({getIsActiveItem:qe,getIsNextItem:Ve,getIsPrevItem:Ye,useListenToCustomEvent:me}):r.renderItem})},`${r.id}-${a}`)),(o||!f)&&d?L.jsx("div",{style:{flexShrink:0,width:d}}):null]})})});return{...Oe,carouselFragment:Be,thumbsFragment:xe}}const nr=l.createContext(void 0);function Er(){const n=l.useContext(nr);if(!n)throw new Error("useSpringCarouselContext must be used within the carousel.");return n}const Me={initial:{opacity:1,position:"relative"},from:{opacity:0,position:"relative"},enter:{position:"relative",opacity:1},leave:{opacity:1,position:"absolute"}};function Tr({init:n=!0,disableGestures:p=!1,items:m,springConfig:$=Q.config.default,exitBeforeEnter:U=!1,trail:h,withLoop:w=!1,activeItem:f,toPrevItemSpringProps:d=Me,toNextItemSpringProps:v=Me,draggingSlideTreshold:N=50,thumbsSlideAxis:A="x"}){const I=l.useRef("next"),o=l.useRef("initial"),B=l.useRef(null),[b,ae]=l.useState(f??0),{emitEvent:F,useListenToCustomEvent:O}=sr(),{handleScroll:ne,thumbsFragment:De}=lr({thumbsSlideAxis:A,items:m,renderThumbFnProps:{getIsNextItem:M,getIsPrevItem:x,useListenToCustomEvent:O,activeItem:{index:b,id:m[b].id}}});function ie(){return I.current==="prev"?{initial:{...d.initial},from:{...d.from},enter:{...d.enter},leave:{...d.leave}}:I.current==="next"?{initial:{...v.initial},from:{...v.from},enter:{...v.enter},leave:{...v.leave}}:{initial:{...Me.initial},from:{...Me.from},enter:{...Me.enter},leave:{...Me.leave}}}l.useEffect(()=>{typeof f=="number"&&f!==b&&ae(f)},[f]);function Y({to:c,slideType:T,slideMode:k}){I.current=T,o.current=k,F({eventName:"onSlideStartChange",slideActionType:I.current,slideMode:o.current,nextItem:{index:c,id:m[c].id,startReached:c===0,endReached:c===m.length-1}}),ae(c),ne(b)}function ue(c){if(!n)return;const T=b===0;!w&&T||Y(w&&T?{to:m.length-1,slideType:"prev",slideMode:c}:{to:b-1,slideType:"prev",slideMode:c})}function oe(c){if(!n)return;const T=b===m.length-1;!w&&T||Y(w&&T?{to:0,slideType:"next",slideMode:c}:{to:b+1,slideType:"next",slideMode:c})}const z=Q.useTransition(b,{config:$,key:null,trail:h,exitBeforeEnter:U,...ie(),onRest(c,T,k){c.finished&&k===b&&F({eventName:"onSlideChange",slideActionType:I.current,slideMode:o.current,currentItem:{index:b,id:m[b].id,startReached:b===0,endReached:b===m.length-1}})}}),Ee=cr.useDrag(({last:c,movement:[T]})=>{if(c){const k=T>N,X=T<-N,H=b===0,He=b===m.length-1;if(X){if(!w&&He)return;F({eventName:"onLeftSwipe"}),oe("swipe")}else if(k){if(!w&&H)return;F({eventName:"onRightSwipe"}),ue("swipe")}}},{enabled:!p});function G(c,T){let k=0;if(typeof c=="string"?k=m.findIndex(X=>X.id===c):k=c,k<0||k>=m.length){if(T)throw new Error(T);console.error(`The item doesn't exist; check that the id provided - ${c} - is correct.`),k=-1}return k}function M(c){const T=G(c,"The item doesn't exist; check the provided id."),k=b;return w&&k===m.length-1?T===0:T===k+1}function x(c){const T=G(c,"The item doesn't exist; check the provided id."),k=b;return w&&k===0?T===m.length-1:T===k-1}const R=z((c,T,k,X)=>{const H=m[T].renderItem;return L.jsx(Q.a.div,{id:`use-transition-carousel-item-${X}`,className:"use-transition-carousel-item",style:{...c,flex:"1 0 100%",width:"100%",height:"100%"},children:typeof H=="function"?H({useListenToCustomEvent:O,getIsNextItem:M,getIsPrevItem:x,activeItem:{index:b,id:m[b].id}}):H})});function C(){return p?"unset":"pan-y"}const D={useListenToCustomEvent:O,slideToPrevItem:()=>ue("click"),slideToNextItem:()=>oe("click"),activeItem:b,slideToItem:c=>{const T=G(c,"The item you want to slide to doesn't exist; check the provided id.");if(c===b)return;const k=G(m[b].id),X=G(m[T].id);Y({to:X,slideType:X>k?"next":"prev",slideMode:"click"})}},ge=L.jsx(ir.Provider,{value:D,children:De}),pe=L.jsx(ir.Provider,{value:D,children:L.jsx("div",{className:"use-transition-carousel-wrapper",ref:B,...Ee(),style:{display:"flex",position:"relative",width:"100%",height:"100%",overflow:"hidden",touchAction:C()},children:R})});return{...D,carouselFragment:pe,thumbsFragment:ge}}const ir=l.createContext(void 0);function wr(){const n=l.useContext(ir);if(!n)throw new Error("useTransitionCarouselContext must be used within the carousel.");return n}exports.useSpringCarousel=Rr;exports.useSpringCarouselContext=Er;exports.useTransitionCarousel=Tr;exports.useTransitionCarouselContext=wr;
|
|
28
28
|
//# sourceMappingURL=index.cjs.js.map
|