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

Remove remaining deprecated props #2073

Merged
merged 11 commits into from
Feb 4, 2018
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"@types/enzyme": "^3.1.6",
"@types/enzyme-adapter-react-16": "^1.0.1",
"@types/mocha": "^2.2.46",
"@types/prop-types": "^15.5.2",
"@types/react": "^16.0.34",
"@types/react-dom": "^16.0.3",
"@types/react-transition-group": "^2.0.6",
Expand Down
13 changes: 7 additions & 6 deletions packages/core/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,29 +35,30 @@ export function getDisplayName(ComponentClass: React.ComponentClass | INamed) {

/**
* Safely invoke the function with the given arguments, if it is indeed a
* function, and return its value.
* function, and return its value. Otherwise, return undefined.
*/
export function safeInvoke<R>(func: (() => R) | undefined): R;
export function safeInvoke<A, R>(func: ((arg1: A) => R) | undefined, arg1: A): R;
export function safeInvoke<A, B, R>(func: ((arg1: A, arg2: B) => R) | undefined, arg1: A, arg2: B): R;
export function safeInvoke<R>(func: (() => R) | undefined): R | undefined;
export function safeInvoke<A, R>(func: ((arg1: A) => R) | undefined, arg1: A): R | undefined;
export function safeInvoke<A, B, R>(func: ((arg1: A, arg2: B) => R) | undefined, arg1: A, arg2: B): R | undefined;
export function safeInvoke<A, B, C, R>(
func: ((arg1: A, arg2: B, arg3: C) => R) | undefined,
arg1: A,
arg2: B,
arg3: C,
): R;
): R | undefined;
export function safeInvoke<A, B, C, D, R>(
func: ((arg1: A, arg2: B, arg3: C, arg4: D) => R) | undefined,
arg1: A,
arg2: B,
arg3: C,
arg4: D,
): R;
): R | undefined;
// tslint:disable-next-line:ban-types
export function safeInvoke(func: Function | undefined, ...args: any[]) {
if (isFunction(func)) {
return func(...args);
}
return undefined;
}

/**
Expand Down
3 changes: 0 additions & 3 deletions packages/datetime/src/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ export const DATERANGEPICKER_VALUE_INVALID = DATEPICKER_VALUE_INVALID.replace("D
export const DATERANGEPICKER_PREFERRED_BOUNDARY_TO_MODIFY_INVALID =
"<DateRangePicker> preferredBoundaryToModify must be a valid DateRangeBoundary if defined.";

export const DATEINPUT_WARN_DEPRECATED_POPOVER_POSITION =
ns + ` DEPRECATION: <DateInput> popoverPosition is deprecated. Use popoverProps.position.`;

export const DATERANGEINPUT_NULL_VALUE =
ns +
` <DateRangeInput> value cannot be null. Pass undefined to clear the value and operate in` +
Expand Down
17 changes: 0 additions & 17 deletions packages/datetime/src/dateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {
IProps,
Keys,
Popover,
Position,
Utils,
} from "@blueprintjs/core";

Expand All @@ -31,7 +30,6 @@ import {
momentToString,
stringToMoment,
} from "./common/dateUtils";
import { DATEINPUT_WARN_DEPRECATED_POPOVER_POSITION } from "./common/errors";
import { IDateFormatter } from "./dateFormatter";
import { DatePicker } from "./datePicker";
import { getDefaultMaxDate, getDefaultMinDate, IDatePickerBaseProps } from "./datePickerCore";
Expand Down Expand Up @@ -112,13 +110,6 @@ export interface IDateInputProps extends IDatePickerBaseProps, IProps {
*/
outOfRangeMessage?: string;

/**
* The position the date popover should appear in relative to the input box.
* @default Position.BOTTOM
* @deprecated since v1.15.0, use `popoverProps.position`
*/
popoverPosition?: Position;

