the-omelet-ui 1.3.2 → 1.3.3

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 {useRef,useState,useCallback,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';function j({renderItem:L,data:m,onLoadMore:c,isLoading:a=false,hasMore:v=false,className:R="",showIndicators:k=false,showArrows:h=false,gap:S=12,paddingBottom:P=28,snapScroll:g=true,loadingComponent:C,emptyComponent:z,loadMoreThreshold:p=300}){let r=useRef(null),[B,E]=useState(0),[d,T]=useState(0),[W,A]=useState(false),[$,H]=useState(false),n=useRef(false),M=d>0?B/d:0,b=useCallback(()=>{if(!r.current||!c||n.current||!v)return;let{scrollLeft:t,scrollWidth:l,clientWidth:u}=r.current;l-(t+u)<p&&(n.current=true,Promise.resolve(c()).finally(()=>{n.current=false;}));},[c,v,p]),o=useCallback(()=>{if(!r.current)return;let{scrollLeft:t,scrollWidth:l,clientWidth:u}=r.current,f=l-u;E(t),T(f),A(t>10),H(t<f-10),b();},[b]),w=t=>{r.current&&r.current.scrollBy({left:t,behavior:"smooth"});};return useEffect(()=>{o();let t=r.current;if(t)return t.addEventListener("scroll",o),window.addEventListener("resize",o),()=>{t.removeEventListener("scroll",o),window.removeEventListener("resize",o);}},[o]),useEffect(()=>{n.current=a;},[a]),!a&&m.length===0?jsx("div",{className:"flex items-center justify-center py-12",children:z||jsx("div",{className:"text-center text-gray-500",children:jsx("p",{children:"No data available"})})}):jsxs("div",{className:"relative",children:[h&&W&&jsx("button",{onClick:()=>w(-300),className:"absolute left-2 top-1/2 -translate-y-1/2 z-10 bg-white rounded-full shadow-lg p-2 hover:bg-gray-50 transition-colors","aria-label":"Scroll left",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M12 4L6 10L12 16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{ref:r,className:`flex overflow-x-auto ${g?"snap-x snap-mandatory":""} scrollbar-hide ${R}`,style:{gap:`${S}px`,paddingBottom:`${P}px`},children:[m.map((t,l)=>jsx("div",{className:g?"snap-start":"",children:L(t,l)},l)),a&&jsx("div",{className:"flex items-center justify-center min-w-[100px]",children:C||jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsx("div",{className:"w-8 h-8 border-3 border-gray-300 border-t-gray-800 rounded-full animate-spin"}),jsx("span",{className:"text-sm text-gray-500",children:"Loading..."})]})})]}),h&&$&&jsx("button",{onClick:()=>w(300),className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 bg-white rounded-full shadow-lg p-2 hover:bg-gray-50 transition-colors","aria-label":"Scroll right",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M8 4L14 10L8 16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),k&&d>0&&jsxs("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 flex gap-2 items-center",children:[jsx("div",{className:"w-32 h-1 bg-gray-200 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-gray-800 rounded-full transition-all duration-200",style:{width:`${M*100}%`}})}),a&&jsx("div",{className:"w-1.5 h-1.5 bg-gray-800 rounded-full animate-pulse"})]})]})}var D=j;export{D as default};
1
+ import {useRef,useState,useCallback,useEffect}from'react';import {jsx,jsxs}from'react/jsx-runtime';function j({renderItem:L,data:m,onLoadMore:c,isLoading:n=false,hasMore:h=false,className:R="",showIndicators:k=false,showArrows:v=false,gap:S=12,paddingBottom:P=28,snapScroll:g=true,loadingComponent:C,emptyComponent:z,loadMoreThreshold:p=300}){let r=useRef(null),[B,E]=useState(0),[d,T]=useState(0),[W,$]=useState(false),[A,H]=useState(false),a=useRef(false),M=d>0?B/d:0,b=useCallback(()=>{if(!r.current||!c||a.current||!h)return;let{scrollLeft:t,scrollWidth:l,clientWidth:u}=r.current;l-(t+u)<p&&(a.current=true,Promise.resolve(c()).finally(()=>{a.current=false;}));},[c,h,p]),o=useCallback(()=>{if(!r.current)return;let{scrollLeft:t,scrollWidth:l,clientWidth:u}=r.current,f=l-u;E(t),T(f),$(t>10),H(t<f-10),b();},[b]),w=t=>{r.current&&r.current.scrollBy({left:t,behavior:"smooth"});};return useEffect(()=>{o();let t=r.current;if(t)return t.addEventListener("scroll",o),window.addEventListener("resize",o),()=>{t.removeEventListener("scroll",o),window.removeEventListener("resize",o);}},[o]),useEffect(()=>{a.current=n;},[n]),!n&&m.length===0?jsx("div",{className:"flex items-center justify-center py-12",children:z||jsx("div",{className:"text-center text-gray-500",children:jsx("p",{children:"No data available"})})}):jsxs("div",{className:"relative",children:[v&&W&&jsx("button",{onClick:()=>w(-300),className:"absolute left-2 top-1/2 -translate-y-1/2 z-10 bg-white rounded-full shadow-lg p-2 hover:bg-gray-50 transition-colors","aria-label":"Scroll left",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M12 4L6 10L12 16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),jsxs("div",{ref:r,className:`flex overflow-x-auto ${g?"snap-x snap-mandatory":""} scrollbar-hide ${R}`,style:{gap:`${S}px`,paddingBottom:`${P}px`},children:[m.map((t,l)=>jsx("div",{className:`flex-shrink-0 ${g?"snap-start":""}`,children:L(t,l)},l)),n&&jsx("div",{className:"flex items-center justify-center min-w-[100px] flex-shrink-0",children:C||jsxs("div",{className:"flex flex-col items-center gap-2",children:[jsx("div",{className:"w-8 h-8 border-3 border-gray-300 border-t-gray-800 rounded-full animate-spin"}),jsx("span",{className:"text-sm text-gray-500",children:"Loading..."})]})})]}),v&&A&&jsx("button",{onClick:()=>w(300),className:"absolute right-2 top-1/2 -translate-y-1/2 z-10 bg-white rounded-full shadow-lg p-2 hover:bg-gray-50 transition-colors","aria-label":"Scroll right",children:jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",children:jsx("path",{d:"M8 4L14 10L8 16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}),k&&d>0&&jsxs("div",{className:"absolute bottom-0 left-1/2 -translate-x-1/2 flex gap-2 items-center",children:[jsx("div",{className:"w-32 h-1 bg-gray-200 rounded-full overflow-hidden",children:jsx("div",{className:"h-full bg-gray-800 rounded-full transition-all duration-200",style:{width:`${M*100}%`}})}),n&&jsx("div",{className:"w-1.5 h-1.5 bg-gray-800 rounded-full animate-pulse"})]})]})}var D=j;export{D as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "the-omelet-ui",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",