Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[table] deprecate IMenuContext in favor of MenuContext #6196

Merged
merged 2 commits into from
Jun 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
Column,
ColumnHeaderCell2,
CopyCellsMenuItem,
IMenuContext,
MenuContext,
SelectionModes,
Table2,
Utils,
Expand Down Expand Up @@ -230,7 +230,7 @@ export class TableSortableExample extends React.PureComponent<ExampleProps> {
return this.state.data[rowIndex][columnIndex];
};

private renderBodyContextMenu = (context: IMenuContext) => {
private renderBodyContextMenu = (context: MenuContext) => {
return (
<Menu>
<CopyCellsMenuItem context={context} getCellData={this.getCellData} text="Copy" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const DEPRECATED_TYPE_REFERENCES_BY_PACKAGE = {
"IColumnHeaderCellRenderer",
"IColumnHeaderRenderer",
"IColumnProps",
"IContextMenuRenderer",
"ICoordinateData",
"IFocusedCellCoordinates",
"IJSONFormatProps",
Expand Down
4 changes: 2 additions & 2 deletions packages/table-dev-app/src/features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
CopyCellsMenuItem,
EditableCell2,
EditableName,
IMenuContext,
JSONFormat2,
MenuContext,
Region,
RegionCardinality,
Regions,
Expand Down Expand Up @@ -449,7 +449,7 @@ ReactDOM.render(
document.getElementById("table-1"),
);

const bodyContextMenuRenderer = (context: IMenuContext) => {
const bodyContextMenuRenderer = (context: MenuContext) => {
const getCellData = (row: number, col: number) => {
return Utils.toBase26Alpha(col) + (row + 1);
};
Expand Down
4 changes: 2 additions & 2 deletions packages/table-dev-app/src/mutableTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
EditableName,
FocusedCellCoordinates,
JSONFormat2,
MenuContext,
Region,
RegionCardinality,
Regions,
Expand All @@ -56,7 +57,6 @@ import {
TruncatedPopoverMode,
Utils,
} from "@blueprintjs/table";
import { IMenuContext } from "@blueprintjs/table/src";
import type { ColumnIndices, RowIndices } from "@blueprintjs/table/src/common/grid";

import { DenseGridMutableStore } from "./denseGridMutableStore";
Expand Down Expand Up @@ -1111,7 +1111,7 @@ export class MutableTable extends React.Component<{}, IMutableTableState> {
return handleStringChange(value => this.setState({ [stateKey]: value }));
};

private renderBodyContextMenu = (context: IMenuContext) => {
private renderBodyContextMenu = (context: MenuContext) => {
const menu = (
<Menu>
<CopyCellsMenuItem context={context} icon="clipboard" getCellData={this.getCellValue} text="Copy" />
Expand Down
1 change: 1 addition & 0 deletions packages/table/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type {

export {
CopyCellsMenuItem,
MenuContext,
type IContextMenuRenderer,
type ContextMenuRenderer,
type IMenuContext,
Expand Down
6 changes: 3 additions & 3 deletions packages/table/src/interactions/menus/copyCellsMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ import { MenuItem, MenuItemProps } from "@blueprintjs/core";
import { Clipboard } from "../../common/clipboard";
import { TABLE_COPY_FAILED } from "../../common/errors";
import { Regions } from "../../regions";
import { IMenuContext } from "./menuContext";
import { MenuContext } from "./menuContext";

export interface ICopyCellsMenuItemProps extends MenuItemProps {
/**
* The `IMenuContext` that launched the menu.
* The `MenuContext` that launched the menu.
*/
context: IMenuContext;
context: MenuContext;

/**
* A callback that returns the data for a specific cell. This need not
Expand Down
6 changes: 5 additions & 1 deletion packages/table/src/interactions/menus/menuContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@

import { CellCoordinate, Region, Regions } from "../../regions";

export type IContextMenuRenderer = (context: IMenuContext) => JSX.Element;
/** @deprecated use `ContextMenuRenderer` */
export type IContextMenuRenderer = (context: MenuContext) => JSX.Element;
// eslint-disable-next-line deprecation/deprecation
export type ContextMenuRenderer = IContextMenuRenderer;

/** @deprecated use `MenuContext`, which is forwards-compatible with Blueprint v5.0 */
export interface IMenuContext {
/**
* Returns an array of `Region`s that represent the user-intended context
Expand Down Expand Up @@ -49,6 +52,7 @@ export interface IMenuContext {
getUniqueCells: () => CellCoordinate[];
}

// eslint-disable-next-line deprecation/deprecation
export class MenuContext implements IMenuContext {
private regions: Region[];

Expand Down
6 changes: 3 additions & 3 deletions packages/table/src/tableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import * as Classes from "./common/classes";
import { ContextMenuTargetWrapper } from "./common/contextMenuTargetWrapper";
import { RenderMode } from "./common/renderMode";
import { ICoordinateData } from "./interactions/dragTypes";
import { IContextMenuRenderer, MenuContext } from "./interactions/menus";
import { ContextMenuRenderer, MenuContext } from "./interactions/menus";
import { DragSelectable, ISelectableProps } from "./interactions/selectable";
import { ILocator } from "./locator";
import { Region, Regions } from "./regions";
Expand All @@ -42,10 +42,10 @@ export type TableBodyProps = ITableBodyProps;
export interface ITableBodyProps extends ISelectableProps, ITableBodyCellsProps {
/**
* An optional callback for displaying a context menu when right-clicking
* on the table body. The callback is supplied with an `IMenuContext`
* on the table body. The callback is supplied with an `MenuContext`
* containing the `Region`s of interest.
*/
bodyContextMenuRenderer?: IContextMenuRenderer;
bodyContextMenuRenderer?: ContextMenuRenderer;

/**
* Locates the row/column/cell given a mouse event.
Expand Down
4 changes: 2 additions & 2 deletions packages/table/src/tableProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import type { ColumnIndices, RowIndices } from "./common/grid";
import type { RenderMode } from "./common/renderMode";
import type { IColumnWidths } from "./headers/columnHeader";
import type { IRowHeights, RowHeaderRenderer } from "./headers/rowHeader";
import type { IContextMenuRenderer } from "./interactions/menus";
import type { ContextMenuRenderer } from "./interactions/menus";
import type { IIndexedResizeCallback } from "./interactions/resizable";
import type { ISelectedRegionTransform } from "./interactions/selectable";
import type { Region, RegionCardinality, StyledRegionGroup, TableLoadingOption } from "./regions";
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface ITableProps extends Props, Partial<IRowHeights>, Partial<IColum
* contain all selected regions. Otherwise it will have one `Region` that
* represents the clicked cell.
*/
bodyContextMenuRenderer?: IContextMenuRenderer;
bodyContextMenuRenderer?: ContextMenuRenderer;

/**
* If `true`, adds an interaction bar on top of all column header cells, and
Expand Down