{"version":3,"file":"reactTable-D4yoLO7y.js","sources":["../../../client/app/bundles/Shared/components/reactTable/reactTable.tsx"],"sourcesContent":["import * as React from \"react\";\nimport {\n useExpanded,\n useFilters,\n useGroupBy,\n usePagination,\n useSortBy,\n useTable,\n} from \"react-table\";\n\nimport ReactTablePagination from \"./reactTablePagination\";\n\nimport { NumberFilterInputProps } from \"../../interfaces\";\n\nconst DEFAULT_PAGE_SIZE = 100;\n\nfunction columnClassName(isSorted, isSortedDesc) {\n const defaultClassName = \"rt-th -cursor-pointer\";\n if (!isSorted) {\n return defaultClassName;\n }\n if (isSortedDesc) {\n return `${defaultClassName} -sort-desc`;\n }\n return `${defaultClassName} -sort-asc`;\n}\n\nexport const TextFilter = ({ column, setFilter }) => {\n return (\n setFilter(column.id, event.target.value)}\n style={{ width: \"100%\" }}\n value={column.filterValue}\n />\n );\n};\n\nexport const NumberFilterInput = ({\n handleChange,\n label,\n column,\n}: NumberFilterInputProps) => {\n return (\n
\n handleChange(column.id, e.target.value)}\n placeholder=\"0-5, >1, <1\"\n style={{ marginRight: \"0.5rem\", width: \"100px\" }}\n type=\"text\"\n value={column.filterValue || \"\"}\n />\n
\n );\n};\n\nexport const expanderColumn = {\n Cell: ({ row }) => {\n return (\n \n
\n \n );\n },\n Header: \"\",\n className: \"text-center\",\n id: \"expander\",\n resizable: false,\n};\n\ninterface ReactTableProps {\n SubComponent?: any;\n className?: string;\n columns: any[];\n currentPage?: number;\n data: any[];\n defaultGroupBy?: string;\n defaultPageSize?: number;\n defaultSorted?: string | { id: string; desc: boolean }[];\n disableSortBy?: boolean;\n filterable?: boolean;\n manualFilters?: boolean;\n manualPagination?: boolean;\n manualSortBy?: boolean;\n manualPageCount?: boolean;\n minRows?: number;\n onFiltersChange?: (filters: []) => void;\n onPageChange?: (pageIndex: number) => void;\n onSortedChange?: (sortBy: string) => void;\n showPagination?: boolean;\n showPaginationBottom?: boolean;\n}\n\nexport const ReactTable = ({\n SubComponent,\n className,\n columns,\n currentPage,\n data,\n defaultGroupBy,\n defaultPageSize,\n defaultSorted,\n disableSortBy,\n filterable,\n manualFilters,\n manualPagination,\n manualPageCount,\n manualSortBy,\n onFiltersChange,\n onPageChange,\n onSortedChange,\n showPaginationBottom,\n}: ReactTableProps) => {\n const defaultColumn = {\n width: \"min-content\",\n };\n\n const {\n getTableBodyProps,\n getTableProps,\n gotoPage,\n headerGroups,\n page,\n canNextPage,\n canPreviousPage,\n pageCount,\n prepareRow,\n state: { filters, pageIndex, sortBy },\n } = useTable(\n {\n autoResetSortBy: false,\n columns,\n data,\n defaultColumn,\n disableSortBy,\n filters: [],\n groupBy: defaultGroupBy || [],\n initialState: {\n filters: [],\n groupBy: defaultGroupBy || [],\n pageIndex: currentPage || 0,\n pageSize: defaultPageSize || data.length || DEFAULT_PAGE_SIZE,\n sortBy: defaultSorted || [],\n },\n manualFilters,\n manualPagination,\n manualSortBy,\n pageCount: manualPageCount,\n SubComponent,\n },\n useFilters,\n useGroupBy,\n useSortBy,\n useExpanded,\n usePagination\n );\n\n React.useEffect(() => {\n if (manualSortBy && onSortedChange) {\n onSortedChange(sortBy);\n }\n }, [sortBy]);\n\n React.useEffect(() => {\n if (manualPagination && onPageChange) {\n onPageChange(pageIndex);\n }\n }, [pageIndex]);\n\n React.useEffect(() => {\n if (manualFilters && onFiltersChange) {\n onFiltersChange(filters);\n }\n }, [filters]);\n\n function handleRowClick(row) {\n if (!row.original?.link) { return }\n\n window.location = row.original.link\n }\n\n return (\n
\n \n \n {headerGroups.map((headerGroup) => (\n \n {headerGroup.headers.map((column) => (\n \n {\n if (e.key === \"Enter\" || e.key === \" \") {\n e.preventDefault();\n column.toggleSortBy();\n }\n }}\n >\n {column.render(\"Header\")}\n \n
\n {filterable && column.canFilter ? column.render(\"Filter\") : null}\n
\n \n ))}\n
\n ))}\n \n \n {page.map((row) => {\n prepareRow(row);\n return (\n
\n
{handleRowClick(row)}}>\n {row.cells.map((cell) => (\n \n {cell.isAggregated ? cell.render(\"Aggregated\") : cell.render(\"Cell\")}\n \n ))}\n \n {row.isExpanded && row.original && SubComponent\n ? SubComponent(row)\n : null}\n \n );\n })}\n \n
\n {showPaginationBottom && (\n \n )}\n
\n );\n};\n"],"names":["DEFAULT_PAGE_SIZE","columnClassName","isSorted","isSortedDesc","defaultClassName","TextFilter","column","setFilter","React.createElement","event","NumberFilterInput","handleChange","label","e","expanderColumn","row","ReactTable","SubComponent","className","columns","currentPage","data","defaultGroupBy","defaultPageSize","defaultSorted","disableSortBy","filterable","manualFilters","manualPagination","manualPageCount","manualSortBy","onFiltersChange","onPageChange","onSortedChange","showPaginationBottom","defaultColumn","getTableBodyProps","getTableProps","gotoPage","headerGroups","page","canNextPage","canPreviousPage","pageCount","prepareRow","filters","pageIndex","sortBy","useTable","useFilters","useGroupBy","useSortBy","useExpanded","usePagination","React.useEffect","handleRowClick","_a","headerGroup","cell","ReactTablePagination"],"mappings":"+DAcA,MAAMA,EAAoB,IAE1B,SAASC,EAAgBC,EAAUC,EAAc,CAC/C,MAAMC,EAAmB,wBACzB,OAAKF,EAGDC,EACK,GAAGC,CAAgB,cAErB,GAAGA,CAAgB,aALjBA,CAMX,CAEO,MAAMC,EAAa,CAAC,CAAE,OAAAC,EAAQ,UAAAC,KAEjCC,EAAA,cAAC,QAAA,CACC,aAAW,cACX,SAAWC,GAAUF,EAAUD,EAAO,GAAIG,EAAM,OAAO,KAAK,EAC5D,MAAO,CAAE,MAAO,MAAO,EACvB,MAAOH,EAAO,WAAA,CAAA,EAKPI,EAAoB,CAAC,CAChC,aAAAC,EACA,MAAAC,EACA,OAAAN,CACF,oBAEK,MAAI,CAAA,MAAO,CAAE,QAAS,MACrB,CAAA,EAAAE,EAAA,cAAC,QAAA,CACC,aAAYI,EACZ,SAAWC,GAAMF,EAAaL,EAAO,GAAIO,EAAE,OAAO,KAAK,EACvD,YAAY,cACZ,MAAO,CAAE,YAAa,SAAU,MAAO,OAAQ,EAC/C,KAAK,OACL,MAAOP,EAAO,aAAe,EAAA,C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