najwer23morsels 0.9.0 → 0.9.1

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.
@@ -1 +1 @@
1
- import{jsxs as e,jsx as l,Fragment as i}from"react/jsx-runtime";import r,{useState as t,useRef as n,useEffect as o}from"react";import{s as d}from"./style-inject.es-BnTDb6vU.js";import{L as s}from"./Loader-CL-mm0LT.js";import{a,I as u}from"./IconArrowRight-Bs6HQ5lc.js";import{B as c}from"./Button-DP1hmI08.js";import"./TextBox-B47QWA9m.js";var h={n23mSliderMulti:"SliderMulti-module_n23mSliderMulti__hsL9a",n23mSliderMultiContainerSlider:"SliderMulti-module_n23mSliderMultiContainerSlider__iu4xy",n23mSliderMultiSlideWrapper:"SliderMulti-module_n23mSliderMultiSlideWrapper__KPiK1",n23mSliderMultiSlide:"SliderMulti-module_n23mSliderMultiSlide__NDrCj",n23mSliderMultiControls:"SliderMulti-module_n23mSliderMultiControls__54jy-",n23mSliderMultiControlsButtons:"SliderMulti-module_n23mSliderMultiControlsButtons__JqcZ5"};d("@layer n23mSliderMulti{.SliderMulti-module_n23mSliderMulti__hsL9a{width:100%}.SliderMulti-module_n23mSliderMultiContainerSlider__iu4xy{display:flex;flex-direction:column;gap:10px;height:100%;position:relative;user-select:none;width:100%}.SliderMulti-module_n23mSliderMultiSlideWrapper__KPiK1{height:100%;overflow:hidden;position:relative;width:100%;will-change:transform}.SliderMulti-module_n23mSliderMultiSlide__NDrCj{height:100%;overflow:hidden;position:absolute;top:0;will-change:transform;&>*{height:100%;width:100%}}.SliderMulti-module_n23mSliderMultiControls__54jy-{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderMulti-module_n23mSliderMultiControlsButtons__JqcZ5{display:flex;gap:10px;margin-top:10px}}");const m=(e,l,i=!1,t)=>(i?e.slice(0,l):e.slice(-l)).map((e,l)=>r.cloneElement(e,{key:`${i?"clone-first":"clone-last"}-${l} ${t}`,className:e.props.className})),S=({isCircular:d=!1,children:S,className:p,showControls:g=!0,loading:M=!1,loaderColor:f="black",slidesPerView:_=4,slideSpacingPx:C=10,slidesToScroll:x=4})=>{const y=r.Children.toArray(S).filter(r.isValidElement),[v,w]=t(0),E=n(null);o(()=>{const e=()=>{E.current&&w(E.current.offsetWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[M]);const j=_>0?(v-C*(_-1))/_:0;let b=d?[...m(y,r.Children.toArray(S).length,!1,1),...m(y,r.Children.toArray(S).length,!1,2),...y,...m(y,r.Children.toArray(S).length,!0,3),...m(y,r.Children.toArray(S).length,!0,4)]:y;const[N,F]=t(d?2*r.Children.toArray(S).length:0),[k,B]=t(!1),L=n([]),[A,T]=t(null),[$,W]=t(0);o(()=>{F(d?2*r.Children.toArray(S).length:0)},[d,_,y.length,M]);o(()=>{L.current.forEach((e,l)=>{if(!e)return;const i=(l-N)*(j+C)+(v-j*_-C*(_-1))/2;e.style.transition=k?"transform 0.4s cubic-bezier(.4,0,.2,1)":"none",e.style.transform=`translateX(${i}px)`,e.style.left=""})},[N,v,k,b.length,_,j,C,M]),o(()=>{if(!k)return;let e;const l=()=>{let i=N;N<_&&d?i=N+y.length:N>=y.length+_&&d&&(i=N-y.length),i!==N&&d&&F(i),B(!1),L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)}),clearTimeout(e)};return L.current.forEach(e=>{e&&e.addEventListener("transitionend",l)}),e=window.setTimeout(()=>{B(!1),L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)})},500),()=>{L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)}),clearTimeout(e)}},[N,d,k,y.length,_,b.length,M]);const P=()=>{k||(B(!0),F(e=>e+x))},D=()=>{k||(B(!0),F(e=>e-x))};return L.current.length!==b.length&&(L.current=Array(b.length).fill(null)),e("div",{className:[h.n23mSliderMulti,"n23mSliderMulti",p].filter(Boolean).join(" "),style:{height:M?"calc(100% - 2px)":g?"calc(100% - 60px)":"100%"},onTouchStart:e=>{1===e.touches.length&&(T(e.touches[0].clientX),W(0))},onTouchMove:e=>{null!==A&&W(e.touches[0].clientX-A)},onTouchEnd:()=>{$>50?D():$<-50&&P(),T(null),W(0)},children:[M&&l(s,{loaderColor:f}),!M&&e(i,{children:[l("div",{className:[h.n23mSliderMultiContainerSlider].filter(Boolean).join(" "),children:l("div",{className:[h.n23mSliderMultiSlideWrapper,"n23mSliderMultiSlideWrapper"].join(" "),ref:E,style:{display:"flex",gap:`${C}px`,overflow:"hidden",width:"100%"},children:b.map((e,i)=>l("div",{ref:e=>{L.current[i]=e},className:h.n23mSliderMultiSlide,style:{width:`${j}px`,flex:`0 0 ${j}px`},"aria-hidden":i<N||i>=N+_,children:e},e.key??i))})}),g&&l("div",{className:[h.n23mSliderMultiControls,"n23mSliderMultiControls"].join(" "),children:e("div",{className:[h.n23mSliderMultiControlsButtons,"n23mSliderMultiControlsButtons"].join(" "),children:[l(c,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Prev",onClick:D,borderColor:"black",backgroundColorDisabled:"#F2F0EF",disabled:k||!d&&0===N,children:l(a,{width:24,height:24})}),l(c,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Next",borderColor:"black",backgroundColorDisabled:"#F2F0EF",onClick:P,disabled:k||!d&&N+_>=y.length,children:l(u,{width:24,height:24})})]})})]})]})};S.displayName="Slider";export{S as SliderMulti};
1
+ import{jsxs as e,jsx as l,Fragment as i}from"react/jsx-runtime";import r,{useState as t,useRef as n,useEffect as o}from"react";import{s as d}from"./style-inject.es-BnTDb6vU.js";import{L as s}from"./Loader-CL-mm0LT.js";import{a,I as u}from"./IconArrowRight-Bs6HQ5lc.js";import{B as c}from"./Button-DP1hmI08.js";import"./TextBox-B47QWA9m.js";var h={n23mSliderMulti:"SliderMulti-module_n23mSliderMulti__hsL9a",n23mSliderMultiContainerSlider:"SliderMulti-module_n23mSliderMultiContainerSlider__iu4xy",n23mSliderMultiSlideWrapper:"SliderMulti-module_n23mSliderMultiSlideWrapper__KPiK1",n23mSliderMultiSlide:"SliderMulti-module_n23mSliderMultiSlide__NDrCj",n23mSliderMultiControls:"SliderMulti-module_n23mSliderMultiControls__54jy-",n23mSliderMultiControlsButtons:"SliderMulti-module_n23mSliderMultiControlsButtons__JqcZ5"};d("@layer n23mSliderMulti{.SliderMulti-module_n23mSliderMulti__hsL9a{width:100%}.SliderMulti-module_n23mSliderMultiContainerSlider__iu4xy{display:flex;flex-direction:column;gap:10px;height:100%;position:relative;user-select:none;width:100%}.SliderMulti-module_n23mSliderMultiSlideWrapper__KPiK1{height:100%;overflow:hidden;position:relative;width:100%;will-change:transform}.SliderMulti-module_n23mSliderMultiSlide__NDrCj{height:100%;overflow:hidden;position:absolute;top:0;will-change:transform;&>*{height:100%;width:100%}}.SliderMulti-module_n23mSliderMultiControls__54jy-{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderMulti-module_n23mSliderMultiControlsButtons__JqcZ5{display:flex;gap:10px;margin-top:10px}}");const m=(e,l,i=!1,t)=>(i?e.slice(0,l):e.slice(-l)).map((e,l)=>r.cloneElement(e,{key:`${i?"clone-first":"clone-last"}-${l} ${t}`,className:e.props.className})),S=({isCircular:d=!1,children:S,className:p,showControls:g=!0,loading:M=!1,loaderColor:f="black",slidesPerView:_=4,slideSpacingPx:C=10,slidesToScroll:x=4})=>{const y=r.Children.toArray(S).filter(r.isValidElement),[v,w]=t(0),E=n(null);o(()=>{const e=()=>{E.current&&w(E.current.offsetWidth)};return e(),window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[M]);const j=_>0?(v-C*(_-1))/_:0;let b=d?[...m(y,r.Children.toArray(S).length,!1,1),...m(y,r.Children.toArray(S).length,!1,2),...y,...m(y,r.Children.toArray(S).length,!0,3),...m(y,r.Children.toArray(S).length,!0,4)]:y;const[N,F]=t(d?2*r.Children.toArray(S).length:0),[k,B]=t(!1),L=n([]),[A,T]=t(null),[$,W]=t(0);o(()=>{F(d?2*r.Children.toArray(S).length:0)},[d,_,y.length,M]);o(()=>{L.current.forEach((e,l)=>{if(!e)return;const i=(l-N)*(j+C)+(v-j*_-C*(_-1))/2;e.style.transition=k?"transform 1.05s cubic-bezier(0.645, 0.045, 0.355, 1)":"none",e.style.transform=`translateX(${i}px)`,e.style.left=""})},[N,v,k,b.length,_,j,C,M]),o(()=>{if(!k)return;let e;const l=()=>{let i=N;N<_&&d?i=N+y.length:N>=y.length+_&&d&&(i=N-y.length),i!==N&&d&&F(i),B(!1),L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)}),clearTimeout(e)};return L.current.forEach(e=>{e&&e.addEventListener("transitionend",l)}),e=window.setTimeout(()=>{B(!1),L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)})},1150),()=>{L.current.forEach(e=>{e&&e.removeEventListener("transitionend",l)}),clearTimeout(e)}},[N,d,k,y.length,_,b.length,M]);const P=()=>{k||(B(!0),F(e=>e+x))},D=()=>{k||(B(!0),F(e=>e-x))};return L.current.length!==b.length&&(L.current=Array(b.length).fill(null)),e("div",{className:[h.n23mSliderMulti,"n23mSliderMulti",p].filter(Boolean).join(" "),style:{height:M?"calc(100% - 2px)":g?"calc(100% - 60px)":"100%"},onTouchStart:e=>{1===e.touches.length&&(T(e.touches[0].clientX),W(0))},onTouchMove:e=>{null!==A&&W(e.touches[0].clientX-A)},onTouchEnd:()=>{$>50?D():$<-50&&P(),T(null),W(0)},children:[M&&l(s,{loaderColor:f}),!M&&e(i,{children:[l("div",{className:[h.n23mSliderMultiContainerSlider].filter(Boolean).join(" "),children:l("div",{className:[h.n23mSliderMultiSlideWrapper,"n23mSliderMultiSlideWrapper"].join(" "),ref:E,style:{display:"flex",gap:`${C}px`,overflow:"hidden",width:"100%"},children:b.map((e,i)=>l("div",{ref:e=>{L.current[i]=e},className:h.n23mSliderMultiSlide,style:{width:`${j}px`,flex:`0 0 ${j}px`},"aria-hidden":i<N||i>=N+_,children:e},e.key??i))})}),g&&l("div",{className:[h.n23mSliderMultiControls,"n23mSliderMultiControls"].join(" "),children:e("div",{className:[h.n23mSliderMultiControlsButtons,"n23mSliderMultiControlsButtons"].join(" "),children:[l(c,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Prev",onClick:D,borderColor:"black",backgroundColorDisabled:"#F2F0EF",disabled:k||!d&&0===N,children:l(a,{width:24,height:24})}),l(c,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Next",borderColor:"black",backgroundColorDisabled:"#F2F0EF",onClick:P,disabled:k||!d&&N+_>=y.length,children:l(u,{width:24,height:24})})]})})]})]})};S.displayName="Slider";export{S as SliderMulti};
@@ -1 +1 @@
1
- import{jsxs as r,jsx as e}from"react/jsx-runtime";import{useRef as l,useState as o,useEffect as t}from"react";import{B as n}from"./Button-DP1hmI08.js";import{s as i}from"./style-inject.es-BnTDb6vU.js";import{u as c}from"./useWindowSize-CAQRbyxi.js";import{a as s,I as d}from"./IconArrowRight-Bs6HQ5lc.js";import"./Loader-CL-mm0LT.js";import"./TextBox-B47QWA9m.js";var a={n23mSliderScroll:"SliderScroll-module_n23mSliderScroll__to3-Y",n23mSliderScrollTrack:"SliderScroll-module_n23mSliderScrollTrack__FcsTl",n23mSliderScrollControls:"SliderScroll-module_n23mSliderScrollControls__i64nM",n23mSliderScrollControlsButtons:"SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb"};i("@layer n23mSliderScroll{.SliderScroll-module_n23mSliderScroll__to3-Y{display:grid;position:relative}.SliderScroll-module_n23mSliderScrollTrack__FcsTl{-ms-overflow-style:none;-webkit-overflow-scrolling:touch;display:flex;flex-wrap:nowrap;gap:var(--sliderscroll-gap);overflow-x:scroll;scrollbar-width:none;will-change:scroll-position;&::-webkit-scrollbar{display:none}&>*{flex-shrink:0}}.SliderScroll-module_n23mSliderScrollControls__i64nM{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb{display:flex;gap:10px;margin-top:10px}}");const u=({children:i,className:u,gap:m="5px"})=>{const S=l(null),[f,p]=o(!1),[h,g]=o(!1),{width:v}=c(),w=l(!1),_=l(null),x=()=>{if(!S.current||!S.current.childNodes[1])return 0;const r=S.current.childNodes[1],e=getComputedStyle(r);return parseInt(e.marginLeft)+parseInt(e.marginRight)+r.offsetWidth+Number(m.slice(0,-2))};t(()=>{const r=setTimeout(()=>{C()},1);return()=>clearTimeout(r)},[v]);const b=()=>{w.current=!0,_.current&&clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!1},150)},C=()=>{if(!S.current)return;b();const r=S.current.scrollLeft,e=S.current.scrollWidth-S.current.clientWidth;r<=0?(p(!1),g(0!==e)):r>=e?(p(!0),g(!1)):(p(!0),g(!0))},M=(r,e,l=400,o=!1)=>{if(w.current&&!o)return r.scrollLeft=e,void C();const t=r.scrollLeft,n=e-t,i=performance.now(),c=s=>{if(w.current&&!o)return r.scrollLeft=e,void C();const d=s-i,a=Math.min(d/l,1);var u;r.scrollLeft=t+n*((u=a)<.5?4*u*u*u:1-Math.pow(-2*u+2,3)/2),a<1?requestAnimationFrame(c):C()};requestAnimationFrame(c)},L=l({isDown:!1,startX:0,scrollLeft:0,isMove:!1}),k=()=>{L.current.isDown=!1};return r("div",{className:[a.n23mSliderScroll,"n23mSliderScroll",u].filter(Boolean).join(" "),style:{"--sliderscroll-gap":m},children:[e("div",{className:a.n23mSliderScrollTrack,ref:S,onClick:r=>{L.current.isMove&&(r.preventDefault(),r.stopPropagation())},onScroll:C,onMouseDown:r=>{L.current.isDown=!0,L.current.startX=r.pageX-(S.current?.offsetLeft||0),L.current.scrollLeft=S.current?.scrollLeft||0},onMouseLeave:k,onMouseUp:k,onMouseMove:r=>{if(!L.current.isDown)return void(L.current.isMove=!1);r.preventDefault(),b();var e;const l=1*(("pageX"in(e=r)?e.pageX:"touches"in e?e.touches[0].pageX:0)-(S.current?.offsetLeft||0)-L.current.startX);Math.abs(l)>5&&(L.current.isMove=!0),S.current&&(S.current.scrollLeft=L.current.scrollLeft-l)},onTouchMove:r=>{b()},children:i}),e("div",{className:[a.n23mSliderScrollControls,"n23mSliderScrollControls"].join(" "),children:r("div",{className:[a.n23mSliderScrollControlsButtons,"n23mSliderScrollControlsButtons"].join(" "),children:[e(n,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Prev",onClick:()=>{if(!S.current)return;const r=x();if(0===r)return;const e=Math.floor(S.current.offsetWidth/r)*r,l=Math.max(S.current.scrollLeft-e,0);M(S.current,l,900,!0)},borderColor:"black",backgroundColorDisabled:"#F2F0EF",disabled:!f,children:e(s,{width:24,height:24})}),e(n,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Next",borderColor:"black",backgroundColorDisabled:"#F2F0EF",onClick:()=>{if(!S.current)return;const r=x();if(0===r)return;const e=Math.floor(S.current.offsetWidth/r)*r,l=S.current.scrollWidth-S.current.clientWidth,o=Math.min(S.current.scrollLeft+e,l);M(S.current,o,900,!0)},disabled:!h,children:e(d,{width:24,height:24})})]})})]})};u.displayName="SliderScroll";export{u as SliderScroll};
1
+ import{jsxs as r,jsx as e}from"react/jsx-runtime";import{useRef as l,useState as o,useEffect as t}from"react";import{B as n}from"./Button-DP1hmI08.js";import{s as i}from"./style-inject.es-BnTDb6vU.js";import{u as c}from"./useWindowSize-CAQRbyxi.js";import{a as s,I as a}from"./IconArrowRight-Bs6HQ5lc.js";import"./Loader-CL-mm0LT.js";import"./TextBox-B47QWA9m.js";var d={n23mSliderScrollWrapper:"SliderScroll-module_n23mSliderScrollWrapper__MqXIk",n23mSliderScrollTrack:"SliderScroll-module_n23mSliderScrollTrack__FcsTl",n23mSliderScrollControls:"SliderScroll-module_n23mSliderScrollControls__i64nM",n23mSliderScrollControlsButtons:"SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb"};i("@layer n23mSliderScroll{.SliderScroll-module_n23mSliderScrollWrapper__MqXIk{display:grid;position:relative}.SliderScroll-module_n23mSliderScrollTrack__FcsTl{-ms-overflow-style:none;-webkit-overflow-scrolling:touch;display:flex;flex-wrap:nowrap;gap:var(--sliderscroll-gap);overflow-x:scroll;scrollbar-width:none;will-change:scroll-position;&::-webkit-scrollbar{display:none}&>*{flex-shrink:0}}.SliderScroll-module_n23mSliderScrollControls__i64nM{align-items:center;display:flex;justify-content:flex-end;margin-left:20px;margin-right:20px}.SliderScroll-module_n23mSliderScrollControlsButtons__W-5rb{display:flex;gap:10px;margin-top:10px}}");const u=({children:i,className:u,gap:m="5px"})=>{const S=l(null),[p,f]=o(!1),[h,g]=o(!1),{width:v}=c(),w=l(!1),_=l(null),x=()=>{if(!S.current||!S.current.childNodes[1])return 0;const r=S.current.childNodes[1],e=getComputedStyle(r);return parseInt(e.marginLeft)+parseInt(e.marginRight)+r.offsetWidth+Number(m.slice(0,-2))};t(()=>{const r=setTimeout(()=>{b()},1);return()=>clearTimeout(r)},[v]);const M=()=>{w.current=!0,_.current&&clearTimeout(_.current),_.current=window.setTimeout(()=>{w.current=!1},150)},b=()=>{if(!S.current)return;M();const r=S.current.scrollLeft,e=S.current.scrollWidth-S.current.clientWidth;r<=0?(f(!1),g(0!==e)):r>=e?(f(!0),g(!1)):(f(!0),g(!0))},C=(r,e,l=10,o=!1)=>{if(w.current&&!o)return r.scrollLeft=e,void b();const t=r.scrollLeft,n=e-t,i=performance.now(),c=s=>{if(w.current&&!o)return r.scrollLeft=e,void b();const a=s-i,d=Math.min(a/l,1);r.scrollLeft=t+n*((r=20)=>r<.5?4*r*r*r:1-Math.pow(-2*r+2,3)/2)(d),d<1?requestAnimationFrame(c):b()};requestAnimationFrame(c)},k=l({isDown:!1,startX:0,scrollLeft:0,isMove:!1}),L=()=>{k.current.isDown=!1};return r("div",{className:["n23mSliderScroll",u].filter(Boolean).join(" "),style:{"--sliderscroll-gap":m,height:"calc(100% - 60px)"},children:[e("div",{className:[d.n23mSliderScrollWrapper,"n23mSliderScrollWrapper"].join(" "),children:e("div",{className:d.n23mSliderScrollTrack,ref:S,onClick:r=>{k.current.isMove&&(r.preventDefault(),r.stopPropagation())},onScroll:b,onMouseDown:r=>{k.current.isDown=!0,k.current.startX=r.pageX-(S.current?.offsetLeft||0),k.current.scrollLeft=S.current?.scrollLeft||0},onMouseLeave:L,onMouseUp:L,onMouseMove:r=>{if(!k.current.isDown)return void(k.current.isMove=!1);r.preventDefault(),M();var e;const l=1*(("pageX"in(e=r)?e.pageX:"touches"in e?e.touches[0].pageX:0)-(S.current?.offsetLeft||0)-k.current.startX);Math.abs(l)>5&&(k.current.isMove=!0),S.current&&(S.current.scrollLeft=k.current.scrollLeft-l)},onTouchMove:r=>{M()},children:i})}),e("div",{className:[d.n23mSliderScrollControls,"n23mSliderScrollControls"].join(" "),children:r("div",{className:[d.n23mSliderScrollControlsButtons,"n23mSliderScrollControlsButtons"].join(" "),children:[e(n,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Prev",onClick:()=>{if(!S.current)return;const r=x();if(0===r)return;const e=Math.floor(S.current.offsetWidth/r)*r,l=Math.max(S.current.scrollLeft-e,0);C(S.current,l,900,!0)},borderColor:"black",backgroundColorDisabled:"#F2F0EF",disabled:!p,children:e(s,{width:24,height:24})}),e(n,{height:"50px",width:"50px",backgroundColor:"#F2F0EF",padding:0,title:"Next",borderColor:"black",backgroundColorDisabled:"#F2F0EF",onClick:()=>{if(!S.current)return;const r=x();if(0===r)return;const e=Math.floor(S.current.offsetWidth/r)*r,l=S.current.scrollWidth-S.current.clientWidth,o=Math.min(S.current.scrollLeft+e,l);C(S.current,o,900,!0)},disabled:!h,children:e(a,{width:24,height:24})})]})})]})};u.displayName="SliderScroll";export{u as SliderScroll};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "najwer23morsels",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./lib/index.mjs",
6
6
  "types": "./lib/index.d.ts",