najwer23morsels 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/lib/Button-BF9bCjkn.js +1 -0
- package/lib/Button.js +1 -1
- package/lib/Carousel.js +1 -0
- package/lib/Hooks.js +1 -0
- package/lib/IconArrowRight-Bs6HQ5lc.js +1 -0
- package/lib/Icons.js +1 -0
- package/lib/Slider.js +1 -1
- package/lib/carousel/Carousel.d.ts +6 -0
- package/lib/carousel/index.d.ts +2 -0
- package/lib/hooks/index.d.ts +6 -0
- package/lib/hooks/useIsMounted.d.ts +1 -0
- package/lib/hooks/useResizeObserver.d.ts +12 -0
- package/lib/hooks/useWindowSize.d.ts +6 -0
- package/lib/icons/IconArrowLeft.d.ts +2 -0
- package/lib/icons/IconArrowRight.d.ts +2 -0
- package/lib/icons/Icons.types.d.ts +4 -0
- package/lib/icons/index.d.ts +3 -0
- package/lib/useWindowSize-CAQRbyxi.js +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsxs as o,jsx as e}from"react/jsx-runtime";import{L as t}from"./Loader-Bp_QrPqC.js";import{s as n}from"./TextBox-DnwTtpP2.js";var r={najwer23morselsButtonContainer:"Button-module_najwer23morselsButtonContainer__Okjrw"};n('@layer najwer23morselsButton{.Button-module_najwer23morselsButtonContainer__Okjrw{--boxShadow:0 4px 8px 0 rgba(0,0,0,.24),0 6px 20px 0 rgba(0,0,0,.19);-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:var(--najwer23morselsButtonBg,var(--button-bg));border:unset;border-radius:8px;box-shadow:none;cursor:pointer;height:var(--button-height,auto);letter-spacing:normal;padding:var(--button-padding,10px 17px);position:relative;transition:background-color .3s,box-shadow .3s;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;width:var(--button-width,auto);>span{display:inline-block;position:relative;z-index:1}&:before{background-color:inherit;border-radius:8px;content:"";inset:0;pointer-events:none;position:absolute;transition:filter .3s;z-index:0}@media (hover:hover) and (pointer:fine){&:hover:before{filter:brightness(100%)}&:hover{box-shadow:var(--boxShadow)}}&:active:before{filter:brightness(.8)}&:active{box-shadow:var(--boxShadow)}&:focus-visible:before{filter:brightness(.8);outline:none}&:focus-visible{box-shadow:var(--boxShadow);outline:none}&:disabled{background-color:var(--najwer23morselsButtonBgDisabled,var(--button-bgDisabled));box-shadow:none;cursor:not-allowed}}}');const a=({children:n,className:a,backgroundColor:i,padding:s,loading:l,height:d,width:b,backgroundColorDisabled:u,...h})=>o("div",{className:["MorselsButtonWrapper",a].filter(Boolean).join(" "),children:[l&&e("div",{style:{width:b,height:d},children:e(t,{})}),!l&&e("button",{style:{...null!=s?{"--button-padding":s}:{},"--button-bg":i,"--button-height":d,"--button-width":b,"--button-bgDisabled":u},className:[r.najwer23morselsButtonContainer,"MorselsButton"].filter(Boolean).join(" "),...h,children:e("span",{children:n})})]});a.displayName="Button";export{a as B};
|
package/lib/Button.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{B as Button}from"./Button-BF9bCjkn.js";import"react/jsx-runtime";import"./Loader-Bp_QrPqC.js";import"./TextBox-DnwTtpP2.js";
|
package/lib/Carousel.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as r,jsxs as e}from"react/jsx-runtime";import{useRef as o,useState as t,useEffect as n}from"react";import{B as l}from"./Button-BF9bCjkn.js";import{s as a}from"./TextBox-DnwTtpP2.js";import{u as i}from"./useWindowSize-CAQRbyxi.js";import"./Loader-Bp_QrPqC.js";var s={carousel:"Carousel-module_carousel__Yo2oU",carouselWrapper:"Carousel-module_carouselWrapper__JQHy4",arrowLeft:"Carousel-module_arrowLeft__kk-Rx",arrowRight:"Carousel-module_arrowRight__Spznn",arrowShow:"Carousel-module_arrowShow__NqOi-",buttonArrowRight:"Carousel-module_buttonArrowRight__1-Cq0",buttonArrowLeft:"Carousel-module_buttonArrowLeft__EAxth"};a('@layer najwer23snacksCarouel{.Carousel-module_carousel__Yo2oU{-ms-overflow-style:none;-webkit-overflow-scrolling:touch;display:flex;flex-wrap:nowrap;gap:var(--gap);overflow-x:scroll;scrollbar-width:none;will-change:scroll-position;&::-webkit-scrollbar{display:none}&>*{flex-shrink:0}}.Carousel-module_carouselWrapper__JQHy4{display:grid;position:relative}.Carousel-module_arrowLeft__kk-Rx{display:none;left:20px;position:absolute;top:calc(50% - 25px);@media (max-width:767.98px){display:none}}.Carousel-module_arrowRight__Spznn{display:none;position:absolute;right:20px;top:calc(50% - 25px);@media (max-width:767.98px){display:none}}.Carousel-module_arrowShow__NqOi-{display:block;@media (max-width:767.98px){display:none}}.Carousel-module_buttonArrowLeft__EAxth,.Carousel-module_buttonArrowRight__1-Cq0{height:15px;padding:5px 0;position:relative;transition:all .2s linear;width:15px}.Carousel-module_buttonArrowRight__1-Cq0:after{right:3px;transform:rotate(135deg)}.Carousel-module_buttonArrowLeft__EAxth:after,.Carousel-module_buttonArrowRight__1-Cq0:after{border-left:2px solid #fff;border-top:2px solid #fff;content:"";display:flex;height:15px;position:absolute;width:15px}.Carousel-module_buttonArrowLeft__EAxth:after{left:3px;transform:rotate(-45deg)}}');const u=({children:a,arrowLeftIcon:u,arrowRightIcon:c,gap:d="5px"})=>{const p=o(null),[f,h]=t(!1),[m,w]=t(!1),{width:_}=i(),x=o(!1),g=o(null),C=()=>{if(!p.current||!p.current.childNodes[1])return 0;const r=p.current.childNodes[1],e=getComputedStyle(r);return parseInt(e.marginLeft)+parseInt(e.marginRight)+r.offsetWidth+Number(d.slice(0,-2))};n(()=>{const r=setTimeout(()=>{v()},1);return()=>clearTimeout(r)},[_]);const L=()=>{x.current=!0,g.current&&clearTimeout(g.current),g.current=window.setTimeout(()=>{x.current=!1},150)},v=()=>{if(!p.current)return;L();const r=p.current.scrollLeft,e=p.current.scrollWidth-p.current.clientWidth;r<=0?(h(!1),w(0!==e)):r>=e?(h(!0),w(!1)):(h(!0),w(!0))},b=(r,e,o=400,t=!1)=>{if(x.current&&!t)return r.scrollLeft=e,void v();const n=r.scrollLeft,l=e-n,a=performance.now(),i=s=>{if(x.current&&!t)return r.scrollLeft=e,void v();const u=s-a,c=Math.min(u/o,1);var d;r.scrollLeft=n+l*((d=c)<.5?4*d*d*d:1-Math.pow(-2*d+2,3)/2),c<1?requestAnimationFrame(i):v()};requestAnimationFrame(i)},y=o({isDown:!1,startX:0,scrollLeft:0,isMove:!1}),A=()=>{y.current.isDown=!1};return r("div",{className:s.carouselWrapper,style:{"--gap":d},children:e("div",{className:s.carousel,ref:p,onClick:r=>{y.current.isMove&&(r.preventDefault(),r.stopPropagation())},onScroll:v,onMouseDown:r=>{y.current.isDown=!0,y.current.startX=r.pageX-(p.current?.offsetLeft||0),y.current.scrollLeft=p.current?.scrollLeft||0},onMouseLeave:A,onMouseUp:A,onMouseMove:r=>{if(!y.current.isDown)return void(y.current.isMove=!1);r.preventDefault(),L();var e;const o=1*(("pageX"in(e=r)?e.pageX:"touches"in e?e.touches[0].pageX:0)-(p.current?.offsetLeft||0)-y.current.startX);Math.abs(o)>5&&(y.current.isMove=!0),p.current&&(p.current.scrollLeft=y.current.scrollLeft-o)},onTouchMove:r=>{L()},children:[r("div",{className:[s.arrowLeft,f&&s.arrowShow].join(" "),children:r(l,{type:"button",onClick:()=>{if(!p.current)return;const r=C();if(0===r)return;const e=Math.floor(p.current.offsetWidth/r)*r,o=Math.max(p.current.scrollLeft-e,0);b(p.current,o,900,!0)},height:"40px",width:"40px",children:u||r("div",{className:[s.buttonArrowLeft].join(" ")})})}),a,r("div",{className:[s.arrowRight,m&&s.arrowShow].join(" "),children:r(l,{type:"button",onClick:()=>{if(!p.current)return;const r=C();if(0===r)return;const e=Math.floor(p.current.offsetWidth/r)*r,o=p.current.scrollWidth-p.current.clientWidth,t=Math.min(p.current.scrollLeft+e,o);b(p.current,t,900,!0)},height:"40px",width:"40px",children:c||r("div",{className:[s.buttonArrowRight].join(" ")})})})]})})};u.displayName="Carousel";export{u as Carousel};
|
package/lib/Hooks.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useRef as e,useEffect as t,useCallback as r,useState as i}from"react";export{u as useWindowSize}from"./useWindowSize-CAQRbyxi.js";const n=()=>{const i=e(!1);return t(()=>(i.current=!0,()=>{i.current=!1}),[]),r(()=>i.current,[])},o={width:void 0,height:void 0},c=r=>{const{ref:c,box:h="content-box"}=r,[{width:u,height:s},w]=i(o),x=n(),z=e({...o}),b=e(void 0);return b.current=r.onResize,t(()=>{if(!c.current)return;if("undefined"==typeof window||!("ResizeObserver"in window))return;const e=new ResizeObserver(([e])=>{const t="border-box"===h?"borderBoxSize":"device-pixel-content-box"===h?"devicePixelContentBoxSize":"contentBoxSize",r=d(e,t,"inlineSize"),i=d(e,t,"blockSize");if(z.current.width!==r||z.current.height!==i){const e={width:r,height:i};z.current.width=r,z.current.height=i,b.current?b.current(e):x()&&w(e)}});return e.observe(c.current,{box:h}),()=>{e.disconnect()}},[h,c,x]),{width:u,height:s}},d=(e,t,r)=>e[t]?Array.isArray(e[t])?e[t][0][r]:e[t][r]:"contentBoxSize"===t?e.contentRect["inlineSize"===r?"width":"height"]:void 0;export{n as useIsMounted,c as useResizeObserver};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{jsx as t}from"react/jsx-runtime";const h=({width:h,height:i})=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:h,height:i,fill:"currentColor",children:t("path",{d:"M41.4 233.4c-12.5 12.5-12.5 32.8 0 45.3l160 160c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L109.3 256 246.6 118.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0l-160 160z"})});h.displayName="IconArrowRight";const i=({width:h,height:i})=>t("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 320 512",width:h,height:i,fill:"currentColor",children:t("path",{d:"M278.6 233.4c12.5 12.5 12.5 32.8 0 45.3l-160 160c-12.5 12.5-32.8 12.5-45.3 0s-12.5-32.8 0-45.3L210.7 256 73.4 118.6c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0l160 160z"})});i.displayName="IconArrowRight";export{i as I,h as a};
|
package/lib/Icons.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{a as IconArrowLeft,I as IconArrowRight}from"./IconArrowRight-Bs6HQ5lc.js";import"react/jsx-runtime";
|
package/lib/Slider.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as r,Fragment as n}from"react/jsx-runtime";import l,{useState as t,useRef as o,useEffect as i,useCallback as s}from"react";import{s as a,T as d}from"./TextBox-DnwTtpP2.js";import{L as c}from"./Loader-Bp_QrPqC.js";var
|
|
1
|
+
import{jsxs as e,jsx as r,Fragment as n}from"react/jsx-runtime";import l,{useState as t,useRef as o,useEffect as i,useCallback as s}from"react";import{s as a,T as d}from"./TextBox-DnwTtpP2.js";import{L as c}from"./Loader-Bp_QrPqC.js";import{a as m,I as u}from"./IconArrowRight-Bs6HQ5lc.js";var h={najwer23morselsSliderContainer:"Slider-module_najwer23morselsSliderContainer__1SbJN",najwer23morselsSliderContainerSlider:"Slider-module_najwer23morselsSliderContainerSlider__7ONky",najwer23morselsSlideWrapper:"Slider-module_najwer23morselsSlideWrapper__veeuJ",najwer23morselsSlide:"Slider-module_najwer23morselsSlide__KHKZW",najwer23morselsBtnControl:"Slider-module_najwer23morselsBtnControl__RHrxn",najwer23morselsBtn:"Slider-module_najwer23morselsBtn__10p8D",najwer23morselsSliderCounter:"Slider-module_najwer23morselsSliderCounter__56f5P"};a("@layer najwer23morselsSlider{.Slider-module_najwer23morselsSliderContainer__1SbJN{width:100%}.Slider-module_najwer23morselsSliderContainerSlider__7ONky{display:flex;flex-direction:column;gap:10px;height:100%;position:relative;user-select:none;width:100%}.Slider-module_najwer23morselsSlideWrapper__veeuJ{height:100%;overflow:hidden;position:relative;width:100%;will-change:transform}.Slider-module_najwer23morselsSlide__KHKZW{height:100%;overflow:hidden;position:absolute;top:0;will-change:transform;&>*{height:100%;width:100%}}.Slider-module_najwer23morselsBtnControl__RHrxn{align-items:center;display:flex;height:100%;left:0;opacity:0;padding:0 25px;pointer-events:none;position:absolute;right:0;transition:all .2s linear;z-index:100;@media (max-width:767.98px){display:none}}.Slider-module_najwer23morselsSliderContainer__1SbJN:hover .Slider-module_najwer23morselsBtnControl__RHrxn{opacity:1;pointer-events:auto}.Slider-module_najwer23morselsBtn__10p8D{-webkit-touch-callout:none;-webkit-tap-highlight-color:rgba(0,0,0,0);background-color:var(--najwer23morselsSliderArrowsColorBackground,var(--slider-acbg,#fff));border:1px solid var(--najwer23morselsSliderArrowsColorBorder,var(--slider-acb,#000));border-radius:50%;color:var(--najwer23morselsSliderArrowsColor,var(--slider-ac,#000));cursor:pointer;display:flex;left:50%;padding:10px;pointer-events:auto;transition:all .2s linear;transition:background-color .3s,box-shadow .3s;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;@media (hover:hover) and (pointer:fine){&:hover{box-shadow:0 4px 8px 0 rgba(0,0,0,.24),0 6px 20px 0 rgba(0,0,0,.19);filter:brightness(.95)}}}.Slider-module_najwer23morselsSliderCounter__56f5P{align-items:center;display:flex;height:35px;justify-content:center}}");const w=(e,r,n=!1)=>(n?e.slice(0,r):e.slice(-r)).map((e,r)=>l.cloneElement(e,{key:`${n?"clone-first":"clone-last"}-${r}`,className:e.props.className})),p=({isCircular:a=!1,children:p,className:S,arrowsColor:g,arrowsColorBackground:f,arrowsColorBorder:_,showCounter:j=!0,loading:v=!1,loaderColor:C="black"})=>{const x=l.Children.toArray(p).filter(l.isValidElement),[b,y]=t(a&&x.length>=2?2:0),[N,k]=t(!1),[B,E]=t(0),[T,L]=t(0),W=o(null),$=o([]),z=o(null),[M,A]=t(null),[H,J]=t(0),R=a&&x.length>=2?[...w(x,2,!1),...x.map((e,r)=>l.cloneElement(e,{key:e.key??r,className:e.props.className})),...w(x,2,!0)]:x.map((e,r)=>l.cloneElement(e,{key:e.key??r,className:e.props.className}));$.current.length!==R.length&&($.current=Array(R.length).fill(null)),i(()=>{y(a&&x.length>=2?2:0)},[a,x.length,v]);const K=s(()=>{const e=W.current;if(!e)return;const r=$.current[0];if(!r)return;const n=window.getComputedStyle(r);E(r.offsetWidth+parseFloat(n.marginLeft)+parseFloat(n.marginRight)),L(e.offsetWidth)},[]);i(()=>{K();const e=()=>{null!==z.current&&clearTimeout(z.current),z.current=window.setTimeout(()=>{K(),k(!0)},150)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e),null!==z.current&&clearTimeout(z.current)}},[K,v]),i(()=>{const e=B+10;$.current.forEach((r,n)=>{if(!r)return;const l=(n-b)*e+(T-B)/2;r.style.transition=N?"transform 0.4s cubic-bezier(.4,0,.2,1)":"none",r.style.transform=`translateX(${l}px)`,r.style.left=""})},[b,B,T,N,R.length,a,v]),i(()=>{if(!N||!a)return;const e=$.current.length,r=$.current[e-1];if(!r)return;let n;const l=()=>{let t=b;1===b?t=e-3:b===e-2&&(t=2),t!==b&&y(t),k(!1),r.removeEventListener("transitionend",l),clearTimeout(n)};return r.addEventListener("transitionend",l),n=window.setTimeout(()=>{k(!1),r.removeEventListener("transitionend",l)},500),()=>{r.removeEventListener("transitionend",l),clearTimeout(n)}},[b,a,N,v]),i(()=>{if(!N)return;const e=$.current[0];if(!e)return;let r;const n=()=>{k(!1),e.removeEventListener("transitionend",n),clearTimeout(r)};return e.addEventListener("transitionend",n),r=window.setTimeout(()=>{k(!1),e.removeEventListener("transitionend",n)},500),()=>{e.removeEventListener("transitionend",n),clearTimeout(r)}},[N,v]);const P=()=>{N||(k(!0),y(a?e=>e+1:e=>Math.min(e+1,R.length-1)))},X=()=>{N||(k(!0),y(a?e=>e-1:e=>Math.max(e-1,0)))};return e("div",{className:[h.najwer23morselsSliderContainer,"MorselsSlider",S].filter(Boolean).join(" "),style:{height:v?"calc(100% - 2px)":j?"calc(100% - 35px)":"100%"},onTouchStart:e=>{1===e.touches.length&&(A(e.touches[0].clientX),J(0))},onTouchMove:e=>{null!==M&&J(e.touches[0].clientX-M)},onTouchEnd:()=>{H>50?X():H<-50&&P(),A(null),J(0)},children:[v&&r(c,{loaderColor:C}),!v&&e(n,{children:[e("div",{className:[h.najwer23morselsSliderContainerSlider].filter(Boolean).join(" "),style:{"--slider-ac":g,"--slider-acbg":f,"--slider-acb":_},children:[e("div",{className:[h.najwer23morselsBtnControl,"MorselsSliderControl",S].join(" "),style:{justifyContent:a?"space-between":0===b?"flex-end":b===x.length-1?"flex-start":"space-between"},children:[(a&&x.length>1||0!==b)&&r("button",{title:"Prev",className:h.najwer23morselsBtn,onClick:X,disabled:N,children:r(m,{width:24,height:24})}),(a&&x.length>1||b!==x.length-1)&&r("button",{title:"Next",className:h.najwer23morselsBtn,onClick:P,disabled:N,children:r(u,{width:24,height:24})})]}),r("div",{className:[h.najwer23morselsSlideWrapper,"MorselsSliderWrapper",S].join(" "),ref:W,children:R.map((e,n)=>r("div",{ref:e=>{$.current[n]=e},className:`${h.najwer23morselsSlide}`,style:{width:x.length>1?"calc(100% - 40px)":"100%"},"aria-hidden":b!==n,children:e},e.key??n))})]}),j&&r("div",{className:[h.najwer23morselsSliderCounter,"MorselsSliderCounter",S].join(" "),children:r(d,{mobileSize:16,desktopSize:16,color:"black",children:a?`${(()=>{if(!a)return b;const e=x.length;return e<1?0:(b-2+e)%e})()+1} / ${x.length}`:`${b+1} / ${x.length}`})})]})]})};p.displayName="Slider";export{p as Slider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useIsMounted: () => (() => boolean);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { RefObject } from 'react';
|
|
2
|
+
type Size = {
|
|
3
|
+
width: number | undefined;
|
|
4
|
+
height: number | undefined;
|
|
5
|
+
};
|
|
6
|
+
type UseResizeObserverOptions<T extends HTMLElement = HTMLElement> = {
|
|
7
|
+
ref: RefObject<T | null>;
|
|
8
|
+
onResize?: (size: Size) => void;
|
|
9
|
+
box?: 'border-box' | 'content-box' | 'device-pixel-content-box';
|
|
10
|
+
};
|
|
11
|
+
export declare const useResizeObserver: <T extends HTMLElement = HTMLElement>(options: UseResizeObserverOptions<T>) => Size;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as i,useLayoutEffect as e}from"react";const n=(n=0)=>{const[t,w]=i({width:window.innerWidth,height:window.innerHeight});return e(()=>{let i=null;const e=()=>{0===n&&t.width!==window.innerWidth&&w({width:window.innerWidth,height:window.innerHeight}),0!==n&&(i&&clearTimeout(i),i=setTimeout(()=>{t.width!==window.innerWidth&&w({width:window.innerWidth,height:window.innerHeight})},n))};return window.addEventListener("resize",e),e(),()=>{window.removeEventListener("resize",e),i&&clearTimeout(i)}},[t,n]),t};export{n as u};
|