/**
* Props to pass to the `Popover`.
* Note that `content`, `autoFocus`, and `enforceFocus` cannot be changed.
Expand Down Expand Up @@ -168,7 +159,6 @@ export class DateInput extends AbstractPureComponent<IDateInputProps, IDateInput
maxDate: getDefaultMaxDate(),
minDate: getDefaultMinDate(),
outOfRangeMessage: "Out of range",
popoverPosition: Position.BOTTOM,
reverseMonthAndYearMenus: false,
timePickerProps: {},
};
Expand Down Expand Up @@ -221,7 +211,6 @@ export class DateInput extends AbstractPureComponent<IDateInputProps, IDateInput
return (
<Popover
isOpen={this.state.isOpen && !this.props.disabled}
position={this.props.popoverPosition}
usePortal={false}
{...popoverProps}
autoFocus={false}
Expand Down Expand Up @@ -257,12 +246,6 @@ export class DateInput extends AbstractPureComponent<IDateInputProps, IDateInput
}
}

public validateProps(props: IDateInputProps) {
if (props.popoverPosition !== DateInput.defaultProps.popoverPosition) {
console.warn(DATEINPUT_WARN_DEPRECATED_POPOVER_POSITION);
}
}

private createMoment(valueString: string) {
// Locale here used for parsing, does not set the locale on the moment itself
return stringToMoment(valueString, this.props.format, this.props.locale);
Expand Down
2 changes: 1 addition & 1 deletion packages/docs-app/src/components/blueprintDocs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class BlueprintDocs extends React.Component<IBlueprintDocsProps, { themeN

const match = /docs\/v([0-9]+)/.exec(location.href);
// default to latest release if we can't find a major version in the URL
const currentRelease = match == null ? versions[0].version : match[1];
const currentRelease = match == null ? versions[versions.length - 1].version : match[1];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

const releaseItems = versions.map((rel, i) => <MenuItem key={i} href={rel.url} text={rel.version} />);
const menu = <Menu className="docs-version-list">{releaseItems}</Menu>;

Expand Down
4 changes: 2 additions & 2 deletions packages/docs-theme/src/components/documentation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ export class Documentation extends React.PureComponent<IDocumentationProps, IDoc
<div className={classNames("docs-root", { "docs-examples-only": examplesOnly }, this.props.className)}>
<div className="docs-app">
<div className="pt-navbar docs-navbar docs-flex-row">
<div className="pt-navbar-group">{this.props.navbarLeft}</div>
<div className="pt-navbar-group pt-navbar-group-left">{this.props.navbarLeft}</div>
<div className="pt-navbar-group">
<Navigator items={nav} onNavigate={this.handleNavigation} />
</div>
<div className="pt-navbar-group">{this.props.navbarRight}</div>
<div className="pt-navbar-group pt-navbar-group-right">{this.props.navbarRight}</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we have components for Navbar etc, but whatever

</div>
<div className="docs-nav" ref={this.refHandlers.nav}>
<NavMenu
Expand Down
9 changes: 5 additions & 4 deletions packages/docs-theme/src/styles/_navbar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,16 @@ All the components that live *inside* the navbar.
padding-left: 0;

.pt-navbar-group {
padding-left: $content-padding;
padding-left: $pt-grid-size;

&:first-child {
width: $sidebar-width;
&-left {
// allow extra space for long version strings
width: $sidebar-width + ($pt-grid-size * 2);
padding-left: 0;
}

// last child fills remaining space and right-aligns children
&:last-child {
&-right {
flex: 1 1 auto;
justify-content: flex-end;
}
Expand Down
1 change: 1 addition & 0 deletions packages/table/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"dependencies": {
"@blueprintjs/core": "^2.0.0-beta.3",
"classnames": "^2.2",
"prop-types": "^15.6.0",
"tslib": "^1.5.0"
},
"devDependencies": {
Expand Down
15 changes: 15 additions & 0 deletions packages/table/src/common/context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
* Licensed under the terms of the LICENSE file distributed with this project.
*/

import * as PropTypes from "prop-types";
import * as React from "react";

export interface IColumnInteractionBarContextTypes {
enableColumnInteractionBar: boolean;
}

export const columnInteractionBarContextTypes: React.ValidationMap<IColumnInteractionBarContextTypes> = {
enableColumnInteractionBar: PropTypes.bool,
};
11 changes: 1 addition & 10 deletions packages/table/src/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,7 @@
*/

const ns = "[Blueprint Table]";
const deprec = `${ns} DEPRECATION:`;

export const COLUMN_HEADER_CELL_MENU_DEPRECATED =
deprec + ` <ColumnHeaderCell> menu is deprecated. Use menuRenderer instead.`;
export const COLUMN_HEADER_CELL_USE_INTERACTION_BAR_DEPRECATED =
deprec +
` <ColumnHeaderCell> enableColumnInteractionBar is deprecated. Pass the prop to the top-level <Table> instead. When you pass the prop to <Table>, that value will override the one provided directly to <ColumnHeaderCell>.`;

