+
-There is an updated version of the table component with some new features and compatibility with the
-[new hotkeys API](#core/components/hotkeys-target2): see [Table2](#table/table2).
+
Additional CSS required
+
+__ColumnHeaderCell2__, __JSONFormat2__, and __TruncatedFormat2__ (available since @blueprintjs/table v4.6.0)
+depend on @blueprintjs/popover2 styles, so you must also import this CSS file for those components
+to display properly:
+
+```scss
+@import "~@blueprintjs/popover2/lib/css/blueprint-popover2.css";
+```
### Features
@@ -38,6 +46,12 @@ There is an updated version of the table component with some new features and co
@## Basic usage
+
+
+There is an updated version of the table component with some new features and compatibility with the
+[new hotkeys API](#core/components/hotkeys-target2): see [Table2](#table/table2).
+
+
To create a table, you must define the rows and columns. Add children to the `Table` to create columns,
and change the `numRows` prop on the `Table` to set the number of rows.
diff --git a/packages/table/src/headers/columnHeader.tsx b/packages/table/src/headers/columnHeader.tsx
index f0feb3c018b..0d18973b2ed 100644
--- a/packages/table/src/headers/columnHeader.tsx
+++ b/packages/table/src/headers/columnHeader.tsx
@@ -26,11 +26,11 @@ import { IClientCoordinates } from "../interactions/dragTypes";
import { IIndexedResizeCallback } from "../interactions/resizable";
import { Orientation } from "../interactions/resizeHandle";
import { RegionCardinality, Regions } from "../regions";
-import { ColumnHeaderCell, IColumnHeaderCellProps } from "./columnHeaderCell";
+import { ColumnHeaderCell2, ColumnHeaderCellProps } from "./columnHeaderCell2";
import { Header, IHeaderProps } from "./header";
/** @deprecated use ColumnHeaderRenderer */
-export type IColumnHeaderRenderer = (columnIndex: number) => React.ReactElement
| null;
+export type IColumnHeaderRenderer = (columnIndex: number) => React.ReactElement | null;
// eslint-disable-next-line deprecation/deprecation
export type ColumnHeaderRenderer = IColumnHeaderRenderer;
@@ -44,8 +44,8 @@ export interface IColumnHeaderProps extends IHeaderProps, IColumnWidths, ColumnI
/**
* A ColumnHeaderRenderer that, for each ``, will delegate to:
* 1. The `columnHeaderCellRenderer` method from the ``
- * 2. A `` using the `name` prop from the ``
- * 3. A `` with a `name` generated from `Utils.toBase26Alpha`
+ * 2. A `` using the `name` prop from the ``
+ * 3. A `` with a `name` generated from `Utils.toBase26Alpha`
*/
cellRenderer: ColumnHeaderRenderer;
@@ -211,7 +211,7 @@ export class ColumnHeader extends React.Component {
width: `${rect.width}px`,
};
return (
- React.ReactElement;
}
+/** @deprecated use ColumnHeaderCellProps */
export interface IColumnHeaderCellProps extends IHeaderCellProps, IColumnNameProps {
/**
* Specifies if the column is reorderable.
@@ -82,13 +91,16 @@ export function HorizontalCellDivider(): JSX.Element {
return ;
}
+/** @deprecated use ColumnHeaderCell2 instead */
export class ColumnHeaderCell extends AbstractPureComponent2 {
+ public static displayName = `${DISPLAYNAME_PREFIX}.ColumnHeaderCell`;
+
public static defaultProps: IColumnHeaderCellProps = {
isActive: false,
menuIcon: "chevron-down",
};
- public static contextTypes: React.ValidationMap =
+ public static contextTypes: React.ValidationMap =
columnInteractionBarContextTypes;
/**
@@ -107,7 +119,7 @@ export class ColumnHeaderCell extends AbstractPureComponent2
- {/* HACKHACK: need to migrate to Popover2, see https://github.com/palantir/blueprint/issues/5480 */}
- {/* eslint-disable-next-line deprecation/deprecation, @blueprintjs/no-deprecated-components */}
- {/* eslint-disable-next-line deprecation/deprecation, @blueprintjs/no-deprecated-components */}
);
diff --git a/packages/table/src/headers/columnHeaderCell2.tsx b/packages/table/src/headers/columnHeaderCell2.tsx
new file mode 100644
index 00000000000..2f72b89bea3
--- /dev/null
+++ b/packages/table/src/headers/columnHeaderCell2.tsx
@@ -0,0 +1,175 @@
+/*
+ * Copyright 2022 Palantir Technologies, Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import classNames from "classnames";
+import * as React from "react";
+
+import { AbstractPureComponent2, Utils as CoreUtils, DISPLAYNAME_PREFIX, Icon } from "@blueprintjs/core";
+import { Popover2 } from "@blueprintjs/popover2";
+
+import * as Classes from "../common/classes";
+import { columnInteractionBarContextTypes, ColumnInteractionBarContextTypes } from "../common/context";
+import { LoadableContent } from "../common/loadableContent";
+import { CLASSNAME_EXCLUDED_FROM_TEXT_MEASUREMENT } from "../common/utils";
+import { HorizontalCellDivider, IColumnHeaderCellProps, IColumnHeaderCellState } from "./columnHeaderCell";
+import { HeaderCell } from "./headerCell";
+
+// eslint-disable-next-line deprecation/deprecation
+export type ColumnHeaderCellProps = IColumnHeaderCellProps;
+
+export class ColumnHeaderCell2 extends AbstractPureComponent2