@@ -113,7 +117,7 @@ export const EmptyRows = (props: {
prepareRow,
rows,
width,
- } = useContext(BodyContext);
+ } = useContext(TableBodyContext);
return (
<>
@@ -141,7 +145,7 @@ export const EmptyRow = (props: { style?: CSSProperties }) => {
prepareRow,
rows,
width,
- } = useContext(BodyContext);
+ } = useContext(TableBodyContext);
return renderEmptyRows(
1,
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/StaticTableBody.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/StaticTableBody.tsx
index 3030999e5053..e7edf832aa59 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/StaticTableBody.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/StaticTableBody.tsx
@@ -1,6 +1,19 @@
import React from "react";
import { EmptyRows, Row } from "./Row";
-import type { StaticTableProps } from "./types";
+import type {
+ TableBodyProps,
+ TableBodyPropGetter,
+ Row as ReactTableRowType,
+} from "react-table";
+
+export interface StaticTableProps {
+ getTableBodyProps(
+ propGetter?: TableBodyPropGetter
> | undefined,
+ ): TableBodyProps;
+ pageSize: number;
+ rows: ReactTableRowType>[];
+ height: number;
+}
export const StaticTableBody = (props: StaticTableProps) => {
return (
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/VirtualTableBody.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/VirtualTableBody.tsx
index 4aae1d28920b..1137ed82891e 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/VirtualTableBody.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/VirtualTableBody.tsx
@@ -1,11 +1,16 @@
import React, { useCallback } from "react";
import { useLayoutEffect, useRef } from "react";
-import type { VirtualTableBodyProps } from "./types";
-
+import type { ReactElementType } from "react-window";
+import { useResizeObserver } from "@react-aria/utils";
import { FixedSizeList, areEqual } from "react-window";
import type { ListChildComponentProps } from "react-window";
+
import { Row, EmptyRow } from "./Row";
-import { useResizeObserver } from "@react-aria/utils";
+import type { StaticTableProps } from "./StaticTableBody";
+
+export interface VirtualTableBodyProps extends StaticTableProps {
+ innerElementType?: ReactElementType;
+}
export const VirtualTableBody = (props: VirtualTableBodyProps) => {
const ref = useRef(null);
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/context.ts b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/context.ts
new file mode 100644
index 000000000000..bcccab3287fb
--- /dev/null
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/context.ts
@@ -0,0 +1,45 @@
+import type {
+ Row as ReactTableRowType,
+ TableBodyPropGetter,
+ TableBodyProps,
+} from "react-table";
+import React from "react";
+
+import type { HeaderComponentProps } from "../Table";
+import type { ReactTableColumnProps } from "../Constants";
+
+export type TableBodyContextType = {
+ accentColor: string;
+ borderRadius: string;
+ multiRowSelection: boolean;
+ prepareRow?(row: ReactTableRowType>): void;
+ selectTableRow?: (row: {
+ original: Record;
+ index: number;
+ }) => void;
+ selectedRowIndex: number;
+ selectedRowIndices: number[];
+ columns: ReactTableColumnProps[];
+ width: number;
+ rows: ReactTableRowType>[];
+ primaryColumnId?: string;
+ isAddRowInProgress: boolean;
+ getTableBodyProps?(
+ propGetter?: TableBodyPropGetter> | undefined,
+ ): TableBodyProps;
+ totalColumnsWidth?: number;
+} & Partial;
+
+export const TableBodyContext = React.createContext({
+ accentColor: "",
+ borderRadius: "",
+ multiRowSelection: false,
+ selectedRowIndex: -1,
+ selectedRowIndices: [],
+ columns: [],
+ width: 0,
+ rows: [],
+ primaryColumnId: "",
+ isAddRowInProgress: false,
+ totalColumnsWidth: 0,
+});
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/index.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/index.tsx
index ee33c93a8ff8..b68e0d62d55b 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/index.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/index.tsx
@@ -1,53 +1,13 @@
import React from "react";
-import type {
- Row as ReactTableRowType,
- TableBodyPropGetter,
- TableBodyProps,
-} from "react-table";
-import type { ReactTableColumnProps } from "../Constants";
-import type { HeaderComponentProps } from "../Table";
+
+import { TableBodyContext } from "./context";
import { StaticTableBody } from "./StaticTableBody";
+import type { TableBodyContextType } from "./context";
+import type { VirtualTableBodyProps } from "./VirtualTableBody";
import { VirtualTableBody } from "./VirtualTableBody";
-import type { VirtualTableBodyProps } from "./types";
-
-export type BodyContextType = {
- accentColor: string;
- borderRadius: string;
- multiRowSelection: boolean;
- prepareRow?(row: ReactTableRowType>): void;
- selectTableRow?: (row: {
- original: Record;
- index: number;
- }) => void;
- selectedRowIndex: number;
- selectedRowIndices: number[];
- columns: ReactTableColumnProps[];
- width: number;
- rows: ReactTableRowType>[];
- primaryColumnId?: string;
- isAddRowInProgress: boolean;
- getTableBodyProps?(
- propGetter?: TableBodyPropGetter> | undefined,
- ): TableBodyProps;
- totalColumnsWidth?: number;
-} & Partial;
-
-export const BodyContext = React.createContext({
- accentColor: "",
- borderRadius: "",
- multiRowSelection: false,
- selectedRowIndex: -1,
- selectedRowIndices: [],
- columns: [],
- width: 0,
- rows: [],
- primaryColumnId: "",
- isAddRowInProgress: false,
- totalColumnsWidth: 0,
-});
export const TableBody = (
- props: VirtualTableBodyProps & BodyContextType & { useVirtual: boolean },
+ props: VirtualTableBodyProps & TableBodyContextType & { useVirtual: boolean },
) => {
const {
accentColor,
@@ -81,7 +41,7 @@ export const TableBody = (
} = props;
return (
-
{useVirtual ? (
-
+
) : (
)}
-
+
);
};
+
+export { TableBodyContext };
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/types.ts b/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/types.ts
deleted file mode 100644
index e1698391936c..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableBody/types.ts
+++ /dev/null
@@ -1,20 +0,0 @@
-import type {
- TableBodyProps,
- TableBodyPropGetter,
- Row as ReactTableRowType,
-} from "react-table";
-import type { ReactElementType } from "react-window";
-
-export interface StaticTableProps {
- getTableBodyProps(
- propGetter?: TableBodyPropGetter> | undefined,
- ): TableBodyProps;
- pageSize: number;
- rows: ReactTableRowType>[];
- height: number;
- width?: number;
-}
-
-export interface VirtualTableBodyProps extends StaticTableProps {
- innerElementType?: ReactElementType;
-}
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Actions.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Actions.tsx
deleted file mode 100644
index ef3817d122d6..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Actions.tsx
+++ /dev/null
@@ -1,155 +0,0 @@
-import { ActionGroup, Item } from "@design-system/widgets";
-import type { Key } from "react";
-import React, { useCallback } from "react";
-import type {
- ReactTableColumnProps,
- TableSizes,
- ReactTableFilter,
-} from "../Constants";
-import type { EventType } from "constants/AppsmithActionConstants/ActionConstants";
-import {
- downloadDataAsCSV,
- transformTableDataIntoCsv,
- transformTableDataIntoExcel,
-} from "../utilities";
-import zipcelx from "zipcelx";
-import { useDispatch } from "react-redux";
-import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
-
-export interface ActionsPropsType {
- updatePageNo: (pageNo: number, event?: EventType) => void;
- nextPageClick: () => void;
- prevPageClick: () => void;
- pageNo: number;
- totalRecordsCount?: number;
- tableData: Array>;
- tableColumns: ReactTableColumnProps[];
- pageCount: number;
- currentPageIndex: number;
- pageOptions: number[];
- columns: ReactTableColumnProps[];
- hiddenColumns?: string[];
- widgetName: string;
- widgetId: string;
- serverSidePaginationEnabled: boolean;
- filters?: ReactTableFilter[];
- applyFilter: (filters: ReactTableFilter[]) => void;
- tableSizes: TableSizes;
- isVisibleDownload?: boolean;
- isVisibleFilters?: boolean;
- isVisiblePagination?: boolean;
- delimiter: string;
- allowAddNewRow: boolean;
- onAddNewRow: () => void;
- disableAddNewRow: boolean;
- width: number;
-}
-
-export const Actions = (props: ActionsPropsType) => {
- const dispatch = useDispatch();
- const { allowAddNewRow, isVisibleDownload, isVisibleFilters, widgetId } =
- props;
-
- const toggleFilterPane = useCallback(
- (selected: boolean) => {
- if (selected) {
- dispatch({
- type: ReduxActionTypes.SHOW_TABLE_FILTER_PANE,
- payload: { widgetId, force: true },
- });
- } else {
- dispatch({
- type: ReduxActionTypes.HIDE_TABLE_FILTER_PANE,
- payload: { widgetId },
- });
- }
- },
- [widgetId],
- );
-
- // if no columns are present, return
- if (!props.columns.length) return null;
-
- // if none of the actions are visible, return
- if (!(isVisibleFilters || isVisibleDownload || allowAddNewRow)) return null;
-
- const onAction = (key: Key) => {
- switch (key) {
- case "filter":
- toggleFilterPane(true);
- break;
- case "add-row":
- props.onAddNewRow();
- break;
- case "download-csv":
- const csvData = transformTableDataIntoCsv({
- columns: props.columns,
- data: props.tableData,
- });
-
- downloadDataAsCSV({
- csvData: csvData,
- delimiter: props.delimiter,
- fileName: `${props.widgetName}.csv`,
- });
- break;
- case "download-excel":
- const tableData = transformTableDataIntoExcel({
- columns: props.columns,
- data: props.tableData,
- });
-
- zipcelx({
- filename: props.widgetName,
- sheet: {
- data: tableData,
- },
- });
- break;
- default:
- break;
- }
- };
-
- const actionItems = (() => {
- const items = [];
-
- if (isVisibleFilters)
- items.push(
- -
- Filters
-
,
- );
- if (isVisibleDownload) {
- items.push(
- -
- CSV
-
,
- );
- items.push(
- -
- Excel
-
,
- );
- }
- if (allowAddNewRow)
- items.push(
- -
- Add Row
-
,
- );
-
- return items;
- })();
-
- return (
-
- {actionItems}
-
- );
-};
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/AddNewRowBanner.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/AddNewRowBanner.tsx
deleted file mode 100644
index feb95b29bf87..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/AddNewRowBanner.tsx
+++ /dev/null
@@ -1,56 +0,0 @@
-import React, { useState } from "react";
-import { Text, Button, Flex } from "@design-system/widgets";
-
-import { AddNewRowActions } from "../Constants";
-
-export interface AddNewRowBannerProps {
- onAddNewRowAction: (
- type: AddNewRowActions,
- onActionComplete: () => void,
- ) => void;
- disabledAddNewRowSave: boolean;
-}
-
-function AddNewRowBanner(props: AddNewRowBannerProps) {
- const [isDiscardLoading, setIsDiscardLoading] = useState(false);
- const [isSaveLoading, setIsSaveLoading] = useState(false);
-
- return (
-
- Add New Row
-
-
-
-
-
- );
-}
-
-const MemoizedAddNewRowBanner = React.memo(AddNewRowBanner);
-
-export { MemoizedAddNewRowBanner as AddNewRowBanner };
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/CascadeFields.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/CascadeFields.tsx
deleted file mode 100644
index e86e93a5b15e..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/CascadeFields.tsx
+++ /dev/null
@@ -1,641 +0,0 @@
-import React, { useState, useEffect, useCallback } from "react";
-import styled from "styled-components";
-import { InputGroup } from "@blueprintjs/core";
-import { debounce, isNaN } from "lodash";
-
-import CustomizedDropdown from "pages/common/CustomizedDropdown";
-import { Directions } from "utils/helpers";
-import { Colors } from "constants/Colors";
-import { Skin } from "constants/DefaultTheme";
-import AutoToolTipComponent from "../cellComponents/AutoToolTipComponent";
-import type { Condition, Operator, ReactTableFilter } from "../Constants";
-import { OperatorTypes } from "../Constants";
-import { RenderOptionWrapper } from "../TableStyledWrappers";
-
-//TODO(abhinav): Fix this cross import between widgets
-import DatePickerComponent from "widgets/DatePickerWidget2/component";
-import { TimePrecision } from "widgets/DatePickerWidget2/constants";
-import { ColumnTypes, ReadOnlyColumnTypes } from "../../constants";
-import { importRemixIcon } from "design-system-old";
-import type { DropdownOption } from "./FilterPaneContent";
-
-const CloseIcon = importRemixIcon(
- async () => import("remixicon-react/CloseCircleFillIcon"),
-);
-const ArrowDownIcon = importRemixIcon(
- async () => import("remixicon-react/ArrowDownSLineIcon"),
-);
-
-const LabelWrapper = styled.div`
- width: 95px;
- margin-left: 10px;
- color: var(--wds-color-text-light);
- font-size: 14px;
- font-weight: 500;
-`;
-
-const FieldWrapper = styled.div`
- display: flex;
- align-items: center;
- justify-content: flex-start;
- margin-top: 14px;
-`;
-
-const DropdownWrapper = styled.div<{ width: number }>`
- width: ${(props) => props.width}px;
- margin-left: 10px;
-`;
-
-const StyledInputGroup = styled(InputGroup)<{
- borderRadius?: string;
-}>`
- background: var(--wds-color-bg);
- border: 1px solid var(--wds-color-border);
- box-sizing: border-box;
- border-radius: ${(props) => props.borderRadius || "0"};
- color: var(--wds-color-text);
- height: 32px;
- width: 120px;
- margin-left: 10px;
- overflow: hidden;
-
- input {
- box-shadow: none;
- }
-
- input:focus {
- box-shadow: none;
- }
- &:hover {
- border-color: var(--wds-color-border-hover);
- }
-`;
-
-const DatePickerWrapper = styled.div`
- margin-left: 10px;
- width: 150px;
-`;
-
-const DropdownTrigger = styled.div<{
- borderRadius?: string;
-}>`
- display: flex;
- align-items: center;
- justify-content: space-between;
- width: 100%;
- height: 32px;
- background: var(--wds-color-bg);
- border: 1px solid var(--wds-color-border);
- box-sizing: border-box;
- border-radius: ${(props) => props.borderRadius || "0"};
- font-size: 14px;
- padding: 5px 12px 7px;
- color: var(--wds-color-text);
- cursor: pointer;
-
- &:hover {
- border-color: var(--wds-color-border-hover);
- }
- &&& span {
- margin-right: 0;
- }
-`;
-
-const AutoToolTipComponentWrapper = styled(AutoToolTipComponent)`
- width: 100%;
- color: ${Colors.OXFORD_BLUE};
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- margin-right: 5px;
-`;
-
-const typeOperatorsMap: Record = {
- [ColumnTypes.TEXT]: [
- { label: "contains", value: "contains", type: "input" },
- { label: "does not contain", value: "doesNotContain", type: "input" },
- { label: "starts with", value: "startsWith", type: "input" },
- { label: "ends with", value: "endsWith", type: "input" },
- { label: "is exactly", value: "isExactly", type: "input" },
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
- [ColumnTypes.URL]: [
- { label: "contains", value: "contains", type: "input" },
- { label: "does not contain", value: "doesNotContain", type: "input" },
- { label: "starts with", value: "startsWith", type: "input" },
- { label: "ends with", value: "endsWith", type: "input" },
- { label: "is exactly", value: "isExactly", type: "input" },
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
- [ColumnTypes.DATE]: [
- { label: "is", value: "is", type: "date" },
- { label: "is before", value: "isBefore", type: "date" },
- { label: "is after", value: "isAfter", type: "date" },
- { label: "is not", value: "isNot", type: "date" },
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
- [ColumnTypes.IMAGE]: [
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
- [ColumnTypes.VIDEO]: [
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
- [ColumnTypes.NUMBER]: [
- { label: "is equal to", value: "isEqualTo", type: "input" },
- { label: "not equal to", value: "notEqualTo", type: "input" },
- { label: "greater than", value: "greaterThan", type: "input" },
- {
- label: "greater than or equal to",
- value: "greaterThanEqualTo",
- type: "input",
- },
- { label: "less than", value: "lessThan", type: "input" },
- {
- label: "less than or equal to",
- value: "lessThanEqualTo",
- type: "input",
- },
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
- [ColumnTypes.CHECKBOX]: [
- { label: "is checked", value: "isChecked", type: "" },
- { label: "is unchecked", value: "isUnChecked", type: "" },
- ],
- [ColumnTypes.SWITCH]: [
- { label: "is checked", value: "isChecked", type: "" },
- { label: "is unchecked", value: "isUnChecked", type: "" },
- ],
- [ColumnTypes.SELECT]: [
- { label: "contains", value: "contains", type: "input" },
- { label: "does not contain", value: "doesNotContain", type: "input" },
- { label: "starts with", value: "startsWith", type: "input" },
- { label: "ends with", value: "endsWith", type: "input" },
- { label: "is exactly", value: "isExactly", type: "input" },
- { label: "empty", value: "empty", type: "" },
- { label: "not empty", value: "notEmpty", type: "" },
- ],
-};
-
-const operatorOptions: DropdownOption[] = [
- { label: "OR", value: OperatorTypes.OR, type: "" },
- { label: "AND", value: OperatorTypes.AND, type: "" },
-];
-
-const columnTypeNameMap: Record = {
- [ReadOnlyColumnTypes.TEXT]: "Text",
- [ReadOnlyColumnTypes.VIDEO]: "Video",
- [ReadOnlyColumnTypes.IMAGE]: "Image",
- [ReadOnlyColumnTypes.NUMBER]: "Num",
- [ReadOnlyColumnTypes.DATE]: "Date",
- [ReadOnlyColumnTypes.URL]: "Url",
- [ReadOnlyColumnTypes.CHECKBOX]: "Check",
- [ReadOnlyColumnTypes.SWITCH]: "Check",
- [ReadOnlyColumnTypes.SELECT]: "Text",
-};
-
-function RenderOption(props: { type: string; title: string; active: boolean }) {
- return (
-
- {props.title}
-
- {columnTypeNameMap[props.type as ReadOnlyColumnTypes]}
-
-
- );
-}
-
-function RenderOptions(props: {
- columns: DropdownOption[];
- selectItem: (column: DropdownOption) => void;
- placeholder: string;
- value?: string | Condition;
- showType?: boolean;
- className?: string;
- borderRadius?: string;
-}) {
- const [selectedValue, selectValue] = useState(props.placeholder);
- const configs = {
- sections: [
- {
- options: props.columns.map((column: DropdownOption) => {
- const isActive = column.value === props.value;
- return {
- content: props.showType ? (
-
- ) : (
- column.label
- ),
- value: column.value,
- active: isActive,
- onSelect: () => {
- selectValue(column.label);
- props.selectItem(column);
- },
- };
- }),
- },
- ],
- openDirection: Directions.DOWN,
- trigger: {
- content: (
-
-
- {selectedValue}
-
-
-
- ),
- },
- skin: Skin.LIGHT,
- borderRadius: props.borderRadius,
- customizedDropdownId: "cascade-dropdown",
- };
- useEffect(() => {
- if (props.value && props.columns) {
- const selectedOptions = props.columns.filter(
- (i) => i.value === props.value,
- );
- if (selectedOptions && selectedOptions.length) {
- selectValue(selectedOptions[0].label);
- } else {
- selectValue(props.placeholder);
- }
- } else {
- selectValue(props.placeholder);
- }
- }, [props.value, props.placeholder, props.columns]);
- return ;
-}
-
-function RenderInput(props: {
- value: string;
- onChange: (value: string) => void;
- className?: string;
- borderRadius?: string;
-}) {
- const debouncedOnChange = useCallback(debounce(props.onChange, 400), []);
- const [value, setValue] = useState(props.value);
- const onChange = (event: React.ChangeEvent) => {
- const value = event.target.value;
- setValue(value);
- debouncedOnChange(value);
- };
- useEffect(() => {
- setValue(props.value);
- }, [props.value]);
- return (
-
- );
-}
-
-interface CascadeFieldProps {
- columns: DropdownOption[];
- column: string;
- condition: Condition;
- value: any;
- operator: Operator;
- id: string;
- index: number;
- hasAnyFilters: boolean;
- applyFilter: (
- filter: ReactTableFilter,
- index: number,
- isOperatorChange: boolean,
- ) => void;
- removeFilter: (index: number) => void;
-}
-
-interface CascadeFieldState {
- column: string;
- condition: Condition;
- value: any;
- operator: Operator;
- conditions: DropdownOption[];
- showConditions: boolean;
- showInput: boolean;
- showDateInput: boolean;
- isDeleted: boolean;
- isUpdate: boolean;
- isOperatorChange: boolean;
-}
-
-const getConditions = (props: CascadeFieldProps) => {
- const columnValue = props.column || "";
- const filteredColumn = props.columns.filter((column: DropdownOption) => {
- return columnValue === column.value;
- });
- if (filteredColumn.length) {
- const type: ReadOnlyColumnTypes = filteredColumn[0]
- .type as ReadOnlyColumnTypes;
- return typeOperatorsMap[type];
- } else {
- return new Array(0);
- }
-};
-
-const showConditionsField = (props: CascadeFieldProps) => {
- const columnValue = props.column || "";
- const filteredColumn = props.columns.filter((column: DropdownOption) => {
- return columnValue === column.value;
- });
- return !!filteredColumn.length;
-};
-
-const showInputField = (
- props: CascadeFieldProps,
- conditions: DropdownOption[],
-) => {
- const conditionValue = props.condition || "";
- const filteredConditions =
- conditions &&
- conditions.filter((condition: DropdownOption) => {
- return condition.value === conditionValue;
- });
- return !!filteredConditions.length && filteredConditions[0].type === "input";
-};
-
-const showDateInputField = (
- props: CascadeFieldProps,
- conditions: DropdownOption[],
-) => {
- const conditionValue = props.condition || "";
- const filteredConditions =
- conditions &&
- conditions.filter((condition: DropdownOption) => {
- return condition.value === conditionValue;
- });
- return !!filteredConditions.length && filteredConditions[0].type === "date";
-};
-
-function calculateInitialState(props: CascadeFieldProps) {
- const showConditions = showConditionsField(props);
- const conditions = getConditions(props);
- const showInput = showInputField(props, conditions);
- const showDateInput = showDateInputField(props, conditions);
- return {
- operator: props.operator,
- column: props.column,
- condition: props.condition,
- value: props.value,
- conditions: conditions,
- showConditions: showConditions,
- showInput: showInput,
- showDateInput: showDateInput,
- isDeleted: false,
- isUpdate: false,
- isOperatorChange: false,
- };
-}
-
-export enum CascadeFieldActionTypes {
- SELECT_COLUMN = "SELECT_COLUMN",
- SELECT_CONDITION = "SELECT_CONDITION",
- CHANGE_VALUE = "CHANGE_VALUE",
- SELECT_OPERATOR = "SELECT_OPERATOR",
- UPDATE_FILTER = "UPDATE_FILTER",
- DELETE_FILTER = "DELETE_FILTER",
-}
-
-type CascadeFieldAction = keyof typeof CascadeFieldActionTypes;
-
-function CaseCaseFieldReducer(
- state: CascadeFieldState,
- action: {
- type: CascadeFieldAction;
- payload?: any;
- },
-) {
- switch (action.type) {
- case CascadeFieldActionTypes.SELECT_COLUMN:
- const type: ReadOnlyColumnTypes = action.payload.type;
- return {
- ...state,
- column: action.payload.value,
- condition: "",
- conditions: typeOperatorsMap[type],
- showConditions: true,
- isUpdate: true,
- };
- case CascadeFieldActionTypes.SELECT_CONDITION:
- return {
- ...state,
- condition: action.payload.value,
- showInput: action.payload.type === "input",
- showDateInput: action.payload.type === "date",
- value: action.payload.type === "" ? "" : state.value,
- isUpdate: true,
- };
- case CascadeFieldActionTypes.CHANGE_VALUE:
- return {
- ...state,
- value: action.payload,
- isUpdate: true,
- };
- case CascadeFieldActionTypes.SELECT_OPERATOR:
- return {
- ...state,
- operator: action.payload,
- isUpdate: true,
- isOperatorChange: true,
- };
- case CascadeFieldActionTypes.UPDATE_FILTER:
- const calculatedState = calculateInitialState(action.payload);
- return {
- ...calculatedState,
- isUpdate: false,
- };
- case CascadeFieldActionTypes.DELETE_FILTER:
- return {
- ...state,
- isDeleted: true,
- };
- default:
- throw new Error();
- }
-}
-
-function CascadeField(props: CascadeFieldProps) {
- const memoizedState = React.useMemo(
- () => calculateInitialState(props),
- [props],
- );
- return ;
-}
-
-function Fields(props: CascadeFieldProps & { state: CascadeFieldState }) {
- const { applyFilter, hasAnyFilters, id, index, removeFilter } = props;
- const [state, dispatch] = React.useReducer(CaseCaseFieldReducer, props.state);
- const handleRemoveFilter = () => {
- dispatch({ type: CascadeFieldActionTypes.DELETE_FILTER });
- };
- const selectColumn = (column: DropdownOption) => {
- dispatch({
- type: CascadeFieldActionTypes.SELECT_COLUMN,
- payload: column,
- });
- };
- const selectCondition = (condition: DropdownOption) => {
- dispatch({
- type: CascadeFieldActionTypes.SELECT_CONDITION,
- payload: condition,
- });
- };
- const onValueChange = (value: string) => {
- const parsedValue = value && !isNaN(Number(value)) ? Number(value) : value;
- dispatch({
- type: CascadeFieldActionTypes.CHANGE_VALUE,
- payload: parsedValue,
- });
- };
- const onDateSelected = (date: string) => {
- dispatch({
- type: CascadeFieldActionTypes.CHANGE_VALUE,
- payload: date,
- });
- };
- const selectOperator = (option: DropdownOption) => {
- dispatch({
- type: CascadeFieldActionTypes.SELECT_OPERATOR,
- payload: OperatorTypes[option.value as Operator],
- });
- };
-
- const {
- column,
- condition,
- conditions,
- isDeleted,
- isOperatorChange,
- isUpdate,
- operator,
- showConditions,
- showDateInput,
- showInput,
- value,
- } = state;
- useEffect(() => {
- if (!isDeleted && isUpdate) {
- applyFilter(
- { id, operator, column, condition, value },
- index,
- isOperatorChange,
- );
- } else if (isDeleted) {
- removeFilter(index);
- }
- }, [
- operator,
- column,
- condition,
- value,
- isDeleted,
- isOperatorChange,
- isUpdate,
- index,
- applyFilter,
- removeFilter,
- ]);
-
- useEffect(() => {
- dispatch({
- type: CascadeFieldActionTypes.UPDATE_FILTER,
- payload: props,
- });
- }, [props]);
- return (
-
-
- {index === 1 ? (
-
-
-
- ) : (
-
- {index === 0 ? "Where" : OperatorTypes[props.operator]}
-
- )}
-
-
-
- {showConditions ? (
-
-
-
- ) : null}
- {showInput ? (
-
- ) : null}
- {showDateInput ? (
-
- {/*@ts-expect-error: types mismatch because we don't use settings styles through props anymore. Remove this after creating WDS datepicker. */}
-
-
- ) : null}
-
- );
-}
-
-export default CascadeField;
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/FilterPane.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/FilterPane.tsx
deleted file mode 100644
index 6c6fa8a29ddc..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/FilterPane.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-import React, { Component } from "react";
-import { connect } from "react-redux";
-import { get } from "lodash";
-import * as log from "loglevel";
-import type { AppState } from "@appsmith/reducers";
-import styled from "styled-components";
-
-import { Colors } from "constants/Colors";
-import type { ReactTableColumnProps, ReactTableFilter } from "../Constants";
-import TableFilterPaneContent from "./FilterPaneContent";
-import { getCurrentThemeMode, ThemeMode } from "selectors/themeSelectors";
-import { Layers } from "constants/Layers";
-import Popper from "pages/Editor/Popper";
-import { getTableFilterState } from "selectors/tableFilterSelectors";
-import { getWidgetMetaProps } from "sagas/selectors";
-import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
-import type { WidgetProps } from "widgets/BaseWidget";
-import { selectWidgetInitAction } from "actions/widgetSelectionActions";
-import { SelectionRequestType } from "sagas/WidgetSelectUtils";
-import { importSvg } from "design-system-old";
-import { CANVAS_ART_BOARD } from "constants/componentClassNameConstants";
-
-const DragHandleIcon = importSvg(
- async () => import("assets/icons/ads/app-icons/draghandler.svg"),
-);
-
-const DragBlock = styled.div`
- height: 40px;
- width: 83px;
- background: var(--wds-color-bg-light);
- box-sizing: border-box;
- font-size: 12px;
- color: ${Colors.GREY_11};
- letter-spacing: 0.04em;
- font-weight: 500;
- display: flex;
- align-items: center;
- justify-content: center;
- cursor: pointer;
-
- span {
- padding-left: 8px;
- color: var(--wds-color-text-light);
- }
-`;
-
-export interface TableFilterPaneProps {
- widgetId: string;
- columns: ReactTableColumnProps[];
- filters?: ReactTableFilter[];
- applyFilter: (filters: ReactTableFilter[]) => void;
- targetNode?: Element;
-}
-
-interface PositionPropsInt {
- top: number;
- left: number;
-}
-
-type Props = ReturnType &
- ReturnType &
- TableFilterPaneProps;
-
-class TableFilterPane extends Component {
- getPopperTheme() {
- return ThemeMode.LIGHT;
- }
-
- handlePositionUpdate = (position: any) => {
- this.props.setPanePosition(
- this.props.tableFilterPane.widgetId as string,
- position,
- );
- };
-
- render() {
- if (
- this.props.tableFilterPane.isVisible &&
- this.props.tableFilterPane.widgetId === this.props.widgetId
- ) {
- log.debug("tablefilter pane rendered");
-
- /*
- Prevent the FilterPane from overflowing the canvas when the
- table widget is on the very top of the canvas.
- */
- const boundaryParent = document.querySelector("#root");
-
- return (
-
-
- Move
-
- }
- renderDragBlockPositions={{
- left: "0px",
- }}
- targetNode={this.props.targetNode}
- themeMode={this.getPopperTheme()}
- zIndex={Layers.tableFilterPane}
- >
-
-
- );
- } else {
- return null;
- }
- }
-}
-
-const mapStateToProps = (state: AppState, ownProps: TableFilterPaneProps) => {
- const widgetLikeProps = {
- widgetId: ownProps.widgetId,
- } as WidgetProps;
-
- return {
- tableFilterPane: getTableFilterState(state),
- themeMode: getCurrentThemeMode(state),
- metaProps: getWidgetMetaProps(state, widgetLikeProps),
- };
-};
-
-const mapDispatchToProps = (dispatch: any) => {
- return {
- setPanePosition: (widgetId: string, position: any) => {
- dispatch({
- type: ReduxActionTypes.TABLE_PANE_MOVED,
- payload: {
- widgetId,
- position,
- },
- });
- dispatch(selectWidgetInitAction(SelectionRequestType.One, [widgetId]));
- },
- hideFilterPane: (widgetId: string) => {
- dispatch({
- type: ReduxActionTypes.HIDE_TABLE_FILTER_PANE,
- payload: { widgetId },
- });
- dispatch(selectWidgetInitAction(SelectionRequestType.One, [widgetId]));
- },
- };
-};
-export default connect(mapStateToProps, mapDispatchToProps)(TableFilterPane);
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/FilterPaneContent.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/FilterPaneContent.tsx
deleted file mode 100644
index d5a360b27cdc..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/FilterPaneContent.tsx
+++ /dev/null
@@ -1,291 +0,0 @@
-import React, { useEffect, useCallback } from "react";
-import styled from "styled-components";
-import { Classes } from "@blueprintjs/core";
-import { Colors } from "constants/Colors";
-import type {
- ReactTableColumnProps,
- ReactTableFilter,
- Operator,
-} from "../Constants";
-import { OperatorTypes, DEFAULT_FILTER } from "../Constants";
-import CascadeFields from "./CascadeFields";
-import {
- createMessage,
- TABLE_FILTER_COLUMN_TYPE_CALLOUT,
-} from "@appsmith/constants/messages";
-import { Icon, IconSize } from "@design-system/widgets-old";
-import { StyledButton as Button } from "widgets/ButtonWidget/component";
-import { ButtonVariantTypes } from "components/constants";
-
-import { cloneDeep } from "lodash";
-import {
- ColumnTypes,
- FilterableColumnTypes,
-} from "widgets/wds/WDSTableWidget/constants";
-import { generateReactKey } from "utils/generators";
-import { importRemixIcon } from "design-system-old";
-
-export interface DropdownOption {
- label: string;
- value: string;
- type: string;
-}
-
-const AddIcon = importRemixIcon(
- async () => import("remixicon-react/AddLineIcon"),
-);
-
-const TableFilterOuterWrapper = styled.div<{
- borderRadius?: string;
-}>`
- display: flex;
- flex-direction: column;
- width: 100%;
- background: ${Colors.WHITE};
- box-shadow: 0 6px 20px 0px rgba(0, 0, 0, 0.15);
- border-radius: ${(props) => props.borderRadius || "0"};
-`;
-
-const TableFilerWrapper = styled.div`
- display: flex;
- flex-direction: column;
- width: 100%;
- padding: 2px 16px 14px;
-`;
-
-const ButtonWrapper = styled.div`
- display: flex;
- width: 100%;
- justify-content: space-between;
- align-items: center;
- background: ${Colors.WHITE};
- margin-top: 14px;
- &&& button:hover {
- background: transparent;
- }
- .${Classes.BUTTON_TEXT} {
- font-weight: 600 !important;
- }
-`;
-
-const ButtonActionsWrapper = styled.div`
- display: flex;
- align-items: center;
- &&& button {
- margin-left: 14px;
- }
-`;
-
-// margin-left is same as move block width in TableFilterPane.tsx
-const ColumnTypeBindingMessage = styled.div`
- height: 40px;
- line-height: 40px;
- background: var(--wds-color-bg-light);
- box-sizing: border-box;
- font-size: 12px;
- color: var(--wds-color-text-light);
- letter-spacing: 0.04em;
- font-weight: 500;
- margin-left: 83px;
- min-width: 350px;
- display: flex;
- align-items: center;
- justify-content: space-between;
-
- & .message-text {
- padding: 0 8px 0 16px;
- }
-
- & .close-button {
- cursor: pointer;
- margin: 3px;
- height: 34px;
- width: 34px;
- display: flex;
- justify-content: center;
- &:hover {
- background-color: ${Colors.GREY_3};
- svg path {
- fill: ${Colors.GREY_10};
- }
- }
- }
-`;
-
-interface TableFilterProps {
- columns: ReactTableColumnProps[];
- filters?: ReactTableFilter[];
- applyFilter: (filters: ReactTableFilter[]) => void;
- hideFilterPane: (widgetId: string) => void;
- widgetId: string;
-}
-
-const defaultFilters = [{ ...DEFAULT_FILTER }];
-const getTableFilters = (filters: ReactTableFilter[] | undefined) => {
- if (!filters || filters.length === 0) {
- return defaultFilters;
- }
- return filters;
-};
-
-function TableFilterPaneContent(props: TableFilterProps) {
- const [filters, updateFilters] = React.useState(
- getTableFilters(props.filters),
- );
-
- useEffect(() => {
- const updatedFiltersState = getTableFilters(props.filters);
- //if props has been updated update the filters state
- if (updatedFiltersState !== filters) {
- updateFilters(updatedFiltersState);
- }
- }, [props.filters]);
-
- const addFilter = () => {
- const updatedFilters = filters ? [...filters] : [];
- let operator: Operator = OperatorTypes.OR;
- if (updatedFilters.length >= 2) {
- operator = updatedFilters[1].operator;
- }
- // New id is generated for new filter here
- updatedFilters.push({
- ...DEFAULT_FILTER,
- id: generateReactKey(),
- operator,
- });
- updateFilters(updatedFilters);
- };
-
- const applyFilter = () => {
- props.applyFilter(filters);
- };
-
- const hideFilter = () => {
- props.hideFilterPane(props.widgetId);
- };
-
- const clearFilters = useCallback(() => {
- props.applyFilter([]);
- }, [props]);
-
- const columns: DropdownOption[] = props.columns
- .map((column: ReactTableColumnProps) => {
- const type = column.metaProperties?.type || ColumnTypes.TEXT;
-
- return {
- label: column.Header,
- value: column.alias,
- type: type,
- };
- })
- .filter((column: { label: string; value: string; type: ColumnTypes }) => {
- return FilterableColumnTypes.includes(column.type);
- });
-
- const hasAnyFilters = !!(
- filters.length >= 1 &&
- filters[0].column &&
- filters[0].condition
- );
-
- return (
- {
- e.stopPropagation();
- }}
- >
-
-
- {createMessage(TABLE_FILTER_COLUMN_TYPE_CALLOUT)}
-
-
-
-
-
- e.stopPropagation()}>
- {filters.map((filter: ReactTableFilter, index: number) => {
- return (
- {
- // here updated filters store in state, not in redux
- const updatedFilters = filters ? cloneDeep(filters) : [];
- updatedFilters[index] = filter;
- if (isOperatorChange) {
- /*
- This if-block updates the operator for all filters after
- second filter if the second filter operator is changed
- */
- let index = 2;
- while (index < updatedFilters.length) {
- updatedFilters[index].operator = updatedFilters[1].operator;
- index++;
- }
- }
- updateFilters(updatedFilters);
- }}
- column={filter.column}
- columns={columns}
- condition={filter.condition}
- hasAnyFilters={hasAnyFilters}
- id={filter.id}
- index={index}
- key={filter.id}
- operator={
- filters.length >= 2 ? filters[1].operator : filter.operator
- }
- removeFilter={(index: number) => {
- const updatedFilters = cloneDeep(filters);
- let newFilters: Array = [];
- if (updatedFilters) {
- if (index === 1 && updatedFilters.length > 2) {
- updatedFilters[2].operator = updatedFilters[1].operator;
- }
- newFilters = [
- ...updatedFilters.slice(0, index),
- ...updatedFilters.slice(index + 1),
- ];
- }
- // removed filter directly update redux
- // with redux update, useEffect will update local state too
- props.applyFilter(newFilters);
- }}
- value={filter.value}
- />
- );
- })}
- {hasAnyFilters ? (
-
- }
- onClick={addFilter}
- size="small"
- text="Add Filter"
- />
-
-
-
-
-
- ) : null}
-
-
- );
-}
-
-export default TableFilterPaneContent;
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Pagination.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Pagination.tsx
index c8d2398e853e..2fad3a26febf 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Pagination.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/Pagination.tsx
@@ -1,12 +1,9 @@
+import React from "react";
import { IconButton, Text } from "@design-system/widgets";
import { EventType } from "constants/AppsmithActionConstants/ActionConstants";
-import React from "react";
+
+import type { ReactTableColumnProps } from "../Constants";
import { PageNumberInput } from "./PageNumberInput";
-import type {
- ReactTableColumnProps,
- ReactTableFilter,
- TableSizes,
-} from "../Constants";
export interface PaginationProps {
updatePageNo: (pageNo: number, event?: EventType) => void;
@@ -15,116 +12,60 @@ export interface PaginationProps {
pageNo: number;
totalRecordsCount?: number;
tableData: Array>;
- tableColumns: ReactTableColumnProps[];
pageCount: number;
currentPageIndex: number;
- pageOptions: number[];
columns: ReactTableColumnProps[];
- hiddenColumns?: string[];
- widgetName: string;
- widgetId: string;
- searchKey: string;
- searchTableData: (searchKey: any) => void;
serverSidePaginationEnabled: boolean;
- filters?: ReactTableFilter[];
- applyFilter: (filters: ReactTableFilter[]) => void;
- tableSizes: TableSizes;
- isVisibleDownload?: boolean;
- isVisibleFilters?: boolean;
isVisiblePagination?: boolean;
- isVisibleSearch?: boolean;
- delimiter: string;
- allowAddNewRow: boolean;
- onAddNewRow: () => void;
- disableAddNewRow: boolean;
- width: number;
}
export const Pagination = (props: PaginationProps) => {
- const pageCount = `${props.pageNo + 1}${
- props.totalRecordsCount ? ` of ${props.pageCount}` : ``
- }`;
+ if (!props.columns.length) return null;
+ if (!props.isVisiblePagination) return null;
return (
- <>
- {!!props.columns.length &&
- props.isVisiblePagination &&
- props.serverSidePaginationEnabled && (
-
- {props.totalRecordsCount ? (
-
- {props.totalRecordsCount} Records
-
- ) : null}
-
-
- Page {pageCount}
-
-
-
- )}
- {!!props.columns.length &&
- props.isVisiblePagination &&
- !props.serverSidePaginationEnabled && (
-
-
- {props.tableData?.length} Records
-
-
{
- const pageNo =
- props.currentPageIndex > 0 ? props.currentPageIndex - 1 : 0;
- !(props.currentPageIndex === 0) &&
- props.updatePageNo(pageNo + 1, EventType.ON_PREV_PAGE);
- }}
- size="small"
- variant="outlined"
- />
-
- Page
-
-
-
- of {props.pageCount}
-
- {
- const pageNo =
- props.currentPageIndex < props.pageCount - 1
- ? props.currentPageIndex + 1
- : 0;
- !(props.currentPageIndex === props.pageCount - 1) &&
- props.updatePageNo(pageNo + 1, EventType.ON_NEXT_PAGE);
- }}
- size="small"
- variant="outlined"
- />
-
- )}
- >
+
+
+ {props.tableData?.length} Records
+
+
{
+ const pageNo =
+ props.currentPageIndex > 0 ? props.currentPageIndex - 1 : 0;
+ !(props.currentPageIndex === 0) &&
+ props.updatePageNo(pageNo + 1, EventType.ON_PREV_PAGE);
+ }}
+ size="small"
+ variant="outlined"
+ />
+
+ Page
+
+
+
+ of {props.pageCount}
+
+ {
+ const pageNo =
+ props.currentPageIndex < props.pageCount - 1
+ ? props.currentPageIndex + 1
+ : 0;
+ !(props.currentPageIndex === props.pageCount - 1) &&
+ props.updatePageNo(pageNo + 1, EventType.ON_NEXT_PAGE);
+ }}
+ size="small"
+ variant="outlined"
+ />
+
);
};
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/TableColumnHeader.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/TableColumnHeader.tsx
index e83e4860c779..1ce88b7bbab6 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/TableColumnHeader.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/TableColumnHeader.tsx
@@ -68,8 +68,6 @@ const TableColumnHeader = (props: TableColumnHeaderProps) => {
renderHeaderCheckBoxCell(
props.handleAllRowSelectClick,
props.rowSelectionState,
- props.accentColor,
- props.borderRadius,
)}
{headerGroup.headers.map((column: any, columnIndex: number) => {
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/VirtualTableInnerElement.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/VirtualTableInnerElement.tsx
index b9b378ffa6f6..97abea1feff7 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/VirtualTableInnerElement.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/VirtualTableInnerElement.tsx
@@ -1,9 +1,10 @@
import React from "react";
import { useContext } from "react";
import styled from "styled-components";
-import { MULTISELECT_CHECKBOX_WIDTH } from "../Constants";
-import { BodyContext } from "../TableBody";
+
+import { TableBodyContext } from "../TableBody";
import TableColumnHeader from "./TableColumnHeader";
+import { MULTISELECT_CHECKBOX_WIDTH } from "../Constants";
const StyledTableBodyWrapper = styled.div<{
multiRowSelection?: boolean;
@@ -44,7 +45,7 @@ const VirtualTableInnerElement = ({
totalColumnsWidth,
widgetId,
width,
- } = useContext(BodyContext) as any;
+ } = useContext(TableBodyContext) as any;
return (
<>
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/index.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/index.tsx
index 2448ba22be11..655dce0bac17 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/index.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableHeader/index.tsx
@@ -1,50 +1,30 @@
import React, { useRef } from "react";
+import { Flex } from "@design-system/widgets";
import { Search } from "./Search";
-import { Actions } from "./Actions";
-import type { SearchProps } from "./Search";
-import type { ActionsPropsType } from "./Actions";
-import { AddNewRowBanner } from "./AddNewRowBanner";
-import type { AddNewRowBannerProps } from "./AddNewRowBanner";
-
-import FilterPane from "./FilterPane";
import styles from "./styles.module.css";
+import type { SearchProps } from "./Search";
+import type { PaginationProps } from "./Pagination";
import { Pagination } from "./Pagination";
-import { Flex } from "@design-system/widgets";
-interface TableHeaderProps
- extends ActionsPropsType,
- AddNewRowBannerProps,
- SearchProps {
- isAddRowInProgress: boolean;
-}
+interface TableHeaderProps extends SearchProps, PaginationProps {}
function TableHeader(props: TableHeaderProps) {
const {
- applyFilter,
columns,
- disabledAddNewRowSave,
- isAddRowInProgress,
+ isVisiblePagination,
isVisibleSearch,
- onAddNewRowAction,
onSearch,
searchKey,
tableData,
- widgetId,
...rest
} = props;
+
const tableHeaderRef = useRef(null);
- const content = (() => {
- if (isAddRowInProgress) {
- return (
-
- );
- }
+ if (!(isVisibleSearch || isVisiblePagination)) return null;
+ const content = (() => {
return (
<>
-
@@ -75,12 +45,9 @@ function TableHeader(props: TableHeaderProps) {
})();
return (
- <>
-
-
- >
+
);
}
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/TableStyledWrappers.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/TableStyledWrappers.tsx
index a95fa8373741..949dbe026fa6 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/TableStyledWrappers.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/TableStyledWrappers.tsx
@@ -1,53 +1,25 @@
import styled, { css } from "styled-components";
import type {
- TableSizes,
CellLayoutProperties,
CellAlignment,
VerticalAlignment,
ImageSize,
} from "./Constants";
import {
- JUSTIFY_CONTENT,
- ALIGN_ITEMS,
- IMAGE_HORIZONTAL_ALIGN,
- IMAGE_VERTICAL_ALIGN,
- TEXT_ALIGN,
TABLE_SIZES,
ImageSizes,
MULTISELECT_CHECKBOX_WIDTH,
} from "./Constants";
-import type { Color } from "constants/Colors";
import { Colors } from "constants/Colors";
import { invisible } from "constants/DefaultTheme";
import { lightenColor, darkenColor } from "widgets/WidgetUtils";
import { FontStyleTypes } from "constants/WidgetConstants";
import { Classes } from "@blueprintjs/core";
-import type { TableVariant } from "../constants";
import { Layers } from "constants/Layers";
const BORDER_RADIUS = "border-radius: 4px;";
const HEADER_CONTROL_FONT_SIZE = "12px";
-export const TableWrapper = styled.div<{
- width: number;
- height: number;
- tableSizes: TableSizes;
- accentColor: string;
- backgroundColor?: Color;
- triggerRowSelection: boolean;
- isHeaderVisible?: boolean;
- borderRadius: string;
- boxShadow?: string;
- borderColor?: string;
- borderWidth?: number;
- isResizingColumn?: boolean;
- variant?: TableVariant;
- isAddRowInProgress: boolean;
-}>`
- .column-freeze {
- }
-`;
-
export const DropDownWrapper = styled.div`
display: flex;
flex-direction: column;
@@ -169,12 +141,6 @@ export const CellWrapper = styled.div<{
props.fontStyle?.includes(FontStyleTypes.UNDERLINE) && props.isTextType
? "underline"
: ""};
- justify-content: ${(props) =>
- props.horizontalAlignment && JUSTIFY_CONTENT[props.horizontalAlignment]};
- text-align: ${(props) =>
- props.horizontalAlignment && TEXT_ALIGN[props.horizontalAlignment]};
- align-items: ${(props) =>
- props.verticalAlignment && ALIGN_ITEMS[props.verticalAlignment]};
background: ${(props) => {
if (props.isCellDisabled) {
@@ -219,16 +185,6 @@ export const CellWrapper = styled.div<{
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;`}
- .image-cell-wrapper {
- width: 100%;
- height: 100%;
- display: flex;
- align-items: ${(props) =>
- props.verticalAlignment && IMAGE_VERTICAL_ALIGN[props.verticalAlignment]};
- justify-content: ${(props) =>
- props.horizontalAlignment &&
- IMAGE_HORIZONTAL_ALIGN[props.horizontalAlignment]};
- }
.image-cell {
height: ${(props) =>
props.imageSize ? ImageSizes[props.imageSize] : ImageSizes.DEFAULT};
@@ -254,14 +210,6 @@ export const CellWrapper = styled.div<{
${BORDER_RADIUS}
}
}
- .link-text {
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- word-break: break-word;
- text-align: ${(props) =>
- props.horizontalAlignment && TEXT_ALIGN[props.horizontalAlignment]};
- }
.hidden-icon {
display: none;
}
@@ -272,34 +220,12 @@ export const CellWrapper = styled.div<{
}
`;
-export const CellCheckboxWrapper = styled(CellWrapper)<{
- isChecked?: boolean;
- accentColor?: string;
- borderRadius?: string;
-}>`
+export const CellCheckboxWrapper = styled(CellWrapper)`
left: 0;
z-index: ${Layers.modalWidget};
justify-content: center;
width: ${MULTISELECT_CHECKBOX_WIDTH}px;
height: auto;
- & > div {
- border-radius: ${({ borderRadius }) => borderRadius};
-
- ${(props) =>
- props.isChecked
- ? `
- background: ${props.accentColor};
- &:hover {
- background: ${darkenColor(props.accentColor)};
- }
- `
- : `
- border: 1px solid ${Colors.GREY_3};
- &:hover {
- border: 1px solid ${Colors.GREY_5};
- }
- `};
- }
`;
export const CellCheckbox = styled.div`
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/BasicCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/BasicCell.tsx
deleted file mode 100644
index 2e30ed6185e6..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/BasicCell.tsx
+++ /dev/null
@@ -1,190 +0,0 @@
-import type { Ref } from "react";
-import React, { useCallback } from "react";
-import { Tooltip } from "@blueprintjs/core";
-import styled from "styled-components";
-import type { BaseCellComponentProps } from "../Constants";
-import { TABLE_SIZES } from "../Constants";
-import { TooltipContentWrapper } from "../TableStyledWrappers";
-import AutoToolTipComponent from "./AutoToolTipComponent";
-import { importSvg } from "design-system-old";
-
-const EditIcon = importSvg(
- async () => import("assets/icons/control/edit-variant1.svg"),
-);
-
-const Wrapper = styled.div<{
- allowWrapping?: boolean;
- compactMode: string;
- isCellEditMode?: boolean;
-}>`
- display: flex;
- position: relative;
- align-items: center;
- width: 100%;
- height: 100%;
- opacity: ${(props) => (props.isCellEditMode ? 0 : 1)};
-
- &:hover {
- .editable-cell-icon {
- display: ${(props) => (props.isCellEditMode ? "none" : "block")};
- }
- }
-`;
-
-const StyledAutoToolTipComponent = styled(AutoToolTipComponent)`
- width: 100%;
-`;
-
-const UnsavedChangesMarker = styled.div<{ accentColor: string }>`
- position: absolute;
- top: -1px;
- right: -3px;
- width: 0;
- height: 0;
- border-left: 5px solid transparent;
- border-right: 5px solid transparent;
- border-bottom: 5px solid ${(props) => props.accentColor};
- transform: rotateZ(45deg);
-`;
-
-const Content = styled.div`
- overflow: hidden;
- text-overflow: ellipsis;
-`;
-
-const StyledEditIcon = styled.div<{
- accentColor?: string;
- backgroundColor?: string;
- compactMode: string;
- disabledEditIcon: boolean;
-}>`
- position: absolute;
- right: 6px;
- top: ${(props) => TABLE_SIZES[props.compactMode].EDIT_ICON_TOP}px;
- background: ${(props) =>
- props.disabledEditIcon ? "#999" : props.accentColor};
- padding: 2px;
- cursor: ${(props) => (props.disabledEditIcon ? "default" : "pointer")};
- display: none;
- & svg {
- transform: scale(0.9);
- path {
- fill: #fff;
- }
- }
-`;
-
-type PropType = BaseCellComponentProps & {
- accentColor: string;
- value: any;
- columnType: string;
- tableWidth: number;
- isCellEditable?: boolean;
- isCellEditMode?: boolean;
- hasUnsavedChanges?: boolean;
- displayText?: string;
- disabledEditIcon: boolean;
- onEdit?: () => void;
- url?: string;
- disabledEditIconMessage: string;
-};
-
-export const BasicCell = React.forwardRef(
- (
- {
- accentColor,
- allowCellWrapping,
- cellBackground,
- columnType,
- compactMode,
- disabledEditIcon,
- disabledEditIconMessage,
- fontStyle,
- hasUnsavedChanges,
- horizontalAlignment,
- isCellDisabled,
- isCellEditable,
- isCellEditMode,
- isCellVisible,
- isHidden,
- onEdit,
- tableWidth,
- textColor,
- textSize,
- url,
- value,
- verticalAlignment,
- }: PropType,
- contentRef: Ref,
- ) => {
- const onEditHandler = useCallback(
- (e: React.MouseEvent) => {
- if (isCellEditable && !disabledEditIcon && onEdit) {
- e.stopPropagation();
- onEdit();
- }
- },
- [onEdit, disabledEditIcon, isCellEditable],
- );
-
- return (
-
- {hasUnsavedChanges && (
-
- )}
-
- {value}
-
- {isCellEditable && (
-
- {disabledEditIcon ? (
-
- {disabledEditIconMessage}
-
- }
- hoverOpenDelay={200}
- position="top"
- >
- e.stopPropagation()} />
-
- ) : (
- e.stopPropagation()} />
- )}
-
- )}
-
- );
- },
-);
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/Button.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/Button.tsx
deleted file mode 100644
index 6267ea0cd6eb..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/Button.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import React, { useState } from "react";
-
-import { ActionWrapper } from "../TableStyledWrappers";
-import { BaseButton } from "widgets/ButtonWidget/component";
-import type { ButtonColumnActions } from "widgets/wds/WDSTableWidget/constants";
-import styled from "styled-components";
-
-const StyledButton = styled(BaseButton)<{
- compactMode?: string;
-}>`
- min-width: 40px;
-
- min-height: ${({ compactMode }) =>
- compactMode === "SHORT" ? "24px" : "30px"};
- font-size: ${({ compactMode }) =>
- compactMode === "SHORT" ? "12px" : "14px"};
- line-height: ${({ compactMode }) =>
- compactMode === "SHORT" ? "24px" : "28px"};
-`;
-
-interface ButtonProps {
- isCellVisible: boolean;
- isSelected: boolean;
- isDisabled?: boolean;
- action: ButtonColumnActions;
- compactMode?: string;
- onCommandClick: (dynamicTrigger: string, onComplete: () => void) => void;
-}
-
-export function Button(props: ButtonProps) {
- const [loading, setLoading] = useState(false);
- const onComplete = () => {
- setLoading(false);
- };
- const handleClick = () => {
- setLoading(true);
- props.onCommandClick(props.action.dynamicTrigger, onComplete);
- };
-
- return (
- {
- e.stopPropagation();
- }}
- >
- {props.isCellVisible && props.action.isVisible ? (
-
- ) : null}
-
- );
-}
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ButtonCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ButtonCell.tsx
index 2af13fb8ae53..6596385c2353 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ButtonCell.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ButtonCell.tsx
@@ -1,87 +1,46 @@
-import React, { memo } from "react";
+import React, { memo, useState } from "react";
+import type { ButtonProps, COLORS } from "@design-system/widgets";
+import { Button } from "@design-system/widgets";
-import { CellWrapper } from "../TableStyledWrappers";
import type { BaseCellComponentProps } from "../Constants";
-import { TABLE_SIZES } from "../Constants";
-import { Button } from "./Button";
-import type { ButtonColumnActions } from "widgets/wds/WDSTableWidget/constants";
-import styled from "styled-components";
-const StyledButton = styled(Button)<{ compactMode: string }>`
- max-height: ${(props) => TABLE_SIZES[props.compactMode].ROW_HEIGHT}px;
-`;
-
-export interface RenderActionProps extends BaseCellComponentProps {
- isSelected: boolean;
- columnActions?: ButtonColumnActions[];
- isDisabled: boolean;
- onCommandClick: (dynamicTrigger: string, onComplete: () => void) => void;
+export interface ButtonCellProps {
+ buttonLabel?: string;
+ cellColor?: "default" | keyof typeof COLORS;
+ buttonVariant?: ButtonProps["variant"];
+ onClick?: (onComplete: () => void) => void;
+ isDisabled?: boolean;
}
-function ButtonCellComponent(props: RenderActionProps) {
- const {
- allowCellWrapping,
- cellBackground,
- columnActions,
- compactMode,
- fontStyle,
- horizontalAlignment,
- isCellDisabled,
- isCellVisible,
- isDisabled,
- isHidden,
- isSelected,
- onCommandClick,
- textColor,
- textSize,
- verticalAlignment,
- } = props;
+function ButtonCell(props: ButtonCellProps & BaseCellComponentProps) {
+ const { buttonLabel, buttonVariant, cellColor, isDisabled } = props;
+ const [isLoading, setIsLoading] = useState(false);
+
+ const onComplete = () => {
+ setIsLoading(false);
+ };
+
+ const onClick = () => {
+ setIsLoading(true);
- if (!columnActions)
- return (
-
- );
+ if (props.onClick) {
+ props.onClick(onComplete);
+ }
+ };
return (
-
- {columnActions.map((action: ButtonColumnActions) => {
- return (
-
- );
- })}
-
+ {buttonLabel}
+
);
}
-export const ButtonCell = memo(ButtonCellComponent);
+
+const MemoizedButtonCell = memo(ButtonCell);
+
+export { MemoizedButtonCell as ButtonCell };
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/CheckboxCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/CheckboxCell.tsx
index b1200db93137..6eca71158daf 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/CheckboxCell.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/CheckboxCell.tsx
@@ -1,51 +1,6 @@
import React, { memo } from "react";
-import type { BaseCellComponentProps, CellAlignment } from "../Constants";
-import { ALIGN_ITEMS, JUSTIFY_CONTENT } from "../Constants";
-import { CellWrapper, TooltipContentWrapper } from "../TableStyledWrappers";
-import CheckboxComponent from "widgets/CheckboxWidget/component/index";
-import { LabelPosition } from "components/constants";
-import styled from "styled-components";
-import { Tooltip } from "@blueprintjs/core";
-
-const UnsavedChangesMarker = styled.div<{ accentColor: string }>`
- position: absolute;
- top: -1px;
- right: -3px;
- width: 0;
- height: 0;
- border-left: 5px solid transparent;
- border-right: 5px solid transparent;
- border-bottom: 5px solid ${(props) => props.accentColor};
- transform: rotateZ(45deg);
-`;
-
-const CheckboxCellWrapper = styled(CellWrapper)<{
- horizontalAlignment?: CellAlignment;
-}>`
- & div {
- justify-content: ${(props) =>
- props.horizontalAlignment &&
- JUSTIFY_CONTENT[props.horizontalAlignment]} !important;
-
- align-items: ${(props) =>
- props.verticalAlignment &&
- ALIGN_ITEMS[props.verticalAlignment]} !important;
-
- & .bp3-checkbox {
- gap: 0px;
- }
- }
- & .bp3-disabled {
- cursor: grab !important;
- & .bp3-control-indicator::before {
- cursor: grab !important;
- }
- }
-
- & > .bp3-popover-wrapper {
- overflow: unset;
- }
-`;
+import type { BaseCellComponentProps } from "../Constants";
+import { Checkbox } from "@design-system/widgets";
type CheckboxCellProps = BaseCellComponentProps & {
value: boolean;
@@ -60,67 +15,16 @@ type CheckboxCellProps = BaseCellComponentProps & {
};
const CheckboxCellComponent = (props: CheckboxCellProps) => {
- const {
- accentColor,
- borderRadius,
- cellBackground,
- compactMode,
- disabledCheckbox,
- disabledCheckboxMessage,
- hasUnSavedChanges,
- horizontalAlignment,
- isCellDisabled,
- isCellEditable,
- isCellVisible,
- isHidden,
- onChange,
- value,
- verticalAlignment,
- } = props;
+ const { disabledCheckbox, isCellEditable, onChange, value } = props;
- const checkbox = (
- onChange()}
- widgetId={""}
+ isSelected={value}
+ onChange={() => onChange()}
/>
);
- return (
-
- {hasUnSavedChanges && }
- {isCellEditable && !!disabledCheckbox ? (
-
- {disabledCheckboxMessage}
-
- }
- hoverOpenDelay={200}
- position="top"
- >
- {checkbox}
-
- ) : (
- checkbox
- )}
-
- );
};
export const CheckboxCell = memo(CheckboxCellComponent);
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/DateCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/DateCell.tsx
deleted file mode 100644
index a60ae8f6a18c..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/DateCell.tsx
+++ /dev/null
@@ -1,358 +0,0 @@
-import React, { useMemo, useRef, useState } from "react";
-import type { VerticalAlignment } from "../Constants";
-import {
- ALIGN_ITEMS,
- EDITABLE_CELL_PADDING_OFFSET,
- TABLE_SIZES,
-} from "../Constants";
-import DateComponent from "widgets/DatePickerWidget2/component";
-import { TimePrecision } from "widgets/DatePickerWidget2/constants";
-import type { RenderDefaultPropsType } from "./PlainTextCell";
-import styled from "styled-components";
-import { EditableCellActions } from "widgets/wds/WDSTableWidget/constants";
-import { ISO_DATE_FORMAT } from "constants/WidgetValidation";
-import moment from "moment";
-import { BasicCell } from "./BasicCell";
-import { Colors } from "constants/Colors";
-import ErrorTooltip from "components/editorComponents/ErrorTooltip";
-import {
- createMessage,
- INPUT_WIDGET_DEFAULT_VALIDATION_ERROR,
-} from "@appsmith/constants/messages";
-
-type DateComponentProps = RenderDefaultPropsType &
- editPropertyType & {
- accentColor?: string;
- borderRadius?: string;
- boxShadow?: string;
- closeOnSelection: boolean;
- maxDate: string;
- minDate: string;
- onDateChange?: string;
- shortcuts: boolean;
- timePrecision: TimePrecision;
- inputFormat: string;
- outputFormat: string;
- onDateSave: (
- rowIndex: number,
- alias: string,
- value: string,
- onSubmit?: string,
- ) => void;
- onDateSelectedString: string;
- firstDayOfWeek?: number;
- isRequired: boolean;
- updateNewRowValues: (
- alias: string,
- value: unknown,
- parsedValue: unknown,
- ) => void;
- };
-
-const COMPONENT_DEFAULT_VALUES = {
- maxDate: "2121-12-31T18:29:00.000Z",
- minDate: "1920-12-31T18:30:00.000Z",
- timePrecision: TimePrecision.MINUTE,
-};
-
-interface editPropertyType {
- alias: string;
- onDateSelectedString: string;
- rowIndex: number;
-}
-
-const DEFAULT_BORDER_RADIUS = "0";
-
-const Container = styled.div<{
- isCellEditMode?: boolean;
- verticalAlignment?: VerticalAlignment;
- cellBackground?: string;
-}>`
- height: 100%;
- width: 100%;
- display: flex;
- align-items: ${(props) =>
- props.verticalAlignment && ALIGN_ITEMS[props.verticalAlignment]};
-`;
-
-const FOCUS_CLASS = "has-focus";
-
-const Wrapper = styled.div<{
- accentColor: string;
- compactMode: string;
- allowCellWrapping?: boolean;
- verticalAlignment?: VerticalAlignment;
- textSize?: string;
- isEditableCellValid: boolean;
- paddedInput: boolean;
-}>`
- padding: 1px;
- border: 1px solid
- ${(props) => (!props.isEditableCellValid ? Colors.DANGER_SOLID : "#fff")};
- background: #fff;
- position: absolute;
- width: ${(props) =>
- props.paddedInput
- ? `calc(100% - ${EDITABLE_CELL_PADDING_OFFSET}px)`
- : "100%"};
- left: 50%;
- transform: translate(-50%, 0);
- overflow: hidden;
- border-radius: 3px;
- display: flex;
- height: ${(props) => {
- if (props.allowCellWrapping) {
- return props.paddedInput
- ? `calc(100% - ${EDITABLE_CELL_PADDING_OFFSET}px)`
- : "100%";
- } else {
- return props.paddedInput
- ? `${
- TABLE_SIZES[props.compactMode].ROW_HEIGHT -
- EDITABLE_CELL_PADDING_OFFSET
- }px`
- : `${TABLE_SIZES[props.compactMode].ROW_HEIGHT}px`;
- }
- }};
- ${(props) => {
- switch (props.verticalAlignment) {
- case "TOP":
- return `top: 0;`;
- case "BOTTOM":
- return `bottom: 0;`;
- case "CENTER":
- return `
- top: calc(50% - (${TABLE_SIZES[props.compactMode].ROW_HEIGHT}/2)px);
- `;
- }
- }}
-
- &&&&& {
- .bp3-input,
- .bp3-input:focus {
- border: none;
- /*
- * using !important since underlying
- * component styles has !important
- */
- box-shadow: none !important;
- padding: 0px 5px 0px 6px;
- font-size: ${(props) => props.textSize};
- background: transparent;
- color: inherit;
- }
- }
-
- &.${FOCUS_CLASS} {
- ${(props) =>
- props.isEditableCellValid && `border: 1px solid ${props.accentColor}`}
- }
-`;
-
-export const DateCell = (props: DateComponentProps) => {
- const {
- accentColor,
- alias,
- allowCellWrapping,
- borderRadius,
- cellBackground,
- columnType,
- compactMode,
- disabledEditIcon,
- disabledEditIconMessage,
- firstDayOfWeek,
- fontStyle,
- hasUnsavedChanges,
- horizontalAlignment,
- inputFormat,
- isCellDisabled,
- isCellEditable,
- isCellEditMode,
- isCellVisible,
- isHidden,
- isNewRow,
- isRequired,
- maxDate,
- minDate,
- onDateSave,
- onDateSelectedString,
- outputFormat,
- rowIndex,
- shortcuts,
- tableWidth,
- textColor,
- textSize,
- timePrecision,
- toggleCellEditMode,
- updateNewRowValues,
- validationErrorMessage,
- value,
- verticalAlignment,
- widgetId,
- } = props;
-
- const [hasFocus, setHasFocus] = useState(false);
- const [isValid, setIsValid] = useState(true);
- const [showRequiredError, setShowRequiredError] = useState(false);
- const contentRef = useRef(null);
-
- const valueInISOFormat = useMemo(() => {
- if (typeof value !== "string") return "";
-
- if (moment(value, ISO_DATE_FORMAT, true).isValid()) {
- return value;
- }
-
- const valueInSelectedFormat = moment(value, props.outputFormat, true);
-
- if (valueInSelectedFormat.isValid()) {
- return valueInSelectedFormat.format(ISO_DATE_FORMAT);
- }
-
- return value;
- }, [value, props.outputFormat]);
-
- const onDateSelected = (date: string) => {
- if (isNewRow) {
- updateNewRowValues(alias, date, date);
- return;
- }
-
- if (isRequired && !date) {
- setIsValid(false);
- setShowRequiredError(true);
- return;
- }
- setIsValid(true);
- setShowRequiredError(false);
- setHasFocus(false);
-
- const formattedDate = date ? moment(date).format(inputFormat) : "";
- onDateSave(rowIndex, alias, formattedDate, onDateSelectedString);
- };
-
- const onDateCellEdit = () => {
- setHasFocus(true);
- if (isRequired && !value) {
- setIsValid(false);
- setShowRequiredError(true);
- }
- toggleCellEditMode(true, rowIndex, alias, value);
- };
-
- const onPopoverClosed = () => {
- setHasFocus(false);
- setIsValid(true);
- toggleCellEditMode(
- false,
- rowIndex,
- alias,
- value,
- "",
- EditableCellActions.DISCARD,
- );
- };
-
- const onDateOutOfRange = () => {
- setIsValid(false);
- setShowRequiredError(false);
- };
-
- const onDateInputFocus = () => {
- if (isNewRow) {
- setHasFocus(true);
- }
- };
-
- let editor;
-
- if (isCellEditMode) {
- editor = (
-
-
-
-
-
- );
- }
-
- return (
-
-
- {editor}
-
- );
-};
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EditActionsCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EditActionsCell.tsx
deleted file mode 100644
index 5e65c9b1621a..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EditActionsCell.tsx
+++ /dev/null
@@ -1,93 +0,0 @@
-import React, { memo } from "react";
-import type { EventType } from "constants/AppsmithActionConstants/ActionConstants";
-import type { ButtonColumnActions } from "widgets/wds/WDSTableWidget/constants";
-import { EditableCellActions } from "widgets/wds/WDSTableWidget/constants";
-import { Button } from "./Button";
-import type { BaseCellComponentProps } from "../Constants";
-import { CellWrapper } from "../TableStyledWrappers";
-
-type RenderEditActionsProps = BaseCellComponentProps & {
- isSelected: boolean;
- columnActions: ButtonColumnActions[];
- onCommandClick: (
- dynamicTrigger: string,
- onComplete: () => void,
- eventType: EventType,
- ) => void;
- onDiscard: () => void;
-};
-
-function EditActionCellComponent(props: RenderEditActionsProps) {
- const {
- allowCellWrapping,
- cellBackground,
- columnActions,
- compactMode,
- fontStyle,
- horizontalAlignment,
- isCellDisabled,
- isCellVisible,
- isHidden,
- isSelected,
- onCommandClick,
- onDiscard,
- textColor,
- textSize,
- verticalAlignment,
- } = props;
-
- if (!columnActions) {
- return (
-
- );
- }
-
- return (
-
- {columnActions.map((action: ButtonColumnActions) => {
- return (
-
- );
-}
-export const EditActionCell = memo(EditActionCellComponent);
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EmptyCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EmptyCell.tsx
index e68a00278714..c4378ad3808a 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EmptyCell.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/EmptyCell.tsx
@@ -46,8 +46,7 @@ export const renderEmptyRows = (
};
return (
- {multiRowSelection &&
- renderBodyCheckBoxCell(false, accentColor, borderRadius)}
+ {multiRowSelection && renderBodyCheckBoxCell(false)}
{row.cells.map(
(cell: Cell>, cellIndex: number) => {
const cellProps = cell.getCellProps();
@@ -100,8 +99,7 @@ export const renderEmptyRows = (
return rows.map((row: string, index: number) => {
return (
- {multiRowSelection &&
- renderBodyCheckBoxCell(false, accentColor, borderRadius)}
+ {multiRowSelection && renderBodyCheckBoxCell(false)}
{tableColumns.map((column: any, colIndex: number) => {
const distanceFromEdge: {
left?: number;
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/HeaderCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/HeaderCell.tsx
index 1b6ef81fea67..eaaf8225e5c7 100644
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/HeaderCell.tsx
+++ b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/HeaderCell.tsx
@@ -189,7 +189,11 @@ const HeaderCellComponent = (props: HeaderProps) => {
-
+
{props.isAscOrder !== undefined && (
{
- Sort column ascending
- Sort column descending
- -
- Separator
-
- - Freeze column left
- - Freeze column right
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/IconButtonCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/IconButtonCell.tsx
deleted file mode 100644
index 426ecdce670d..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/IconButtonCell.tsx
+++ /dev/null
@@ -1,147 +0,0 @@
-import React, { useState } from "react";
-
-import type { ColumnAction } from "components/propertyControls/ColumnActionSelectorControl";
-import type { IconName } from "@blueprintjs/icons";
-import type { ButtonVariant } from "components/constants";
-import type { BaseCellComponentProps } from "../Constants";
-import { CellWrapper, IconButtonWrapper } from "../TableStyledWrappers";
-import { StyledButton } from "widgets/IconButtonWidget/component";
-
-interface RenderIconButtonProps extends BaseCellComponentProps {
- isSelected: boolean;
- columnActions?: ColumnAction[];
- iconName?: IconName;
- buttonVariant: ButtonVariant;
- buttonColor: string;
- borderRadius: string;
- boxShadow: string;
- onCommandClick: (dynamicTrigger: string, onComplete: () => void) => void;
- disabled: boolean;
-}
-
-function IconButton(props: {
- iconName?: IconName;
- onCommandClick: (dynamicTrigger: string, onComplete: () => void) => void;
- isSelected: boolean;
- action: ColumnAction;
- buttonColor: string;
- buttonVariant: ButtonVariant;
- borderRadius: string;
- boxShadow: string;
- disabled: boolean;
- compactMode?: string;
-}): JSX.Element {
- const [loading, setLoading] = useState(false);
- const onComplete = () => {
- setLoading(false);
- };
- const handlePropagation = (
- e: React.MouseEvent,
- ) => {
- if (props.isSelected) {
- e.stopPropagation();
- }
- };
- const handleClick = (e: React.MouseEvent) => {
- e.stopPropagation();
- if (props.action.dynamicTrigger) {
- setLoading(true);
- props.onCommandClick(props.action.dynamicTrigger, onComplete);
- }
- };
- return (
-
-
-
- );
-}
-
-export function IconButtonCell(props: RenderIconButtonProps) {
- const {
- allowCellWrapping,
- borderRadius,
- boxShadow,
- buttonColor,
- buttonVariant,
- cellBackground,
- columnActions,
- compactMode,
- disabled,
- fontStyle,
- horizontalAlignment,
- iconName,
- isCellDisabled,
- isCellVisible,
- isHidden,
- isSelected,
- onCommandClick,
- textColor,
- textSize,
- verticalAlignment,
- } = props;
-
- if (!columnActions)
- return (
-
- );
-
- return (
-
- {columnActions.map((action: ColumnAction, index: number) => {
- return (
-
- );
- })}
-
- );
-}
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ImageCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ImageCell.tsx
deleted file mode 100644
index 66ce26513a42..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/ImageCell.tsx
+++ /dev/null
@@ -1,126 +0,0 @@
-import React from "react";
-import { isString, noop } from "lodash";
-
-import { CellWrapper } from "../TableStyledWrappers";
-import type { BaseCellComponentProps, ImageSize } from "../Constants";
-
-/*
- * Function to split the CSV of image url's
- */
-function getImageArray(value: unknown) {
- // better regex: /(?
- match.length > 1 ? `${match.charAt(0)} ,` : " ,",
- )
- .split(imageSplitRegex)
- );
-}
-
-type renderImageType = BaseCellComponentProps & {
- value: unknown;
- onClick?: () => void;
- isSelected?: boolean;
- imageSize?: ImageSize;
-};
-
-export function ImageCell(props: renderImageType) {
- const {
- allowCellWrapping,
- cellBackground,
- compactMode,
- fontStyle,
- horizontalAlignment,
- imageSize,
- isCellDisabled,
- isCellVisible,
- isHidden,
- onClick = noop,
- textColor,
- textSize,
- value,
- verticalAlignment,
- } = props;
-
- if (!value) {
- return (
-
- );
- } else if (!isString(value)) {
- return (
-
- Invalid Image
-
- );
- }
-
- const imageUrlRegex =
- /(http(s?):)([/|.|\w|\s|-])*\.(?:jpeg|jpg|gif|png)??(?:&?[^=&]*=[^=&]*)*/;
- const base64ImageRegex = /^data:image\/.*;base64/;
- return (
-
- {getImageArray(value).map((item: string, index: number) => {
- if (imageUrlRegex.test(item) || base64ImageRegex.test(item)) {
- return (
- {
- e.stopPropagation();
- onClick();
- }}
- >
-
-
- );
- } else {
- return Invalid Image
;
- }
- })}
-
- );
-}
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/InlineCellEditor.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/InlineCellEditor.tsx
deleted file mode 100644
index e85305009588..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/InlineCellEditor.tsx
+++ /dev/null
@@ -1,304 +0,0 @@
-import { Colors } from "constants/Colors";
-import { isNil } from "lodash";
-import React, {
- useCallback,
- useLayoutEffect,
- useMemo,
- useRef,
- useState,
-} from "react";
-import styled from "styled-components";
-import type { InputHTMLType } from "widgets/BaseInputWidget/component";
-import BaseInputComponent from "widgets/BaseInputWidget/component";
-import { InputTypes } from "widgets/BaseInputWidget/constants";
-import type { EditableCell } from "widgets/wds/WDSTableWidget/constants";
-import type { VerticalAlignment } from "../Constants";
-import { EDITABLE_CELL_PADDING_OFFSET, TABLE_SIZES } from "../Constants";
-import {
- getLocaleDecimalSeperator,
- getLocaleThousandSeparator,
-} from "widgets/WidgetUtils";
-import { limitDecimalValue } from "widgets/CurrencyInputWidget/component/utilities";
-import * as Sentry from "@sentry/react";
-import { getLocale } from "utils/helpers";
-
-const FOCUS_CLASS = "has-focus";
-
-const Wrapper = styled.div<{
- accentColor: string;
- compactMode: string;
- allowCellWrapping?: boolean;
- verticalAlignment?: VerticalAlignment;
- textSize?: string;
- isEditableCellValid: boolean;
- paddedInput: boolean;
-}>`
- padding: 1px;
- border: 1px solid
- ${(props) => (!props.isEditableCellValid ? Colors.DANGER_SOLID : "#fff")};
- background: #fff;
- position: absolute;
- width: ${(props) =>
- props.paddedInput
- ? `calc(100% - ${EDITABLE_CELL_PADDING_OFFSET}px)`
- : "100%"};
- left: 50%;
- transform: translate(-50%, 0);
- overflow: hidden;
- border-radius: 3px;
- height: ${(props) => {
- if (props.allowCellWrapping) {
- return props.paddedInput
- ? `calc(100% - ${EDITABLE_CELL_PADDING_OFFSET}px)`
- : "100%";
- } else {
- return props.paddedInput
- ? `${
- TABLE_SIZES[props.compactMode].ROW_HEIGHT -
- EDITABLE_CELL_PADDING_OFFSET
- }px`
- : `${TABLE_SIZES[props.compactMode].ROW_HEIGHT}px`;
- }
- }};
- ${(props) => {
- switch (props.verticalAlignment) {
- case "TOP":
- return `top: 0;`;
- case "BOTTOM":
- return `bottom: 0;`;
- case "CENTER":
- return `
- top: calc(50% - (${TABLE_SIZES[props.compactMode].ROW_HEIGHT}/2)px);
- `;
- }
- }}
-
- &&&&& {
- .bp3-input,
- .bp3-input:focus {
- border: none;
- /*
- * using !important since underlying
- * component styles has !important
- */
- box-shadow: none !important;
- padding: 0px 5px 0px 6px;
- min-height: 34px;
- font-size: ${(props) => props.textSize};
- }
-
- .currency-change-dropdown-trigger {
- border: none;
- height: ${(props) =>
- TABLE_SIZES[props.compactMode].EDITABLE_CELL_HEIGHT}px;
- padding: 0 0 0 5px;
- margin-right: 0;
- }
-
- .bp3-button-group.bp3-vertical {
- display: none;
- }
-
- textarea.bp3-input {
- &,
- &:focus {
- line-height: 28px;
- padding: ${(props) =>
- TABLE_SIZES[props.compactMode].VERTICAL_EDITOR_PADDING}px
- 6px 0px 6px;
- }
- }
-
- .text-input-wrapper {
- height: calc(100% + 4px);
- border: none;
- box-shadow: none !important;
- }
- }
-
- &.${FOCUS_CLASS} {
- ${(props) =>
- props.isEditableCellValid && `border: 1px solid ${props.accentColor}`}
- }
-`;
-
-function convertToNumber(inputValue: string) {
- inputValue = inputValue.replace(
- new RegExp(`[${getLocaleDecimalSeperator()}]`),
- ".",
- );
-
- const parsedValue = Number(inputValue);
-
- if (isNaN(parsedValue) || inputValue.trim() === "" || isNil(inputValue)) {
- return null;
- } else if (Number.isFinite(parsedValue)) {
- return parsedValue;
- } else {
- return null;
- }
-}
-
-interface InlineEditorPropsType {
- accentColor: string;
- compactMode: string;
- inputType: InputTypes;
- inputHTMLType: InputHTMLType;
- multiline: boolean;
- onChange: (value: EditableCell["value"], inputValue: string) => void;
- onDiscard: () => void;
- onSave: () => void;
- value: any;
- allowCellWrapping?: boolean;
- verticalAlignment?: VerticalAlignment;
- textSize?: string;
- isEditableCellValid: boolean;
- validationErrorMessage: string;
- widgetId: string;
- paddedInput: boolean;
- autoFocus: boolean;
- additionalProps: Record;
-}
-
-export function InlineCellEditor({
- accentColor,
- additionalProps = {},
- allowCellWrapping,
- autoFocus,
- compactMode,
- inputHTMLType,
- inputType = InputTypes.TEXT,
- isEditableCellValid,
- multiline,
- onChange,
- onDiscard,
- onSave,
- textSize,
- validationErrorMessage,
- value,
- verticalAlignment,
- widgetId,
-}: InlineEditorPropsType) {
- const inputRef = useRef(null);
- const [hasFocus, setHasFocus] = useState(false);
- const [cursorPos, setCursorPos] = useState(value.length);
-
- const onFocusChange = useCallback(
- (focus: boolean) => {
- !focus && onSave();
- setHasFocus(focus);
- },
- [onSave],
- );
-
- const onKeyDown = useCallback(
- (event: React.KeyboardEvent) => {
- const { key } = event;
-
- switch (key) {
- case "Escape":
- onDiscard();
- break;
- case "Enter":
- if (!event.shiftKey) {
- onSave();
- event.preventDefault();
- }
- break;
- }
- },
- [onDiscard, onSave],
- );
-
- const onTextChange = useCallback(
- (inputValue: string) => {
- setCursorPos(inputRef.current?.selectionStart);
-
- let value: EditableCell["value"] = inputValue;
-
- if (inputType === InputTypes.NUMBER) {
- value = convertToNumber(inputValue);
- } else if (inputType === InputTypes.CURRENCY) {
- const decimalSeperator = getLocaleDecimalSeperator();
-
- try {
- if (inputValue && inputValue.includes(decimalSeperator)) {
- inputValue = limitDecimalValue(
- additionalProps.decimals as number,
- inputValue,
- );
- }
-
- value = convertToNumber(inputValue);
- } catch (e) {
- Sentry.captureException(e);
- }
- }
-
- onChange(value, inputValue);
- },
- [setCursorPos, onChange, inputType],
- );
-
- useLayoutEffect(() => {
- if (inputRef.current) {
- inputRef.current.selectionStart = cursorPos;
-
- if (cursorPos < value.length) {
- inputRef.current.selectionEnd = cursorPos;
- }
- }
- }, [multiline]);
-
- const parsedValue = useMemo(() => {
- if (inputType === InputTypes.CURRENCY && typeof value === "number") {
- return Intl.NumberFormat(getLocale(), {
- style: "decimal",
- minimumFractionDigits: additionalProps.decimals as number,
- maximumFractionDigits: additionalProps.decimals as number,
- })
- .format(value)
- .replaceAll(getLocaleThousandSeparator(), "");
- } else {
- return value;
- }
- }, [value]);
-
- return (
-
-
-
- );
-}
diff --git a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/MenuButtonCell.tsx b/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/MenuButtonCell.tsx
deleted file mode 100644
index 9f521301c02a..000000000000
--- a/app/client/src/widgets/wds/WDSTableWidget/component/cellComponents/MenuButtonCell.tsx
+++ /dev/null
@@ -1,135 +0,0 @@
-import React from "react";
-import type { IconName } from "@blueprintjs/icons";
-import type { Alignment } from "@blueprintjs/core";
-
-import type { BaseCellComponentProps } from "../Constants";
-import type { ButtonVariant } from "components/constants";
-import { CellWrapper } from "../TableStyledWrappers";
-import type { ColumnAction } from "components/propertyControls/ColumnActionSelectorControl";
-import MenuButtonTableComponent from "./menuButtonTableComponent";
-import type {
- ConfigureMenuItems,
- MenuItem,
- MenuItems,
- MenuItemsSource,
-} from "widgets/MenuButtonWidget/constants";
-
-interface MenuButtonProps extends Omit {
- action?: ColumnAction;
-}
-
-function MenuButton({
- borderRadius,
- boxShadow,
- compactMode,
- configureMenuItems,
- getVisibleItems,
- iconAlign,
- iconName,
- isCompact,
- isDisabled,
- isSelected,
- label,
- menuColor,
- menuItems,
- menuItemsSource,
- menuVariant,
- onCommandClick,
- rowIndex,
- sourceData,
-}: MenuButtonProps): JSX.Element {
- const handlePropagation = (
- e: React.MouseEvent,
- ) => {
- if (isSelected) {
- e.stopPropagation();
- }
- };
- const onItemClicked = (onClick?: string, index?: number) => {
- if (onClick) {
- onCommandClick(onClick, index);
- }
- };
-
- return (
-
-
-
- );
-}
-
-export interface RenderMenuButtonProps extends BaseCellComponentProps {
- isSelected: boolean;
- label: string;
- isDisabled: boolean;
- onCommandClick: (
- dynamicTrigger: string,
- index?: number,
- onComplete?: () => void,
- ) => void;
- isCompact?: boolean;
- menuItems: MenuItems;
- menuVariant?: ButtonVariant;
- menuColor?: string;
- borderRadius?: string;
- boxShadow?: string;
- iconName?: IconName;
- iconAlign?: Alignment;
- rowIndex: number;
- getVisibleItems: (rowIndex: number) => Array