export const ROW_HEADER_CELL_MENU_DEPRECATED =
deprec + ` <RowHeaderCell> menu is deprecated. Use menuRenderer instead.`;
// const deprec = `${ns} DEPRECATION:`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

eh, sort of on purpose. will be useful as a reminder for future deprecation messages 🤷‍♂️


export const QUADRANT_ON_SCROLL_UNNECESSARILY_DEFINED =
ns + ` <TableQuadrant> onScroll need not be defined for any quadrant aside from the MAIN quadrant.`;
Expand Down
54 changes: 1 addition & 53 deletions packages/table/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Licensed under the terms of the LICENSE file distributed with this project.
*/

import { IProps, Utils as CoreUtils } from "@blueprintjs/core";
import { IProps } from "@blueprintjs/core";
import * as classNames from "classnames";
import * as React from "react";

Expand Down Expand Up @@ -340,58 +340,6 @@ export const Utils = {
return event.button === 0;
},

// these functions used to live here but now live in core. since these Utils
// are in the public API, we provide facades here - complete with function
// descriptions - so as to make the refactor invisible externally.

/**
* Returns true if the arrays are equal. Elements will be shallowly compared
* by default, or they will be compared using the custom `compare` function
* if one is provided.
* @deprecated since @blueprintjs/table 1.26.0; import this function from
* core Utils instead.
*/
arraysEqual: CoreUtils.arraysEqual,

/**
* Deep comparison between objects. If `keys` is provided, just that subset
* of keys will be compared; otherwise, all keys will be compared.
* @deprecated since @blueprintjs/table 1.26.0; import this function from
* core Utils instead.
*/
deepCompareKeys: CoreUtils.deepCompareKeys,

/**
* Returns a descriptive object for each key whose values are deeply unequal
* between two provided objects. Useful for debugging shouldComponentUpdate.
* @deprecated since @blueprintjs/table 1.26.0; import this function from
* core Utils instead.
*/
getDeepUnequalKeyValues<T extends object>(objA: T, objB: T, keys?: Array<keyof T>) {
return CoreUtils.getDeepUnequalKeyValues(objA, objB, keys);
},

/**
* Returns a descriptive object for each key whose values are shallowly
* unequal between two provided objects. Useful for debugging
* shouldComponentUpdate.
* @deprecated since @blueprintjs/table 1.26.0; import this function from
* core Utils instead.
*/
getShallowUnequalKeyValues<T extends object>(objA: T, objB: T, keys?: IKeyBlacklist<T> | IKeyWhitelist<T>) {
return CoreUtils.getShallowUnequalKeyValues(objA, objB, keys);
},

/**
* Shallow comparison between objects. If `keys` is provided, just that
* subset of keys will be compared; otherwise, all keys will be compared.
* @deprecated since @blueprintjs/table 1.26.0; import this function from
* core Utils instead.
*/
shallowCompareKeys<T extends object>(objA: T, objB: T, keys?: IKeyBlacklist<T> | IKeyWhitelist<T>) {
return CoreUtils.shallowCompareKeys(objA, objB, keys);
},

