Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

74 changes: 0 additions & 74 deletions .eslintrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
node-version: [18.x, 20.x, 22.x]
steps:
- uses: actions/checkout@v2

Expand Down
5 changes: 0 additions & 5 deletions .storybook/main.js

This file was deleted.

11 changes: 0 additions & 11 deletions .storybook/preview.js

This file was deleted.

5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- migrated to eslint 9 flat config
- removed obsolete storybook
Comment thread
neotob marked this conversation as resolved.

## [5.13.0] - 2025-10-08

### Changed
Expand Down
4 changes: 4 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import neolutionEslintConfig from "@neolution-ch/eslint-config-neolution";
import storybook from "eslint-plugin-storybook";

export default [...neolutionEslintConfig.configs.flat["react-library"], ...storybook.configs["flat/recommended"]];
16 changes: 6 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"scripts": {
"build": "rollup -c && yarn copy-definitionfile",
"build-storybook": "build-storybook",
"lint": "eslint \"**/*.{ts,tsx}\" --cache --max-warnings 0",
"lint": "eslint --cache",
"prepack": "yarn build",
"prepare-pr": "yarn prettier . --write && yarn lint && yarn build && yarn test\"",
"prettier-check": "prettier --check .",
Expand All @@ -49,6 +49,7 @@
"@dnd-kit/core": "^6.1.0",
"@dnd-kit/modifiers": "^7.0.0",
"@dnd-kit/sortable": "^8.0.0",
"@neolution-ch/eslint-config-neolution": "https://pkg.pr.new/neolution-ch/eslint-config-neolution/@neolution-ch/eslint-config-neolution@18",
Comment thread
neotob marked this conversation as resolved.
Outdated
"@neolution-ch/react-pattern-ui": "^5.3.0",
"@tanstack/react-table": "^8.12.0",
"@tanstack/react-virtual": "^3.13.12",
Expand Down Expand Up @@ -84,17 +85,12 @@
"bootstrap": "^4.0.0",
"concurrently": "^8.0.1",
"cross-env": "^7.0.3",
"eslint": "^8.39.0",
"eslint-config-prettier": "^8.8.0",
"eslint-import-resolver-typescript": "^3.5.5",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-react": "^7.33.2",
"eslint-plugin-react-hooks": "^4.6.0",
"eslint-plugin-storybook": "^0.6.12",
"eslint": "^9.37.0",
"eslint-plugin-storybook": "^0.10.0",
Comment thread
neotob marked this conversation as resolved.
"gh-pages": "^5.0.0",
"jest": "^27.5.1",
"nodemon": "^2.0.22",
"prettier": "^2.8.8",
"prettier": "^3.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"reactstrap": "^8.10.1",
Expand All @@ -118,7 +114,7 @@
"reactstrap": "^8.0.0 || ^9.0.0"
},
"engines": {
"node": ">=14"
"node": ">=18"
},
"publishConfig": {
"access": "public",
Expand Down
4 changes: 1 addition & 3 deletions rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import commonjs from "@rollup/plugin-commonjs";
// eslint-disable-next-line import/no-named-as-default
import nodeResolve from "@rollup/plugin-node-resolve";
Comment thread
manni497 marked this conversation as resolved.
Outdated
import external from "rollup-plugin-peer-deps-external";
import terser from "@rollup/plugin-terser";
Expand Down Expand Up @@ -41,7 +42,6 @@ export default [
sourcemap: true,
globals: { react: "React" },
exports: "named",
sourcemap: true,
interop: "auto",
},
plugins,
Expand All @@ -55,7 +55,6 @@ export default [
sourcemap: true,
globals: { react: "React" },
exports: "named",
sourcemap: true,
},
plugins,
},
Expand All @@ -68,7 +67,6 @@ export default [
sourcemap: true,
globals: { react: "React" },
exports: "named",
sourcemap: true,
},
plugins,
},
Expand Down
10 changes: 7 additions & 3 deletions src/lib/ReactDataTable/ReactDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,20 @@ import { reactDataTableTranslations } from "../translations/translations";
import { ReactDataTableProps } from "./ReactDataTableProps";
import { FilterModel } from "../types/TableState";
import { getModelFromColumnFilter } from "../utils/getModelFromColumnFilter";
import { Fragment } from "react";
import { Fragment, useRef } from "react";
import { DndContext, KeyboardSensor, MouseSensor, TouchSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
import { restrictToVerticalAxis } from "@dnd-kit/modifiers";
import { getCommonPinningStyles } from "../utils/getCommonPinningStyles";
import { getFilterValue, setFilterValue } from "../utils/customFilterMethods";
import { useVirtualizer, Virtualizer } from "@tanstack/react-virtual";
import { useRef } from "react";

Comment thread
manni497 marked this conversation as resolved.
Outdated
import { TableBody } from "./TableBody";

interface TableInternalProps<TData, TFilter extends FilterModel = Record<string, never>> extends ReactDataTableProps<TData, TFilter> {
virtualizer?: Virtualizer<HTMLDivElement, Element>;
}

// eslint-disable-next-line complexity
Comment thread
neotob marked this conversation as resolved.
Outdated
const TableInternal = <TData, TFilter extends FilterModel = Record<string, never>>(props: TableInternalProps<TData, TFilter>) => {
const {
virtualizer,
Expand Down Expand Up @@ -96,6 +97,7 @@ const TableInternal = <TData, TFilter extends FilterModel = Record<string, never
</tr>
{!withoutHeaderFilters && !headerGroup.headers.every((x) => !!x.column.columnDef.meta?.hideHeaderFilters) && (
<tr key={`${headerGroup.id}-col-filters`}>
{/* eslint-disable-next-line complexity */}
{headerGroup.headers.map((header) => {
const {
column: {
Expand Down Expand Up @@ -336,4 +338,6 @@ const ReactDataTable = <TData, TFilter extends FilterModel = Record<string, neve
);
};

export { ReactDataTable, ReactDataTableProps };
export { ReactDataTable };

export { ReactDataTableProps } from "./ReactDataTableProps";
Comment thread
manni497 marked this conversation as resolved.
Outdated
16 changes: 8 additions & 8 deletions src/lib/ReactDataTable/TableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ const TableBody = <TData, TFilter extends FilterModel = Record<string, never>>(p
<DraggableRow<TData, TFilter>
key={index}
row={row}
enableRowClick={enableRowClick as ReactDataTableProps<TData, TFilter>["enableRowClick"]}
onRowClick={onRowClick as ReactDataTableProps<TData, TFilter>["onRowClick"]}
enableRowClick={enableRowClick}
onRowClick={onRowClick}
enableRowSelection={enableRowSelection as boolean | ((row: Row<TData>) => boolean)}
enableExpanding={enableExpanding as boolean | ((row: Row<TData>) => boolean)}
rowStyle={{
...(x.rowStyle ?? {}),
...x.rowStyle,
...(rowStyle ? rowStyle(row.original) : {}),
}}
fullRowSelectable={fullRowSelectable}
subRowComponent={subRowComponent as ReactDataTableProps<TData, TFilter>["subRowComponent"]}
subRowComponent={subRowComponent}
/>
);
})}
Expand All @@ -78,17 +78,17 @@ const TableBody = <TData, TFilter extends FilterModel = Record<string, never>>(p
<InternalTableRow<TData, TFilter>
key={index}
row={row}
enableRowClick={enableRowClick as ReactDataTableProps<TData, TFilter>["enableRowClick"]}
onRowClick={onRowClick as ReactDataTableProps<TData, TFilter>["onRowClick"]}
enableRowClick={enableRowClick}
onRowClick={onRowClick}
enableRowSelection={enableRowSelection as boolean | ((row: Row<TData>) => boolean)}
enableExpanding={enableExpanding as boolean | ((row: Row<TData>) => boolean)}
rowStyle={{
...(x.rowStyle ?? {}),
...x.rowStyle,
...(rowStyle ? rowStyle(row.original) : {}),
}}
fullRowSelectable={fullRowSelectable}
hasPinnedColumns={table.getIsSomeColumnsPinned()}
subRowComponent={subRowComponent as ReactDataTableProps<TData, TFilter>["subRowComponent"]}
subRowComponent={subRowComponent}
/>
);
})}
Expand Down
1 change: 0 additions & 1 deletion src/lib/translations/translations.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/**
* This are the possible translations for the data table
*
* @interface DataTableTranslations
* @property {string} clearSearchToolTip is used to print out the bottom text, possible placeholders are: {from}, {to} and {total}
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ interface useFullyControlledReactDataTableProps<TData, TFilter extends FilterMod

/**
* A helper hook to use the useReactDataTable hook which is fully controlled. Usefull for server side filtering, sorting and pagination.
* @param props The properties to configure the table
* @returns The table instance and the state of the table
*/
const useFullyControlledReactDataTable = <TData, TFilter extends FilterModel>(
props: useFullyControlledReactDataTableProps<TData, TFilter>,
Expand Down
27 changes: 17 additions & 10 deletions src/lib/useReactDataTable/useReactDataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import { useMemo } from "react";

/**
* A react hook that returns a react table instance and the state of the table
* @param props The properties to configure the table
* @returns The table instance and the state of the table
*/
// eslint-disable-next-line complexity
const useReactDataTable = <TData, TFilter extends FilterModel = Record<string, never>>(
props: useReactDataTableProps<TData, TFilter>,
): useReactDataTableResult<TData, TFilter> => {
Expand Down Expand Up @@ -96,14 +99,14 @@ const useReactDataTable = <TData, TFilter extends FilterModel = Record<string, n
const effectiveOnColumnPinningChange = onColumnPinningChange ?? setColumnPinningInternal;

// If we active the manual filtering, we have to unset the filter function, else it still does automatic filtering
if (manualFiltering) columns.forEach((x) => (x.filterFn = undefined));
if (manualFiltering) for (const x of columns) x.filterFn = undefined;
Comment thread
neotob marked this conversation as resolved.

const internalColumns = columns.filter((x) => x.meta?.isHidden !== true);
const skeletonColumns = internalColumns.map((column) => ({
...column,
cell: () => <Skeleton />,
}));
const skeletonData = Array.from({ length: paginationInternal.pageSize }, () => ({} as TData));
const skeletonData = Array.from({ length: paginationInternal.pageSize }, () => ({}) as TData);

const columnFilters = useMemo(() => getColumnFilterFromModel(effectiveColumnFilters), [effectiveColumnFilters]);
const sorting = useMemo(() => getSortingStateFromModel(effectiveSorting), [effectiveSorting]);
Expand All @@ -113,29 +116,29 @@ const useReactDataTable = <TData, TFilter extends FilterModel = Record<string, n
columns: isLoading ? skeletonColumns : internalColumns,

onColumnFiltersChange: (filtersOrUpdaterFn) => {
const newFilter = typeof filtersOrUpdaterFn !== "function" ? filtersOrUpdaterFn : filtersOrUpdaterFn(columnFilters);
const newFilter = typeof filtersOrUpdaterFn === "function" ? filtersOrUpdaterFn(columnFilters) : filtersOrUpdaterFn;
return effectiveOnColumnFiltersChange(getModelFromColumnFilter(newFilter));
},
onPaginationChange: (paginationOrUpdaterFn) => {
const newFilter = typeof paginationOrUpdaterFn !== "function" ? paginationOrUpdaterFn : paginationOrUpdaterFn(effectivePagination);
const newFilter = typeof paginationOrUpdaterFn === "function" ? paginationOrUpdaterFn(effectivePagination) : paginationOrUpdaterFn;
return effectiveOnPaginationChange(newFilter);
},
onSortingChange: (sortingOrUpdaterFn) => {
const newFilter = typeof sortingOrUpdaterFn !== "function" ? sortingOrUpdaterFn : sortingOrUpdaterFn(sorting);
const newFilter = typeof sortingOrUpdaterFn === "function" ? sortingOrUpdaterFn(sorting) : sortingOrUpdaterFn;
return effectiveOnSortingChange(getModelFromSortingState(newFilter));
},
onRowSelectionChange: (rowSelectionOrUpdaterFn) => {
const newRowSelection =
typeof rowSelectionOrUpdaterFn !== "function" ? rowSelectionOrUpdaterFn : rowSelectionOrUpdaterFn(effectiveRowSelection);
typeof rowSelectionOrUpdaterFn === "function" ? rowSelectionOrUpdaterFn(effectiveRowSelection) : rowSelectionOrUpdaterFn;
return effectiveOnRowSelectionChange(newRowSelection);
},
onExpandedChange: (expandedOrUpdaterFn) => {
const newExpanded = typeof expandedOrUpdaterFn !== "function" ? expandedOrUpdaterFn : expandedOrUpdaterFn(effectiveExpanded);
const newExpanded = typeof expandedOrUpdaterFn === "function" ? expandedOrUpdaterFn(effectiveExpanded) : expandedOrUpdaterFn;
return effectiveOnExpandedChange(newExpanded);
},
onColumnPinningChange: (columnPinningOrUpdaterFn) => {
const newColumnPinning =
typeof columnPinningOrUpdaterFn !== "function" ? columnPinningOrUpdaterFn : columnPinningOrUpdaterFn(effectiveColumnPinning);
typeof columnPinningOrUpdaterFn === "function" ? columnPinningOrUpdaterFn(effectiveColumnPinning) : columnPinningOrUpdaterFn;
return effectiveOnColumnPinningChange(newColumnPinning);
},

Expand Down Expand Up @@ -184,7 +187,7 @@ const useReactDataTable = <TData, TFilter extends FilterModel = Record<string, n

return {
table,
columnFilters: effectiveColumnFilters as TFilter,
columnFilters: effectiveColumnFilters,
pagination: effectivePagination,
sorting: effectiveSorting,
rowSelection: effectiveRowSelection,
Expand All @@ -199,4 +202,8 @@ const useReactDataTable = <TData, TFilter extends FilterModel = Record<string, n
};
};

export { useReactDataTable, useReactDataTableProps, useReactDataTableResult };
export { useReactDataTable };

export { useReactDataTableProps } from "./useReactDataTableProps";

export { useReactDataTableResult } from "./useReactDataTableResult";
Comment thread
manni497 marked this conversation as resolved.
Outdated
7 changes: 6 additions & 1 deletion src/lib/useReactDataTableState/useReactDataTableState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OptionalNullable } from "../types/NullableTypes";

/**
* A custom hook that will initialize all the state needed for the react data table
* @param props The properties to configure the initial state
* @returns the state and the setters
*/
const useReactDataTableState = <TData, TFilter extends FilterModel = Record<string, never>>(
Expand Down Expand Up @@ -46,4 +47,8 @@ const useReactDataTableState = <TData, TFilter extends FilterModel = Record<stri
};
};

export { useReactDataTableState, useReactDataTableStateProps, useReactDataTableStateResult };
export { useReactDataTableState };

export { useReactDataTableStateProps } from "./useReactDataTableStateProps";
Comment thread
manni497 marked this conversation as resolved.
Outdated

export { useReactDataTableStateResult } from "./useReactDataTableStateResult";
Loading
Loading