PromucFlow_constructor/app/client/src/widgets/TableWidgetV2/component/Constants.ts

540 lines
13 KiB
TypeScript
Raw Normal View History

import { isString } from "lodash";
import moment from "moment";
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 { IconName } from "@blueprintjs/icons";
import type { Alignment } from "@blueprintjs/core";
import type {
ButtonBorderRadius,
ButtonStyleType,
ButtonVariant,
} from "components/constants";
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 { DropdownOption } from "widgets/SelectWidget/constants";
import type {
ConfigureMenuItems,
MenuItem,
MenuItems,
MenuItemsSource,
} from "widgets/MenuButtonWidget/constants";
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 { ColumnTypes } from "../constants";
import type { TimePrecision } from "widgets/DatePickerWidget2/constants";
fix: Table filter text loses focus when user is typing (#19951) ## Description TL;DR When user types in the input box for table filter, the input loses focus after a 500ms while typing. This is a regression from https://github.com/appsmithorg/appsmith/pull/16904 PR (bug - https://github.com/appsmithorg/appsmith/issues/12638) We were stringifying the whole filter object and using it in the key for each table filter. But when we changed the filter value the key would get updated and hence the filter re-rendered and the text input lost focus. The key was previously set this way to address another bug where the value field of the filter would not update in the DOM although the filter data was correct. The solution to address both these issues was to assign a unique key to the filters. Since the filter data is totally front-end generated we do not have any unique id to use here as the key. So we generate unique id for each filter now and use it as the key. Fixes #18040 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR > Suggested tests >- Verify that value input does not lose focus in table filter >- Verify bug - https://github.com/appsmithorg/appsmith/issues/12638 >- Verify that clearing filters don't reset the current page in the table and only adding and applying a filter resets the page to 1 >- Verify basic filter functionalities ### 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 - [x] I have performed a self-review of my own code - [x] 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
2023-02-09 11:29:06 +00:00
import { generateReactKey } from "widgets/WidgetUtils";
export type TableSizes = {
COLUMN_HEADER_HEIGHT: number;
TABLE_HEADER_HEIGHT: number;
ROW_HEIGHT: number;
ROW_FONT_SIZE: number;
VERTICAL_PADDING: number;
EDIT_ICON_TOP: number;
ROW_VIRTUAL_OFFSET: number;
VERTICAL_EDITOR_PADDING: number;
};
export enum CompactModeTypes {
SHORT = "SHORT",
DEFAULT = "DEFAULT",
TALL = "TALL",
}
export enum CellAlignmentTypes {
LEFT = "LEFT",
RIGHT = "RIGHT",
CENTER = "CENTER",
}
export enum VerticalAlignmentTypes {
TOP = "TOP",
BOTTOM = "BOTTOM",
CENTER = "CENTER",
}
export enum ImageSizes {
DEFAULT = "32px",
MEDIUM = "64px",
LARGE = "128px",
}
export const TABLE_SIZES: { [key: string]: TableSizes } = {
[CompactModeTypes.DEFAULT]: {
COLUMN_HEADER_HEIGHT: 32,
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
TABLE_HEADER_HEIGHT: 40,
ROW_HEIGHT: 40,
ROW_FONT_SIZE: 14,
VERTICAL_PADDING: 6,
VERTICAL_EDITOR_PADDING: 0,
EDIT_ICON_TOP: 10,
ROW_VIRTUAL_OFFSET: 3,
},
[CompactModeTypes.SHORT]: {
COLUMN_HEADER_HEIGHT: 32,
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
TABLE_HEADER_HEIGHT: 40,
ROW_HEIGHT: 30,
ROW_FONT_SIZE: 12,
VERTICAL_PADDING: 0,
VERTICAL_EDITOR_PADDING: 0,
EDIT_ICON_TOP: 5,
ROW_VIRTUAL_OFFSET: 1,
},
[CompactModeTypes.TALL]: {
COLUMN_HEADER_HEIGHT: 32,
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
TABLE_HEADER_HEIGHT: 40,
ROW_HEIGHT: 60,
ROW_FONT_SIZE: 18,
VERTICAL_PADDING: 16,
VERTICAL_EDITOR_PADDING: 16,
EDIT_ICON_TOP: 21,
ROW_VIRTUAL_OFFSET: 3,
},
};
export enum OperatorTypes {
OR = "OR",
AND = "AND",
}
export enum SortOrderTypes {
asc = "asc",
desc = "desc",
}
export interface TableStyles {
cellBackground?: string;
textColor?: string;
textSize?: string;
fontStyle?: string;
horizontalAlignment?: CellAlignment;
verticalAlignment?: VerticalAlignment;
}
export type CompactMode = keyof typeof CompactModeTypes;
export type Condition = keyof typeof ConditionFunctions | "";
export type Operator = keyof typeof OperatorTypes;
export type CellAlignment = keyof typeof CellAlignmentTypes;
export type VerticalAlignment = keyof typeof VerticalAlignmentTypes;
export type ImageSize = keyof typeof ImageSizes;
export interface ReactTableFilter {
fix: Table filter text loses focus when user is typing (#19951) ## Description TL;DR When user types in the input box for table filter, the input loses focus after a 500ms while typing. This is a regression from https://github.com/appsmithorg/appsmith/pull/16904 PR (bug - https://github.com/appsmithorg/appsmith/issues/12638) We were stringifying the whole filter object and using it in the key for each table filter. But when we changed the filter value the key would get updated and hence the filter re-rendered and the text input lost focus. The key was previously set this way to address another bug where the value field of the filter would not update in the DOM although the filter data was correct. The solution to address both these issues was to assign a unique key to the filters. Since the filter data is totally front-end generated we do not have any unique id to use here as the key. So we generate unique id for each filter now and use it as the key. Fixes #18040 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR > Suggested tests >- Verify that value input does not lose focus in table filter >- Verify bug - https://github.com/appsmithorg/appsmith/issues/12638 >- Verify that clearing filters don't reset the current page in the table and only adding and applying a filter resets the page to 1 >- Verify basic filter functionalities ### 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 - [x] I have performed a self-review of my own code - [x] 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
2023-02-09 11:29:06 +00:00
id: string;
column: string;
operator: Operator;
condition: Condition;
value: any;
}
export interface EditActionCellProperties {
discardActionIconName?: IconName;
discardActionLabel?: string;
discardButtonColor: string;
discardButtonVariant: ButtonVariant;
discardBorderRadius: ButtonBorderRadius;
discardIconAlign: Alignment;
isDiscardDisabled?: boolean;
isDiscardVisible?: boolean;
isSaveDisabled?: boolean;
isSaveVisible?: boolean;
saveActionIconName?: IconName;
saveActionLabel?: string;
saveButtonColor: string;
saveButtonVariant: ButtonVariant;
saveBorderRadius: ButtonBorderRadius;
saveIconAlign: Alignment;
}
export interface InlineEditingCellProperties {
isCellEditable: boolean;
hasUnsavedChanges?: boolean;
}
export interface CellWrappingProperties {
allowCellWrapping: boolean;
}
export interface ButtonCellProperties {
buttonVariant: ButtonVariant;
buttonColor?: string;
buttonLabel?: string;
isCompact?: boolean;
iconName?: IconName;
iconAlign?: Alignment;
}
export interface MenuButtonCellProperties {
menuButtonLabel?: string;
menuItems: MenuItems;
menuVariant?: ButtonVariant;
menuColor?: string;
menuButtoniconName?: IconName;
onItemClicked?: (onClick: string | undefined) => void;
menuItemsSource: MenuItemsSource;
configureMenuItems: ConfigureMenuItems;
sourceData?: Array<Record<string, unknown>>;
}
export interface URLCellProperties {
displayText?: string;
}
export interface SelectCellProperties {
isFilterable?: boolean;
serverSideFiltering?: boolean;
placeholderText?: string;
resetFilterTextOnClose?: boolean;
selectOptions?: DropdownOption[];
}
export interface ImageCellProperties {
imageSize?: ImageSize;
}
export interface DateCellProperties {
inputFormat: string;
outputFormat: string;
shortcuts: boolean;
timePrecision?: TimePrecision;
}
export interface BaseCellProperties {
horizontalAlignment?: CellAlignment;
verticalAlignment?: VerticalAlignment;
textSize?: string;
fontStyle?: string;
textColor?: string;
cellBackground?: string;
isVisible?: boolean;
isDisabled?: boolean;
borderRadius: string;
boxShadow: string;
isCellVisible: boolean;
isCellDisabled?: boolean;
}
export interface CellLayoutProperties
extends EditActionCellProperties,
InlineEditingCellProperties,
CellWrappingProperties,
ButtonCellProperties,
URLCellProperties,
MenuButtonCellProperties,
SelectCellProperties,
ImageCellProperties,
DateCellProperties,
BaseCellProperties {}
export interface TableColumnMetaProps {
isHidden: boolean;
format?: string;
inputFormat?: string;
type: ColumnTypes;
}
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
export enum StickyType {
LEFT = "left",
RIGHT = "right",
NONE = "",
}
export interface TableColumnProps {
id: string;
Header: string;
alias: string;
accessor: any;
width?: number;
minWidth: number;
draggable: boolean;
isHidden?: boolean;
isAscOrder?: boolean;
metaProperties?: TableColumnMetaProps;
isDerived?: boolean;
columnProperties: ColumnProperties;
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
sticky?: StickyType;
}
export interface ReactTableColumnProps extends TableColumnProps {
Cell: (props: any) => JSX.Element;
}
export interface ColumnBaseProperties {
id: string;
originalId: string;
label?: string;
columnType: string;
isVisible: boolean;
isDisabled?: boolean;
index: number;
enableFilter?: boolean;
enableSort?: boolean;
isDerived: boolean;
computedValue: string;
isCellVisible?: boolean;
isAscOrder?: boolean;
alias: string;
allowCellWrapping: boolean;
}
export interface ColumnStyleProperties {
width: number;
cellBackground?: string;
horizontalAlignment?: CellAlignment;
verticalAlignment?: VerticalAlignment;
textSize?: string;
fontStyle?: string;
textColor?: string;
}
export interface DateColumnProperties {
outputFormat?: string;
inputFormat?: string;
shortcuts?: boolean;
timePrecision?: TimePrecision;
}
export interface ColumnEditabilityProperties {
isCellEditable: boolean; // Cell level editability
isEditable: boolean; // column level edtitability
validation?: {
regex?: string;
isEditableCellValid?: boolean;
errorMessage?: string;
isEditableCellRequired?: boolean;
min?: number;
max?: number;
minDate?: string;
maxDate?: string;
};
}
export interface EditActionColumnProperties {
saveButtonVariant?: ButtonVariant;
saveButtonColor?: string;
saveIconAlign?: Alignment;
saveBorderRadius?: ButtonBorderRadius;
saveActionIconName?: string;
saveActionLabel?: string;
isSaveVisible?: boolean;
isSaveDisabled?: boolean;
discardButtonVariant?: ButtonVariant;
discardButtonColor?: string;
discardIconAlign?: Alignment;
discardBorderRadius?: ButtonBorderRadius;
discardActionLabel?: string;
discardActionIconName?: string;
isDiscardVisible?: boolean;
isDiscardDisabled?: boolean;
isFilterable?: boolean;
serverSideFiltering?: boolean;
placeholderText?: string;
resetFilterTextOnClose?: boolean;
selectOptions?: DropdownOption[] | DropdownOption[][];
}
export interface ColumnProperties
extends ColumnBaseProperties,
ColumnStyleProperties,
DateColumnProperties,
ColumnEditabilityProperties,
EditActionColumnProperties {
fix: add select options field to new row (#22003) ## Description This PR introduces new two new properties: `Same options in new row` and `New row options` for the select column type. We show these two fields when the allow add new row is turned on in table - SameOptionsInNewRow -- Boolean field ; When turned on the option for the first row is used in the new row. Default is true - Label : Use same options in new row - Tooltip : Toggle to display same choices for new row and editing existing row in column. - NewRowOptions -- Array field; when the above boolean is turned off we show this option to let people add options specifically for new row. Supports static and dynamic data, but doesn't support currentRow - Label: New row options - Tooltip : Options exclusively displayed in the column for new row addition. Fixes #20230 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Cypress: - When allowAddNewRow is turned on, same new option should be true and new row option should be invisible. - When turned on same option, options of the first row should appear while editing as well as adding new row. - When turned off, New row option should be visible - Fill new row options, the new row options should appear while adding new row in select field. - New row options should not have access to the currentRow - Both the options should only be visible only when allowNewRow is true. - Should support static and dynamic values in new row options - Manual - For the new DnD Tables. Check if the above functionality is working as expected. - For Existing tables, Check if the above functionality is working as expected. This needed to be tested from migration standpoint ### Test Plan > https://github.com/appsmithorg/TestSmith/issues/2367 ### 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 - [x] I have performed a self-review of my own code - [x] 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 - [x] 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
2023-04-06 18:28:24 +00:00
allowSameOptionsInNewRow?: boolean;
newRowSelectOptions?: DropdownOption[];
buttonLabel?: string;
menuButtonLabel?: string;
buttonColor?: string;
onClick?: string;
dropdownOptions?: string;
onOptionChange?: string;
displayText?: string;
buttonVariant?: ButtonVariant;
isCompact?: boolean;
menuItems?: MenuItems;
menuVariant?: ButtonVariant;
menuColor?: string;
borderRadius?: ButtonBorderRadius;
boxShadow?: string;
boxShadowColor?: string;
iconName?: IconName;
menuButtoniconName?: IconName;
iconAlign?: Alignment;
onItemClicked?: (onClick: string | undefined) => void;
iconButtonStyle?: ButtonStyleType;
imageSize?: ImageSize;
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
sticky?: StickyType;
getVisibleItems?: () => Array<MenuItem>;
menuItemsSource?: MenuItemsSource;
configureMenuItems?: ConfigureMenuItems;
sourceData?: Array<Record<string, unknown>>;
}
export const ConditionFunctions: {
[key: string]: (a: any, b: any) => boolean;
} = {
isExactly: (a: any, b: any) => {
return a.toString() === b.toString();
},
empty: (a: any) => {
return a === "" || a === undefined || a === null;
},
notEmpty: (a: any) => {
return a !== "" && a !== undefined && a !== null;
},
notEqualTo: (a: any, b: any) => {
return a.toString() !== b.toString();
},
isEqualTo: (a: any, b: any) => {
return a.toString() === b.toString();
},
lessThan: (a: any, b: any) => {
const numericB = Number(b);
const numericA = Number(a);
return numericA < numericB;
},
lessThanEqualTo: (a: any, b: any) => {
const numericB = Number(b);
const numericA = Number(a);
return numericA <= numericB;
},
greaterThan: (a: any, b: any) => {
const numericB = Number(b);
const numericA = Number(a);
return numericA > numericB;
},
greaterThanEqualTo: (a: any, b: any) => {
const numericB = Number(b);
const numericA = Number(a);
return numericA >= numericB;
},
contains: (a: any, b: any) => {
if (isString(a) && isString(b)) {
return a.includes(b);
}
return false;
},
doesNotContain: (a: any, b: any) => {
if (isString(a) && isString(b)) {
return !a.includes(b);
}
return false;
},
startsWith: (a: any, b: any) => {
if (isString(a) && isString(b)) {
return a.indexOf(b) === 0;
}
return false;
},
endsWith: (a: any, b: any) => {
if (isString(a) && isString(b)) {
return a.length === a.lastIndexOf(b) + b.length;
}
return false;
},
is: (a: any, b: any) => {
return moment(a).isSame(moment(b), "d");
},
isNot: (a: any, b: any) => {
return !moment(a).isSame(moment(b), "d");
},
isAfter: (a: any, b: any) => {
return !moment(a).isAfter(moment(b), "d");
},
isBefore: (a: any, b: any) => {
return !moment(a).isBefore(moment(b), "d");
},
};
export enum JUSTIFY_CONTENT {
LEFT = "flex-start",
CENTER = "center",
RIGHT = "flex-end",
}
export enum TEXT_ALIGN {
LEFT = "left",
CENTER = "center",
RIGHT = "right",
}
export enum ALIGN_ITEMS {
TOP = "flex-start",
CENTER = "center",
BOTTOM = "flex-end",
}
export enum IMAGE_HORIZONTAL_ALIGN {
LEFT = "flex-start",
CENTER = "center",
RIGHT = "flex-end",
}
export enum IMAGE_VERTICAL_ALIGN {
TOP = "flex-start",
CENTER = "center",
BOTTOM = "flex-end",
}
export type BaseCellComponentProps = {
compactMode: string;
isHidden: boolean;
allowCellWrapping?: boolean;
horizontalAlignment?: CellAlignment;
verticalAlignment?: VerticalAlignment;
cellBackground?: string;
isCellVisible: boolean;
fontStyle?: string;
textColor?: string;
textSize?: string;
isCellDisabled?: boolean;
};
export enum CheckboxState {
UNCHECKED = 0,
CHECKED = 1,
PARTIAL = 2,
}
export const scrollbarOnHoverCSS = `
.track-horizontal {
height: 6px;
bottom: 1px;
width: 100%;
opacity: 0;
transition: opacity 0.15s ease-in;
&:active {
opacity: 1;
}
}
&:hover {
.track-horizontal {
opacity: 1;
}
}
.thumb-horizontal {
&:hover, &:active {
height: 6px !important;
}
}
`;
export const MULTISELECT_CHECKBOX_WIDTH = 40;
export enum AddNewRowActions {
SAVE = "SAVE",
DISCARD = "DISCARD",
}
export const EDITABLE_CELL_PADDING_OFFSET = 8;
fix: Table filter text loses focus when user is typing (#19951) ## Description TL;DR When user types in the input box for table filter, the input loses focus after a 500ms while typing. This is a regression from https://github.com/appsmithorg/appsmith/pull/16904 PR (bug - https://github.com/appsmithorg/appsmith/issues/12638) We were stringifying the whole filter object and using it in the key for each table filter. But when we changed the filter value the key would get updated and hence the filter re-rendered and the text input lost focus. The key was previously set this way to address another bug where the value field of the filter would not update in the DOM although the filter data was correct. The solution to address both these issues was to assign a unique key to the filters. Since the filter data is totally front-end generated we do not have any unique id to use here as the key. So we generate unique id for each filter now and use it as the key. Fixes #18040 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR > Suggested tests >- Verify that value input does not lose focus in table filter >- Verify bug - https://github.com/appsmithorg/appsmith/issues/12638 >- Verify that clearing filters don't reset the current page in the table and only adding and applying a filter resets the page to 1 >- Verify basic filter functionalities ### 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 - [x] I have performed a self-review of my own code - [x] 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
2023-02-09 11:29:06 +00:00
feat: added column freeze and unfreeze functionality to table widget (#18757) **PRD**: https://www.notion.so/appsmith/Ability-to-freeze-columns-dd118f7ed2e14e008ee305056b79874a?d=300f4968889244da9f737e1bfd8c06dc#2ddaf28e10a0475cb69f1af77b938d0b This PR adds the following features to the table widget: - Freeze the columns to the left or right of the table.(Both canvas and page view mode). - Unfreeze the frozen columns. (Both canvas and page view mode). - Columns that are left frozen, will get unfrozen at a position after the last left frozen column. (Both canvas and page view mode). - Columns that are right frozen, will get unfrozen at a position before the first right frozen column. (Both canvas and page view mode). - Column order can be persisted in the Page view mode. - Users can also unfreeze the columns that are frozen by the developers. - Columns that are frozen cannot be reordered(Both canvas and page view mode) - **Property pane changes (Columns property)**: - If the column is frozen to the left then that column should appear at top of the list. - If the column is frozen to the right then that column should appear at the bottom of the list. - The columns that are frozen cannot be moved or re-ordered in the list. They remain fixed in their position. - In-Page mode, If there is a change in frozen or unfrozen columns in multiple tables then the order of columns and frozen and unfrozen columns should get persisted on refresh i.e. changes should get persisted across refreshes.
2023-02-15 11:42:46 +00:00
export const TABLE_SCROLLBAR_WIDTH = 10;
export const TABLE_SCROLLBAR_HEIGHT = 8;
export const POPOVER_ITEMS_TEXT_MAP = {
SORT_ASC: "Sort column ascending",
SORT_DSC: "Sort column descending",
FREEZE_LEFT: "Freeze column left",
FREEZE_RIGHT: "Freeze column right",
};
export const HEADER_MENU_PORTAL_CLASS = ".header-menu-portal";
export const MENU_CONTENT_CLASS = ".menu-content";
fix: Table filter text loses focus when user is typing (#19951) ## Description TL;DR When user types in the input box for table filter, the input loses focus after a 500ms while typing. This is a regression from https://github.com/appsmithorg/appsmith/pull/16904 PR (bug - https://github.com/appsmithorg/appsmith/issues/12638) We were stringifying the whole filter object and using it in the key for each table filter. But when we changed the filter value the key would get updated and hence the filter re-rendered and the text input lost focus. The key was previously set this way to address another bug where the value field of the filter would not update in the DOM although the filter data was correct. The solution to address both these issues was to assign a unique key to the filters. Since the filter data is totally front-end generated we do not have any unique id to use here as the key. So we generate unique id for each filter now and use it as the key. Fixes #18040 ## Type of change - Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? - Manual ### Test Plan > Add Testsmith test cases links that relate to this PR > Suggested tests >- Verify that value input does not lose focus in table filter >- Verify bug - https://github.com/appsmithorg/appsmith/issues/12638 >- Verify that clearing filters don't reset the current page in the table and only adding and applying a filter resets the page to 1 >- Verify basic filter functionalities ### 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 - [x] I have performed a self-review of my own code - [x] 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
2023-02-09 11:29:06 +00:00
export const DEFAULT_FILTER = {
id: generateReactKey(),
column: "",
operator: OperatorTypes.OR,
value: "",
condition: "",
};