getApproxCellHeight(
cellText: string,
columnWidth: number,
Expand Down
48 changes: 13 additions & 35 deletions packages/table/src/headers/columnHeaderCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,11 @@ import {
} from "@blueprintjs/core";

import * as Classes from "../common/classes";
import * as Errors from "../common/errors";
import { columnInteractionBarContextTypes, IColumnInteractionBarContextTypes } from "../common/context";
import { LoadableContent } from "../common/loadableContent";
import { HeaderCell, IHeaderCellProps } from "./headerCell";

export interface IColumnNameProps {
/**
* If `true`, adds an interaction bar on top of the column header cell and
* moves the menu and selection interactions to it.
*
* This allows you to override the rendering of column name without worry of
* clobbering the menu or other interactions.
*
* @default false
* @deprecated since blueprintjs/table v1.27.0; pass this prop to `Table`
* instead.
*/
enableColumnInteractionBar?: boolean;

/**
* The name displayed in the header of the column.
*/
Expand All @@ -49,7 +36,7 @@ export interface IColumnNameProps {
* `EditableName` component for editing column names.
*
* If you define this callback, we recommend you also set
* `enableColumnInteractionBar` to `true`, to avoid issues with menus or selection.
* `<Table enableColumnInteractionBar={true}>` to avoid issues with menus or selection.
*
* The callback will also receive the column index if an `index` was originally
* provided via props.
Expand Down Expand Up @@ -85,11 +72,14 @@ export function HorizontalCellDivider(): JSX.Element {

export class ColumnHeaderCell extends AbstractPureComponent<IColumnHeaderCellProps, IColumnHeaderCellState> {
public static defaultProps: IColumnHeaderCellProps = {
enableColumnInteractionBar: false,
isActive: false,
menuIconName: "chevron-down",
};

public static contextTypes: React.ValidationMap<
IColumnInteractionBarContextTypes
> = columnInteractionBarContextTypes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't need React.ValidationMap... type info. let it come from columnInteractionBarContextTypes

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you do need it. there's a whole "typescript cannot name this type even though it knows where it comes from" rabbit hole which I won't bother explaining here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dang i gotcha


/**
* This method determines if a `MouseEvent` was triggered on a target that
* should be used as the header click/drag target. This enables users of
Expand All @@ -106,6 +96,7 @@ export class ColumnHeaderCell extends AbstractPureComponent<IColumnHeaderCellPro
);
}

public context: IColumnInteractionBarContextTypes;
public state = {
isActive: false,
};
Expand All @@ -120,14 +111,13 @@ export class ColumnHeaderCell extends AbstractPureComponent<IColumnHeaderCellPro
// from IColumnNameProps
name,
nameRenderer,
enableColumnInteractionBar,

// from IHeaderProps
...spreadableProps
} = this.props;

const classes = classNames(spreadableProps.className, Classes.TABLE_COLUMN_HEADER_CELL, {
[Classes.TABLE_HAS_INTERACTION_BAR]: enableColumnInteractionBar,
[Classes.TABLE_HAS_INTERACTION_BAR]: this.context.enableColumnInteractionBar,
[Classes.TABLE_HAS_REORDER_HANDLE]: this.props.reorderHandle != null,
});

Expand All @@ -145,17 +135,8 @@ export class ColumnHeaderCell extends AbstractPureComponent<IColumnHeaderCellPro
);
}

protected validateProps(nextProps: IColumnHeaderCellProps) {
if (nextProps.menu != null) {
// throw this warning from the publicly exported, higher-order *HeaderCell components
// rather than HeaderCell, so consumers know exactly which components are receiving the
// offending prop
console.warn(Errors.COLUMN_HEADER_CELL_MENU_DEPRECATED);
}
}

private renderName() {
const { index, loading, name, nameRenderer, reorderHandle, enableColumnInteractionBar } = this.props;
const { index, loading, name, nameRenderer, reorderHandle } = this.props;

const dropdownMenu = this.maybeRenderDropdownMenu();
const defaultName = <div className={Classes.TABLE_TRUNCATED_TEXT}>{name}</div>;
Expand All @@ -168,7 +149,7 @@ export class ColumnHeaderCell extends AbstractPureComponent<IColumnHeaderCellPro
</LoadableContent>
);

if (enableColumnInteractionBar) {
if (this.context.enableColumnInteractionBar) {
return (
<div className={Classes.TABLE_COLUMN_NAME} title={name}>
<div className={Classes.TABLE_INTERACTION_BAR}>
Expand Down Expand Up @@ -199,24 +180,21 @@ export class ColumnHeaderCell extends AbstractPureComponent<IColumnHeaderCellPro
}

private maybeRenderDropdownMenu() {
const { index, menu, menuIconName, menuRenderer } = this.props;
const { index, menuIconName, menuRenderer } = this.props;

if (menuRenderer == null && menu == null) {
if (!CoreUtils.isFunction(menuRenderer)) {
return undefined;
}

const classes = classNames(Classes.TABLE_TH_MENU_CONTAINER, {
[Classes.TABLE_TH_MENU_OPEN]: this.state.isActive,
});

// prefer menuRenderer if it's defined
const content = CoreUtils.isFunction(menuRenderer) ? menuRenderer(index) : menu;

return (
<div className={classes}>
<div className={Classes.TABLE_TH_MENU_CONTAINER_BACKGROUND} />
<Popover
content={content}
content={menuRenderer(index)}
position={Position.BOTTOM}
className={Classes.TABLE_TH_MENU}
modifiers={{ preventOverflow: { boundariesElement: "window" } }}
Expand Down
Loading