UNPKG

siegel

Version:

Web application development ecosystem

1 lines 1.79 kB
import e from"react";import t from"../_internals/resolve_tag_attributes.js";import a from"../_internals/apply_classname.js";import n from"../_internals/component.js";import l from"../_internals/ref_apply.js";let r=void 0,i="-ui-pagination",o=(t,{curPage:n,theme:l})=>e.createElement("div",{className:a(l.page,[[l.page__active,t==n]]),key:t,"data-page":t,children:t});function s(t,a,n,l,r){let{theme:i,separator:s}=l,p=t-a==1?o(r?t:a,l):e.createElement("div",{key:r?"n":"p",className:i.separator,children:s});n.push(p)}function p(e,t,a,n){for(let l=e;l<=t;l++)a.push(o(l,n))}let c=n(i,{theme:{root:r,_single:r,separator:r,goto_prev:r,goto_next:r,change__disabled:r,page:r,page__active:r},elementsBySide:1,elementsByMiddle:1,fixedWidth:!0},n=>{let{listLength:r,showPerPage:i}=n,o=Math.ceil(r/i)||1;return e.createElement("div",{...function(n,r){let{rootTagAttributes:i,curPage:o,payload:c,theme:d,className:m,onChange:_,onMouseDown:g}=n,f={className:a(m,[[d._single,1==r]]),onMouseDown(e){if(g?.(e),!e.defaultPrevented){let t=e.target.dataset.page;if(t){let a=o;"p"==t&&1!=o?a--:"n"==t&&o!=r?a++:0<+t&&+t<=r&&(a=+t),o!=a&&_(a,e,c)}}},children:function(t,n){let{theme:l,elementsByMiddle:r,elementsBySide:i,iconPrev:o,iconNext:c,curPage:d,fixedWidth:m}=t,_=r+i,g=2*_+3,f=[];if(g>n)p(1,n,f,t);else{let e=d-r,a=i+1,l=d+r,o=n-i;if(p(1,i,f,t),e>a?s(e,a,f,t):m&&(l+=g-_-d-1),e<=i&&(e=a),l>o&&(l=o),m){let t=n-_-1;d>t&&(e+=t-d)}p(e,l,f,t),l<o&&s(o,l,f,t,!0),p(o+1,n,f,t)}return e.createElement(e.Fragment,null,e.createElement("div",{children:o,"data-page":"p",className:a(l.goto_prev,[[l.change__disabled,1==d]])}),f,e.createElement("div",{children:c,"data-page":"n",className:a(l.goto_next,[[l.change__disabled,d==n]])}))}(n,r)};return l(f,n),f=t(f,i)}(n,o)})});export default c;export{i as componentID};