UNPKG

sui-explorer-local

Version:
10 lines (9 loc) 3.7 kB
import{j as t}from"./jsx-runtime-ffb262ed.js";import{r as u}from"./index-76fb7be0.js";import"./_commonjsHelpers-de833af9.js";const x=e=>t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...e,children:[t.jsx("path",{fill:"#fff",stroke:"currentColor",d:"m18.521 6.807-7.912 4.315a1 1 0 0 0 0 1.756l7.912 4.315A1 1 0 0 0 20 16.315v-8.63a1 1 0 0 0-1.479-.878Z"}),t.jsx("path",{fill:"#fff",stroke:"currentColor",d:"M10.521 6.807 2.61 11.122a1 1 0 0 0 0 1.756l7.912 4.315A1 1 0 0 0 12 16.315v-8.63a1 1 0 0 0-1.479-.878Z"})]}),m=x;try{PaginationFirst24.displayName="PaginationFirst24",PaginationFirst24.__docgenInfo={description:"",displayName:"PaginationFirst24",props:{}}}catch{}const P=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...e,children:t.jsx("path",{stroke:"currentColor",d:"m9.479 6.807 7.912 4.315a1 1 0 0 1 0 1.756l-7.912 4.315A1 1 0 0 1 8 16.315v-8.63a1 1 0 0 1 1.479-.878Z"})}),h=P;try{PaginationNext24.displayName="PaginationNext24",PaginationNext24.__docgenInfo={description:"",displayName:"PaginationNext24",props:{}}}catch{}const _=e=>t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"none",viewBox:"0 0 24 24",...e,children:t.jsx("path",{stroke:"currentColor",d:"M14.521 6.807 6.61 11.122a1 1 0 0 0 0 1.756l7.912 4.315A1 1 0 0 0 16 16.315v-8.63a1 1 0 0 0-1.479-.878Z"})}),v=_;try{PaginationPrev24.displayName="PaginationPrev24",PaginationPrev24.__docgenInfo={description:"",displayName:"PaginationPrev24",props:{}}}catch{}function d(e){var r,o;const[a,n]=u.useState(0);return{...e,data:(r=e.data)==null?void 0:r.pages[a],pagination:{onFirst:()=>n(0),onNext:()=>{!e.data||e.isFetchingNextPage||(a>=e.data.pages.length-1&&e.fetchNextPage(),n(a+1))},onPrev:()=>{n(Math.max(a-1,0))},hasNext:!e.isFetchingNextPage&&(a<(((o=e.data)==null?void 0:o.pages.length)??0)-1||!!e.hasNextPage),hasPrev:a!==0,currentPage:a}}}function s({label:e,icon:a,disabled:n,onClick:r}){return t.jsx("button",{className:"rounded-md border border-steel px-2 py-1 text-steel shadow-xs disabled:border-gray-45 disabled:text-gray-45","aria-label":e,type:"button",disabled:n,onClick:r,children:t.jsx(a,{className:"text-[24px]"})})}function l({hasNext:e,hasPrev:a,onFirst:n,onPrev:r,onNext:o}){return t.jsxs("div",{className:"flex gap-2",children:[t.jsx(s,{label:"Go to First",icon:m,disabled:!a,onClick:n}),t.jsx(s,{label:"Previous",icon:v,disabled:!a,onClick:r}),t.jsx(s,{label:"Next",icon:h,disabled:!e,onClick:o})]})}try{d.displayName="useCursorPagination",d.__docgenInfo={description:"",displayName:"useCursorPagination",props:{}}}catch{}try{l.displayName="Pagination",l.__docgenInfo={description:"",displayName:"Pagination",props:{hasPrev:{defaultValue:null,description:"",name:"hasPrev",required:!0,type:{name:"boolean"}},hasNext:{defaultValue:null,description:"",name:"hasNext",required:!0,type:{name:"boolean"}},onFirst:{defaultValue:null,description:"",name:"onFirst",required:!0,type:{name:"() => void"}},onPrev:{defaultValue:null,description:"",name:"onPrev",required:!0,type:{name:"() => void"}},onNext:{defaultValue:null,description:"",name:"onNext",required:!0,type:{name:"() => void"}}}}}catch{}const w={component:l},i={args:{hasPrev:!0,hasNext:!0,onNext(){},onPrev(){},onFirst(){}}};var c,p,g;i.parameters={...i.parameters,docs:{...(c=i.parameters)==null?void 0:c.docs,source:{originalSource:`{ args: { hasPrev: true, hasNext: true, onNext() {}, onPrev() {}, onFirst() {} } }`,...(g=(p=i.parameters)==null?void 0:p.docs)==null?void 0:g.source}}};const b=["Default"];export{i as Default,b as __namedExportsOrder,w as default};