UNPKG

siegel

Version:

Web application development ecosystem

1 lines 1.48 kB
import e,{useState as t}from"react";import r from"../_internals/resolve_tag_attributes.js";import a from"../_internals/apply_classname.js";import o from"../_internals/component.js";import l from"../_internals/children.js";import i from"../_internals/ref_apply.js";import n from"../Table/index.js";import{getBody as s,getHead as m,getPaginationFooter as p,applyVirtualization as _}from"./helpers/index.js";import d from"./styles.sass";let c="-ui-data_grid",g=void 0,f=()=>({sortByField:{ID:g,value:1},searchByField:{},toggledColumns:new Set,showPerPage:0,currentPage:1,__resultIDs:[]}),u=o(c,{theme:{root:g,_with_footer:g,children:g,table:g,table_resizer:g,pagination_wrapper:g,pagination_single_page:g}},o=>{let c,{theme:g,className:u,rootTagAttributes:h,withFooter:w,tableAttributes:P,virtualization:b,children:j,store:S,onScroll:v}=o,x=S||t(f()),[y]=x,D={onScroll:v,className:a(u,[[g._with_footer,w]])};w&&!y.showPerPage&&(y.showPerPage=w.defaultShowPerPage),b&&(c=_({state:y,rootAttributes:D,props:o}),D.onScroll=c.onScrollHandler),i(D,o),D=r(D,h);let{body:I,resultIDs:z,from:B,to:C}=s(o,y,c?.slideWindowRange);c?.useVirtualizationScrolling(Math.min(c.maxItemsCount,z.length));let E={body:I,head:m(o,y,z,B,C),className:a(d.table,[[g.table,!0]])};return w&&(E.foot=[{children:[{value:p(o,x,z),attributes:{colSpan:100}}]}]),E=r(E,P),y.__resultIDs=z,e.createElement("div",{...D},e.createElement(n,{...E}),l(j,g))});export default u;export{f as getDefaultState,c as componentID};