2023-03-30 04:54:29 +00:00
|
|
|
import React, { useCallback, useEffect, useMemo, useRef } from "react";
|
|
|
|
|
import { reduce } from "lodash";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { Row as ReactTableRowType } from "react-table";
|
2022-07-14 07:02:35 +00:00
|
|
|
import {
|
|
|
|
|
useTable,
|
|
|
|
|
usePagination,
|
|
|
|
|
useBlockLayout,
|
|
|
|
|
useResizeColumns,
|
|
|
|
|
useRowSelect,
|
|
|
|
|
} from "react-table";
|
2023-02-15 11:42:46 +00:00
|
|
|
import { useSticky } from "react-table-sticky";
|
2022-07-14 07:02:35 +00:00
|
|
|
import {
|
|
|
|
|
TableWrapper,
|
|
|
|
|
TableHeaderWrapper,
|
|
|
|
|
TableHeaderInnerWrapper,
|
|
|
|
|
} from "./TableStyledWrappers";
|
2022-11-05 09:54:20 +00:00
|
|
|
import TableHeader from "./header";
|
2022-07-14 07:02:35 +00:00
|
|
|
import { Classes } from "@blueprintjs/core";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type {
|
2022-07-14 07:02:35 +00:00
|
|
|
ReactTableColumnProps,
|
|
|
|
|
ReactTableFilter,
|
|
|
|
|
CompactMode,
|
2022-11-05 09:54:20 +00:00
|
|
|
AddNewRowActions,
|
2023-02-15 11:42:46 +00:00
|
|
|
StickyType,
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
} from "./Constants";
|
|
|
|
|
import {
|
|
|
|
|
TABLE_SIZES,
|
|
|
|
|
CompactModeTypes,
|
2023-02-15 11:42:46 +00:00
|
|
|
TABLE_SCROLLBAR_HEIGHT,
|
2022-07-14 07:02:35 +00:00
|
|
|
} from "./Constants";
|
|
|
|
|
import { Colors } from "constants/Colors";
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
import type { EventType } from "constants/AppsmithActionConstants/ActionConstants";
|
|
|
|
|
import type { EditableCell, TableVariant } from "../constants";
|
2023-02-15 11:42:46 +00:00
|
|
|
import SimpleBar from "simplebar-react";
|
|
|
|
|
import "simplebar-react/dist/simplebar.min.css";
|
|
|
|
|
import { createGlobalStyle } from "styled-components";
|
|
|
|
|
import { Classes as PopOver2Classes } from "@blueprintjs/popover2";
|
2023-03-05 14:19:44 +00:00
|
|
|
import StaticTable from "./StaticTable";
|
|
|
|
|
import VirtualTable from "./VirtualTable";
|
|
|
|
|
import fastdom from "fastdom";
|
2023-10-03 08:10:51 +00:00
|
|
|
import { ConnectDataOverlay } from "widgets/ConnectDataOverlay";
|
|
|
|
|
import { TABLE_CONNECT_OVERLAY_TEXT } from "../constants/messages";
|
|
|
|
|
import {
|
|
|
|
|
createMessage,
|
|
|
|
|
CONNECT_BUTTON_TEXT,
|
|
|
|
|
} from "@appsmith/constants/messages";
|
2023-02-15 11:42:46 +00:00
|
|
|
|
|
|
|
|
const SCROLL_BAR_OFFSET = 2;
|
|
|
|
|
const HEADER_MENU_PORTAL_CLASS = ".header-menu-portal";
|
2022-07-14 07:02:35 +00:00
|
|
|
|
2023-02-15 11:42:46 +00:00
|
|
|
const PopoverStyles = createGlobalStyle<{
|
|
|
|
|
widgetId: string;
|
|
|
|
|
borderRadius: string;
|
|
|
|
|
}>`
|
2023-10-03 08:10:51 +00:00
|
|
|
${HEADER_MENU_PORTAL_CLASS}-${({ widgetId }) => widgetId} {
|
|
|
|
|
font-family: var(--wds-font-family) !important;
|
2023-03-05 14:19:44 +00:00
|
|
|
|
2023-10-03 08:10:51 +00:00
|
|
|
& .${PopOver2Classes.POPOVER2},
|
|
|
|
|
.${PopOver2Classes.POPOVER2_CONTENT},
|
|
|
|
|
.bp3-menu {
|
|
|
|
|
border-radius: ${({ borderRadius }) =>
|
|
|
|
|
borderRadius >= `1.5rem` ? `0.375rem` : borderRadius} !important;
|
2023-03-05 14:19:44 +00:00
|
|
|
}
|
2023-10-03 08:10:51 +00:00
|
|
|
}
|
2023-02-15 11:42:46 +00:00
|
|
|
`;
|
2023-10-03 08:10:51 +00:00
|
|
|
|
2023-03-05 14:19:44 +00:00
|
|
|
export interface TableProps {
|
2022-07-14 07:02:35 +00:00
|
|
|
width: number;
|
|
|
|
|
height: number;
|
|
|
|
|
pageSize: number;
|
|
|
|
|
widgetId: string;
|
|
|
|
|
widgetName: string;
|
|
|
|
|
searchKey: string;
|
|
|
|
|
isLoading: boolean;
|
|
|
|
|
columnWidthMap?: { [key: string]: number };
|
|
|
|
|
columns: ReactTableColumnProps[];
|
|
|
|
|
data: Array<Record<string, unknown>>;
|
|
|
|
|
totalRecordsCount?: number;
|
|
|
|
|
editMode: boolean;
|
|
|
|
|
editableCell: EditableCell;
|
|
|
|
|
sortTableColumn: (columnIndex: number, asc: boolean) => void;
|
|
|
|
|
handleResizeColumn: (columnWidthMap: { [key: string]: number }) => void;
|
2023-03-05 14:19:44 +00:00
|
|
|
handleReorderColumn: (columnOrder: string[]) => void;
|
2022-07-14 07:02:35 +00:00
|
|
|
selectTableRow: (row: {
|
|
|
|
|
original: Record<string, unknown>;
|
|
|
|
|
index: number;
|
|
|
|
|
}) => void;
|
|
|
|
|
pageNo: number;
|
|
|
|
|
updatePageNo: (pageNo: number, event?: EventType) => void;
|
|
|
|
|
multiRowSelection?: boolean;
|
|
|
|
|
isSortable?: boolean;
|
|
|
|
|
nextPageClick: () => void;
|
|
|
|
|
prevPageClick: () => void;
|
|
|
|
|
serverSidePaginationEnabled: boolean;
|
|
|
|
|
selectedRowIndex: number;
|
|
|
|
|
selectedRowIndices: number[];
|
|
|
|
|
disableDrag: () => void;
|
|
|
|
|
enableDrag: () => void;
|
|
|
|
|
toggleAllRowSelect: (
|
|
|
|
|
isSelect: boolean,
|
2022-10-06 09:32:09 +00:00
|
|
|
pageData: ReactTableRowType<Record<string, unknown>>[],
|
2022-07-14 07:02:35 +00:00
|
|
|
) => void;
|
|
|
|
|
triggerRowSelection: boolean;
|
|
|
|
|
searchTableData: (searchKey: any) => void;
|
|
|
|
|
filters?: ReactTableFilter[];
|
|
|
|
|
applyFilter: (filters: ReactTableFilter[]) => void;
|
|
|
|
|
compactMode?: CompactMode;
|
|
|
|
|
isVisibleDownload?: boolean;
|
|
|
|
|
isVisibleFilters?: boolean;
|
|
|
|
|
isVisiblePagination?: boolean;
|
|
|
|
|
isVisibleSearch?: boolean;
|
|
|
|
|
delimiter: string;
|
|
|
|
|
accentColor: string;
|
|
|
|
|
borderRadius: string;
|
2022-11-05 09:54:20 +00:00
|
|
|
boxShadow: string;
|
2022-10-14 04:53:31 +00:00
|
|
|
borderWidth?: number;
|
|
|
|
|
borderColor?: string;
|
2022-07-14 07:02:35 +00:00
|
|
|
onBulkEditDiscard: () => void;
|
|
|
|
|
onBulkEditSave: () => void;
|
2022-10-14 04:53:31 +00:00
|
|
|
variant?: TableVariant;
|
2022-10-06 09:32:09 +00:00
|
|
|
primaryColumnId?: string;
|
2022-11-05 09:54:20 +00:00
|
|
|
isAddRowInProgress: boolean;
|
|
|
|
|
allowAddNewRow: boolean;
|
|
|
|
|
onAddNewRow: () => void;
|
|
|
|
|
onAddNewRowAction: (
|
|
|
|
|
type: AddNewRowActions,
|
|
|
|
|
onActionComplete: () => void,
|
|
|
|
|
) => void;
|
|
|
|
|
disabledAddNewRowSave: boolean;
|
2023-02-15 11:42:46 +00:00
|
|
|
handleColumnFreeze?: (columnName: string, sticky?: StickyType) => void;
|
|
|
|
|
canFreezeColumn?: boolean;
|
2023-06-01 17:26:05 +00:00
|
|
|
showConnectDataOverlay: boolean;
|
|
|
|
|
onConnectData: () => void;
|
2022-07-14 07:02:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const defaultColumn = {
|
|
|
|
|
minWidth: 30,
|
|
|
|
|
width: 150,
|
|
|
|
|
};
|
|
|
|
|
|
2023-10-11 07:35:24 +00:00
|
|
|
export interface HeaderComponentProps {
|
2023-02-15 11:42:46 +00:00
|
|
|
enableDrag: () => void;
|
|
|
|
|
disableDrag: () => void;
|
|
|
|
|
multiRowSelection?: boolean;
|
|
|
|
|
handleAllRowSelectClick: (
|
|
|
|
|
e: React.MouseEvent<HTMLDivElement, MouseEvent>,
|
|
|
|
|
) => void;
|
2023-03-05 14:19:44 +00:00
|
|
|
handleReorderColumn: (columnOrder: string[]) => void;
|
|
|
|
|
columnOrder?: string[];
|
2023-02-15 11:42:46 +00:00
|
|
|
accentColor: string;
|
|
|
|
|
borderRadius: string;
|
|
|
|
|
headerGroups: any;
|
|
|
|
|
canFreezeColumn?: boolean;
|
|
|
|
|
editMode: boolean;
|
|
|
|
|
handleColumnFreeze?: (columnName: string, sticky?: StickyType) => void;
|
|
|
|
|
isResizingColumn: React.MutableRefObject<boolean>;
|
|
|
|
|
isSortable?: boolean;
|
|
|
|
|
sortTableColumn: (columnIndex: number, asc: boolean) => void;
|
|
|
|
|
columns: ReactTableColumnProps[];
|
|
|
|
|
width: number;
|
|
|
|
|
subPage: ReactTableRowType<Record<string, unknown>>[];
|
|
|
|
|
prepareRow: any;
|
|
|
|
|
headerWidth?: number;
|
|
|
|
|
rowSelectionState: 0 | 1 | 2 | null;
|
|
|
|
|
widgetId: string;
|
2023-10-11 07:35:24 +00:00
|
|
|
}
|
2022-08-23 06:32:48 +00:00
|
|
|
|
2023-03-30 04:54:29 +00:00
|
|
|
const emptyArr: any = [];
|
2023-06-01 17:26:05 +00:00
|
|
|
|
2022-07-14 07:02:35 +00:00
|
|
|
export function Table(props: TableProps) {
|
|
|
|
|
const isResizingColumn = React.useRef(false);
|
|
|
|
|
const handleResizeColumn = (columnWidths: Record<string, number>) => {
|
|
|
|
|
const columnWidthMap = {
|
|
|
|
|
...props.columnWidthMap,
|
|
|
|
|
...columnWidths,
|
|
|
|
|
};
|
|
|
|
|
for (const i in columnWidthMap) {
|
|
|
|
|
if (columnWidthMap[i] < 60) {
|
|
|
|
|
columnWidthMap[i] = 60;
|
|
|
|
|
} else if (columnWidthMap[i] === undefined) {
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
const columnCounts = props.columns.filter(
|
|
|
|
|
(column) => !column.isHidden,
|
|
|
|
|
).length;
|
2022-07-14 07:02:35 +00:00
|
|
|
columnWidthMap[i] = props.width / columnCounts;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
props.handleResizeColumn(columnWidthMap);
|
|
|
|
|
};
|
2023-06-01 17:26:05 +00:00
|
|
|
const {
|
|
|
|
|
columns,
|
|
|
|
|
data,
|
|
|
|
|
multiRowSelection,
|
|
|
|
|
showConnectDataOverlay,
|
|
|
|
|
toggleAllRowSelect,
|
|
|
|
|
} = props;
|
2023-03-30 04:54:29 +00:00
|
|
|
|
2022-07-14 07:02:35 +00:00
|
|
|
const tableHeadercolumns = React.useMemo(
|
|
|
|
|
() =>
|
2023-03-30 04:54:29 +00:00
|
|
|
columns.filter((column: ReactTableColumnProps) => {
|
2022-07-14 07:02:35 +00:00
|
|
|
return column.alias !== "actions";
|
|
|
|
|
}),
|
2023-03-30 04:54:29 +00:00
|
|
|
[columns],
|
2022-07-14 07:02:35 +00:00
|
|
|
);
|
2023-04-17 11:59:43 +00:00
|
|
|
|
2022-07-14 07:02:35 +00:00
|
|
|
const pageCount =
|
2023-04-17 11:59:43 +00:00
|
|
|
props.serverSidePaginationEnabled && props.totalRecordsCount
|
|
|
|
|
? Math.ceil(props.totalRecordsCount / props.pageSize)
|
2022-07-14 07:02:35 +00:00
|
|
|
: Math.ceil(props.data.length / props.pageSize);
|
|
|
|
|
const currentPageIndex = props.pageNo < pageCount ? props.pageNo : 0;
|
|
|
|
|
const {
|
|
|
|
|
getTableBodyProps,
|
|
|
|
|
getTableProps,
|
|
|
|
|
headerGroups,
|
|
|
|
|
page,
|
|
|
|
|
pageOptions,
|
|
|
|
|
prepareRow,
|
|
|
|
|
state,
|
2023-02-15 11:42:46 +00:00
|
|
|
totalColumnsWidth,
|
2022-07-14 07:02:35 +00:00
|
|
|
} = useTable(
|
|
|
|
|
{
|
2023-03-30 04:54:29 +00:00
|
|
|
//columns and data needs to be memoised as per useTable specs
|
|
|
|
|
columns,
|
2022-07-14 07:02:35 +00:00
|
|
|
data,
|
|
|
|
|
defaultColumn,
|
|
|
|
|
initialState: {
|
|
|
|
|
pageIndex: currentPageIndex,
|
|
|
|
|
pageSize: props.pageSize,
|
|
|
|
|
},
|
|
|
|
|
manualPagination: true,
|
|
|
|
|
pageCount,
|
|
|
|
|
},
|
|
|
|
|
useBlockLayout,
|
|
|
|
|
useResizeColumns,
|
|
|
|
|
usePagination,
|
|
|
|
|
useRowSelect,
|
2023-02-15 11:42:46 +00:00
|
|
|
useSticky,
|
2022-07-14 07:02:35 +00:00
|
|
|
);
|
|
|
|
|
//Set isResizingColumn as true when column is resizing using table state
|
|
|
|
|
if (state.columnResizing.isResizingColumn) {
|
|
|
|
|
isResizingColumn.current = true;
|
|
|
|
|
} else {
|
|
|
|
|
// We are updating column size since the drag is complete when we are changing value of isResizing from true to false
|
|
|
|
|
if (isResizingColumn.current) {
|
2023-03-30 04:54:29 +00:00
|
|
|
//clear timeout logic
|
2022-07-14 07:02:35 +00:00
|
|
|
//update isResizingColumn in next event loop so that dragEnd event does not trigger click event.
|
chore: upgrade to prettier v2 + enforce import types (#21013)Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
## Description
This PR upgrades Prettier to v2 + enforces TypeScript’s [`import
type`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export)
syntax where applicable. It’s submitted as a separate PR so we can merge
it easily.
As a part of this PR, we reformat the codebase heavily:
- add `import type` everywhere where it’s required, and
- re-format the code to account for Prettier 2’s breaking changes:
https://prettier.io/blog/2020/03/21/2.0.0.html#breaking-changes
This PR is submitted against `release` to make sure all new code by team
members will adhere to new formatting standards, and we’ll have fewer
conflicts when merging `bundle-optimizations` into `release`. (I’ll
merge `release` back into `bundle-optimizations` once this PR is
merged.)
### Why is this needed?
This PR is needed because, for the Lodash optimization from
https://github.com/appsmithorg/appsmith/commit/7cbb12af886621256224be0c93e6a465dd710ad3,
we need to use `import type`. Otherwise, `babel-plugin-lodash` complains
that `LoDashStatic` is not a lodash function.
However, just using `import type` in the current codebase will give you
this:
<img width="962" alt="Screenshot 2023-03-08 at 17 45 59"
src="https://user-images.githubusercontent.com/2953267/223775744-407afa0c-e8b9-44a1-90f9-b879348da57f.png">
That’s because Prettier 1 can’t parse `import type` at all. To parse it,
we need to upgrade to Prettier 2.
### Why enforce `import type`?
Apart from just enabling `import type` support, this PR enforces
specifying `import type` everywhere it’s needed. (Developers will get
immediate TypeScript and ESLint errors when they forget to do so.)
I’m doing this because I believe `import type` improves DX and makes
refactorings easier.
Let’s say you had a few imports like below. Can you tell which of these
imports will increase the bundle size? (Tip: it’s not all of them!)
```ts
// app/client/src/workers/Linting/utils.ts
import { Position } from "codemirror";
import { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
It’s pretty hard, right?
What about now?
```ts
// app/client/src/workers/Linting/utils.ts
import type { Position } from "codemirror";
import type { LintError as JSHintError, LintOptions } from "jshint";
import { get, isEmpty, isNumber, keys, last, set } from "lodash";
```
Now, it’s clear that only `lodash` will be bundled.
This helps developers to see which imports are problematic, but it
_also_ helps with refactorings. Now, if you want to see where
`codemirror` is bundled, you can just grep for `import \{.*\} from
"codemirror"` – and you won’t get any type-only imports.
This also helps (some) bundlers. Upon transpiling, TypeScript erases
type-only imports completely. In some environment (not ours), this makes
the bundle smaller, as the bundler doesn’t need to bundle type-only
imports anymore.
## Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## How Has This Been Tested?
This was tested to not break the build.
### Test Plan
> Add Testsmith test cases links that relate to this PR
### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
## Checklist:
### Dev activity
- [x] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag
### QA activity:
- [ ] Test plan has been approved by relevant developers
- [ ] Test plan has been peer reviewed by QA
- [ ] Cypress test cases have been added and approved by either SDET or
manual QA
- [ ] Organized project review call with relevant stakeholders after
Round 1/2 of QA
- [ ] Added Test Plan Approved label after reveiwing all Cypress test
---------
Co-authored-by: Satish Gandham <hello@satishgandham.com>
Co-authored-by: Satish Gandham <satish.iitg@gmail.com>
2023-03-16 11:41:47 +00:00
|
|
|
setTimeout(function () {
|
2022-07-14 07:02:35 +00:00
|
|
|
isResizingColumn.current = false;
|
|
|
|
|
handleResizeColumn(state.columnResizing.columnWidths);
|
|
|
|
|
}, 0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
let startIndex = currentPageIndex * props.pageSize;
|
|
|
|
|
let endIndex = startIndex + props.pageSize;
|
|
|
|
|
if (props.serverSidePaginationEnabled) {
|
|
|
|
|
startIndex = 0;
|
|
|
|
|
endIndex = props.data.length;
|
|
|
|
|
}
|
2023-03-30 04:54:29 +00:00
|
|
|
const subPage = useMemo(
|
|
|
|
|
() => page.slice(startIndex, endIndex),
|
|
|
|
|
[page, startIndex, endIndex],
|
|
|
|
|
);
|
|
|
|
|
const selectedRowIndices = props.selectedRowIndices || emptyArr;
|
2022-07-14 07:02:35 +00:00
|
|
|
const tableSizes = TABLE_SIZES[props.compactMode || CompactModeTypes.DEFAULT];
|
|
|
|
|
const tableWrapperRef = useRef<HTMLDivElement | null>(null);
|
2023-03-05 14:19:44 +00:00
|
|
|
const scrollBarRef = useRef<SimpleBar | null>(null);
|
2022-07-14 07:02:35 +00:00
|
|
|
const tableHeaderWrapperRef = React.createRef<HTMLDivElement>();
|
|
|
|
|
const rowSelectionState = React.useMemo(() => {
|
|
|
|
|
// return : 0; no row selected | 1; all row selected | 2: some rows selected
|
2023-03-30 04:54:29 +00:00
|
|
|
if (!multiRowSelection) return null;
|
2022-07-14 07:02:35 +00:00
|
|
|
const selectedRowCount = reduce(
|
|
|
|
|
page,
|
|
|
|
|
(count, row) => {
|
|
|
|
|
return selectedRowIndices.includes(row.index) ? count + 1 : count;
|
|
|
|
|
},
|
|
|
|
|
0,
|
|
|
|
|
);
|
|
|
|
|
const result =
|
|
|
|
|
selectedRowCount === 0 ? 0 : selectedRowCount === page.length ? 1 : 2;
|
|
|
|
|
return result;
|
2023-03-30 04:54:29 +00:00
|
|
|
}, [multiRowSelection, page, selectedRowIndices]);
|
|
|
|
|
const handleAllRowSelectClick = useCallback(
|
|
|
|
|
(e: React.MouseEvent<HTMLDivElement, MouseEvent>) => {
|
|
|
|
|
// if all / some rows are selected we remove selection on click
|
|
|
|
|
// else select all rows
|
|
|
|
|
toggleAllRowSelect(!Boolean(rowSelectionState), page);
|
|
|
|
|
// loop over subPage rows and toggleRowSelected if required
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
},
|
|
|
|
|
[page, rowSelectionState, toggleAllRowSelect],
|
|
|
|
|
);
|
2022-07-14 07:02:35 +00:00
|
|
|
const isHeaderVisible =
|
|
|
|
|
props.isVisibleSearch ||
|
|
|
|
|
props.isVisibleFilters ||
|
|
|
|
|
props.isVisibleDownload ||
|
2023-01-27 07:32:26 +00:00
|
|
|
props.isVisiblePagination ||
|
|
|
|
|
props.allowAddNewRow;
|
2022-07-14 07:02:35 +00:00
|
|
|
|
2023-02-15 11:42:46 +00:00
|
|
|
const scrollContainerStyles = useMemo(() => {
|
|
|
|
|
return {
|
|
|
|
|
height: isHeaderVisible
|
|
|
|
|
? props.height -
|
|
|
|
|
tableSizes.TABLE_HEADER_HEIGHT -
|
|
|
|
|
TABLE_SCROLLBAR_HEIGHT -
|
|
|
|
|
SCROLL_BAR_OFFSET
|
|
|
|
|
: props.height - TABLE_SCROLLBAR_HEIGHT - SCROLL_BAR_OFFSET,
|
|
|
|
|
};
|
|
|
|
|
}, [isHeaderVisible, props.height, tableSizes.TABLE_HEADER_HEIGHT]);
|
2022-07-14 07:02:35 +00:00
|
|
|
|
2022-10-06 09:32:09 +00:00
|
|
|
const shouldUseVirtual =
|
|
|
|
|
props.serverSidePaginationEnabled &&
|
|
|
|
|
!props.columns.some(
|
|
|
|
|
(column) => !!column.columnProperties.allowCellWrapping,
|
|
|
|
|
);
|
|
|
|
|
|
2022-11-05 09:54:20 +00:00
|
|
|
useEffect(() => {
|
2023-03-05 14:19:44 +00:00
|
|
|
if (props.isAddRowInProgress) {
|
|
|
|
|
fastdom.mutate(() => {
|
|
|
|
|
if (scrollBarRef && scrollBarRef?.current) {
|
|
|
|
|
scrollBarRef.current.getScrollElement().scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
});
|
2022-11-05 09:54:20 +00:00
|
|
|
}
|
|
|
|
|
}, [props.isAddRowInProgress]);
|
|
|
|
|
|
2022-07-14 07:02:35 +00:00
|
|
|
return (
|
2023-06-01 17:26:05 +00:00
|
|
|
<>
|
|
|
|
|
{showConnectDataOverlay && (
|
2023-10-03 08:10:51 +00:00
|
|
|
<ConnectDataOverlay
|
|
|
|
|
btnText={createMessage(CONNECT_BUTTON_TEXT)}
|
|
|
|
|
message={createMessage(TABLE_CONNECT_OVERLAY_TEXT)}
|
|
|
|
|
onConnectData={props.onConnectData}
|
|
|
|
|
/>
|
2023-06-01 17:26:05 +00:00
|
|
|
)}
|
|
|
|
|
<TableWrapper
|
|
|
|
|
accentColor={props.accentColor}
|
|
|
|
|
backgroundColor={Colors.ATHENS_GRAY_DARKER}
|
|
|
|
|
borderColor={props.borderColor}
|
2023-02-15 11:42:46 +00:00
|
|
|
borderRadius={props.borderRadius}
|
2023-06-01 17:26:05 +00:00
|
|
|
borderWidth={props.borderWidth}
|
|
|
|
|
boxShadow={props.boxShadow}
|
|
|
|
|
height={props.height}
|
|
|
|
|
id={`table${props.widgetId}`}
|
|
|
|
|
isAddRowInProgress={props.isAddRowInProgress}
|
|
|
|
|
isHeaderVisible={isHeaderVisible}
|
|
|
|
|
isResizingColumn={isResizingColumn.current}
|
|
|
|
|
multiRowSelection={props.multiRowSelection}
|
|
|
|
|
tableSizes={tableSizes}
|
|
|
|
|
triggerRowSelection={props.triggerRowSelection}
|
|
|
|
|
variant={props.variant}
|
|
|
|
|
width={props.width}
|
|
|
|
|
>
|
|
|
|
|
<PopoverStyles
|
|
|
|
|
borderRadius={props.borderRadius}
|
|
|
|
|
widgetId={props.widgetId}
|
|
|
|
|
/>
|
|
|
|
|
{isHeaderVisible && (
|
|
|
|
|
<SimpleBar
|
|
|
|
|
style={{
|
|
|
|
|
maxHeight: tableSizes.TABLE_HEADER_HEIGHT,
|
|
|
|
|
}}
|
2022-07-14 07:02:35 +00:00
|
|
|
>
|
2023-06-01 17:26:05 +00:00
|
|
|
<TableHeaderWrapper
|
2022-07-14 07:02:35 +00:00
|
|
|
backgroundColor={Colors.WHITE}
|
2023-06-01 17:26:05 +00:00
|
|
|
ref={tableHeaderWrapperRef}
|
2022-07-14 07:02:35 +00:00
|
|
|
serverSidePaginationEnabled={props.serverSidePaginationEnabled}
|
|
|
|
|
tableSizes={tableSizes}
|
|
|
|
|
width={props.width}
|
|
|
|
|
>
|
2023-06-01 17:26:05 +00:00
|
|
|
<TableHeaderInnerWrapper
|
|
|
|
|
backgroundColor={Colors.WHITE}
|
|
|
|
|
serverSidePaginationEnabled={props.serverSidePaginationEnabled}
|
|
|
|
|
tableSizes={tableSizes}
|
|
|
|
|
variant={props.variant}
|
|
|
|
|
width={props.width}
|
|
|
|
|
>
|
|
|
|
|
<TableHeader
|
|
|
|
|
accentColor={props.accentColor}
|
|
|
|
|
allowAddNewRow={props.allowAddNewRow}
|
|
|
|
|
applyFilter={props.applyFilter}
|
|
|
|
|
borderRadius={props.borderRadius}
|
|
|
|
|
boxShadow={props.boxShadow}
|
|
|
|
|
columns={tableHeadercolumns}
|
|
|
|
|
currentPageIndex={currentPageIndex}
|
|
|
|
|
delimiter={props.delimiter}
|
|
|
|
|
disableAddNewRow={!!props.editableCell?.column}
|
|
|
|
|
disabledAddNewRowSave={props.disabledAddNewRowSave}
|
|
|
|
|
filters={props.filters}
|
|
|
|
|
isAddRowInProgress={props.isAddRowInProgress}
|
|
|
|
|
isVisibleDownload={props.isVisibleDownload}
|
|
|
|
|
isVisibleFilters={props.isVisibleFilters}
|
|
|
|
|
isVisiblePagination={props.isVisiblePagination}
|
|
|
|
|
isVisibleSearch={props.isVisibleSearch}
|
|
|
|
|
nextPageClick={props.nextPageClick}
|
|
|
|
|
onAddNewRow={props.onAddNewRow}
|
|
|
|
|
onAddNewRowAction={props.onAddNewRowAction}
|
|
|
|
|
pageCount={pageCount}
|
|
|
|
|
pageNo={props.pageNo}
|
|
|
|
|
pageOptions={pageOptions}
|
|
|
|
|
prevPageClick={props.prevPageClick}
|
|
|
|
|
searchKey={props.searchKey}
|
|
|
|
|
searchTableData={props.searchTableData}
|
|
|
|
|
serverSidePaginationEnabled={
|
|
|
|
|
props.serverSidePaginationEnabled
|
|
|
|
|
}
|
|
|
|
|
tableColumns={columns}
|
|
|
|
|
tableData={data}
|
|
|
|
|
tableSizes={tableSizes}
|
|
|
|
|
totalRecordsCount={props.totalRecordsCount}
|
|
|
|
|
updatePageNo={props.updatePageNo}
|
|
|
|
|
widgetId={props.widgetId}
|
|
|
|
|
widgetName={props.widgetName}
|
|
|
|
|
/>
|
|
|
|
|
</TableHeaderInnerWrapper>
|
|
|
|
|
</TableHeaderWrapper>
|
|
|
|
|
</SimpleBar>
|
|
|
|
|
)}
|
|
|
|
|
<div
|
|
|
|
|
className={
|
|
|
|
|
props.isLoading
|
|
|
|
|
? Classes.SKELETON
|
|
|
|
|
: shouldUseVirtual
|
|
|
|
|
? "tableWrap virtual"
|
|
|
|
|
: "tableWrap"
|
|
|
|
|
}
|
|
|
|
|
ref={tableWrapperRef}
|
|
|
|
|
>
|
|
|
|
|
<div {...getTableProps()} className="table column-freeze">
|
|
|
|
|
{!shouldUseVirtual && (
|
|
|
|
|
<StaticTable
|
2022-07-14 07:02:35 +00:00
|
|
|
accentColor={props.accentColor}
|
|
|
|
|
borderRadius={props.borderRadius}
|
2023-06-01 17:26:05 +00:00
|
|
|
canFreezeColumn={props.canFreezeColumn}
|
|
|
|
|
columns={props.columns}
|
|
|
|
|
disableDrag={props.disableDrag}
|
|
|
|
|
editMode={props.editMode}
|
|
|
|
|
enableDrag={props.enableDrag}
|
|
|
|
|
getTableBodyProps={getTableBodyProps}
|
|
|
|
|
handleAllRowSelectClick={handleAllRowSelectClick}
|
|
|
|
|
handleColumnFreeze={props.handleColumnFreeze}
|
|
|
|
|
handleReorderColumn={props.handleReorderColumn}
|
|
|
|
|
headerGroups={headerGroups}
|
|
|
|
|
height={props.height}
|
2022-11-05 09:54:20 +00:00
|
|
|
isAddRowInProgress={props.isAddRowInProgress}
|
2023-06-01 17:26:05 +00:00
|
|
|
isResizingColumn={isResizingColumn}
|
|
|
|
|
isSortable={props.isSortable}
|
|
|
|
|
multiRowSelection={props?.multiRowSelection}
|
|
|
|
|
pageSize={props.pageSize}
|
|
|
|
|
prepareRow={prepareRow}
|
|
|
|
|
primaryColumnId={props.primaryColumnId}
|
|
|
|
|
ref={scrollBarRef}
|
|
|
|
|
rowSelectionState={rowSelectionState}
|
|
|
|
|
scrollContainerStyles={scrollContainerStyles}
|
|
|
|
|
selectTableRow={props.selectTableRow}
|
|
|
|
|
selectedRowIndex={props.selectedRowIndex}
|
|
|
|
|
selectedRowIndices={props.selectedRowIndices}
|
|
|
|
|
sortTableColumn={props.sortTableColumn}
|
|
|
|
|
subPage={subPage}
|
2022-07-14 07:02:35 +00:00
|
|
|
tableSizes={tableSizes}
|
2023-06-01 17:26:05 +00:00
|
|
|
totalColumnsWidth={totalColumnsWidth}
|
|
|
|
|
useVirtual={shouldUseVirtual}
|
2022-07-14 07:02:35 +00:00
|
|
|
widgetId={props.widgetId}
|
2023-06-01 17:26:05 +00:00
|
|
|
width={props.width}
|
2022-07-14 07:02:35 +00:00
|
|
|
/>
|
2023-06-01 17:26:05 +00:00
|
|
|
)}
|
2023-02-15 11:42:46 +00:00
|
|
|
|
2023-06-01 17:26:05 +00:00
|
|
|
{shouldUseVirtual && (
|
|
|
|
|
<VirtualTable
|
|
|
|
|
accentColor={props.accentColor}
|
|
|
|
|
borderRadius={props.borderRadius}
|
|
|
|
|
canFreezeColumn={props.canFreezeColumn}
|
|
|
|
|
columns={props.columns}
|
|
|
|
|
disableDrag={props.disableDrag}
|
|
|
|
|
editMode={props.editMode}
|
|
|
|
|
enableDrag={props.enableDrag}
|
|
|
|
|
getTableBodyProps={getTableBodyProps}
|
|
|
|
|
handleAllRowSelectClick={handleAllRowSelectClick}
|
|
|
|
|
handleColumnFreeze={props.handleColumnFreeze}
|
|
|
|
|
handleReorderColumn={props.handleReorderColumn}
|
|
|
|
|
headerGroups={headerGroups}
|
|
|
|
|
height={props.height}
|
|
|
|
|
isAddRowInProgress={props.isAddRowInProgress}
|
|
|
|
|
isResizingColumn={isResizingColumn}
|
|
|
|
|
isSortable={props.isSortable}
|
|
|
|
|
multiRowSelection={props?.multiRowSelection}
|
|
|
|
|
pageSize={props.pageSize}
|
|
|
|
|
prepareRow={prepareRow}
|
|
|
|
|
primaryColumnId={props.primaryColumnId}
|
|
|
|
|
ref={scrollBarRef}
|
|
|
|
|
rowSelectionState={rowSelectionState}
|
|
|
|
|
scrollContainerStyles={scrollContainerStyles}
|
|
|
|
|
selectTableRow={props.selectTableRow}
|
|
|
|
|
selectedRowIndex={props.selectedRowIndex}
|
|
|
|
|
selectedRowIndices={props.selectedRowIndices}
|
|
|
|
|
sortTableColumn={props.sortTableColumn}
|
|
|
|
|
subPage={subPage}
|
|
|
|
|
tableSizes={tableSizes}
|
|
|
|
|
totalColumnsWidth={totalColumnsWidth}
|
|
|
|
|
useVirtual={shouldUseVirtual}
|
|
|
|
|
widgetId={props.widgetId}
|
|
|
|
|
width={props.width}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
2023-02-15 11:42:46 +00:00
|
|
|
</div>
|
2023-06-01 17:26:05 +00:00
|
|
|
</TableWrapper>
|
|
|
|
|
</>
|
2022-07-14 07:02:35 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Table;
|