@collana-solutions/react-data-table 0.0.0-stage → 6.3.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.
Files changed (39) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -3
  3. package/dist/index.d.ts +15 -0
  4. package/dist/index.js +2 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/index.modern.js +2 -0
  7. package/dist/index.modern.js.map +1 -0
  8. package/dist/index.umd.js +2 -0
  9. package/dist/index.umd.js.map +1 -0
  10. package/dist/lib/ReactDataTable/DragAndDropOptions.d.ts +15 -0
  11. package/dist/lib/ReactDataTable/ReactDataTable.d.ts +9 -0
  12. package/dist/lib/ReactDataTable/ReactDataTableProps.d.ts +116 -0
  13. package/dist/lib/ReactDataTable/TableBody.d.ts +13 -0
  14. package/dist/lib/ReactDataTable/TableRows.d.ts +16 -0
  15. package/dist/lib/ReactDataTable/VirtualizationOptions.d.ts +15 -0
  16. package/dist/lib/hooks/useVirtualizationTableHeight.d.ts +12 -0
  17. package/dist/lib/translations/translations.d.ts +15 -0
  18. package/dist/lib/types/ColumnFilterState.d.ts +5 -0
  19. package/dist/lib/types/NullableTypes.d.ts +27 -0
  20. package/dist/lib/types/SortingState.d.ts +13 -0
  21. package/dist/lib/types/TableState.d.ts +26 -0
  22. package/dist/lib/useFullyControlledReactDataTable/useFullyControlledReactDataTable.d.ts +23 -0
  23. package/dist/lib/useReactDataTable/useReactDataTable.d.ts +10 -0
  24. package/dist/lib/useReactDataTable/useReactDataTableProps.d.ts +74 -0
  25. package/dist/lib/useReactDataTable/useReactDataTableResult.d.ts +62 -0
  26. package/dist/lib/useReactDataTableState/usePersistentReactDataTableState.d.ts +22 -0
  27. package/dist/lib/useReactDataTableState/useReactDataTableState.d.ts +11 -0
  28. package/dist/lib/useReactDataTableState/useReactDataTableStateProps.d.ts +37 -0
  29. package/dist/lib/useReactDataTableState/useReactDataTableStateResult.d.ts +64 -0
  30. package/dist/lib/utils/createReactDataTableColumnHelper.d.ts +9 -0
  31. package/dist/lib/utils/customFilterMethods.d.ts +4 -0
  32. package/dist/lib/utils/getColumnFilterFromModel.d.ts +4 -0
  33. package/dist/lib/utils/getCommonPinningStyles.d.ts +4 -0
  34. package/dist/lib/utils/getModelFromColumnFilter.d.ts +4 -0
  35. package/dist/lib/utils/getModelFromSortingState.d.ts +4 -0
  36. package/dist/lib/utils/getSortingStateFromModel.d.ts +4 -0
  37. package/dist/lib/utils/getStronglyTypedColumnFilter.d.ts +3 -0
  38. package/dist/react-table.d.ts +85 -0
  39. package/package.json +129 -6
