@webority/ui-react 0.79.0 → 0.80.0

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{devWarn as e}from"../lib/devWarn.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import r from"./AppIcon.js";import{AppSkeletonRows as i}from"./AppSkeleton.js";import a from"./AppTablePagination.js";import{attachRowDrag as o,attachScrollEdges as s,syncTargets as c}from"@webority/ui-elements/helpers";import{Fragment as ee,useEffect as l,useLayoutEffect as u,useMemo as d,useRef as f,useState as p}from"react";import{Fragment as te,jsx as m,jsxs as h}from"react/jsx-runtime";import{COLUMN_MAX_WIDTH as ne,COLUMN_MIN_WIDTH as re,DATA_TABLE_TEXT as ie,PIN_AT_VAR as ae,PIN_SIDES as oe,ROW_HEIGHTS as se,ROW_MOVE_LIMIT as ce,ROW_SAVE_ERROR_CLASS as le,groupCount as ue,groupItems as de,measureRows as fe,pinAtValue as pe,pinClasses as me,planPins as he,playRowMoves as ge,rowOrderChanged as _e,saveOutcomeText as ve,settledRows as ye,virtualRange as be}from"@webority/ui-elements/elements/data-table";var xe=[`comfortable`,`cozy`,`compact`],g=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},_=new Set;function v(t,n){_.has(t)||!g()||(_.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Se=100;function y(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function Ce(e){return e==null||e===``?`-`:typeof e==`boolean`?String(e):e}function we(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function b({columns:e,rows:g,rowKey:_=e=>e.id,sort:b,onSort:x,loading:S=!1,skeletonRows:Te=5,empty:Ee=`No records found.`,emptyFiltered:De,sourceCount:Oe,rowActions:C,rowActionsLabel:ke,pagination:w,ariaLabel:Ae,className:je=``,wrapperClassName:Me=``,selectable:T=!1,selectedIds:E,isRowSelectable:D,onToggleRow:O,onToggleAll:Ne,onSelectRange:Pe,renderExpanded:Fe,density:k=`comfortable`,striped:Ie=!1,flush:Le=!1,rowDrag:A=!1,maxHeight:j,stickyFirstColumn:Re=!1,stickyActions:ze=!1,stackOnMobile:M=!1,hiddenColumns:Be,rowStatus:Ve,rowHref:N,onRowClick:P,activeRowKey:He,resizableColumns:F=!1,viewKey:Ue,groupBy:I,groupLabel:We,virtual:L=!1,rowSaving:Ge,rowSaveError:Ke,...qe}){n(`AppDataTable`,qe);let Je=Be?.length?new Set(Be):null;e=Je?e.filter(e=>!(e.hideable&&Je.has(e.key))):e,t(`AppDataTable`,`density`,k,xe);for(let n of e)t(`AppDataTable`,`column.pin`,n.pin,oe);let Ye=[`table table-ledger`,k===`cozy`||k===`compact`?`wui-table-${k}`:``,Ie?`wui-table-striped`:``,Re?`wui-table-sticky-first`:``,ze?`wui-table-sticky-actions`:``,M?`wui-table-stack`:``,je].filter(Boolean).join(` `),R=typeof Fe==`function`,[Xe,Ze]=p(()=>new Set),Qe=e=>Ze(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),$e=e.some(e=>typeof e.footer==`function`),z=typeof N==`function`||typeof P==`function`,et=e=>!!e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`),tt=(e,t)=>{if(et(t)||(P&&P(e),!N))return;let n=N(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},B=j!==void 0,nt=[`table-wrap`,B?`wui-table-scroll`:``,Le?`wui-table-flush`:``,Me].filter(Boolean).join(` `),rt=B?{maxHeight:j}:void 0,V=Math.max(1,e.length+ +!!C+ +!!T+ +!!R),it=e.some(e=>e.pin===`start`||e.pin===`end`),H=it||F||!!I||L,U=+!!R+ +!!T,at=it?he([...R?[`lead`]:[],...T?[`lead`]:[],...e.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...C?[null]:[]]):[],W=(e,t=``)=>{let n=at[e];return n?{className:`${t.trim()} ${me(n)}`.trim(),style:{[ae]:pe(n.side,n.ordinal)}}:{className:t,style:void 0}},ot=(e,t)=>at[e]?{...t,...W(e).style}:t,st=e.length-1+ +!!C;Ue&&!F&&v(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),L&&!B&&v(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),L&&(R||M)&&v(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`.");let G=L&&B&&!R&&!M&&!S&&g?.length>0,K=(e,t)=>!D||!!D(e,t),ct=T&&g?g.reduce((e,t,n)=>e+ +!!K(t,n),0):0,q=T&&g?g.reduce((e,t,n)=>e+(K(t,n)&&E?.has(_(t,n))?1:0),0):0,lt=ct>0&&q===ct,ut=q>0&&!lt,dt=e=>{e&&(e.indeterminate=ut)},ft=f(null),pt=(e,t)=>{let n=ft.current;ft.current=e;let r=t&&n!==null?g.findIndex((e,t)=>_(e,t)===n):-1,i=g.findIndex((t,n)=>_(t,n)===e);if(r<0||i<0||r===i){O?.(e);return}let a=!E?.has(e),o=Math.min(r,i),s=g.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>K(e,t)).map(([e,t])=>_(e,t)).filter(e=>(E?.has(e)||!1)!==a);if(Pe)Pe(s,a);else for(let e of s)O?.(e)},mt=e=>{if(!D){Ne?.(e);return}(g||[]).forEach((t,n)=>{let r=_(t,n);K(t,n)&&(E?.has(r)||!1)!==e&&O?.(r)})},[ht,gt]=p(()=>new Set),_t=e=>gt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=d(()=>{let e=(g||[]).map((e,t)=>({row:e,i:t}));return I?de(e,({row:e})=>String(e[I]??``)).flatMap(e=>[{group:e,open:!ht.has(e.key)},...ht.has(e.key)?[]:e.items]):e},[g,I,ht]),Y=f(null),vt=f(null);l(()=>{let e=Y.current;if(!e)return;let t=e=>{let t=e.target.closest?.(`.u-name`);t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=t.textContent.trim())},n=e=>{let t=e.target.closest?.(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`);vt.current=t?Number(t)-2:null},r=t=>{e.contains(t.relatedTarget)||(vt.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=s(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[H]),l(()=>{if(!A||!Y.current)return;let e=o(Y.current);return c(document),e},[A,H]);let yt=f(!1);l(()=>{!yt.current&&(yt.current=!0,q===0)||Y.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:q,total:g?.length??0,keys:g?g.flatMap((e,t)=>{let n=_(e,t);return K(e,t)&&E?.has(n)?[String(n)]:[]}):[]}}))},[T,q]);let[bt,xt]=p({top:0,height:0}),[X,St]=p(se[k]??se.comfortable);l(()=>{let e=Y.current;if(!G||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};xt(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[G,H]),u(()=>{if(!G)return;let e=(Y.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;e>0&&Math.abs(e-X)>.5&&St(e)});let Z={start:0,end:J.length,before:0,after:0};if(G){Z=be({scrollTop:bt.top,viewport:bt.height||Number.parseFloat(j)||0,rowHeight:X,count:J.length});let e=vt.current;e!==null&&e>=0&&e<J.length&&(e<Z.start&&Z.start-e<=Se&&(Z={...Z,start:e,before:e*X}),e>=Z.end&&e-Z.end<Se&&(Z={...Z,end:e+1,after:(J.length-e-1)*X}))}let Ct=f(null),wt=f(null),Tt=f(null),Et=!L&&!S&&g?.length>0&&g.length<=ce;u(()=>{let e=Ct.current;if(!Et||!e){wt.current=null,Tt.current=null;return}let t=g.map((e,t)=>_(e,t));_e(Tt.current,t)&&ge(e.rows,wt.current),wt.current=fe(e.rows),Tt.current=t});let Dt=typeof Ge==`function`||typeof Ke==`function`,Ot=e=>{let t=!!Ge?.(e),n=t?``:Ke?.(e)||``;return{state:t?`saving`:n?`error`:null,message:n}},kt=f(null),At=f(null);l(()=>{if(!Dt){At.current=null;return}let t=e[0]?.key,n=new Map;(g||[]).forEach((e,r)=>{let i=t===void 0?void 0:e[t],a=typeof i==`string`||typeof i==`number`?String(i):``;n.set(_(e,r),{...Ot(e),label:a})});let r=ve(ye(At.current,n));At.current=n,r&&kt.current&&(kt.current.textContent=r)});let jt=De!==void 0&&Oe>0?De:Ee,Mt=({group:e,open:t},n)=>{let i=e.items[0].row[I],a=e.items.map(e=>e.row);return m(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":G?n+2:void 0,children:m(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:V,children:h(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":t,onClick:()=>_t(e.key),children:[m(r,{name:`chevron-down`,size:16}),m(`span`,{className:`wui-group-label`,children:We?We(i,a):Ce(i)}),m(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),m(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${ie.rows(e.items.length)}`})]})})},`group:${e.key}`)},Nt=({row:t,i:n},i)=>{let a=_(t,n),o=R&&Xe.has(a),s=He!=null&&String(He)===String(a),c=String(a).replace(/[^a-z0-9]/gi,`_`),l=W(0,`wui-expand-cell`),u=W(+!!R,`wui-select-cell`),d=Dt?Ot(t):null,f=K(t,n);return h(ee,{children:[h(`tr`,{className:[T&&f&&E?.has(a)?`is-selected`:``,z?`wui-row-link`:``,s?`wui-row-active`:``].filter(Boolean).join(` `)||void 0,"aria-current":s?`true`:void 0,"aria-rowindex":G?i+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":Ve?.(t)||void 0,"data-href":N?.(t)||void 0,"data-row-key":A?String(a):void 0,tabIndex:z?0:void 0,onClick:z?e=>tt(t,e):void 0,onAuxClick:z&&N?e=>e.button===1&&tt(t,e):void 0,onKeyDown:z?e=>{e.key===`Enter`&&e.target===e.currentTarget&&tt(t,e)}:void 0,children:[R&&m(`td`,{className:l.className,style:l.style,children:m(`button`,{type:`button`,className:`wui-expand-toggle${o?` is-open`:``}`,"aria-expanded":o,"aria-controls":o?`${c}-expanded`:void 0,"aria-label":o?`Collapse row`:`Expand row`,onClick:()=>Qe(a),children:m(r,{name:`chevron-down`,size:16})})}),T&&m(`td`,{className:u.className,style:u.style,children:m(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(E?.has(a)||!1),disabled:!f,onChange:e=>pt(a,e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":`Select row`})}),e.map((e,n)=>h(`td`,{className:W(U+n,(n===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+y(e.align)+(e.cellClassName?` ${e.cellClassName}`:``)).className,style:ot(U+n,e.cellStyle),"data-label":M&&typeof e.label==`string`?e.label:void 0,children:[e.render?e.render(t):Ce(t[e.key]),n===0&&d?.state===`error`&&m(`span`,{className:le,children:d.message})]},e.key)),C&&m(`td`,{children:m(`div`,{className:`u-row-actions`,children:C(t)})})]}),o&&m(`tr`,{className:`wui-row-expanded`,children:m(`td`,{id:`${c}-expanded`,colSpan:V,children:Fe(t)})})]},a)},Pt=(e,t)=>e.group?Mt(e,t):Nt(e,t),Ft=(e,t)=>G?m(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:m(`td`,{colSpan:V,style:{height:t}})},e):null,Q=W(0,`wui-expand-cell`),$=W(+!!R,`wui-select-cell`);return h(te,{children:[h(H?`wui-data-table`:`div`,{ref:Y,...H?{class:nt,resizable:F?``:void 0,"view-key":Ue||void 0,"data-wui-row-drag":A?``:void 0}:{className:nt,"data-wui-row-drag":A?``:void 0},style:rt,tabIndex:0,...qe,children:[h(`table`,{className:Ye,"aria-label":Ae,"aria-rowcount":G?J.length+1:void 0,children:[m(`thead`,{children:h(`tr`,{"aria-rowindex":G?1:void 0,children:[R&&m(`th`,{className:Q.className,style:Q.style,children:m(`span`,{className:`visually-hidden`,children:`Expand`})}),T&&m(`th`,{className:$.className,style:$.style,children:m(`input`,{ref:dt,type:`checkbox`,className:`wui-check`,checked:lt,onChange:e=>mt(e.target.checked),"aria-label":`Select all rows`})}),e.map((e,t)=>{let n=!!(e.sortable&&x),i=b&&b.key===e.key,a=e.align===`num`||e.align===`end`,o=n&&m(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:m(r,{name:`chevrons-up-down`,size:14})}),s=F&&t!==st,c=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return h(`th`,{className:W(U+t,(n?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(s?`wui-col-resizable `:``)+y(e.align)).className,style:ot(U+t,c),"data-key":H?e.key:void 0,"aria-label":s&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:n?0:void 0,"aria-sort":i?b.dir===`asc`?`ascending`:`descending`:n?`none`:void 0,onClick:n?()=>x(e.key):void 0,onKeyDown:n?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),x(e.key))}:void 0,children:[a&&o,e.label,!a&&o,s&&m(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":re,"aria-valuemax":ne,tabIndex:0,"aria-label":ie.resize(typeof e.label==`string`?e.label:e.key)})]},e.key)}),C&&(ke?m(`th`,{className:`wui-cell-end`,children:ke}):m(`th`,{className:`wui-cell-end`,children:m(`span`,{className:`visually-hidden`,children:`Actions`})}))]})}),m(`tbody`,{ref:Ct,children:S?m(i,{rows:Te,cols:V}):g?.length?h(te,{children:[Ft(`before`,Z.before),J.slice(Z.start,Z.end).map((e,t)=>Pt(e,Z.start+t)),Ft(`after`,Z.after)]}):null}),$e&&!S&&g?.length>0&&m(`tfoot`,{children:h(`tr`,{children:[R&&m(`td`,{className:Q.className,style:Q.style}),T&&m(`td`,{className:$.className,style:$.style}),e.map((e,t)=>m(`td`,{className:W(U+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+y(e.align)).className,style:ot(U+t,void 0),children:e.footer?e.footer(g):null},e.key)),C&&m(`td`,{})]})})]}),!S&&!g?.length&&m(`div`,{className:`tbl-empty-block`,children:typeof jt==`string`?m(`div`,{className:`tbl-empty-plain`,children:jt}):jt})]}),we(w)&&m(a,{page:w.page,totalPages:w.totalPages,pageSize:w.pageSize,onPageChange:w.setPage,onPageSizeChange:w.setPageSize,pageSizes:w.pageSizes,mode:w.mode}),Dt&&m(`div`,{ref:kt,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{b as default};
1
+ import{devWarn as e}from"../lib/devWarn.js";import t from"./warnInvalidValue.js";import n from"./warnUnknownProps.js";import r from"./AppIcon.js";import{AppSkeletonRows as i}from"./AppSkeleton.js";import a from"./AppTablePagination.js";import{attachRowDrag as o,attachScrollEdges as s,syncTargets as c}from"@webority/ui-elements/helpers";import{Fragment as ee,useEffect as l,useLayoutEffect as u,useMemo as d,useRef as f,useState as p}from"react";import{Fragment as te,jsx as m,jsxs as h}from"react/jsx-runtime";import{COLUMN_MAX_WIDTH as ne,COLUMN_MIN_WIDTH as re,DATA_TABLE_TEXT as ie,PIN_AT_VAR as ae,PIN_SIDES as oe,ROW_HEIGHTS as se,ROW_MOVE_LIMIT as ce,ROW_SAVE_ERROR_CLASS as le,groupCount as ue,groupItems as de,measureRows as fe,pinAtValue as pe,pinClasses as me,planPins as he,playRowMoves as ge,rowOrderChanged as _e,saveOutcomeText as ve,settledRows as ye,virtualRange as be}from"@webority/ui-elements/elements/data-table";var xe=[`comfortable`,`cozy`,`compact`],g=()=>{try{return process.env.NODE_ENV!==`production`}catch{return!0}},_=new Set;function v(t,n){_.has(t)||!g()||(_.add(t),e(`[@webority/ui-react] <AppDataTable> ${n}`))}var Se=100,Ce=e=>e.id,we=(e,t,n)=>{let r=!!t?.(e),i=r?``:n?.(e)||``;return{state:r?`saving`:i?`error`:null,message:i}};function y(e){return e===`end`?`wui-cell-end`:e===`num`?`num`:e===`center`?`text-center`:``}function Te(e){return e==null||e===``?`-`:typeof e==`boolean`?String(e):e}function Ee(e){if(!e||!(e.total>0))return!1;let t=e.pageSizes?.length?e.pageSizes:[e.pageSize];return e.total>Math.min(...t)}function b({columns:e,rows:g,rowKey:_=Ce,sort:b,onSort:x,loading:S=!1,skeletonRows:De=5,empty:Oe=`No records found.`,emptyFiltered:ke,sourceCount:Ae,rowActions:C,rowActionsLabel:je,pagination:w,ariaLabel:Me,className:Ne=``,wrapperClassName:Pe=``,selectable:T=!1,selectedIds:E,isRowSelectable:D,onToggleRow:O,onToggleAll:Fe,onSelectRange:Ie,renderExpanded:Le,density:k=`comfortable`,striped:Re=!1,flush:ze=!1,rowDrag:A=!1,maxHeight:Be,stickyFirstColumn:Ve=!1,stickyActions:He=!1,stackOnMobile:j=!1,hiddenColumns:Ue,rowStatus:We,rowHref:M,onRowClick:Ge,activeRowKey:Ke,resizableColumns:N=!1,viewKey:qe,groupBy:P,groupLabel:Je,virtual:F=!1,rowSaving:I,rowSaveError:L,...Ye}){n(`AppDataTable`,Ye);let Xe=Ue?.length?new Set(Ue):null;e=Xe?e.filter(e=>!(e.hideable&&Xe.has(e.key))):e,t(`AppDataTable`,`density`,k,xe);for(let n of e)t(`AppDataTable`,`column.pin`,n.pin,oe);let Ze=[`table table-ledger`,k===`cozy`||k===`compact`?`wui-table-${k}`:``,Re?`wui-table-striped`:``,Ve?`wui-table-sticky-first`:``,He?`wui-table-sticky-actions`:``,j?`wui-table-stack`:``,Ne].filter(Boolean).join(` `),R=typeof Le==`function`,[Qe,$e]=p(()=>new Set),et=e=>$e(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),tt=e.some(e=>typeof e.footer==`function`),z=typeof M==`function`||typeof Ge==`function`,nt=e=>!!e.target.closest(`a, button, input, select, textarea, label, [role='menu'], [role='menuitem'], .dropdown`),rt=(e,t)=>{if(nt(t)||(Ge&&Ge(e),!M))return;let n=M(e);n&&(t.ctrlKey||t.metaKey||t.button===1?window.open(n,`_blank`,`noopener`):window.location.assign(n))},B=Be!==void 0,it=[`table-wrap`,B?`wui-table-scroll`:``,ze?`wui-table-flush`:``,Pe].filter(Boolean).join(` `),at=B?{maxHeight:Be}:void 0,V=Math.max(1,e.length+ +!!C+ +!!T+ +!!R),ot=e.some(e=>e.pin===`start`||e.pin===`end`),H=ot||N||!!P||F,U=+!!R+ +!!T,st=ot?he([...R?[`lead`]:[],...T?[`lead`]:[],...e.map(e=>e.pin===`start`||e.pin===`end`?e.pin:null),...C?[null]:[]]):[],W=(e,t=``)=>{let n=st[e];return n?{className:`${t.trim()} ${me(n)}`.trim(),style:{[ae]:pe(n.side,n.ordinal)}}:{className:t,style:void 0}},ct=(e,t)=>st[e]?{...t,...W(e).style}:t,lt=e.length-1+ +!!C;qe&&!N&&v(`view-key`,"`viewKey` remembers resized widths: add `resizableColumns`."),F&&!B&&v(`virtual-height`,"`virtual` needs `maxHeight`: without a scroll box every row renders."),F&&(R||j)&&v(`virtual-shape`,"`virtual` takes rows of one height, so it is off with `renderExpanded` or `stackOnMobile`."),!F&&g?.length>500&&v(`rows-without-virtual`,`renders more than 500 rows without virtual: add virtual with maxHeight, or page the data.`);let G=F&&B&&!R&&!j&&!S&&g?.length>0,K=(e,t)=>!D||!!D(e,t),ut=T&&g?g.reduce((e,t,n)=>e+ +!!K(t,n),0):0,q=T&&g?g.reduce((e,t,n)=>e+(K(t,n)&&E?.has(_(t,n))?1:0),0):0,dt=ut>0&&q===ut,ft=q>0&&!dt,pt=e=>{e&&(e.indeterminate=ft)},mt=f(null),ht=(e,t)=>{let n=mt.current;mt.current=e;let r=t&&n!==null?g.findIndex((e,t)=>_(e,t)===n):-1,i=g.findIndex((t,n)=>_(t,n)===e);if(r<0||i<0||r===i){O?.(e);return}let a=!E?.has(e),o=Math.min(r,i),s=g.slice(o,Math.max(r,i)+1).map((e,t)=>[e,o+t]).filter(([e,t])=>K(e,t)).map(([e,t])=>_(e,t)).filter(e=>(E?.has(e)||!1)!==a);if(Ie)Ie(s,a);else for(let e of s)O?.(e)},gt=e=>{if(!D){Fe?.(e);return}(g||[]).forEach((t,n)=>{let r=_(t,n);K(t,n)&&(E?.has(r)||!1)!==e&&O?.(r)})},[_t,vt]=p(()=>new Set),yt=e=>vt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),J=d(()=>{let e=(g||[]).map((e,t)=>({row:e,i:t}));return P?de(e,({row:e})=>String(e[P]??``)).flatMap(e=>[{group:e,open:!_t.has(e.key)},..._t.has(e.key)?[]:e.items]):e},[g,P,_t]),Y=f(null),bt=f(null);l(()=>{let e=Y.current;if(!e)return;let t=e=>{let t=e.target.closest?.(`.u-name`);t&&!t.title&&(t.scrollWidth>t.clientWidth||t.scrollHeight>t.clientHeight)&&(t.title=t.textContent.trim())},n=e=>{let t=e.target.closest?.(`tbody > tr[aria-rowindex]`)?.getAttribute(`aria-rowindex`);bt.current=t?Number(t)-2:null},r=t=>{e.contains(t.relatedTarget)||(bt.current=null)};e.addEventListener(`mouseover`,t),e.addEventListener(`focusin`,t),e.addEventListener(`focusin`,n),e.addEventListener(`focusout`,r);let i=s(e);return()=>{e.removeEventListener(`mouseover`,t),e.removeEventListener(`focusin`,t),e.removeEventListener(`focusin`,n),e.removeEventListener(`focusout`,r),i()}},[H]),l(()=>{if(!A||!Y.current)return;let e=o(Y.current);return c(document),e},[A,H]);let xt=f(!1);l(()=>{!xt.current&&(xt.current=!0,q===0)||Y.current?.querySelector(`table`)?.dispatchEvent(new CustomEvent(`selectionchange`,{bubbles:!0,detail:{selected:q,total:g?.length??0,keys:g?g.flatMap((e,t)=>{let n=_(e,t);return K(e,t)&&E?.has(n)?[String(n)]:[]}):[]}}))},[T,q]);let[St,Ct]=p({top:0,height:0}),[X,wt]=p(se[k]??se.comfortable);l(()=>{let e=Y.current;if(!G||!e)return;let t=0,n=()=>{t=0;let n=e.querySelector(`:scope > table > thead`)?.getBoundingClientRect().height||0,r={top:Math.max(0,e.scrollTop-n),height:e.clientHeight};Ct(e=>e.top===r.top&&e.height===r.height?e:r)},r=()=>{t||=requestAnimationFrame(n)};e.addEventListener(`scroll`,r,{passive:!0});let i=typeof ResizeObserver<`u`?new ResizeObserver(r):null;return i?.observe(e),n(),()=>{e.removeEventListener(`scroll`,r),i?.disconnect(),t&&cancelAnimationFrame(t)}},[G,H]),u(()=>{if(!G)return;let e=(Y.current?.querySelector(`:scope > table > tbody > tr:not(.wui-virtual-spacer, .wui-group-row)`))?.getBoundingClientRect().height;e>0&&Math.abs(e-X)>.5&&wt(e)},[k,g?.length,F,G]);let Z={start:0,end:J.length,before:0,after:0};if(G){Z=be({scrollTop:St.top,viewport:St.height||Number.parseFloat(Be)||0,rowHeight:X,count:J.length});let e=bt.current;e!==null&&e>=0&&e<J.length&&(e<Z.start&&Z.start-e<=Se&&(Z={...Z,start:e,before:e*X}),e>=Z.end&&e-Z.end<Se&&(Z={...Z,end:e+1,after:(J.length-e-1)*X}))}let Tt=f(null),Et=f(null),Dt=f(null),Ot=!F&&!S&&g?.length>0&&g.length<=ce;u(()=>{let e=Tt.current;if(!Ot||!e){Et.current=null,Dt.current=null;return}let t=g.map((e,t)=>_(e,t));_e(Dt.current,t)&&ge(e.rows,Et.current),Et.current=fe(e.rows),Dt.current=t});let kt=typeof I==`function`||typeof L==`function`,At=f(null),jt=f(null);l(()=>{if(!kt){jt.current=null;return}let t=e[0]?.key,n=new Map;(g||[]).forEach((e,r)=>{let i=t===void 0?void 0:e[t],a=typeof i==`string`||typeof i==`number`?String(i):``;n.set(_(e,r),{...we(e,I,L),label:a})});let r=ve(ye(jt.current,n));jt.current=n,r&&At.current&&(At.current.textContent=r)},[g,I,L,_]);let Mt=ke!==void 0&&Ae>0?ke:Oe,Nt=({group:e,open:t},n)=>{let i=e.items[0].row[P],a=e.items.map(e=>e.row);return m(`tr`,{className:`wui-group-row`,"data-group-key":e.key,"aria-rowindex":G?n+2:void 0,children:m(`th`,{className:`wui-group-cell`,scope:`rowgroup`,colSpan:V,children:h(`button`,{type:`button`,className:`wui-group-toggle`,"aria-expanded":t,onClick:()=>yt(e.key),children:[m(r,{name:`chevron-down`,size:16}),m(`span`,{className:`wui-group-label`,children:Je?Je(i,a):Te(i)}),m(`span`,{className:`wui-group-count`,"aria-hidden":`true`,children:ue(e.items.length)}),m(`span`,{className:`visually-hidden wui-group-rows`,children:`, ${ie.rows(e.items.length)}`})]})})},`group:${e.key}`)},Pt=({row:t,i:n},i)=>{let a=_(t,n),o=R&&Qe.has(a),s=Ke!=null&&String(Ke)===String(a),c=String(a).replace(/[^a-z0-9]/gi,`_`),l=W(0,`wui-expand-cell`),u=W(+!!R,`wui-select-cell`),d=kt?we(t,I,L):null,f=K(t,n);return h(ee,{children:[h(`tr`,{className:[T&&f&&E?.has(a)?`is-selected`:``,z?`wui-row-link`:``,s?`wui-row-active`:``].filter(Boolean).join(` `)||void 0,"aria-current":s?`true`:void 0,"aria-rowindex":G?i+2:void 0,"aria-busy":d?.state===`saving`?`true`:void 0,"data-wui-save-state":d?.state||void 0,"data-status":We?.(t)||void 0,"data-href":M?.(t)||void 0,"data-row-key":A?String(a):void 0,tabIndex:z?0:void 0,onClick:z?e=>rt(t,e):void 0,onAuxClick:z&&M?e=>e.button===1&&rt(t,e):void 0,onKeyDown:z?e=>{e.key===`Enter`&&e.target===e.currentTarget&&rt(t,e)}:void 0,children:[R&&m(`td`,{className:l.className,style:l.style,children:m(`button`,{type:`button`,className:`wui-expand-toggle${o?` is-open`:``}`,"aria-expanded":o,"aria-controls":o?`${c}-expanded`:void 0,"aria-label":o?`Collapse row`:`Expand row`,onClick:()=>et(a),children:m(r,{name:`chevron-down`,size:16})})}),T&&m(`td`,{className:u.className,style:u.style,children:m(`input`,{type:`checkbox`,className:`wui-check`,checked:f&&(E?.has(a)||!1),disabled:!f,onChange:e=>ht(a,e.nativeEvent.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},"aria-label":`Select row`})}),e.map((e,n)=>h(`td`,{className:W(U+n,(n===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+y(e.align)+(e.cellClassName?` ${e.cellClassName}`:``)).className,style:ct(U+n,e.cellStyle),"data-label":j&&typeof e.label==`string`?e.label:void 0,children:[e.render?e.render(t):Te(t[e.key]),n===0&&d?.state===`error`&&m(`span`,{className:le,children:d.message})]},e.key)),C&&m(`td`,{children:m(`div`,{className:`u-row-actions`,children:C(t)})})]}),o&&m(`tr`,{className:`wui-row-expanded`,children:m(`td`,{id:`${c}-expanded`,colSpan:V,children:Le(t)})})]},a)},Ft=(e,t)=>e.group?Nt(e,t):Pt(e,t),It=(e,t)=>G?m(`tr`,{className:`wui-virtual-spacer`,"aria-hidden":`true`,hidden:t===0,children:m(`td`,{colSpan:V,style:{height:t}})},e):null,Q=W(0,`wui-expand-cell`),$=W(+!!R,`wui-select-cell`);return h(te,{children:[h(H?`wui-data-table`:`div`,{ref:Y,...H?{class:it,resizable:N?``:void 0,"view-key":qe||void 0,"data-wui-row-drag":A?``:void 0}:{className:it,"data-wui-row-drag":A?``:void 0},style:at,tabIndex:0,...Ye,children:[h(`table`,{className:Ze,"aria-label":Me,"aria-rowcount":G?J.length+1:void 0,children:[m(`thead`,{children:h(`tr`,{"aria-rowindex":G?1:void 0,children:[R&&m(`th`,{className:Q.className,style:Q.style,children:m(`span`,{className:`visually-hidden`,children:`Expand`})}),T&&m(`th`,{className:$.className,style:$.style,children:m(`input`,{ref:pt,type:`checkbox`,className:`wui-check`,checked:dt,onChange:e=>gt(e.target.checked),"aria-label":`Select all rows`})}),e.map((e,t)=>{let n=!!(e.sortable&&x),i=b&&b.key===e.key,a=e.align===`num`||e.align===`end`,o=n&&m(`span`,{className:`sort-icon${a?` wui-sort-lead`:``}`,children:m(r,{name:`chevrons-up-down`,size:14})}),s=N&&t!==lt,c=e.width||e.minWidth?{width:e.width,minWidth:e.minWidth}:void 0;return h(`th`,{className:W(U+t,(n?`sortable `:``)+(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+(e.grow?`wui-col-grow `:``)+(s?`wui-col-resizable `:``)+y(e.align)).className,style:ct(U+t,c),"data-key":H?e.key:void 0,"aria-label":s&&typeof e.label==`string`?e.label:void 0,"data-pin":e.pin===`start`||e.pin===`end`?e.pin:void 0,tabIndex:n?0:void 0,"aria-sort":i?b.dir===`asc`?`ascending`:`descending`:n?`none`:void 0,onClick:n?()=>x(e.key):void 0,onKeyDown:n?t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),x(e.key))}:void 0,children:[a&&o,e.label,!a&&o,s&&m(`span`,{className:`wui-col-resize`,role:`separator`,"aria-orientation":`vertical`,"aria-valuemin":re,"aria-valuemax":ne,tabIndex:0,"aria-label":ie.resize(typeof e.label==`string`?e.label:e.key)})]},e.key)}),C&&(je?m(`th`,{className:`wui-cell-end`,children:je}):m(`th`,{className:`wui-cell-end`,children:m(`span`,{className:`visually-hidden`,children:`Actions`})}))]})}),m(`tbody`,{ref:Tt,children:S?m(i,{rows:De,cols:V}):g?.length?h(te,{children:[It(`before`,Z.before),J.slice(Z.start,Z.end).map((e,t)=>Ft(e,Z.start+t)),It(`after`,Z.after)]}):null}),tt&&!S&&g?.length>0&&m(`tfoot`,{children:h(`tr`,{children:[R&&m(`td`,{className:Q.className,style:Q.style}),T&&m(`td`,{className:$.className,style:$.style}),e.map((e,t)=>m(`td`,{className:W(U+t,(t===0?`wui-name-cell `:``)+(e.nowrap?`text-nowrap `:``)+y(e.align)).className,style:ct(U+t,void 0),children:e.footer?e.footer(g):null},e.key)),C&&m(`td`,{})]})})]}),!S&&!g?.length&&m(`div`,{className:`tbl-empty-block`,children:typeof Mt==`string`?m(`div`,{className:`tbl-empty-plain`,children:Mt}):Mt})]}),Ee(w)&&m(a,{page:w.page,totalPages:w.totalPages,pageSize:w.pageSize,onPageChange:w.setPage,onPageSizeChange:w.setPageSize,pageSizes:w.pageSizes,mode:w.mode}),kt&&m(`div`,{ref:At,className:`visually-hidden`,role:`status`,"aria-live":`polite`,"data-wui-table-status":``})]})}export{b as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@webority/ui-react",
3
- "version": "0.79.0",
3
+ "version": "0.80.0",
4
4
  "description": "Webority shared React component library — App* primitives on react-bootstrap + the @webority/theme design system.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "module",
@@ -27,11 +27,11 @@
27
27
  },
28
28
  "sideEffects": false,
29
29
  "dependencies": {
30
- "@webority/theme": "0.79.0",
31
- "@webority/ui-elements": "0.79.0"
30
+ "@webority/theme": "0.80.0",
31
+ "@webority/ui-elements": "0.80.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@webority/analytics": "^0.23.0",
34
+ "@webority/analytics": "^0.24.0",
35
35
  "bootstrap": "5.3.3",
36
36
  "react": "^19.0.0",
37
37
  "react-bootstrap": "^2.10.0",
@@ -45,7 +45,7 @@
45
45
  "@types/react": "^19.2.17",
46
46
  "@vitejs/plugin-react": "^6.0.1",
47
47
  "@vitest/coverage-v8": "5.0.1",
48
- "@webority/analytics": "0.23.3",
48
+ "@webority/analytics": "0.24.0",
49
49
  "bootstrap": "5.3.3",
50
50
  "jsdom": "30.1.1",
51
51
  "react": "^19.2.6",