@eliseubatista99/react-scaffold-core 0.1.33 → 0.1.35
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.
|
@@ -7,7 +7,7 @@ export interface CarouselSlideProps {
|
|
|
7
7
|
export interface CarouselProps {
|
|
8
8
|
content: CarouselSlideProps[];
|
|
9
9
|
settings?: Settings;
|
|
10
|
-
gap?:
|
|
10
|
+
gap?: number;
|
|
11
11
|
styles?: CSSProperties;
|
|
12
12
|
}
|
|
13
13
|
export declare const Carousel: ({ styles, content, settings, gap, }: CarouselProps) => import("react/jsx-runtime").JSX.Element;
|
package/dist/index.cjs.js
CHANGED
|
@@ -45,7 +45,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
45
45
|
box-sizing: border-box;
|
|
46
46
|
display: flex;
|
|
47
47
|
}
|
|
48
|
-
`,Qi=({styles:e,content:t,settings:r,gap:o=
|
|
48
|
+
`,Qi=({styles:e,content:t,settings:r,gap:o=15})=>{const[i,a]=W.useState(1),l=W.useRef(null),f=W.useRef(null);var d={dots:!1,speed:500,slidesToScroll:1,infinite:!1,variableWidth:!0,arrows:!1,rows:1,...r};const h=t.map((E,R)=>G.jsx(Zi,{ref:R===0?f:void 0,styles:{paddingRight:`${o}px`,overflow:"visible",...E.styles},"data-testid":"carousel-slide-item",children:E.content})),w=()=>{d.slidesToShow&&a(d.slidesToShow);const E=(l.current?.offsetWidth||1)+o,R=f.current?.offsetWidth||1,A=Math.floor(E/R);console.log("Slides to show > ",{container:E,slide:R,res:A}),a(A)};return W.useEffect(()=>{w()},[l,f]),G.jsx(Ji,{ref:l,styles:{...e},children:G.jsx(ei,{...d,slidesToShow:i,children:h})})},eo=e=>W.useEffect(e,[]),qr=()=>{const[e,t]=W.useState({}),[r,o]=W.useState(!1);return W.useEffect(()=>{const i=f=>{t({x:f.clientX,y:f.clientY})},a=f=>{o(!0)},l=f=>{o(!1)};return window.addEventListener("pointermove",i),window.addEventListener("pointerdown",a),window.addEventListener("pointerup",l),()=>{window.removeEventListener("pointermove",i),window.removeEventListener("pointerdown",a),window.removeEventListener("pointerup",l)}},[]),{pointerPosition:e,isPointerDown:r}},Br=({ref:e,onDrag:t,onDragStart:r,onDragEnd:o})=>{const i=W.useRef(!1),a=W.useRef(!1),{pointerPosition:l,isPointerDown:f}=qr(),d=W.useRef({isDragging:!1}),h=W.useCallback(C=>{if(!e||!e.current||!d.current)return;const v={...d.current};return v.posY=C.y,v.posX=C.x,d.current.startPosX&&d.current.posX&&(v.distanceX=d.current.startPosX-d.current.posX),d.current.startPosY&&d.current.posY&&(v.distanceY=-(d.current.startPosY-d.current.posY)),v},[]),w=W.useCallback(C=>{C.preventDefault(),C.stopPropagation(),d.current.isDragging=!0,d.current.startPosY=C.clientY,d.current.startPosX=C.clientX;const v=h({x:C.clientX,y:C.clientY});v&&(d.current=v,r?.(v))},[h]),E=W.useCallback(C=>{d.current.isDragging=!1;const v=h(l);v&&(o?.(v),v.startPosX=void 0,v.startPosY=void 0,d.current=v)},[h,l]),R=W.useCallback(C=>{if(console.debug("useDrag > onPointerMove > Is Dragging >",d.current.isDragging),!d.current.isDragging)return;const v=h(l);console.debug("useDrag > onPointerMove > Drag Result >",v),v&&(t?.(v),d.current=v)},[h,l]),A=W.useCallback(async()=>{if(!i.current){for(;!e?.current;)await new Promise(C=>setTimeout(C,300));i.current=!0,e.current.onpointerdown=w,e.current.style.touchAction="none"}},[e?.current,w]);W.useEffect(()=>{A()},[A]),W.useEffect(()=>{R()},[l]),W.useEffect(()=>{f!==a.current&&(a.current=f,f||E())},[f,a.current])},to=()=>{const e=(r,o)=>{let i=0,a=`${r}?`;for(const l in o){const f=o[l];i>0&&(a=`${a}&`),a=`${a}${l}=${f}`,i++}return a};return async(r,o)=>{const i=e(r,o);return await(await fetch(i)).json()}};class Ur{static waitForMilliseconds=t=>new Promise(r=>setTimeout(r,t));static waitForCondition=t=>new Promise(r=>{const o=()=>{t()?r():setTimeout(o,100)};o()});static waitForAsyncCondition=t=>new Promise(r=>{const o=async()=>{await t()?r():setTimeout(o,100)};o()});static differenceInMonths=(t,r)=>{let o=0;return o=(r.getFullYear()-t.getFullYear())*12,o-=t.getMonth(),o+=r.getMonth(),o};static isDateOneAfterDateTwo=(t,r)=>t.getFullYear()>=r.getFullYear()&&t.getMonth()>=r.getMonth()?t.getDay()>r.getDay():!1}const ro=(e,t=0)=>{const r=W.useRef(0),[o,i]=W.useState(0),a=W.useRef(null),[l,f]=W.useState(!1),d=W.useCallback(()=>{f(E=>!E)},[]),h=W.useCallback(()=>r.current===0?!1:o>=r.current-t,[t,o]),w=W.useCallback(()=>e.current!==null&&e.current!==void 0,[e]);return W.useEffect(()=>{const E=()=>{if(!e.current)return;const A=e.current.scrollHeight-e.current.clientHeight;r.current=A,i(e.current.scrollTop)};return(async()=>{await Ur.waitForCondition(w),a.current=e.current,a.current?.addEventListener("scroll",E)})(),()=>{a.current?.removeEventListener("scroll",E)}},[e,r,i,o,w,l]),{isTouchingBottom:h(),refresh:d}},Yr={xs:0,sm:420,md:768,lg:991,xl:1200,xxl:1440},no=e=>{const t={...Yr,...e?.breakpointConfiguration},[r,o]=W.useState(br(t)),i=()=>{o(br(t))};return W.useEffect(()=>(window.addEventListener("resize",i),()=>{window.removeEventListener("resize",i)}),[]),W.useMemo(()=>r,[r])},io=(e,t)=>e<t.sm?"xs":e<t.md?"sm":e<t.lg?"md":e<t.xl?"lg":e<t.xxl?"xl":"xxl",oo=(e,t)=>e<=t.sm?"mobile":e<=t.md?"tablet":"desktop",br=e=>{const t=window.innerWidth,r=window.innerHeight,o=io(t,e),i=oo(t,e);return{currentWidth:t,currentHeight:r,currentBreakpoint:o,currentSize:i}},ao=e=>{const t=e.translations,r=e.language,o=(a,l)=>{if(!a)return;let f=a[r];if(f)return l&&Object.keys(l).forEach(d=>{const h=l[d];f=f.replaceAll(`{{${d}}}`,`${h}`)}),f};return{t:(a,l)=>{if(t[a]){const f=o(t[a],l);return f??a}return a},getTranslation:o}};var qe={},wr;function so(){if(wr)return qe;wr=1,Object.defineProperty(qe,"__esModule",{value:!0}),qe.parse=l,qe.serialize=h;const e=/^[\u0021-\u003A\u003C\u003E-\u007E]+$/,t=/^[\u0021-\u003A\u003C-\u007E]*$/,r=/^([.]?[a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)([.][a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?)*$/i,o=/^[\u0020-\u003A\u003D-\u007E]*$/,i=Object.prototype.toString,a=(()=>{const R=function(){};return R.prototype=Object.create(null),R})();function l(R,A){const C=new a,v=R.length;if(v<2)return C;const M=A?.decode||w;let k=0;do{const N=R.indexOf("=",k);if(N===-1)break;const B=R.indexOf(";",k),U=B===-1?v:B;if(N>U){k=R.lastIndexOf(";",N-1)+1;continue}const p=f(R,k,N),g=d(R,N,p),y=R.slice(p,g);if(C[y]===void 0){let O=f(R,N+1,U),m=d(R,U,O);const c=M(R.slice(O,m));C[y]=c}k=U+1}while(k<v);return C}function f(R,A,C){do{const v=R.charCodeAt(A);if(v!==32&&v!==9)return A}while(++A<C);return C}function d(R,A,C){for(;A>C;){const v=R.charCodeAt(--A);if(v!==32&&v!==9)return A+1}return C}function h(R,A,C){const v=C?.encode||encodeURIComponent;if(!e.test(R))throw new TypeError(`argument name is invalid: ${R}`);const M=v(A);if(!t.test(M))throw new TypeError(`argument val is invalid: ${A}`);let k=R+"="+M;if(!C)return k;if(C.maxAge!==void 0){if(!Number.isInteger(C.maxAge))throw new TypeError(`option maxAge is invalid: ${C.maxAge}`);k+="; Max-Age="+C.maxAge}if(C.domain){if(!r.test(C.domain))throw new TypeError(`option domain is invalid: ${C.domain}`);k+="; Domain="+C.domain}if(C.path){if(!o.test(C.path))throw new TypeError(`option path is invalid: ${C.path}`);k+="; Path="+C.path}if(C.expires){if(!E(C.expires)||!Number.isFinite(C.expires.valueOf()))throw new TypeError(`option expires is invalid: ${C.expires}`);k+="; Expires="+C.expires.toUTCString()}if(C.httpOnly&&(k+="; HttpOnly"),C.secure&&(k+="; Secure"),C.partitioned&&(k+="; Partitioned"),C.priority)switch(typeof C.priority=="string"?C.priority.toLowerCase():void 0){case"low":k+="; Priority=Low";break;case"medium":k+="; Priority=Medium";break;case"high":k+="; Priority=High";break;default:throw new TypeError(`option priority is invalid: ${C.priority}`)}if(C.sameSite)switch(typeof C.sameSite=="string"?C.sameSite.toLowerCase():C.sameSite){case!0:case"strict":k+="; SameSite=Strict";break;case"lax":k+="; SameSite=Lax";break;case"none":k+="; SameSite=None";break;default:throw new TypeError(`option sameSite is invalid: ${C.sameSite}`)}return k}function w(R){if(R.indexOf("%")===-1)return R;try{return decodeURIComponent(R)}catch{return R}}function E(R){return i.call(R)==="[object Date]"}return qe}so();/**
|
|
49
49
|
* react-router v7.6.3
|
|
50
50
|
*
|
|
51
51
|
* Copyright (c) Remix Software Inc.
|
package/dist/index.es.js
CHANGED
|
@@ -3766,7 +3766,7 @@ const Ki = je.div`
|
|
|
3766
3766
|
styles: e,
|
|
3767
3767
|
content: t,
|
|
3768
3768
|
settings: r,
|
|
3769
|
-
gap: o =
|
|
3769
|
+
gap: o = 15
|
|
3770
3770
|
}) => {
|
|
3771
3771
|
const [i, a] = q.useState(1), l = q.useRef(null), f = q.useRef(null);
|
|
3772
3772
|
var d = {
|
|
@@ -3784,7 +3784,7 @@ const Ki = je.div`
|
|
|
3784
3784
|
{
|
|
3785
3785
|
ref: R === 0 ? f : void 0,
|
|
3786
3786
|
styles: {
|
|
3787
|
-
|
|
3787
|
+
paddingRight: `${o}px`,
|
|
3788
3788
|
overflow: "visible",
|
|
3789
3789
|
// marginLeft: index !== 0 ? "0px" : margin,
|
|
3790
3790
|
...E.styles
|
|
@@ -3794,7 +3794,7 @@ const Ki = je.div`
|
|
|
3794
3794
|
}
|
|
3795
3795
|
)), w = () => {
|
|
3796
3796
|
d.slidesToShow && a(d.slidesToShow);
|
|
3797
|
-
const E = l.current?.offsetWidth || 1, R = f.current?.offsetWidth || 1, A = Math.floor(E / R);
|
|
3797
|
+
const E = (l.current?.offsetWidth || 1) + o, R = f.current?.offsetWidth || 1, A = Math.floor(E / R);
|
|
3798
3798
|
console.log("Slides to show > ", {
|
|
3799
3799
|
container: E,
|
|
3800
3800
|
slide: R,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eliseubatista99/react-scaffold-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A library which provides basic components, hooks, helpers and providers to easily build a React application and avoid repeating the usual code.",
|
|
6
6
|
"main": "dist/index.cjs.js",
|