Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: infinite tree #23

Merged
merged 31 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
ecbf711
feat: adjustments for restoring column state
mguellsegarra Jul 30, 2024
2e55cca
chore: remove comments
mguellsegarra Jul 30, 2024
dda47a6
fix: undefined array
mguellsegarra Jul 31, 2024
1ff86fd
fix: weird bug
mguellsegarra Jul 31, 2024
cd51e63
fix: try to debug weird bug
mguellsegarra Jul 31, 2024
d4c9c36
fix: weird bug debugging
mguellsegarra Jul 31, 2024
5c8057d
fix: debug weird ag grid issue
mguellsegarra Jul 31, 2024
ebc01a5
fix: debug ag grid bug
mguellsegarra Jul 31, 2024
cf15324
fix: debug weird bug
mguellsegarra Jul 31, 2024
2da6076
fix: try to debug weird production only glitch
mguellsegarra Jul 31, 2024
440e6dc
fix: suppressDragLeaveHidesColumns adjustment
mguellsegarra Aug 14, 2024
fa0ac55
fix: try to fix weird order bug
mguellsegarra Aug 14, 2024
4561cb3
fix: more adjustments
mguellsegarra Aug 14, 2024
79dae82
Merge branch 'feat/user-view-prefs' into feat/sort-columns
mguellsegarra Aug 15, 2024
c2c2407
feat: add sort feature to columns
mguellsegarra Aug 15, 2024
0965d90
fix: improvements in sort columns feature
mguellsegarra Aug 28, 2024
eb2f9be
Merge branch 'feat/sort-columns' into feat/infinite-tree
mguellsegarra Aug 28, 2024
543df4a
Merge branch 'v2' into feat/infinite-tree
mguellsegarra Sep 17, 2024
89e483d
feat: improve restoring scroll position in infinite tables
mguellsegarra Sep 20, 2024
cf9386e
feat: performance issues
mguellsegarra Sep 20, 2024
539b4dd
feat: add hook useWhyDidYouRender
mguellsegarra Sep 20, 2024
eff90b3
feat: improve rerenders
mguellsegarra Sep 20, 2024
d69e0a5
feat: more adjustmetns
mguellsegarra Sep 20, 2024
7647bfb
feat: work in selecting all rows
mguellsegarra Sep 20, 2024
5fae7ff
feat: changes in selection
mguellsegarra Sep 21, 2024
7743162
fix: getRows out of sync
mguellsegarra Sep 21, 2024
ccdb564
fix: ditch unused hook
mguellsegarra Sep 21, 2024
23b0c2a
fix: rendering glitch solved
mguellsegarra Sep 21, 2024
a5ae697
fix: adjust block sizes for performance
mguellsegarra Sep 23, 2024
d68015c
fix: adjust few things in infinite table
mguellsegarra Sep 23, 2024
fe2ed62
fix: more tweaks and adjustments in infinite table
mguellsegarra Sep 24, 2024
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
101 changes: 50 additions & 51 deletions src/components/InfiniteTable/HeaderCheckbox.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
import React, { memo, useEffect } from "react";
import React, { memo, useEffect, useCallback } from "react";

interface HeaderCheckboxCompProps {
value: boolean | null;
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
}

const HeaderCheckboxComp = memo(
({
value,
onChange,
}: {
value: boolean | null;
onChange: (value: boolean | null) => void;
}) => {
const checkboxRef = React.useRef();
({ value, onChange }: HeaderCheckboxCompProps) => {
const checkboxRef = React.useRef<HTMLInputElement>(null);

useEffect(() => {
const cbRef = checkboxRef.current as any;

if (value === true) {
cbRef.checked = true;
cbRef.indeterminate = false;
} else if (value === false) {
cbRef.checked = false;
cbRef.indeterminate = false;
} else if (value === null) {
cbRef.checked = false;
cbRef.indeterminate = true;
const cbRef = checkboxRef.current;
if (cbRef) {
if (value === true) {
cbRef.checked = true;
cbRef.indeterminate = false;
} else if (value === false) {
cbRef.checked = false;
cbRef.indeterminate = false;
} else if (value === null) {
cbRef.checked = false;
cbRef.indeterminate = true;
}
}
});
}, [value]);

const handleChange = useCallback(
(event: React.ChangeEvent<HTMLInputElement>) => {
onChange(event);
},
[onChange],
);

return (
<input
Expand All @@ -37,9 +44,10 @@ const HeaderCheckboxComp = memo(
onDoubleClick={(e) => {
e.stopPropagation();
}}
ref={checkboxRef as any}
ref={checkboxRef}
type="checkbox"
onChange={onChange as any}
onChange={handleChange}
checked={value === true}
tabIndex={-1}
/>
);
Expand All @@ -48,40 +56,31 @@ const HeaderCheckboxComp = memo(

HeaderCheckboxComp.displayName = "HeaderCheckboxComp";

interface HeaderCheckboxProps {
selectedRowKeysLength: number;
totalRows: number;
onSelectionCheckboxClicked?: (
event: React.ChangeEvent<HTMLInputElement>,
) => void;
}

export const HeaderCheckbox = memo(
({
selectedRowKeysLength,
totalRows,
allRowSelected,
onHeaderCheckboxChange,
allRowSelectedMode,
}: {
selectedRowKeysLength: number;
totalRows: number;
allRowSelected: boolean;
onHeaderCheckboxChange: (value: boolean | null) => void;
allRowSelectedMode: boolean;
}) => {
const noRowsSelected = selectedRowKeysLength === 0;
const someRowsSelected =
selectedRowKeysLength > 0 && totalRows !== selectedRowKeysLength;

let value: boolean | null = false;

if (allRowSelectedMode) {
value = true;
} else if (totalRows === selectedRowKeysLength && totalRows > 0) {
value = true;
} else if (allRowSelected) {
value = true;
} else if (noRowsSelected) {
value = false;
} else if (someRowsSelected) {
value = null;
}
onSelectionCheckboxClicked,
}: HeaderCheckboxProps) => {
const value = React.useMemo(() => {
if (selectedRowKeysLength === 0) return false;
if (selectedRowKeysLength === totalRows && totalRows > 0) return true;
return null;
}, [selectedRowKeysLength, totalRows]);

return (
<HeaderCheckboxComp value={value} onChange={onHeaderCheckboxChange} />
<HeaderCheckboxComp
value={value}
onChange={onSelectionCheckboxClicked!}
/>
);
},
);
Expand Down
Loading
Loading