@@ -0,0 +1,2 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@neolution-ch/javascript-utils"),require("react/jsx-runtime"),require("@tanstack/react-table"),require("react-loading-skeleton"),require("@fortawesome/free-solid-svg-icons"),require("@fortawesome/react-fontawesome"),require("@neolution-ch/react-pattern-ui"),require("@neolution-ch/reactstrap"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@tanstack/react-virtual"),require("@dnd-kit/sortable"),require("@dnd-kit/utilities")):"function"==typeof define&&define.amd?define(["exports","react","@neolution-ch/javascript-utils","react/jsx-runtime","@tanstack/react-table","react-loading-skeleton","@fortawesome/free-solid-svg-icons","@fortawesome/react-fontawesome","@neolution-ch/react-pattern-ui","@neolution-ch/reactstrap","@dnd-kit/core","@dnd-kit/modifiers","@tanstack/react-virtual","@dnd-kit/sortable","@dnd-kit/utilities"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ReactDataTable={},e.React,e.javascriptUtils,e.jsxRuntime,e.reactTable,e.Skeleton,e.freeSolidSvgIcons,e.reactFontawesome,e.reactPatternUi,e.reactstrap,e.core,e.modifiers,e.reactVirtual,e.sortable,e.utilities)}(this,function(e,t,n,o,i,a,l,r,s,c,u,d,g,m,p){"use strict";e.reactDataTableTranslations={actionTitle:"Aktionen",clearSearchToolTip:"Suche zurücksetzen",searchToolTip:"Suchen",showedItemsText:"Zeige {from} bis {to} von insgesamt {total} Resultaten",itemsPerPageDropdown:"Anzahl pro Seite",noEntries:"Keine Einträge vorhanden"};const S=e=>{const{initialColumnFilters:n,initialSorting:o,initialPagination:i,initialRowSelection:a,initialExpanded:l,initialColumnPinning:r,initialAfterSearchFilter:s}=e,[c,u]=t.useState(n??{}),[d,g]=t.useState(s??n??{}),[m,p]=t.useState(o),[S,f]=t.useState(a??{}),[h,b]=t.useState(l??{}),[w,x]=t.useState(r??{}),[C,F]=t.useState({pageIndex:i?.pageIndex??0,pageSize:i?.pageSize??10});return{sorting:m,pagination:C,columnFilters:c,afterSearchFilter:d,rowSelection:S,expanded:h,columnPinning:w,setSorting:p,setColumnFilters:u,setPagination:F,setAfterSearchFilter:g,setRowSelection:f,setExpanded:b,setColumnPinning:x}},f=e=>Object.entries(e).map(([e,t])=>({id:e,value:t})),h=e=>Object.fromEntries(e.map(({id:e,value:t})=>[e,t])),b=e=>e?[{id:String(e.id),desc:e.desc}]:[],w=e=>{const{data:n=[],columns:l,isLoading:r,initialState:s,manualFiltering:c,manualPagination:u,manualSorting:d,state:g,onColumnFiltersChange:m,onPaginationChange:p,onSortingChange:w,onRowSelectionChange:x,onExpandedChange:C,onColumnPinningChange:F,reactTableOptions:R}=e,{columnFilters:P,sorting:y,pagination:j,rowSelection:v,expanded:k,columnPinning:D}=s??{},{columnFilters:E,pagination:I,sorting:T,rowSelection:z,expanded:A,columnPinning:M}=g??{},{columnFilters:N,pagination:$,sorting:H,rowSelection:L,expanded:q,columnPinning:V,setColumnFilters:_,setPagination:O,setSorting:G,setRowSelection:K,setExpanded:U,setColumnPinning:B}=S({initialColumnFilters:P,initialPagination:j,initialSorting:y}),Y=E??N,Z=I??$,J=T??H,Q=z??L,W=A??q,X=M??V,ee=m??_,te=p??O,ne=w??G,oe=x??K,ie=C??U,ae=F??B;if(c)for(const e of l)e.filterFn=void 0;const le=l.filter(e=>!0!==e.meta?.isHidden),re=le.map(e=>({...e,cell:()=>o.jsx(a,{})})),se=Array.from({length:$.pageSize},()=>({})),ce=t.useMemo(()=>f(Y),[Y]),ue=t.useMemo(()=>b(J),[J]);return{table:i.useReactTable({data:r?se:n,columns:r?re:le,onColumnFiltersChange:e=>{const t="function"==typeof e?e(ce):e;return ee(h(t))},onPaginationChange:e=>{const t="function"==typeof e?e(Z):e;return te(t)},onSortingChange:e=>{const t="function"==typeof e?e(ue):e;return ne((e=>{const[t]=e;return t?{id:t.id,desc:t.desc}:void 0})(t))},onRowSelectionChange:e=>{const t="function"==typeof e?e(Q):e;return oe(t)},onExpandedChange:e=>{const t="function"==typeof e?e(W):e;return ie(t)},onColumnPinningChange:e=>{const t="function"==typeof e?e(X):e;return ae(t)},state:{columnFilters:ce,pagination:Z,sorting:ue,rowSelection:Q,expanded:W,columnPinning:X},initialState:{columnFilters:f(P??E??{}),pagination:j??I,sorting:b(y??T),expanded:k??A,columnPinning:D??M},getCoreRowModel:i.getCoreRowModel(),getFilteredRowModel:i.getFilteredRowModel(),getSortedRowModel:i.getSortedRowModel(),getPaginationRowModel:i.getPaginationRowModel(),getExpandedRowModel:i.getExpandedRowModel(),manualFiltering:c,manualPagination:u,manualSorting:d,enableMultiSort:!1,enableMultiRowSelection:!1,enableSubRowSelection:!1,enableRowSelection:R?.enableRowSelection??!1,defaultColumn:{enableColumnFilter:!1,enableSorting:!1},enableExpanding:R?.enableExpanding??!1,...R}),columnFilters:Y,pagination:Z,sorting:J,rowSelection:Q,expanded:W,columnPinning:X,setColumnFilters:ee,setPagination:te,setSorting:ne,setRowSelection:oe,setExpanded:ie,setColumnPinning:ae}},x=e=>{const t=e.getIsPinned();return{left:"left"===t?`${e.getStart("left")}px`:void 0,right:"right"===t?`${e.getAfter("right")}px`:void 0,position:t?"sticky":"relative",width:e.getSize(),zIndex:t?1:0}},C=(e,t,n)=>{const o=e.columnDef.meta?.customFilterName;o?t.setColumnFilters(e=>[...e.filter(e=>e.id!==o),{id:o,value:n}]):e.setFilterValue(n)},F=(e,t)=>{const n=e.columnDef.meta?.customFilterName;return n?t.getState().columnFilters.find(e=>e.id===n)?.value:e.getFilterValue()},R=e=>{const{row:t,rowStyle:n,setNodeRef:a,enableRowSelection:l=!1,fullRowSelectable:r=!0,onRowClick:s,enableRowClick:c,hasPinnedColumns:u,subRowComponent:d}=e,g=("function"==typeof l?l(t):l)&&r,m="function"==typeof c?c(t):c;return o.jsxs(o.Fragment,{children:[o.jsx("tr",{ref:a,onClick:async()=>{g?t.toggleSelected():m&&s&&await s(t)},className:g||m?"cursor-pointer":void 0,style:n,children:t.getVisibleCells().map(e=>o.jsx("td",{style:{...e.column.columnDef.meta?.cellStyle,...u?x(e.column):{}},className:e.column.columnDef.meta?.cellClassName,children:i.flexRender(e.column.columnDef.cell,e.getContext())},e.id))},t.id),d&&t.getIsExpanded()&&d(t)]})},P=e=>{const{row:t,rowStyle:n}=e,{transform:i,transition:a,setNodeRef:l,isDragging:r}=m.useSortable({id:t.id}),s={transform:p.CSS.Transform.toString(i),transition:a,opacity:r?.8:1,zIndex:r?1:0,position:"relative"};return o.jsx(R,{...e,setNodeRef:l,rowStyle:n?{...n,...s}:s})},y=e=>{const{enableDragAndDrop:n,table:i,rowStyle:a,enableRowClick:l,onRowClick:r,virtualizer:s,subRowComponent:c}=e;if(n&&!i.options.getRowId)throw new Error("You must provide 'getRowId()' to data-table options in order to use the drag-and-drop feature.");const{options:{enableRowSelection:u,enableExpanding:d,fullRowSelectable:g}}=i,{rows:p}=i.getRowModel(),S=s?.getVirtualItems(),f=t.useMemo(()=>S?S.map((e,t)=>({row:p[e.index],rowStyle:{height:`${e.size}px`,transform:`translateY(${e.start-t*e.size}px)`}})):p.map(e=>({row:e})),[p,S]);return n?o.jsx(m.SortableContext,{items:i.getRowModel().rows.map(e=>e.id),strategy:m.verticalListSortingStrategy,children:f.map((e,t)=>{const{row:n}=e;return o.jsx(P,{row:n,enableRowClick:l,onRowClick:r,enableRowSelection:u,enableExpanding:d,rowStyle:{...e.rowStyle,...a?a(n.original):{}},fullRowSelectable:g,subRowComponent:c},t)})}):o.jsx(o.Fragment,{children:f.map((e,t)=>{const{row:n}=e;return o.jsx(R,{row:n,enableRowClick:l,onRowClick:r,enableRowSelection:u,enableExpanding:d,rowStyle:{...e.rowStyle,...a?a(n.original):{}},fullRowSelectable:g,hasPinnedColumns:i.getIsSomeColumnsPinned(),subRowComponent:c},t)})})},j=e=>{const{parentRef:n,virtualizer:o,enabled:i,onPseudoHeightChange:a}=e,l=t.useRef(null),r=t.useRef(null),[s,c]=t.useState(!1),u=i?o.getVirtualItems():[],d=i?o.getTotalSize():0,g=t.useCallback(()=>((e,t,n)=>{if(!e.current)return;const o=window.getComputedStyle(e.current,"::after"),i=Number.parseFloat(o.height)||0,a=e.current.clientHeight-i,l=Math.max(t-a,0);return n?.(l),l})(r,d,a),[r,d,a]),m=t.useCallback(()=>{if(n.current){const e=n.current?.scrollTop,t=n.current?.clientHeight;c(e>.95*d-t)}},[n,d]);return t.useEffect(()=>{if(!i)return;const e=n.current;return e&&e.addEventListener("scroll",m),g(),()=>{e&&e.removeEventListener("scroll",m)}},[m,g,n,i]),t.useEffect(()=>{i&&s&&g()},[s,u.length,g,i]),{scrollableRef:l,tableRef:r}},v=n=>{const{virtualizer:a,isLoading:s,isFetching:u,table:d,tableClassName:g,tableStyle:m,rowStyle:p,onEnter:S,withoutHeaders:f=!1,withoutHeaderFilters:b=!1,dragAndDropOptions:w,noEntriesMessage:R,isStriped:P=!0,showClearSearchButton:j=!0,tableRef:v,tableHeaderStyle:k}=n,{options:{manualPagination:D},resetPageIndex:E}=d;return o.jsxs(c.Table,{striped:P,hover:!0,size:"sm",className:g,style:!s&&u?{...m,background:"linear-gradient(90deg, #E8E8E8, #ffffff, #E8E8E8)",backgroundSize:"200% 200%",animation:"reloadingAnimation 3s linear infinite"}:m,innerRef:v,children:[!f&&o.jsx("thead",{style:k,children:d.getHeaderGroups().map(e=>o.jsxs(t.Fragment,{children:[o.jsx("tr",{children:e.headers.map(e=>o.jsxs("th",{onClick:e.column.getToggleSortingHandler(),style:{...e.column.columnDef.meta?.headerStyle,...e.column.getCanSort()?{cursor:"pointer"}:{},...d.getIsSomeColumnsPinned()?x(e.subHeaders.length>0?e.subHeaders[0].column:e.column):{}},className:e.column.columnDef.meta?.headerClassName,colSpan:e.colSpan,children:[e.isPlaceholder?null:i.flexRender(e.column.columnDef.header,e.getContext()),"desc"===e.column.getIsSorted()?o.jsx(r.FontAwesomeIcon,{icon:l.faSortDown,className:"ms-1"}):"asc"===e.column.getIsSorted()?o.jsx(r.FontAwesomeIcon,{icon:l.faSortUp,className:"ms-1"}):e.column.getCanSort()?o.jsx(r.FontAwesomeIcon,{icon:l.faSort,className:"ms-1"}):""]},e.id))},`${e.id}-col-header`),!b&&!e.headers.every(e=>!!e.column.columnDef.meta?.hideHeaderFilters)&&o.jsx("tr",{children:e.headers.map(e=>{const{column:{columnDef:{meta:t}}}=e;return o.jsxs("th",{style:{...e.column.columnDef.meta?.headerFilterStyle,...d.getIsSomeColumnsPinned()?x(e.column):{}},children:[0===e.index&&o.jsxs(o.Fragment,{children:[S&&o.jsx(r.FontAwesomeIcon,{style:{cursor:"pointer",marginBottom:"4px",marginRight:"5px"},icon:l.faSearch,onClick:()=>{D&&E(!0),S(h(d.getState().columnFilters))}}),j&&o.jsx(r.FontAwesomeIcon,{style:{cursor:"pointer",marginBottom:"4px",marginRight:"5px"},icon:l.faTimes,onClick:()=>{S&&S(h(d.initialState.columnFilters)),d.setColumnFilters(d.initialState.columnFilters),D&&E(!0)}})]}),e.column.getCanFilter()&&o.jsx(o.Fragment,{children:t?.customFilter?t?.customFilter(F(e.column,d),t=>C(e.column,d,t),d):t?.dropdownFilter?o.jsx(c.Input,{type:"select",value:F(e.column,d)??"",onChange:n=>{C(e.column,d,t.dropdownFilter?.options[n.target.selectedIndex]?.value??n.target.value),!S&&D&&E(!0)},onKeyUp:({key:e})=>{"Enter"===e&&S&&(D&&E(!0),S(h(d.getState().columnFilters)))},bsSize:"sm",children:t.dropdownFilter.options.map(({label:e,value:t,disabled:n},i)=>o.jsx("option",{value:t,disabled:n,children:e},i))}):o.jsx(c.Input,{type:"text",value:F(e.column,d)??"",onChange:t=>{C(e.column,d,t.target.value),!S&&D&&E(!0)},onKeyUp:({key:e})=>{"Enter"===e&&S&&(D&&E(!0),S(h(d.getState().columnFilters)))},bsSize:"sm"})})]},`${e.id}-col-filter`)})},`${e.id}-col-filters`)]},e.id))}),o.jsx("tbody",{children:0===d.getRowModel().rows.length?o.jsx("tr",{children:o.jsx("td",{colSpan:d.getVisibleFlatColumns().length,children:R??e.reactDataTableTranslations.noEntries})}):o.jsx(y,{...n,table:d,enableDragAndDrop:!!w?.enableDragAndDrop,rowStyle:p,virtualizer:a})}),d.getFooterGroups().length>0&&d.getFooterGroups().some(e=>e.headers.some(e=>!e.isPlaceholder&&e.column.columnDef.footer))&&o.jsx("tfoot",{children:d.getFooterGroups().map(e=>o.jsx("tr",{children:e.headers.map(e=>o.jsx("th",{style:e.column.columnDef.meta?.footerStyle,className:e.column.columnDef.meta?.footerClassName,children:e.isPlaceholder?null:i.flexRender(e.column.columnDef.footer,e.getContext())},e.id))},e.id))})]})};e.ReactDataTable=n=>{const{virtualizerOptions:i={count:0,enabled:!1,estimateSize:()=>0},table:l,pageSizes:r,showPaging:c,hidePageSizeChange:m,totalRecords:p=l.getCoreRowModel().rows.length,dragAndDropOptions:S,pagingNavigationComponents:f,isLoading:h,isFetching:b,onPseudoHeightChange:w}=n,{pagination:x}=l.getState(),C=t.useRef(null),F=g.useVirtualizer({...i,count:p,getScrollElement:()=>C.current}),R=u.useSensors(u.useSensor(u.MouseSensor,{}),u.useSensor(u.TouchSensor,{}),u.useSensor(u.KeyboardSensor,{})),{scrollableRef:P,tableRef:y}=j({parentRef:C,virtualizer:F,enabled:i.enabled??!1,onPseudoHeightChange:w});return o.jsxs(o.Fragment,{children:[o.jsxs(u.DndContext,{collisionDetection:u.closestCenter,modifiers:[d.restrictToVerticalAxis],onDragEnd:S?.onDragEnd,sensors:R,children:[o.jsx("style",{children:" \n @-webkit-keyframes reloadingAnimation {\n 0%{\n background-position-x: 200%\n }\n 100%{\n background-position-x: 0%\n }\n }"}),i.enabled?o.jsx("div",{ref:C,style:{height:i.height??600,overflow:"auto"},children:o.jsx("div",{ref:P,style:{height:`${F.getTotalSize()}px`},children:o.jsx(v,{...n,virtualizer:F,tableRef:y})})}):o.jsx(v,{...n})]}),c&&o.jsx(o.Fragment,{children:h||b?o.jsx(a,{count:1,height:20}):o.jsx(s.Paging,{currentItemsPerPage:x.pageSize,currentPage:x.pageIndex+1,totalRecords:p,currentRecordCount:l.getRowModel().rows.length,setItemsPerPage:e=>{l.setPageSize(e)},setCurrentPage:e=>l.setPageIndex(e-1),possiblePageItemCounts:r,translations:{itemsPerPageDropdown:e.reactDataTableTranslations.itemsPerPageDropdown,showedItemsText:e.reactDataTableTranslations.showedItemsText},pagingPossible:!0,changePageSizePossible:!m,navigationComponents:f})})]})},e.createReactDataTableColumnHelper=()=>{const e=i.createColumnHelper();return{...e,createDraggableColumn:(t,n,i,a)=>{const s=({row:e})=>{const t=void 0===i||("function"==typeof i?i(e):i),{attributes:n,listeners:s,isDragging:c}=m.useSortable({id:e.id,disabled:!t});return o.jsx("span",{...n,...s,className:!1===t?"opacity-25":"opacity-100",style:{cursor:!1===t?"auto":c?"grabbing":"grab"},children:a??o.jsx(r.FontAwesomeIcon,{icon:l.faGripLines})})};return e.display({...n,id:t,cell:({row:e})=>o.jsx(s,{row:e})})},createEnumColumn:(t,n,o)=>e.accessor(t,{cell:e=>Array.isArray(n)?n.find(t=>t.value===e.getValue())?.label:n[e.getValue()],enableColumnFilter:!0,meta:{dropdownFilter:{options:Array.isArray(n)?n:Object.entries(n).map(([e,t])=>({label:t,value:e}))}},...o})}},e.getColumnFilterFromModel=f,e.getModelFromColumnFilter=h,e.getStronglyTypedColumnFilter=(e,t,n)=>{const o=e.find(e=>e.id===t);if(o){if("string"===n)return o.value;if("number"===n){const e=Number.parseFloat(o.value);return Number.isNaN(e)?void 0:e}}},e.setDataTableTranslations=function(t){e.reactDataTableTranslations=t},e.useFullyControlledReactDataTable=e=>w({manualFiltering:!0,manualPagination:!0,manualSorting:!0,...e}),e.usePersistentReactDataTableState=e=>{const{initialColumnFilters:o,initialSorting:i,initialPagination:a,initialRowSelection:l,initialExpanded:r,initialColumnPinning:s,initialAfterSearchFilter:c,localStorageKey:u,getExpirationDate:d}=e,g=t.useRef(d);t.useInsertionEffect(()=>{g.current=d},[d]);const{pagination:m,setPagination:p,columnFilters:f,columnPinning:h,expanded:b,rowSelection:w,sorting:x,setColumnFilters:C,afterSearchFilter:F,setAfterSearchFilter:R,setColumnPinning:P,setExpanded:y,setRowSelection:j,setSorting:v}=S({initialColumnPinning:n.getLocalStorageItem(`${u}_columnPinning`)??s,initialExpanded:n.getLocalStorageItem(`${u}_expanded`)??r,initialPagination:n.getLocalStorageItem(`${u}_pagination`)??a,initialRowSelection:n.getLocalStorageItem(`${u}_rowSelection`)??l,initialSorting:n.getLocalStorageItem(`${u}_sorting`)??i,initialColumnFilters:n.getLocalStorageItem(`${u}_columnFilters`)??o,initialAfterSearchFilter:n.getLocalStorageItem(`${u}_afterSearchFilter`)??c}),k=t.useRef({pagination:m,columnFilters:f,afterSearchFilter:F,columnPinning:h,expanded:b,rowSelection:w,sorting:x}),D=t.useCallback((e,t,o)=>{const i="function"==typeof o?o(k.current[e]):o;k.current[e]=i,n.setLocalStorageItem(`${u}_${e}`,i,g.current?.()),t(o)},[u]);return{pagination:m,setPagination:t.useCallback(e=>D("pagination",p,e),[D,p]),columnFilters:f,setColumnFilters:t.useCallback(e=>D("columnFilters",C,e),[D,C]),afterSearchFilter:F,setAfterSearchFilter:t.useCallback(e=>D("afterSearchFilter",R,e),[D,R]),columnPinning:h,setColumnPinning:t.useCallback(e=>D("columnPinning",P,e),[D,P]),expanded:b,setExpanded:t.useCallback(e=>D("expanded",y,e),[D,y]),rowSelection:w,setRowSelection:t.useCallback(e=>D("rowSelection",j,e),[D,j]),sorting:x,setSorting:t.useCallback(e=>D("sorting",v,e),[D,v])}},e.useReactDataTable=w,e.useReactDataTableState=S});
2
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../src/lib/translations/translations.ts","../src/lib/useReactDataTableState/useReactDataTableState.ts","../src/lib/utils/getColumnFilterFromModel.ts","../src/lib/utils/getModelFromColumnFilter.ts","../src/lib/utils/getSortingStateFromModel.ts","../src/lib/useReactDataTable/useReactDataTable.tsx","../src/lib/utils/getModelFromSortingState.ts","../src/lib/utils/getCommonPinningStyles.ts","../src/lib/utils/customFilterMethods.ts","../src/lib/ReactDataTable/TableRows.tsx","../src/lib/ReactDataTable/TableBody.tsx","../src/lib/hooks/useVirtualizationTableHeight.tsx","../src/lib/ReactDataTable/ReactDataTable.tsx","../src/lib/utils/createReactDataTableColumnHelper.tsx","../src/lib/utils/getStronglyTypedColumnFilter.ts","../src/lib/useFullyControlledReactDataTable/useFullyControlledReactDataTable.tsx","../src/lib/useReactDataTableState/usePersistentReactDataTableState.ts"],"sourcesContent":["/**\r\n * This are the possible translations for the data table\r\n * @interface DataTableTranslations\r\n * @property {string} clearSearchToolTip is used to print out the bottom text, possible placeholders are: {from}, {to} and {total}\r\n */\r\nexport interface ReactDataTableTranslations {\r\n actionTitle: string;\r\n showedItemsText: string;\r\n searchToolTip: string;\r\n clearSearchToolTip: string;\r\n itemsPerPageDropdown: string;\r\n noEntries: string;\r\n}\r\n\r\nexport let reactDataTableTranslations: ReactDataTableTranslations = {\r\n actionTitle: \"Aktionen\",\r\n clearSearchToolTip: \"Suche zurücksetzen\",\r\n searchToolTip: \"Suchen\",\r\n showedItemsText: \"Zeige {from} bis {to} von insgesamt {total} Resultaten\",\r\n itemsPerPageDropdown: \"Anzahl pro Seite\",\r\n noEntries: \"Keine Einträge vorhanden\",\r\n};\r\n\r\nexport function setDataTableTranslations(translations: ReactDataTableTranslations) {\r\n reactDataTableTranslations = translations;\r\n}\r\n","import { useState } from \"react\";\r\nimport { ColumnPinningState, ExpandedState, PaginationState, RowSelectionState } from \"@tanstack/react-table\";\r\nimport { useReactDataTableStateProps } from \"./useReactDataTableStateProps\";\r\nimport { useReactDataTableStateResult } from \"./useReactDataTableStateResult\";\r\nimport { FilterModel } from \"../types/TableState\";\r\nimport { SortingState } from \"../types/SortingState\";\r\nimport { OptionalNullable } from \"../types/NullableTypes\";\r\n\r\n/**\r\n * A custom hook that will initialize all the state needed for the react data table\r\n * @param props The properties to configure the initial state\r\n * @returns the state and the setters\r\n */\r\nconst useReactDataTableState = <TData, TFilter extends FilterModel = Record<string, never>>(\r\n props: OptionalNullable<useReactDataTableStateProps<TData, TFilter>>,\r\n): useReactDataTableStateResult<TData, TFilter> => {\r\n const {\r\n initialColumnFilters,\r\n initialSorting,\r\n initialPagination,\r\n initialRowSelection,\r\n initialExpanded,\r\n initialColumnPinning,\r\n initialAfterSearchFilter,\r\n } = props as useReactDataTableStateProps<TData, TFilter>;\r\n\r\n const [columnFilters, setColumnFilters] = useState<TFilter>((initialColumnFilters ?? {}) as TFilter);\r\n const [afterSearchFilter, setAfterSearchFilter] = useState<TFilter>((initialAfterSearchFilter ?? initialColumnFilters ?? {}) as TFilter);\r\n const [sorting, setSorting] = useState<SortingState<TData> | undefined>(initialSorting);\r\n const [rowSelection, setRowSelection] = useState<RowSelectionState>(initialRowSelection ?? ({} as RowSelectionState));\r\n const [expanded, setExpanded] = useState<ExpandedState>(initialExpanded ?? ({} as ExpandedState));\r\n const [columnPinning, setColumnPinning] = useState<ColumnPinningState>(initialColumnPinning ?? ({} as ColumnPinningState));\r\n\r\n const [pagination, setPagination] = useState<PaginationState>({\r\n pageIndex: initialPagination?.pageIndex ?? 0,\r\n pageSize: initialPagination?.pageSize ?? 10,\r\n });\r\n\r\n return {\r\n sorting,\r\n pagination,\r\n columnFilters,\r\n afterSearchFilter,\r\n rowSelection,\r\n expanded,\r\n columnPinning,\r\n setSorting,\r\n setColumnFilters,\r\n setPagination,\r\n setAfterSearchFilter,\r\n setRowSelection,\r\n setExpanded,\r\n setColumnPinning,\r\n };\r\n};\r\n\r\nexport { useReactDataTableState };\r\n","import { ColumnFiltersState } from \"@tanstack/react-table\";\r\nimport { FilterModel } from \"../types/TableState\";\r\n\r\nconst getColumnFilterFromModel = <TFilter extends FilterModel>(filter: TFilter): ColumnFiltersState =>\r\n Object.entries(filter).map(([id, value]) => ({ id, value: value as unknown }));\r\n\r\nexport { getColumnFilterFromModel };\r\n","import { ColumnFilter, ColumnFiltersState } from \"@tanstack/react-table\";\r\nimport { FilterModel } from \"../types/TableState\";\r\n\r\nconst getModelFromColumnFilter = <TFilter extends FilterModel>(filter: ColumnFiltersState): TFilter =>\r\n Object.fromEntries(filter.map(({ id, value }: ColumnFilter) => [id, value])) as TFilter;\r\n\r\nexport { getModelFromColumnFilter };\r\n","import { SortingState } from \"@tanstack/react-table\";\r\nimport { SortingState as CustomSortingState } from \"../types/SortingState\";\r\n\r\nconst getSortingStateFromModel = <TData>(sortingState?: CustomSortingState<TData>): SortingState =>\r\n sortingState ? [{ id: String(sortingState.id), desc: sortingState.desc }] : [];\r\n\r\nexport { getSortingStateFromModel };\r\n","import {\r\n getCoreRowModel,\r\n getExpandedRowModel,\r\n getFilteredRowModel,\r\n getPaginationRowModel,\r\n getSortedRowModel,\r\n useReactTable,\r\n} from \"@tanstack/react-table\";\r\nimport { useReactDataTableState } from \"../useReactDataTableState/useReactDataTableState\";\r\nimport Skeleton from \"react-loading-skeleton\";\r\nimport { useReactDataTableProps } from \"./useReactDataTableProps\";\r\nimport { useReactDataTableResult } from \"./useReactDataTableResult\";\r\nimport { getColumnFilterFromModel } from \"../utils/getColumnFilterFromModel\";\r\nimport { FilterModel } from \"../types/TableState\";\r\nimport { getModelFromColumnFilter } from \"../utils/getModelFromColumnFilter\";\r\nimport { getSortingStateFromModel } from \"../utils/getSortingStateFromModel\";\r\nimport { getModelFromSortingState } from \"../utils/getModelFromSortingState\";\r\nimport { OptionalNullable } from \"../types/NullableTypes\";\r\nimport { useMemo } from \"react\";\r\nimport { useReactDataTableStateProps } from \"../useReactDataTableState/useReactDataTableStateProps\";\r\n\r\n/**\r\n * A react hook that returns a react table instance and the state of the table\r\n * @param props The properties to configure the table\r\n * @returns The table instance and the state of the table\r\n */\r\n\r\nconst useReactDataTable = <TData, TFilter extends FilterModel = Record<string, never>>(\r\n props: useReactDataTableProps<TData, TFilter>,\r\n): useReactDataTableResult<TData, TFilter> => {\r\n const {\r\n data = [],\r\n columns,\r\n isLoading,\r\n initialState,\r\n manualFiltering,\r\n manualPagination,\r\n manualSorting,\r\n state,\r\n onColumnFiltersChange,\r\n onPaginationChange,\r\n onSortingChange,\r\n onRowSelectionChange,\r\n onExpandedChange,\r\n onColumnPinningChange,\r\n reactTableOptions,\r\n } = props;\r\n\r\n const {\r\n columnFilters: columnFiltersInitial,\r\n sorting: sortingInitial,\r\n pagination: paginationInitial,\r\n rowSelection: rowSelectionInitial,\r\n expanded: expandedInitial,\r\n columnPinning: columnPinningInitial,\r\n } = initialState ?? {};\r\n const {\r\n columnFilters: columnFiltersExternal,\r\n pagination: paginationExternal,\r\n sorting: sortingExternal,\r\n rowSelection: rowSelectionExternal,\r\n expanded: expandedExternal,\r\n columnPinning: columnPinningExternal,\r\n } = state ?? {};\r\n\r\n const {\r\n columnFilters: columnFiltersInternal,\r\n pagination: paginationInternal,\r\n sorting: sortingInternal,\r\n rowSelection: rowSelectionInteral,\r\n expanded: expandedInternal,\r\n columnPinning: columnPinningInternal,\r\n setColumnFilters: setColumnFiltersInternal,\r\n setPagination: setPaginationInternal,\r\n setSorting: setSortingInternal,\r\n setRowSelection: setRowSelectionInternal,\r\n setExpanded: setExpandedInternal,\r\n setColumnPinning: setColumnPinningInternal,\r\n } = useReactDataTableState<TData, TFilter>({\r\n initialColumnFilters: columnFiltersInitial as TFilter,\r\n initialPagination: paginationInitial,\r\n initialSorting: sortingInitial,\r\n rowSelection: rowSelectionInitial,\r\n expanded: expandedInitial,\r\n columnPinning: columnPinningInitial,\r\n } as unknown as OptionalNullable<useReactDataTableStateProps<TData, TFilter>>);\r\n\r\n const effectiveColumnFilters = columnFiltersExternal ?? columnFiltersInternal;\r\n const effectivePagination = paginationExternal ?? paginationInternal;\r\n const effectiveSorting = sortingExternal ?? sortingInternal;\r\n const effectiveRowSelection = rowSelectionExternal ?? rowSelectionInteral;\r\n const effectiveExpanded = expandedExternal ?? expandedInternal;\r\n const effectiveColumnPinning = columnPinningExternal ?? columnPinningInternal;\r\n const effectiveOnColumnFiltersChange = onColumnFiltersChange ?? setColumnFiltersInternal;\r\n const effectiveOnPaginationChange = onPaginationChange ?? setPaginationInternal;\r\n const effectiveOnSortingChange = onSortingChange ?? setSortingInternal;\r\n const effectiveOnRowSelectionChange = onRowSelectionChange ?? setRowSelectionInternal;\r\n const effectiveOnExpandedChange = onExpandedChange ?? setExpandedInternal;\r\n const effectiveOnColumnPinningChange = onColumnPinningChange ?? setColumnPinningInternal;\r\n\r\n // If we active the manual filtering, we have to unset the filter function, else it still does automatic filtering\r\n if (manualFiltering) for (const x of columns) x.filterFn = undefined;\r\n\r\n const internalColumns = columns.filter((x) => x.meta?.isHidden !== true);\r\n const skeletonColumns = internalColumns.map((column) => ({\r\n ...column,\r\n cell: () => <Skeleton />,\r\n }));\r\n const skeletonData = Array.from({ length: paginationInternal.pageSize }, () => ({}) as TData);\r\n\r\n const columnFilters = useMemo(() => getColumnFilterFromModel(effectiveColumnFilters), [effectiveColumnFilters]);\r\n const sorting = useMemo(() => getSortingStateFromModel(effectiveSorting), [effectiveSorting]);\r\n\r\n // known issue for tanstack with open ticket: https://github.com/facebook/react/issues/33057\r\n // eslint-disable-next-line react-hooks/incompatible-library\r\n const table = useReactTable<TData>({\r\n data: isLoading ? skeletonData : data,\r\n columns: isLoading ? skeletonColumns : internalColumns,\r\n\r\n onColumnFiltersChange: (filtersOrUpdaterFn) => {\r\n const newFilter = typeof filtersOrUpdaterFn === \"function\" ? filtersOrUpdaterFn(columnFilters) : filtersOrUpdaterFn;\r\n return effectiveOnColumnFiltersChange(getModelFromColumnFilter(newFilter));\r\n },\r\n onPaginationChange: (paginationOrUpdaterFn) => {\r\n const newFilter = typeof paginationOrUpdaterFn === \"function\" ? paginationOrUpdaterFn(effectivePagination) : paginationOrUpdaterFn;\r\n return effectiveOnPaginationChange(newFilter);\r\n },\r\n onSortingChange: (sortingOrUpdaterFn) => {\r\n const newFilter = typeof sortingOrUpdaterFn === \"function\" ? sortingOrUpdaterFn(sorting) : sortingOrUpdaterFn;\r\n return effectiveOnSortingChange(getModelFromSortingState(newFilter));\r\n },\r\n onRowSelectionChange: (rowSelectionOrUpdaterFn) => {\r\n const newRowSelection =\r\n typeof rowSelectionOrUpdaterFn === \"function\" ? rowSelectionOrUpdaterFn(effectiveRowSelection) : rowSelectionOrUpdaterFn;\r\n return effectiveOnRowSelectionChange(newRowSelection);\r\n },\r\n onExpandedChange: (expandedOrUpdaterFn) => {\r\n const newExpanded = typeof expandedOrUpdaterFn === \"function\" ? expandedOrUpdaterFn(effectiveExpanded) : expandedOrUpdaterFn;\r\n return effectiveOnExpandedChange(newExpanded);\r\n },\r\n onColumnPinningChange: (columnPinningOrUpdaterFn) => {\r\n const newColumnPinning =\r\n typeof columnPinningOrUpdaterFn === \"function\" ? columnPinningOrUpdaterFn(effectiveColumnPinning) : columnPinningOrUpdaterFn;\r\n return effectiveOnColumnPinningChange(newColumnPinning);\r\n },\r\n\r\n state: {\r\n columnFilters,\r\n pagination: effectivePagination,\r\n sorting,\r\n rowSelection: effectiveRowSelection,\r\n expanded: effectiveExpanded,\r\n columnPinning: effectiveColumnPinning,\r\n },\r\n\r\n initialState: {\r\n columnFilters: getColumnFilterFromModel(columnFiltersInitial ?? columnFiltersExternal ?? {}),\r\n pagination: paginationInitial ?? paginationExternal,\r\n sorting: getSortingStateFromModel(sortingInitial ?? sortingExternal),\r\n expanded: expandedInitial ?? expandedExternal,\r\n columnPinning: columnPinningInitial ?? columnPinningExternal,\r\n },\r\n\r\n getCoreRowModel: getCoreRowModel(),\r\n getFilteredRowModel: getFilteredRowModel(),\r\n getSortedRowModel: getSortedRowModel(),\r\n getPaginationRowModel: getPaginationRowModel(),\r\n getExpandedRowModel: getExpandedRowModel(),\r\n\r\n manualFiltering,\r\n manualPagination,\r\n manualSorting,\r\n\r\n enableMultiSort: false,\r\n enableMultiRowSelection: false,\r\n enableSubRowSelection: false,\r\n\r\n // The row selection is enabled by default in Tanstack API. We don't want it per default\r\n enableRowSelection: reactTableOptions?.enableRowSelection ?? false,\r\n defaultColumn: {\r\n enableColumnFilter: false,\r\n enableSorting: false,\r\n },\r\n\r\n enableExpanding: reactTableOptions?.enableExpanding ?? false,\r\n\r\n ...reactTableOptions,\r\n });\r\n\r\n return {\r\n table,\r\n columnFilters: effectiveColumnFilters,\r\n pagination: effectivePagination,\r\n sorting: effectiveSorting,\r\n rowSelection: effectiveRowSelection,\r\n expanded: effectiveExpanded,\r\n columnPinning: effectiveColumnPinning,\r\n setColumnFilters: effectiveOnColumnFiltersChange,\r\n setPagination: effectiveOnPaginationChange,\r\n setSorting: effectiveOnSortingChange,\r\n setRowSelection: effectiveOnRowSelectionChange,\r\n setExpanded: effectiveOnExpandedChange,\r\n setColumnPinning: effectiveOnColumnPinningChange,\r\n };\r\n};\r\n\r\nexport { useReactDataTable };\r\n","import { SortingState as CustomSortingState } from \"../types/SortingState\";\r\nimport { SortingState } from \"@tanstack/react-table\";\r\n\r\nconst getModelFromSortingState = <TData>(sortingState: SortingState): CustomSortingState<TData> | undefined => {\r\n const [first] = sortingState;\r\n return first ? { id: first.id as keyof TData, desc: first.desc } : undefined;\r\n};\r\n\r\nexport { getModelFromSortingState };\r\n","import { Column } from \"@tanstack/react-table\";\r\nimport { CSSProperties } from \"react\";\r\n\r\n// These are the important styles to make sticky column pinning work!\r\nconst getCommonPinningStyles = <TData>(column: Column<TData>): CSSProperties => {\r\n const isPinned = column.getIsPinned();\r\n\r\n return {\r\n left: isPinned === \"left\" ? `${column.getStart(\"left\")}px` : undefined,\r\n right: isPinned === \"right\" ? `${column.getAfter(\"right\")}px` : undefined,\r\n position: isPinned ? \"sticky\" : \"relative\",\r\n width: column.getSize(),\r\n zIndex: isPinned ? 1 : 0,\r\n };\r\n};\r\n\r\nexport { getCommonPinningStyles };\r\n","import { Column, Table } from \"@tanstack/react-table\";\r\n\r\nconst setFilterValue = <TData>(column: Column<TData, unknown>, table: Table<TData>, value: unknown) => {\r\n const customFilterName = column.columnDef.meta?.customFilterName;\r\n\r\n if (customFilterName) {\r\n table.setColumnFilters((prev) => [...prev.filter((x) => x.id !== customFilterName), { id: customFilterName, value }]);\r\n } else {\r\n column.setFilterValue(value);\r\n }\r\n};\r\n\r\nconst getFilterValue = <TData>(column: Column<TData, unknown>, table: Table<TData>): unknown => {\r\n const customFilterName = column.columnDef.meta?.customFilterName;\r\n\r\n if (customFilterName) {\r\n return table.getState().columnFilters.find((x) => x.id === customFilterName)?.value;\r\n }\r\n return column.getFilterValue();\r\n};\r\n\r\nexport { setFilterValue, getFilterValue };\r\n","import { useSortable } from \"@dnd-kit/sortable\";\r\nimport { Row, flexRender } from \"@tanstack/react-table\";\r\nimport { CSSProperties } from \"react\";\r\nimport { CSS } from \"@dnd-kit/utilities\";\r\nimport { getCommonPinningStyles } from \"../utils/getCommonPinningStyles\";\r\nimport { FilterModel } from \"../types/TableState\";\r\nimport { ReactDataTableProps } from \"./ReactDataTableProps\";\r\n\r\ninterface TableRowProps<TData, TFilter extends FilterModel = Record<string, never>> extends Pick<\r\n ReactDataTableProps<TData, TFilter>,\r\n \"onRowClick\" | \"enableRowClick\" | \"subRowComponent\"\r\n> {\r\n row: Row<TData>;\r\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean);\r\n fullRowSelectable?: boolean;\r\n enableExpanding?: boolean | ((row: Row<TData>) => boolean);\r\n rowStyle?: CSSProperties;\r\n setNodeRef?: (node: HTMLElement | null) => void;\r\n hasPinnedColumns?: boolean;\r\n}\r\n\r\nconst InternalTableRow = <TData, TFilter extends FilterModel = Record<string, never>>(props: TableRowProps<TData, TFilter>) => {\r\n const {\r\n row,\r\n rowStyle,\r\n setNodeRef,\r\n enableRowSelection = false,\r\n fullRowSelectable = true,\r\n onRowClick,\r\n enableRowClick,\r\n hasPinnedColumns,\r\n subRowComponent,\r\n } = props;\r\n const isRowSelectionEnabled =\r\n (typeof enableRowSelection === \"function\" ? enableRowSelection(row) : enableRowSelection) && fullRowSelectable;\r\n const isRowClickable = typeof enableRowClick === \"function\" ? enableRowClick(row) : enableRowClick;\r\n return (\r\n <>\r\n <tr\r\n key={row.id}\r\n ref={setNodeRef}\r\n onClick={async () => {\r\n if (isRowSelectionEnabled) {\r\n row.toggleSelected();\r\n } else if (isRowClickable && onRowClick) {\r\n await onRowClick(row);\r\n } else {\r\n // Nothing to execute\r\n }\r\n }}\r\n className={isRowSelectionEnabled || isRowClickable ? \"cursor-pointer\" : undefined}\r\n style={rowStyle}\r\n >\r\n {row.getVisibleCells().map((cell) => (\r\n <td\r\n key={cell.id}\r\n style={{\r\n ...cell.column.columnDef.meta?.cellStyle,\r\n ...(hasPinnedColumns ? getCommonPinningStyles(cell.column) : {}),\r\n }}\r\n className={cell.column.columnDef.meta?.cellClassName}\r\n >\r\n {flexRender(cell.column.columnDef.cell, cell.getContext())}\r\n </td>\r\n ))}\r\n </tr>\r\n {subRowComponent && row.getIsExpanded() && subRowComponent(row)}\r\n </>\r\n );\r\n};\r\n\r\nconst DraggableRow = <TData, TFilter extends FilterModel = Record<string, never>>(props: TableRowProps<TData, TFilter>) => {\r\n const { row, rowStyle } = props;\r\n const { transform, transition, setNodeRef, isDragging } = useSortable({ id: row.id });\r\n const draggableStyle: CSSProperties = {\r\n transform: CSS.Transform.toString(transform),\r\n transition: transition,\r\n opacity: isDragging ? 0.8 : 1,\r\n zIndex: isDragging ? 1 : 0,\r\n position: \"relative\",\r\n };\r\n return (\r\n <InternalTableRow<TData, TFilter>\r\n {...props}\r\n setNodeRef={setNodeRef}\r\n rowStyle={rowStyle ? { ...rowStyle, ...draggableStyle } : draggableStyle}\r\n />\r\n );\r\n};\r\n\r\nexport { InternalTableRow, DraggableRow };\r\n","import { DraggableRow, InternalTableRow } from \"./TableRows\";\r\nimport { SortableContext, verticalListSortingStrategy } from \"@dnd-kit/sortable\";\r\nimport { Row, Table } from \"@tanstack/react-table\";\r\nimport { CSSProperties, useMemo } from \"react\";\r\nimport { FilterModel } from \"../types/TableState\";\r\nimport { ReactDataTableProps } from \"./ReactDataTableProps\";\r\nimport { Virtualizer } from \"@tanstack/react-virtual\";\r\n\r\ninterface TableBodyProps<TData, TFilter extends FilterModel = Record<string, never>> extends Pick<\r\n ReactDataTableProps<TData, TFilter>,\r\n \"enableRowClick\" | \"onRowClick\" | \"subRowComponent\"\r\n> {\r\n enableDragAndDrop: boolean;\r\n table: Table<TData>;\r\n rowStyle?: (row: TData) => CSSProperties;\r\n virtualizer?: Virtualizer<HTMLDivElement, Element>;\r\n}\r\n\r\ninterface InternalRow<TData> {\r\n row: Row<TData>;\r\n rowStyle?: CSSProperties;\r\n}\r\n\r\nconst TableBody = <TData, TFilter extends FilterModel = Record<string, never>>(props: TableBodyProps<TData, TFilter>) => {\r\n const { enableDragAndDrop, table, rowStyle, enableRowClick, onRowClick, virtualizer, subRowComponent } = props;\r\n\r\n if (enableDragAndDrop && !table.options.getRowId) {\r\n throw new Error(\"You must provide 'getRowId()' to data-table options in order to use the drag-and-drop feature.\");\r\n }\r\n\r\n const {\r\n options: { enableRowSelection, enableExpanding, fullRowSelectable },\r\n } = table;\r\n\r\n const { rows } = table.getRowModel();\r\n\r\n const virtualizerRows = virtualizer?.getVirtualItems();\r\n\r\n const rowsToRender: InternalRow<TData>[] = useMemo(\r\n () =>\r\n virtualizerRows\r\n ? virtualizerRows.map((virtualRow, index) => ({\r\n row: rows[virtualRow.index],\r\n rowStyle: {\r\n height: `${virtualRow.size}px`,\r\n transform: `translateY(${virtualRow.start - index * virtualRow.size}px)`,\r\n },\r\n }))\r\n : rows.map((row) => ({ row })),\r\n [rows, virtualizerRows],\r\n );\r\n\r\n return enableDragAndDrop ? (\r\n <SortableContext items={table.getRowModel().rows.map((row) => row.id)} strategy={verticalListSortingStrategy}>\r\n {rowsToRender.map((x, index) => {\r\n const { row } = x;\r\n return (\r\n <DraggableRow<TData, TFilter>\r\n key={index}\r\n row={row}\r\n enableRowClick={enableRowClick}\r\n onRowClick={onRowClick}\r\n enableRowSelection={enableRowSelection as boolean | ((row: Row<TData>) => boolean)}\r\n enableExpanding={enableExpanding as boolean | ((row: Row<TData>) => boolean)}\r\n rowStyle={{\r\n ...x.rowStyle,\r\n ...(rowStyle ? rowStyle(row.original) : {}),\r\n }}\r\n fullRowSelectable={fullRowSelectable}\r\n subRowComponent={subRowComponent}\r\n />\r\n );\r\n })}\r\n </SortableContext>\r\n ) : (\r\n <>\r\n {rowsToRender.map((x, index) => {\r\n const { row } = x;\r\n return (\r\n <InternalTableRow<TData, TFilter>\r\n key={index}\r\n row={row}\r\n enableRowClick={enableRowClick}\r\n onRowClick={onRowClick}\r\n enableRowSelection={enableRowSelection as boolean | ((row: Row<TData>) => boolean)}\r\n enableExpanding={enableExpanding as boolean | ((row: Row<TData>) => boolean)}\r\n rowStyle={{\r\n ...x.rowStyle,\r\n ...(rowStyle ? rowStyle(row.original) : {}),\r\n }}\r\n fullRowSelectable={fullRowSelectable}\r\n hasPinnedColumns={table.getIsSomeColumnsPinned()}\r\n subRowComponent={subRowComponent}\r\n />\r\n );\r\n })}\r\n </>\r\n );\r\n};\r\n\r\nexport { TableBody };\r\n","import { Virtualizer } from \"@tanstack/react-virtual\";\r\nimport { useCallback, useEffect, useRef, useState } from \"react\";\r\n\r\nconst adjustTableHeight = (\r\n tableRef: React.RefObject<HTMLTableElement | null>,\r\n virtualHeight: number,\r\n onPseudoHeightChange: useVirtualizationTableHeightProps[\"onPseudoHeightChange\"],\r\n) => {\r\n if (!tableRef.current) return;\r\n\r\n // calculate the height for the pseudo element after the table\r\n const existingPseudoElement = window.getComputedStyle(tableRef.current, \"::after\");\r\n const existingPseudoHeight = Number.parseFloat(existingPseudoElement.height) || 0;\r\n const tableHeight = tableRef.current.clientHeight - existingPseudoHeight;\r\n const pseudoHeight = Math.max(virtualHeight - tableHeight, 0);\r\n onPseudoHeightChange?.(pseudoHeight);\r\n\r\n return pseudoHeight;\r\n};\r\n\r\nexport interface useVirtualizationTableHeightProps {\r\n parentRef: React.RefObject<HTMLDivElement | null>;\r\n virtualizer: Virtualizer<HTMLDivElement, Element>;\r\n enabled: boolean;\r\n onPseudoHeightChange?: (height: number) => void;\r\n}\r\n\r\n// https://github.com/TanStack/virtual/issues/640\r\nconst useVirtualizationTableHeight = (props: useVirtualizationTableHeightProps) => {\r\n const { parentRef, virtualizer, enabled, onPseudoHeightChange } = props;\r\n const scrollableRef = useRef<HTMLDivElement>(null);\r\n const tableRef = useRef<HTMLTableElement>(null);\r\n const [isScrollNearBottom, setIsScrollNearBottom] = useState(false);\r\n\r\n // avoid calling virtualizer methods when virtualization is disabled\r\n const virtualItems = enabled ? virtualizer.getVirtualItems() : [];\r\n const virtualSize = enabled ? virtualizer.getTotalSize() : 0;\r\n\r\n // callback to adjust the height of the pseudo element\r\n const handlePseudoResize = useCallback(\r\n () => adjustTableHeight(tableRef, virtualSize, onPseudoHeightChange),\r\n [tableRef, virtualSize, onPseudoHeightChange],\r\n );\r\n\r\n // callback to handle scrolling, checking if we are near the bottom\r\n const handleScroll = useCallback(() => {\r\n if (parentRef.current) {\r\n const scrollPosition = parentRef.current?.scrollTop;\r\n const visibleHeight = parentRef.current?.clientHeight;\r\n setIsScrollNearBottom(scrollPosition > virtualSize * 0.95 - visibleHeight);\r\n }\r\n }, [parentRef, virtualSize]);\r\n\r\n // add an event listener on the scrollable parent container and resize the\r\n // pseudo element whenever the table renders with new data\r\n useEffect(() => {\r\n if (!enabled) {\r\n return;\r\n }\r\n\r\n const scrollable = parentRef.current;\r\n if (scrollable) scrollable.addEventListener(\"scroll\", handleScroll);\r\n handlePseudoResize();\r\n\r\n return () => {\r\n if (scrollable) scrollable.removeEventListener(\"scroll\", handleScroll);\r\n };\r\n }, [handleScroll, handlePseudoResize, parentRef, enabled]);\r\n\r\n // if we are near the bottom of the table, resize the pseudo element each time\r\n // the length of virtual items changes (which is effectively the number of table\r\n // rows rendered to the DOM). This ensures we don't scroll too far or too short.\r\n useEffect(() => {\r\n if (!enabled) {\r\n return;\r\n }\r\n\r\n if (isScrollNearBottom) handlePseudoResize();\r\n }, [isScrollNearBottom, virtualItems.length, handlePseudoResize, enabled]);\r\n\r\n return { scrollableRef, tableRef };\r\n};\r\n\r\nexport { useVirtualizationTableHeight };\r\n","/* eslint max-lines: [\"error\", 400] */\r\nimport { faSortDown, faSortUp, faSearch, faTimes, faSort } from \"@fortawesome/free-solid-svg-icons\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { Paging } from \"@neolution-ch/react-pattern-ui\";\r\nimport { flexRender } from \"@tanstack/react-table\";\r\nimport { Table as ReactStrapTable, Input } from \"@neolution-ch/reactstrap\";\r\nimport { reactDataTableTranslations } from \"../translations/translations\";\r\nimport { ReactDataTableProps } from \"./ReactDataTableProps\";\r\nimport { FilterModel } from \"../types/TableState\";\r\nimport { getModelFromColumnFilter } from \"../utils/getModelFromColumnFilter\";\r\nimport { Fragment, useRef } from \"react\";\r\nimport { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors } from \"@dnd-kit/core\";\r\nimport { restrictToVerticalAxis } from \"@dnd-kit/modifiers\";\r\nimport { getCommonPinningStyles } from \"../utils/getCommonPinningStyles\";\r\nimport { getFilterValue, setFilterValue } from \"../utils/customFilterMethods\";\r\nimport { useVirtualizer, Virtualizer } from \"@tanstack/react-virtual\";\r\nimport { TableBody } from \"./TableBody\";\r\nimport { useVirtualizationTableHeight } from \"../hooks/useVirtualizationTableHeight\";\r\nimport Skeleton from \"react-loading-skeleton\";\r\n\r\ninterface TableInternalProps<TData, TFilter extends FilterModel = Record<string, never>> extends ReactDataTableProps<TData, TFilter> {\r\n virtualizer?: Virtualizer<HTMLDivElement, Element>;\r\n tableRef?: React.RefObject<HTMLTableElement | null>;\r\n}\r\n\r\nconst TableInternal = <TData, TFilter extends FilterModel = Record<string, never>>(props: TableInternalProps<TData, TFilter>) => {\r\n const {\r\n virtualizer,\r\n isLoading,\r\n isFetching,\r\n table,\r\n tableClassName,\r\n tableStyle,\r\n rowStyle,\r\n onEnter,\r\n withoutHeaders = false,\r\n withoutHeaderFilters = false,\r\n dragAndDropOptions,\r\n noEntriesMessage,\r\n isStriped = true,\r\n showClearSearchButton = true,\r\n tableRef,\r\n tableHeaderStyle,\r\n } = props;\r\n\r\n const {\r\n options: { manualPagination },\r\n resetPageIndex,\r\n } = table;\r\n\r\n return (\r\n <ReactStrapTable\r\n striped={isStriped}\r\n hover\r\n size=\"sm\"\r\n className={tableClassName}\r\n style={\r\n !isLoading && isFetching\r\n ? {\r\n ...tableStyle,\r\n background: \"linear-gradient(90deg, #E8E8E8, #ffffff, #E8E8E8)\",\r\n backgroundSize: \"200% 200%\",\r\n animation: \"reloadingAnimation 3s linear infinite\",\r\n }\r\n : tableStyle\r\n }\r\n innerRef={tableRef}\r\n >\r\n {!withoutHeaders && (\r\n <thead style={tableHeaderStyle}>\r\n {table.getHeaderGroups().map((headerGroup) => (\r\n <Fragment key={headerGroup.id}>\r\n <tr key={`${headerGroup.id}-col-header`}>\r\n {headerGroup.headers.map((header) => (\r\n <th\r\n key={header.id}\r\n onClick={header.column.getToggleSortingHandler()}\r\n style={{\r\n ...header.column.columnDef.meta?.headerStyle,\r\n ...(header.column.getCanSort() ? { cursor: \"pointer\" } : {}),\r\n ...(table.getIsSomeColumnsPinned()\r\n ? getCommonPinningStyles(header.subHeaders.length > 0 ? header.subHeaders[0].column : header.column)\r\n : {}),\r\n }}\r\n className={header.column.columnDef.meta?.headerClassName}\r\n colSpan={header.colSpan}\r\n >\r\n {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}\r\n\r\n {header.column.getIsSorted() === \"desc\" ? (\r\n <FontAwesomeIcon icon={faSortDown} className=\"ms-1\" />\r\n ) : header.column.getIsSorted() === \"asc\" ? (\r\n <FontAwesomeIcon icon={faSortUp} className=\"ms-1\" />\r\n ) : header.column.getCanSort() ? (\r\n <FontAwesomeIcon icon={faSort} className=\"ms-1\" />\r\n ) : (\r\n \"\"\r\n )}\r\n </th>\r\n ))}\r\n </tr>\r\n {!withoutHeaderFilters && !headerGroup.headers.every((x) => !!x.column.columnDef.meta?.hideHeaderFilters) && (\r\n <tr key={`${headerGroup.id}-col-filters`}>\r\n {headerGroup.headers.map((header) => {\r\n const {\r\n column: {\r\n columnDef: { meta },\r\n },\r\n } = header;\r\n\r\n return (\r\n <th\r\n key={`${header.id}-col-filter`}\r\n style={{\r\n ...header.column.columnDef.meta?.headerFilterStyle,\r\n ...(table.getIsSomeColumnsPinned() ? getCommonPinningStyles(header.column) : {}),\r\n }}\r\n >\r\n {header.index === 0 && (\r\n <>\r\n {onEnter && (\r\n <FontAwesomeIcon\r\n style={{ cursor: \"pointer\", marginBottom: \"4px\", marginRight: \"5px\" }}\r\n icon={faSearch}\r\n onClick={() => {\r\n if (manualPagination) {\r\n resetPageIndex(true);\r\n }\r\n onEnter(getModelFromColumnFilter(table.getState().columnFilters));\r\n }}\r\n />\r\n )}\r\n\r\n {showClearSearchButton && (\r\n <FontAwesomeIcon\r\n style={{ cursor: \"pointer\", marginBottom: \"4px\", marginRight: \"5px\" }}\r\n icon={faTimes}\r\n onClick={() => {\r\n if (onEnter) {\r\n onEnter(getModelFromColumnFilter(table.initialState.columnFilters));\r\n }\r\n\r\n table.setColumnFilters(table.initialState.columnFilters);\r\n if (manualPagination) {\r\n resetPageIndex(true);\r\n }\r\n }}\r\n />\r\n )}\r\n </>\r\n )}\r\n {header.column.getCanFilter() && (\r\n <>\r\n {meta?.customFilter ? (\r\n meta?.customFilter(\r\n getFilterValue(header.column, table),\r\n (value) => setFilterValue(header.column, table, value),\r\n table,\r\n )\r\n ) : meta?.dropdownFilter ? (\r\n <Input\r\n type=\"select\"\r\n value={(getFilterValue(header.column, table) as string) ?? \"\"}\r\n onChange={(e) => {\r\n setFilterValue(\r\n header.column,\r\n table,\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n meta.dropdownFilter?.options[(e.target as any as HTMLSelectElement).selectedIndex]?.value ??\r\n e.target.value,\r\n );\r\n if (!onEnter && manualPagination) {\r\n resetPageIndex(true);\r\n }\r\n }}\r\n onKeyUp={({ key }) => {\r\n if (key === \"Enter\" && onEnter) {\r\n if (manualPagination) {\r\n resetPageIndex(true);\r\n }\r\n onEnter(getModelFromColumnFilter(table.getState().columnFilters));\r\n }\r\n }}\r\n bsSize=\"sm\"\r\n >\r\n {meta.dropdownFilter.options.map(({ label, value, disabled }, i) => (\r\n <option key={i} value={value} disabled={disabled}>\r\n {label}\r\n </option>\r\n ))}\r\n </Input>\r\n ) : (\r\n <Input\r\n type=\"text\"\r\n value={(getFilterValue(header.column, table) as string) ?? \"\"}\r\n onChange={(e) => {\r\n setFilterValue(header.column, table, e.target.value);\r\n if (!onEnter && manualPagination) {\r\n resetPageIndex(true);\r\n }\r\n }}\r\n onKeyUp={({ key }) => {\r\n if (key === \"Enter\" && onEnter) {\r\n if (manualPagination) {\r\n resetPageIndex(true);\r\n }\r\n onEnter(getModelFromColumnFilter(table.getState().columnFilters));\r\n }\r\n }}\r\n bsSize=\"sm\"\r\n ></Input>\r\n )}\r\n </>\r\n )}\r\n </th>\r\n );\r\n })}\r\n </tr>\r\n )}\r\n </Fragment>\r\n ))}\r\n </thead>\r\n )}\r\n <tbody>\r\n {table.getRowModel().rows.length === 0 ? (\r\n <tr>\r\n <td colSpan={table.getVisibleFlatColumns().length}>{noEntriesMessage ?? reactDataTableTranslations.noEntries}</td>\r\n </tr>\r\n ) : (\r\n <TableBody<TData>\r\n {...props}\r\n table={table}\r\n enableDragAndDrop={!!dragAndDropOptions?.enableDragAndDrop}\r\n rowStyle={rowStyle}\r\n virtualizer={virtualizer}\r\n />\r\n )}\r\n </tbody>\r\n {table.getFooterGroups().length > 0 &&\r\n table.getFooterGroups().some((x) => x.headers.some((y) => !y.isPlaceholder && y.column.columnDef.footer)) && (\r\n <tfoot>\r\n {table.getFooterGroups().map((footerGroup) => (\r\n <tr key={footerGroup.id}>\r\n {footerGroup.headers.map((header) => (\r\n <th\r\n key={header.id}\r\n style={header.column.columnDef.meta?.footerStyle}\r\n className={header.column.columnDef.meta?.footerClassName}\r\n >\r\n {header.isPlaceholder ? null : flexRender(header.column.columnDef.footer, header.getContext())}\r\n </th>\r\n ))}\r\n </tr>\r\n ))}\r\n </tfoot>\r\n )}\r\n </ReactStrapTable>\r\n );\r\n};\r\n\r\n/**\r\n * The table renderer for the react data table\r\n * @param props according to {@link ReactDataTableProps}\r\n * @returns The rendered ReactDataTable component\r\n */\r\nconst ReactDataTable = <TData, TFilter extends FilterModel = Record<string, never>>(props: ReactDataTableProps<TData, TFilter>) => {\r\n const {\r\n virtualizerOptions = { count: 0, enabled: false, estimateSize: () => 0 },\r\n table,\r\n pageSizes,\r\n showPaging,\r\n hidePageSizeChange,\r\n totalRecords = table.getCoreRowModel().rows.length,\r\n dragAndDropOptions,\r\n pagingNavigationComponents,\r\n isLoading,\r\n isFetching,\r\n onPseudoHeightChange,\r\n } = props;\r\n\r\n const { pagination } = table.getState();\r\n\r\n const loadingCss = ` \r\n @-webkit-keyframes reloadingAnimation {\r\n 0%{\r\n background-position-x: 200%\r\n }\r\n 100%{\r\n background-position-x: 0%\r\n }\r\n }`;\r\n\r\n const parentRef = useRef<HTMLDivElement>(null);\r\n\r\n const virtualizer = useVirtualizer({\r\n ...virtualizerOptions,\r\n count: totalRecords,\r\n getScrollElement: () => parentRef.current,\r\n });\r\n\r\n const sensors = useSensors(useSensor(MouseSensor, {}), useSensor(TouchSensor, {}), useSensor(KeyboardSensor, {}));\r\n\r\n const { scrollableRef, tableRef } = useVirtualizationTableHeight({\r\n parentRef,\r\n virtualizer,\r\n enabled: virtualizerOptions.enabled ?? false,\r\n onPseudoHeightChange,\r\n });\r\n\r\n return (\r\n <>\r\n <DndContext\r\n collisionDetection={closestCenter}\r\n modifiers={[restrictToVerticalAxis]}\r\n onDragEnd={dragAndDropOptions?.onDragEnd}\r\n sensors={sensors}\r\n >\r\n <style>{loadingCss}</style>\r\n\r\n {virtualizerOptions.enabled ? (\r\n <div ref={parentRef} style={{ height: virtualizerOptions.height ?? 600, overflow: \"auto\" }}>\r\n <div ref={scrollableRef} style={{ height: `${virtualizer.getTotalSize()}px` }}>\r\n <TableInternal<TData, TFilter> {...props} virtualizer={virtualizer} tableRef={tableRef} />\r\n </div>\r\n </div>\r\n ) : (\r\n <TableInternal<TData, TFilter> {...props} />\r\n )}\r\n </DndContext>\r\n\r\n {showPaging && (\r\n <>\r\n {isLoading || isFetching ? (\r\n <Skeleton count={1} height={20} />\r\n ) : (\r\n <Paging\r\n currentItemsPerPage={pagination.pageSize}\r\n currentPage={pagination.pageIndex + 1}\r\n totalRecords={totalRecords}\r\n currentRecordCount={table.getRowModel().rows.length}\r\n setItemsPerPage={(x) => {\r\n table.setPageSize(x);\r\n }}\r\n setCurrentPage={(x) => table.setPageIndex(x - 1)}\r\n possiblePageItemCounts={pageSizes}\r\n translations={{\r\n itemsPerPageDropdown: reactDataTableTranslations.itemsPerPageDropdown,\r\n showedItemsText: reactDataTableTranslations.showedItemsText,\r\n }}\r\n pagingPossible={true}\r\n changePageSizePossible={!hidePageSizeChange}\r\n navigationComponents={pagingNavigationComponents}\r\n />\r\n )}\r\n </>\r\n )}\r\n </>\r\n );\r\n};\r\n\r\nexport { ReactDataTable };\r\n","import { useSortable } from \"@dnd-kit/sortable\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { ColumnDef, ColumnHelper, DeepKeys, DisplayColumnDef, RowData, Row, createColumnHelper } from \"@tanstack/react-table\";\r\nimport { ReactNode } from \"react\";\r\nimport type { DropdownColumnFilterOption } from \"src/react-table\";\r\nimport { faGripLines } from \"@fortawesome/free-solid-svg-icons\";\r\n\r\ninterface ReactDataTableColumnHelper<TData extends RowData> extends ColumnHelper<TData> {\r\n createEnumColumn: <TEnum extends string | number>(\r\n columnKey: DeepKeys<TData>,\r\n enumTranslations: Record<TEnum, string> | DropdownColumnFilterOption[],\r\n columndDef?: Partial<ColumnDef<TData, TEnum>>,\r\n ) => ColumnDef<TData, TEnum>;\r\n createDraggableColumn: (\r\n columnKey: DeepKeys<TData>,\r\n columndDef: Omit<DisplayColumnDef<TData>, \"id\" | \"cell\">,\r\n isEnabled?: boolean | ((row: Row<TData>) => boolean),\r\n draggableElement?: ReactNode,\r\n ) => ColumnDef<TData>;\r\n}\r\n\r\nconst createReactDataTableColumnHelper = <TData extends RowData>(): ReactDataTableColumnHelper<TData> => {\r\n const columnHelper = createColumnHelper<TData>();\r\n\r\n const createDraggableColumn: ReactDataTableColumnHelper<TData>[\"createDraggableColumn\"] = (\r\n columnKey,\r\n columndDef,\r\n isEnabled,\r\n draggableElement,\r\n ) => {\r\n const RowDragHandleCell = ({ row }: { row: Row<TData> }) => {\r\n const isEnabledInternal = isEnabled === undefined ? true : typeof isEnabled === \"function\" ? isEnabled(row) : isEnabled;\r\n const { attributes, listeners, isDragging } = useSortable({ id: row.id, disabled: !isEnabledInternal });\r\n\r\n return (\r\n <span\r\n {...attributes}\r\n {...listeners}\r\n className={isEnabledInternal === false ? \"opacity-25\" : \"opacity-100\"}\r\n style={{ cursor: isEnabledInternal === false ? \"auto\" : isDragging ? \"grabbing\" : \"grab\" }}\r\n >\r\n {draggableElement ?? <FontAwesomeIcon icon={faGripLines} />}\r\n </span>\r\n );\r\n };\r\n\r\n return columnHelper.display({\r\n ...columndDef,\r\n id: columnKey as string,\r\n cell: ({ row }) => <RowDragHandleCell row={row} />,\r\n });\r\n };\r\n\r\n const res: ReactDataTableColumnHelper<TData> = {\r\n ...columnHelper,\r\n createDraggableColumn,\r\n createEnumColumn: (columnKey, enumTranslations, columndDef) =>\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n columnHelper.accessor(columnKey as any, {\r\n cell: (cell) =>\r\n Array.isArray(enumTranslations)\r\n ? enumTranslations.find((x) => x.value === cell.getValue())?.label\r\n : enumTranslations[cell.getValue()],\r\n enableColumnFilter: true,\r\n meta: {\r\n dropdownFilter: {\r\n options: Array.isArray(enumTranslations)\r\n ? enumTranslations\r\n : Object.entries(enumTranslations).map(([key, value]) => ({\r\n label: value as string,\r\n value: key,\r\n })),\r\n },\r\n },\r\n ...columndDef,\r\n }),\r\n };\r\n\r\n return res;\r\n};\r\n\r\nexport { createReactDataTableColumnHelper };\r\n","import { ColumnFiltersState } from \"@tanstack/react-table\";\r\n\r\nconst getStronglyTypedColumnFilter = <TData, TResult extends string | number>(\r\n columnFilters: ColumnFiltersState,\r\n id: keyof TData,\r\n targetType: \"string\" | \"number\",\r\n): TResult | undefined => {\r\n const item = columnFilters.find((element) => element.id === id);\r\n\r\n if (!item) {\r\n return undefined;\r\n }\r\n\r\n if (targetType === \"string\") {\r\n return item.value as TResult;\r\n } else if (targetType === \"number\") {\r\n const parsedValue = Number.parseFloat(item.value as string);\r\n return Number.isNaN(parsedValue) ? undefined : (parsedValue as TResult);\r\n }\r\n\r\n return undefined;\r\n};\r\n\r\nexport { getStronglyTypedColumnFilter };\r\n","import { useReactDataTable } from \"../useReactDataTable/useReactDataTable\";\r\nimport { useReactDataTableProps } from \"../useReactDataTable/useReactDataTableProps\";\r\nimport { useReactDataTableResult } from \"../useReactDataTable/useReactDataTableResult\";\r\nimport { FilterModel, TableState } from \"../types/TableState\";\r\n\r\ntype WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };\r\n\r\ninterface useFullyControlledReactDataTableProps<TData, TFilter extends FilterModel> extends WithRequired<\r\n Omit<useReactDataTableProps<TData, TFilter>, \"manualFiltering\" | \"manualPagination\" | \"manualSorting\">,\r\n \"onColumnFiltersChange\" | \"onPaginationChange\" | \"onSortingChange\"\r\n> {\r\n state: {\r\n columnFilters: TableState<TData, TFilter>[\"columnFilters\"];\r\n pagination: TableState<TData, TFilter>[\"pagination\"];\r\n sorting: TableState<TData, TFilter>[\"sorting\"];\r\n expanded: TableState<TData, TFilter>[\"expanded\"];\r\n rowSelection?: TableState<TData, TFilter>[\"rowSelection\"];\r\n columnPinning?: TableState<TData, TFilter>[\"columnPinning\"];\r\n };\r\n}\r\n\r\n/**\r\n * A helper hook to use the useReactDataTable hook which is fully controlled. Usefull for server side filtering, sorting and pagination.\r\n * @param props The properties to configure the table\r\n * @returns The table instance and the state of the table\r\n */\r\nconst useFullyControlledReactDataTable = <TData, TFilter extends FilterModel>(\r\n props: useFullyControlledReactDataTableProps<TData, TFilter>,\r\n): useReactDataTableResult<TData, TFilter> =>\r\n useReactDataTable<TData, TFilter>({ manualFiltering: true, manualPagination: true, manualSorting: true, ...props });\r\n\r\nexport { useFullyControlledReactDataTable };\r\n","import { getLocalStorageItem, setLocalStorageItem } from \"@neolution-ch/javascript-utils\";\r\nimport { OptionalNullable } from \"../types/NullableTypes\";\r\nimport { useReactDataTableStateProps } from \"./useReactDataTableStateProps\";\r\nimport { useReactDataTableStateResult } from \"./useReactDataTableStateResult\";\r\nimport { useReactDataTableState } from \"./useReactDataTableState\";\r\nimport { FilterModel } from \"../types/TableState\";\r\nimport { Dispatch, SetStateAction, useCallback, useInsertionEffect, useRef } from \"react\";\r\n\r\ninterface PersistentReactDataTableStateProps {\r\n /**\r\n * The prefix of the local storage keys the state is persisted under\r\n */\r\n localStorageKey: string;\r\n /**\r\n * Returns the date the persisted state expires, called on every write (e.g. `() => getEndOfDay(new Date())`).\r\n * Expired state is ignored and the initial state is used instead. Without it, the persisted state never expires.\r\n */\r\n getExpirationDate?: () => Date;\r\n}\r\n\r\ntype PersistedState<TData, TFilter> = Pick<\r\n useReactDataTableStateResult<TData, TFilter>,\r\n \"pagination\" | \"columnFilters\" | \"afterSearchFilter\" | \"columnPinning\" | \"expanded\" | \"rowSelection\" | \"sorting\"\r\n>;\r\n\r\n/**\r\n * A custom hook that will initialize all the state needed for the react data table and will persist it to local storage\r\n * @param props The properties to configure the initial state\r\n * @returns the state and the setters\r\n */\r\nconst usePersistentReactDataTableState = <TData, TFilter extends FilterModel = Record<string, never>>(\r\n props: OptionalNullable<useReactDataTableStateProps<TData, TFilter>> & PersistentReactDataTableStateProps,\r\n): useReactDataTableStateResult<TData, TFilter> => {\r\n const {\r\n initialColumnFilters,\r\n initialSorting,\r\n initialPagination,\r\n initialRowSelection,\r\n initialExpanded,\r\n initialColumnPinning,\r\n initialAfterSearchFilter,\r\n localStorageKey,\r\n getExpirationDate,\r\n } = props as useReactDataTableStateProps<TData, TFilter> & PersistentReactDataTableStateProps;\r\n\r\n // kept in a ref, so an inline function does not make the setters change on every render. Updated in an insertion effect, which\r\n // React runs for the whole tree before any layout effect, so it is already up to date when a setter is called from a layout\r\n // effect in the same commit (also from a child component).\r\n const getExpirationDateRef = useRef(getExpirationDate);\r\n useInsertionEffect(() => {\r\n getExpirationDateRef.current = getExpirationDate;\r\n }, [getExpirationDate]);\r\n\r\n const {\r\n pagination,\r\n setPagination,\r\n columnFilters,\r\n columnPinning,\r\n expanded,\r\n rowSelection,\r\n sorting,\r\n setColumnFilters,\r\n afterSearchFilter,\r\n setAfterSearchFilter,\r\n setColumnPinning,\r\n setExpanded,\r\n setRowSelection,\r\n setSorting,\r\n } = useReactDataTableState<TData, TFilter>({\r\n initialColumnPinning:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialColumnPinning\"]>(`${localStorageKey}_columnPinning`) ??\r\n initialColumnPinning,\r\n initialExpanded:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialExpanded\"]>(`${localStorageKey}_expanded`) ?? initialExpanded,\r\n initialPagination:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialPagination\"]>(`${localStorageKey}_pagination`) ??\r\n initialPagination,\r\n initialRowSelection:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialRowSelection\"]>(`${localStorageKey}_rowSelection`) ??\r\n initialRowSelection,\r\n initialSorting:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialSorting\"]>(`${localStorageKey}_sorting`) ?? initialSorting,\r\n initialColumnFilters:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialColumnFilters\"]>(`${localStorageKey}_columnFilters`) ??\r\n initialColumnFilters,\r\n initialAfterSearchFilter:\r\n getLocalStorageItem<useReactDataTableStateProps<TData, TFilter>[\"initialAfterSearchFilter\"]>(\r\n `${localStorageKey}_afterSearchFilter`,\r\n ) ?? initialAfterSearchFilter,\r\n } as useReactDataTableStateProps<TData, TFilter> as OptionalNullable<useReactDataTableStateProps<TData, TFilter>>);\r\n\r\n // The state of every persisted part after all updates so far. All state changes go through the setters below, so React's\r\n // state ends up at the same value once it has processed them. It lets update functions (e.g. `setSorting(previous => ...)`)\r\n // be resolved synchronously for persisting, also when several of them are called in a row.\r\n const latestStateRef = useRef<PersistedState<TData, TFilter>>({\r\n pagination,\r\n columnFilters,\r\n afterSearchFilter,\r\n columnPinning,\r\n expanded,\r\n rowSelection,\r\n sorting,\r\n });\r\n\r\n // Resolves the new state and persists it right away, outside of React's updater, so that it is neither lost when the\r\n // component unmounts before the next render nor written for a render React discards. React still gets the original action,\r\n // so it can schedule update functions by their priority (e.g. an urgent update while a transition is pending).\r\n const setAndPersistState = useCallback(\r\n <TKey extends keyof PersistedState<TData, TFilter>>(\r\n key: TKey,\r\n setState: Dispatch<SetStateAction<PersistedState<TData, TFilter>[TKey]>>,\r\n newState: SetStateAction<PersistedState<TData, TFilter>[TKey]>,\r\n ) => {\r\n const resolvedState =\r\n typeof newState === \"function\"\r\n ? (newState as (previousState: PersistedState<TData, TFilter>[TKey]) => PersistedState<TData, TFilter>[TKey])(\r\n latestStateRef.current[key],\r\n )\r\n : newState;\r\n\r\n latestStateRef.current[key] = resolvedState;\r\n setLocalStorageItem(`${localStorageKey}_${key}`, resolvedState, getExpirationDateRef.current?.());\r\n setState(newState);\r\n },\r\n [localStorageKey],\r\n );\r\n\r\n return {\r\n pagination,\r\n setPagination: useCallback(\r\n (newPagination) => setAndPersistState(\"pagination\", setPagination, newPagination),\r\n [setAndPersistState, setPagination],\r\n ),\r\n columnFilters,\r\n setColumnFilters: useCallback(\r\n (newColumnFilters) => setAndPersistState(\"columnFilters\", setColumnFilters, newColumnFilters),\r\n [setAndPersistState, setColumnFilters],\r\n ),\r\n afterSearchFilter,\r\n setAfterSearchFilter: useCallback(\r\n (newAfterSearchFilter) => setAndPersistState(\"afterSearchFilter\", setAfterSearchFilter, newAfterSearchFilter),\r\n [setAndPersistState, setAfterSearchFilter],\r\n ),\r\n columnPinning,\r\n setColumnPinning: useCallback(\r\n (newColumnPinning) => setAndPersistState(\"columnPinning\", setColumnPinning, newColumnPinning),\r\n [setAndPersistState, setColumnPinning],\r\n ),\r\n expanded,\r\n setExpanded: useCallback((newExpanded) => setAndPersistState(\"expanded\", setExpanded, newExpanded), [setAndPersistState, setExpanded]),\r\n rowSelection,\r\n setRowSelection: useCallback(\r\n (newRowSelection) => setAndPersistState(\"rowSelection\", setRowSelection, newRowSelection),\r\n [setAndPersistState, setRowSelection],\r\n ),\r\n sorting,\r\n setSorting: useCallback((newSorting) => setAndPersistState(\"sorting\", setSorting, newSorting), [setAndPersistState, setSorting]),\r\n };\r\n};\r\n\r\nexport { usePersistentReactDataTableState };\r\n"],"names":["reactDataTableTranslations","actionTitle","clearSearchToolTip","searchToolTip","showedItemsText","itemsPerPageDropdown","noEntries","useReactDataTableState","props","initialColumnFilters","initialSorting","initialPagination","initialRowSelection","initialExpanded","initialColumnPinning","initialAfterSearchFilter","columnFilters","setColumnFilters","useState","afterSearchFilter","setAfterSearchFilter","sorting","setSorting","rowSelection","setRowSelection","expanded","setExpanded","columnPinning","setColumnPinning","pagination","setPagination","pageIndex","pageSize","getColumnFilterFromModel","filter","Object","entries","map","id","value","getModelFromColumnFilter","fromEntries","getSortingStateFromModel","sortingState","String","desc","useReactDataTable","data","columns","isLoading","initialState","manualFiltering","manualPagination","manualSorting","state","onColumnFiltersChange","onPaginationChange","onSortingChange","onRowSelectionChange","onExpandedChange","onColumnPinningChange","reactTableOptions","columnFiltersInitial","sortingInitial","paginationInitial","rowSelectionInitial","expandedInitial","columnPinningInitial","columnFiltersExternal","paginationExternal","sortingExternal","rowSelectionExternal","expandedExternal","columnPinningExternal","columnFiltersInternal","paginationInternal","sortingInternal","rowSelectionInteral","expandedInternal","columnPinningInternal","setColumnFiltersInternal","setPaginationInternal","setSortingInternal","setRowSelectionInternal","setExpandedInternal","setColumnPinningInternal","effectiveColumnFilters","effectivePagination","effectiveSorting","effectiveRowSelection","effectiveExpanded","effectiveColumnPinning","effectiveOnColumnFiltersChange","effectiveOnPaginationChange","effectiveOnSortingChange","effectiveOnRowSelectionChange","effectiveOnExpandedChange","effectiveOnColumnPinningChange","x","filterFn","undefined","internalColumns","meta","isHidden","skeletonColumns","column","cell","_jsx","Skeleton","skeletonData","Array","from","length","useMemo","table","useReactTable","filtersOrUpdaterFn","newFilter","paginationOrUpdaterFn","sortingOrUpdaterFn","first","getModelFromSortingState","rowSelectionOrUpdaterFn","newRowSelection","expandedOrUpdaterFn","newExpanded","columnPinningOrUpdaterFn","newColumnPinning","getCoreRowModel","getFilteredRowModel","getSortedRowModel","getPaginationRowModel","getExpandedRowModel","enableMultiSort","enableMultiRowSelection","enableSubRowSelection","enableRowSelection","defaultColumn","enableColumnFilter","enableSorting","enableExpanding","getCommonPinningStyles","isPinned","getIsPinned","left","getStart","right","getAfter","position","width","getSize","zIndex","setFilterValue","customFilterName","columnDef","prev","getFilterValue","getState","find","InternalTableRow","row","rowStyle","setNodeRef","fullRowSelectable","onRowClick","enableRowClick","hasPinnedColumns","subRowComponent","isRowSelectionEnabled","isRowClickable","_jsxs","_Fragment","children","ref","onClick","async","toggleSelected","className","style","getVisibleCells","cellStyle","cellClassName","flexRender","getContext","getIsExpanded","DraggableRow","transform","transition","isDragging","useSortable","draggableStyle","CSS","Transform","toString","opacity","TableBody","enableDragAndDrop","virtualizer","options","getRowId","Error","rows","getRowModel","virtualizerRows","getVirtualItems","rowsToRender","virtualRow","index","height","size","start","SortableContext","items","strategy","verticalListSortingStrategy","original","getIsSomeColumnsPinned","useVirtualizationTableHeight","parentRef","enabled","onPseudoHeightChange","scrollableRef","useRef","tableRef","isScrollNearBottom","setIsScrollNearBottom","virtualItems","virtualSize","getTotalSize","handlePseudoResize","useCallback","virtualHeight","current","existingPseudoElement","window","getComputedStyle","existingPseudoHeight","Number","parseFloat","tableHeight","clientHeight","pseudoHeight","Math","max","adjustTableHeight","handleScroll","scrollPosition","scrollTop","visibleHeight","useEffect","scrollable","addEventListener","removeEventListener","TableInternal","isFetching","tableClassName","tableStyle","onEnter","withoutHeaders","withoutHeaderFilters","dragAndDropOptions","noEntriesMessage","isStriped","showClearSearchButton","tableHeaderStyle","resetPageIndex","ReactStrapTable","striped","hover","background","backgroundSize","animation","innerRef","getHeaderGroups","headerGroup","Fragment","headers","header","getToggleSortingHandler","headerStyle","getCanSort","cursor","subHeaders","headerClassName","colSpan","isPlaceholder","getIsSorted","FontAwesomeIcon","icon","faSortDown","faSortUp","faSort","every","hideHeaderFilters","headerFilterStyle","marginBottom","marginRight","faSearch","faTimes","getCanFilter","customFilter","dropdownFilter","Input","type","onChange","e","target","selectedIndex","onKeyUp","key","bsSize","label","disabled","i","getVisibleFlatColumns","getFooterGroups","some","y","footer","footerGroup","footerStyle","footerClassName","virtualizerOptions","count","estimateSize","pageSizes","showPaging","hidePageSizeChange","totalRecords","pagingNavigationComponents","useVirtualizer","getScrollElement","sensors","useSensors","useSensor","MouseSensor","TouchSensor","KeyboardSensor","DndContext","collisionDetection","closestCenter","modifiers","restrictToVerticalAxis","onDragEnd","overflow","Paging","currentItemsPerPage","currentPage","currentRecordCount","setItemsPerPage","setPageSize","setCurrentPage","setPageIndex","possiblePageItemCounts","translations","pagingPossible","changePageSizePossible","navigationComponents","columnHelper","createColumnHelper","createDraggableColumn","columnKey","columndDef","isEnabled","draggableElement","RowDragHandleCell","isEnabledInternal","attributes","listeners","faGripLines","display","createEnumColumn","enumTranslations","accessor","isArray","getValue","targetType","item","element","parsedValue","isNaN","localStorageKey","getExpirationDate","getExpirationDateRef","useInsertionEffect","getLocalStorageItem","latestStateRef","setAndPersistState","setState","newState","resolvedState","setLocalStorageItem","newPagination","newColumnFilters","newAfterSearchFilter","newSorting"],"mappings":"0vCAcWA,EAAAA,2BAAyD,CAClEC,YAAa,WACbC,mBAAoB,qBACpBC,cAAe,SACfC,gBAAiB,yDACjBC,qBAAsB,mBACtBC,UAAW,4BCPb,MAAMC,EACJC,IAEA,MAAMC,qBACJA,EAAoBC,eACpBA,EAAcC,kBACdA,EAAiBC,oBACjBA,EAAmBC,gBACnBA,EAAeC,qBACfA,EAAoBC,yBACpBA,GACEP,GAEGQ,EAAeC,GAAoBC,EAAAA,SAAmBT,GAAwB,CAAA,IAC9EU,EAAmBC,GAAwBF,EAAAA,SAAmBH,GAA4BN,GAAwB,KAClHY,EAASC,GAAcJ,EAAAA,SAA0CR,IACjEa,EAAcC,GAAmBN,EAAAA,SAA4BN,GAAwB,CAAA,IACrFa,EAAUC,GAAeR,EAAAA,SAAwBL,GAAoB,CAAA,IACrEc,EAAeC,GAAoBV,EAAAA,SAA6BJ,GAAyB,CAAA,IAEzFe,EAAYC,GAAiBZ,WAA0B,CAC5Da,UAAWpB,GAAmBoB,WAAa,EAC3CC,SAAUrB,GAAmBqB,UAAY,KAG3C,MAAO,CACLX,UACAQ,aACAb,gBACAG,oBACAI,eACAE,WACAE,gBACAL,aACAL,mBACAa,gBACAV,uBACAI,kBACAE,cACAE,qBCjDEK,EAAyDC,GAC7DC,OAAOC,QAAQF,GAAQG,IAAI,EAAEC,EAAIC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AYqX,GAAa,CAACR,EAAoB7W"}
@@ -0,0 +1,15 @@
1
+ import { DragEndEvent } from "@dnd-kit/core/dist/types/events";
2
+ /**
3
+ * The props for the dragAndDropOptions
4
+ */
5
+ export interface DragAndDropOptions {
6
+ /**
7
+ * enable or disable the drag-and-drop feature.
8
+ */
9
+ enableDragAndDrop: boolean;
10
+ /**
11
+ * the handle drag end method to be called once the row drag has fulfilled
12
+ * @param event the drag end event
13
+ */
14
+ onDragEnd(event: DragEndEvent): void;
15
+ }
@@ -0,0 +1,9 @@
1
+ import { ReactDataTableProps } from "./ReactDataTableProps";
2
+ import { FilterModel } from "../types/TableState";
3
+ /**
4
+ * The table renderer for the react data table
5
+ * @param props according to {@link ReactDataTableProps}
6
+ * @returns The rendered ReactDataTable component
7
+ */
8
+ declare const ReactDataTable: <TData, TFilter extends FilterModel = Record<string, never>>(props: ReactDataTableProps<TData, TFilter>) => import("react/jsx-runtime").JSX.Element;
9
+ export { ReactDataTable };
@@ -0,0 +1,116 @@
1
+ import { Row, Table } from "@tanstack/react-table";
2
+ import { CSSProperties } from "react";
3
+ import { FilterModel } from "../types/TableState";
4
+ import { DragAndDropOptions } from "./DragAndDropOptions";
5
+ import { VirtualizationOptions } from "./VirtualizationOptions";
6
+ import { PagingNavigationComponents } from "@neolution-ch/react-pattern-ui";
7
+ import { useVirtualizationTableHeightProps } from "../hooks/useVirtualizationTableHeight";
8
+ /**
9
+ * The props for the ReactDataTable component
10
+ */
11
+ export interface ReactDataTableProps<TData, TFilter extends FilterModel> extends Pick<useVirtualizationTableHeightProps, "onPseudoHeightChange"> {
12
+ /**
13
+ * the table instance returned from useReactDataTable or useReactTable
14
+ */
15
+ table: Table<TData>;
16
+ /**
17
+ * the page sizes to display in the page size dropdown
18
+ * @default [5, 10, 25, 50, 100]
19
+ */
20
+ pageSizes?: number[];
21
+ /**
22
+ * custom table class name
23
+ */
24
+ tableClassName?: string;
25
+ /**
26
+ * custom table style
27
+ */
28
+ tableStyle?: CSSProperties;
29
+ /**
30
+ * custom header table row style
31
+ */
32
+ tableHeaderStyle?: CSSProperties;
33
+ /**
34
+ * total number of records in the table, if not supplied,
35
+ * the table will assume that all the data is loaded and set it to the length of the data array
36
+ */
37
+ totalRecords?: number;
38
+ /**
39
+ * indicates if the table is loading data for the first time
40
+ * will display skeletons if true
41
+ */
42
+ isLoading?: boolean;
43
+ /**
44
+ * indicates if the table is fetching data
45
+ * will display loading indicator if true while keeping the data in the table and reactive
46
+ */
47
+ isFetching?: boolean;
48
+ /**
49
+ * custom row style
50
+ * @param row the row to style
51
+ * @returns the style
52
+ */
53
+ rowStyle?: (row: TData) => CSSProperties;
54
+ /**
55
+ * boolean indicating whether to enable click for specific row
56
+ * Notice that this is ignored in case of rowSelection feature is enabled and fullRowSelectable is not provided as false
57
+ * @param row the row model
58
+ */
59
+ enableRowClick?: boolean | ((row: Row<TData>) => boolean);
60
+ /**
61
+ * callback which gets triggered when the row is clicked
62
+ * Notice that this is ignored in case of rowSelection feature is enabled and fullRowSelectable is not provided as false
63
+ * @param row the row model
64
+ */
65
+ onRowClick?: (row: Row<TData>) => void | Promise<void>;
66
+ /**
67
+ * boolean flag to indicate if the paging should be displayed
68
+ */
69
+ showPaging?: boolean;
70
+ /**
71
+ * boolean flag to hide the possibility to change the page size
72
+ */
73
+ hidePageSizeChange?: boolean;
74
+ /**
75
+ * callback that gets trigger by pressing enter or clicking the search icon
76
+ */
77
+ onEnter?: (columnFilters: TFilter) => void;
78
+ /**
79
+ * To draw the table without headers (titles + filters)
80
+ */
81
+ withoutHeaders?: boolean;
82
+ /**
83
+ * to draw the table without headers filters
84
+ */
85
+ withoutHeaderFilters?: boolean;
86
+ /**
87
+ * to define drag-and-drop options
88
+ */
89
+ dragAndDropOptions?: DragAndDropOptions;
90
+ /**
91
+ * to define virtualizer options
92
+ */
93
+ virtualizerOptions?: VirtualizationOptions;
94
+ /**
95
+ * to override the default message in case no entries is found
96
+ */
97
+ noEntriesMessage?: string;
98
+ /**
99
+ * boolean flag to indicate if the table should be striped
100
+ * @default true
101
+ */
102
+ isStriped?: boolean;
103
+ /**
104
+ * boolean flag to indicate if the table should have hover effect
105
+ * @default true
106
+ */
107
+ showClearSearchButton?: boolean;
108
+ /**
109
+ * A component to render as a sub-row for a specific row, this will be rendered additionally to the subrows.
110
+ */
111
+ subRowComponent?: (row: Row<TData>) => React.ReactNode;
112
+ /**
113
+ * Custom navigation components for the paging controls
114
+ */
115
+ pagingNavigationComponents?: PagingNavigationComponents;
116
+ }
@@ -0,0 +1,13 @@
1
+ import { Table } from "@tanstack/react-table";
2
+ import { CSSProperties } from "react";
3
+ import { FilterModel } from "../types/TableState";
4
+ import { ReactDataTableProps } from "./ReactDataTableProps";
5
+ import { Virtualizer } from "@tanstack/react-virtual";
6
+ interface TableBodyProps<TData, TFilter extends FilterModel = Record<string, never>> extends Pick<ReactDataTableProps<TData, TFilter>, "enableRowClick" | "onRowClick" | "subRowComponent"> {
7
+ enableDragAndDrop: boolean;
8
+ table: Table<TData>;
9
+ rowStyle?: (row: TData) => CSSProperties;
10
+ virtualizer?: Virtualizer<HTMLDivElement, Element>;
11
+ }
12
+ declare const TableBody: <TData, TFilter extends FilterModel = Record<string, never>>(props: TableBodyProps<TData, TFilter>) => import("react/jsx-runtime").JSX.Element;
13
+ export { TableBody };
@@ -0,0 +1,16 @@
1
+ import { Row } from "@tanstack/react-table";
2
+ import { CSSProperties } from "react";
3
+ import { FilterModel } from "../types/TableState";
4
+ import { ReactDataTableProps } from "./ReactDataTableProps";
5
+ interface TableRowProps<TData, TFilter extends FilterModel = Record<string, never>> extends Pick<ReactDataTableProps<TData, TFilter>, "onRowClick" | "enableRowClick" | "subRowComponent"> {
6
+ row: Row<TData>;
7
+ enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
8
+ fullRowSelectable?: boolean;
9
+ enableExpanding?: boolean | ((row: Row<TData>) => boolean);
10
+ rowStyle?: CSSProperties;
11
+ setNodeRef?: (node: HTMLElement | null) => void;
12
+ hasPinnedColumns?: boolean;
13
+ }
14
+ declare const InternalTableRow: <TData, TFilter extends FilterModel = Record<string, never>>(props: TableRowProps<TData, TFilter>) => import("react/jsx-runtime").JSX.Element;
15
+ declare const DraggableRow: <TData, TFilter extends FilterModel = Record<string, never>>(props: TableRowProps<TData, TFilter>) => import("react/jsx-runtime").JSX.Element;
16
+ export { InternalTableRow, DraggableRow };
@@ -0,0 +1,15 @@
1
+ import { useVirtualizer } from "@tanstack/react-virtual";
2
+ type VirtualizaterOptions = Omit<Parameters<typeof useVirtualizer<HTMLDivElement, Element>>[0], "getScrollElement" | "count" | "enabled">;
3
+ export interface VirtualizationOptions extends VirtualizaterOptions {
4
+ /**
5
+ * indicates whether to enable virtualization
6
+ * @default false
7
+ */
8
+ enabled?: boolean;
9
+ /**
10
+ * indicates the height of the virtualized container
11
+ * @default 600
12
+ */
13
+ height?: number;
14
+ }
15
+ export {};
@@ -0,0 +1,12 @@
1
+ import { Virtualizer } from "@tanstack/react-virtual";
2
+ export interface useVirtualizationTableHeightProps {
3
+ parentRef: React.RefObject<HTMLDivElement | null>;
4
+ virtualizer: Virtualizer<HTMLDivElement, Element>;
5
+ enabled: boolean;
6
+ onPseudoHeightChange?: (height: number) => void;
7
+ }
8
+ declare const useVirtualizationTableHeight: (props: useVirtualizationTableHeightProps) => {
9
+ scrollableRef: import("react").RefObject<HTMLDivElement | null>;
10
+ tableRef: import("react").RefObject<HTMLTableElement | null>;
11
+ };
12
+ export { useVirtualizationTableHeight };
@@ -0,0 +1,15 @@
1
+ /**
2
+ * This are the possible translations for the data table
3
+ * @interface DataTableTranslations
4
+ * @property {string} clearSearchToolTip is used to print out the bottom text, possible placeholders are: {from}, {to} and {total}
5
+ */
6
+ export interface ReactDataTableTranslations {
7
+ actionTitle: string;
8
+ showedItemsText: string;
9
+ searchToolTip: string;
10
+ clearSearchToolTip: string;
11
+ itemsPerPageDropdown: string;
12
+ noEntries: string;
13
+ }
14
+ export declare let reactDataTableTranslations: ReactDataTableTranslations;
15
+ export declare function setDataTableTranslations(translations: ReactDataTableTranslations): void;
@@ -0,0 +1,5 @@
1
+ import { AllNullable } from "./NullableTypes";
2
+ /**
3
+ * Type making the object possibly undefined if all properties are nullable
4
+ */
5
+ export type ColumnFilterState<TFilter> = TFilter extends AllNullable<TFilter> ? TFilter | undefined : TFilter;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Type taking all nullable props from object T
3
+ */
4
+ type PickNullable<T> = {
5
+ [P in keyof T as undefined extends T[P] ? P : never]: T[P];
6
+ };
7
+ /**
8
+ * Type taking all not nullable props from object T
9
+ */
10
+ type PickNotNullable<T> = {
11
+ [P in keyof T as undefined extends T[P] ? never : P]: T[P];
12
+ };
13
+ /**
14
+ * Type defining an object with all nullable props as optional
15
+ */
16
+ type OptionalNullable<T> = {
17
+ [K in keyof PickNullable<T>]?: Exclude<T[K], undefined>;
18
+ } & {
19
+ [K in keyof PickNotNullable<T>]: T[K];
20
+ };
21
+ /**
22
+ * Object type in which all props are nullable
23
+ */
24
+ type AllNullable<T> = {
25
+ [K in keyof T]: undefined extends T[K] ? T[K] : never;
26
+ };
27
+ export { OptionalNullable, AllNullable };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The type sorting state
3
+ */
4
+ export interface SortingState<TData> {
5
+ /**
6
+ * the id of the sortable row
7
+ */
8
+ id: keyof TData;
9
+ /**
10
+ * the descending
11
+ */
12
+ desc: boolean;
13
+ }
@@ -0,0 +1,26 @@
1
+ import { ColumnPinningState, CoreOptions } from "@tanstack/react-table";
2
+ import { SortingState } from "./SortingState";
3
+ /**
4
+ * Object type implementation
5
+ */
6
+ type FilterModel = {
7
+ [k: string]: any;
8
+ };
9
+ /**
10
+ * The table sorting state
11
+ */
12
+ interface TableState<TData, TFilter extends FilterModel> extends Pick<CoreOptions<TData>["state"], "pagination" | "rowSelection" | "expanded"> {
13
+ /**
14
+ * The column filters state
15
+ */
16
+ columnFilters?: TFilter;
17
+ /**
18
+ * The sorting state
19
+ */
20
+ sorting?: SortingState<TData>;
21
+ /**
22
+ * The column pinning state
23
+ */
24
+ columnPinning?: ColumnPinningState;
25
+ }
26
+ export { TableState, FilterModel };
@@ -0,0 +1,23 @@
1
+ import { useReactDataTableProps } from "../useReactDataTable/useReactDataTableProps";
2
+ import { useReactDataTableResult } from "../useReactDataTable/useReactDataTableResult";
3
+ import { FilterModel, TableState } from "../types/TableState";
4
+ type WithRequired<T, K extends keyof T> = T & {
5
+ [P in K]-?: T[P];
6
+ };
7
+ interface useFullyControlledReactDataTableProps<TData, TFilter extends FilterModel> extends WithRequired<Omit<useReactDataTableProps<TData, TFilter>, "manualFiltering" | "manualPagination" | "manualSorting">, "onColumnFiltersChange" | "onPaginationChange" | "onSortingChange"> {
8
+ state: {
9
+ columnFilters: TableState<TData, TFilter>["columnFilters"];
10
+ pagination: TableState<TData, TFilter>["pagination"];
11
+ sorting: TableState<TData, TFilter>["sorting"];
12
+ expanded: TableState<TData, TFilter>["expanded"];
13
+ rowSelection?: TableState<TData, TFilter>["rowSelection"];
14
+ columnPinning?: TableState<TData, TFilter>["columnPinning"];
15
+ };
16
+ }
17
+ /**
18
+ * A helper hook to use the useReactDataTable hook which is fully controlled. Usefull for server side filtering, sorting and pagination.
19
+ * @param props The properties to configure the table
20
+ * @returns The table instance and the state of the table
21
+ */
22
+ declare const useFullyControlledReactDataTable: <TData, TFilter extends FilterModel>(props: useFullyControlledReactDataTableProps<TData, TFilter>) => useReactDataTableResult<TData, TFilter>;
23
+ export { useFullyControlledReactDataTable };
@@ -0,0 +1,10 @@
1
+ import { useReactDataTableProps } from "./useReactDataTableProps";
2
+ import { useReactDataTableResult } from "./useReactDataTableResult";
3
+ import { FilterModel } from "../types/TableState";
4
+ /**
5
+ * A react hook that returns a react table instance and the state of the table
6
+ * @param props The properties to configure the table
7
+ * @returns The table instance and the state of the table
8
+ */
9
+ declare const useReactDataTable: <TData, TFilter extends FilterModel = Record<string, never>>(props: useReactDataTableProps<TData, TFilter>) => useReactDataTableResult<TData, TFilter>;
10
+ export { useReactDataTable };