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

React 16 and Enzyme 3 migration #1885

Merged
merged 43 commits into from
Dec 13, 2017
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
817d141
Bump to react 16, regen lockfile
adidahiya Dec 11, 2017
4478ac8
pure-render-decorator -> React.PureComponent
adidahiya Dec 11, 2017
c5a98e4
Migrate to react-transition-group
adidahiya Dec 11, 2017
73d7a8e
Migrate to ReactDOM.createPortal
adidahiya Dec 11, 2017
3df77f1
Merge remote-tracking branch 'origin/master' into ad/react-16
adidahiya Dec 11, 2017
49f8069
Fix Table component shouldComponentUpdate warnings
adidahiya Dec 11, 2017
c2074d5
Restore wrapper div for Portal component
adidahiya Dec 11, 2017
ab2c99b
Upgrade enzyme, install enzyme-adapter-react-16
adidahiya Dec 11, 2017
cee34d5
Configure isomorphic tests with enzyme adapter
adidahiya Dec 11, 2017
9efdfbf
Skip Portal isomorphic tests
adidahiya Dec 12, 2017
f2ec4e6
Load es6-shim in all tests
adidahiya Dec 12, 2017
d1c94a7
Fix NumericInput prop validation tests
adidahiya Dec 12, 2017
c7fa963
Add TestErrorBoundary component
adidahiya Dec 12, 2017
a1cc25a
Create @blueprintjs/test-commons package
adidahiya Dec 12, 2017
391fadb
Fix DatePicker prop validation tests
adidahiya Dec 12, 2017
4158d2e
Fix more prop validation tests
adidahiya Dec 12, 2017
6d90e49
Fix more prop validation tests
adidahiya Dec 12, 2017
ecfa923
Merge remote-tracking branch 'origin/master' into ad/react-16
adidahiya Dec 12, 2017
307297b
Merge remote-tracking branch 'origin/master' into ad/react-16
adidahiya Dec 12, 2017
02cbae9
Fix up test config for latest Enzyme; load CSS files
adidahiya Dec 12, 2017
3395389
Move tabs2 tests to their own folder
adidahiya Dec 12, 2017
ce4c03f
Skip more tests
adidahiya Dec 12, 2017
53d894d
[CollapsibleList] fix unit tests
adidahiya Dec 12, 2017
583507e
Add test:karma:debug NPM scripts to libraries
adidahiya Dec 12, 2017
2f5a61b
Merge remote-tracking branch 'origin/master' into ad/react-16
adidahiya Dec 12, 2017
c30628f
Upgrade tsc in test-commons package
adidahiya Dec 12, 2017
9e94155
ReactWrapper#getNode() -> ReactWrapper#instance()
adidahiya Dec 12, 2017
b728ccb
Disable karma coverage in debug scripts
adidahiya Dec 12, 2017
b930727
Add two different abstract components, pure and not (#1896)
gscshoyru Dec 12, 2017
18cb414
Remove unused overlayTransition.tsx
adidahiya Dec 12, 2017
0b9ee4a
Merge remote-tracking branch 'origin/master' into ad/react-16
adidahiya Dec 12, 2017
b4f5068
Fix semantic merge conflicts from select package moves
adidahiya Dec 12, 2017
e0238ad
Merge remote-tracking branch 'origin/ad/react-16' into ad/react-16
adidahiya Dec 12, 2017
7f62bdd
Merge remote-tracking branch 'origin/master' into ad/react-16
adidahiya Dec 13, 2017
bf7bfb3
Fix core tests (#1898)
giladgray Dec 13, 2017
9397fe8
Fix table tests (#1897)
themadcreator Dec 13, 2017
3f38773
React 16/Enzyme 3 - Fix datetime tests (#1899)
cmslewis Dec 13, 2017
d4299b8
Skip abstractComponent coverage; fix select package test setup
adidahiya Dec 13, 2017
6a49270
Address follow up comments on #1898
adidahiya Dec 13, 2017
022586c
Remove extraneous core karma test config
adidahiya Dec 13, 2017
5dbc249
Remove extra props interface in table impl
adidahiya Dec 13, 2017
aa47e76
Remove --browsers from test:karma:debug
adidahiya Dec 13, 2017
71988dd
Address CR feedback on tests
adidahiya Dec 13, 2017
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
8 changes: 3 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@
"@types/dom4": "^1.5.20",
"@types/enzyme": "^2.8.0",
"@types/mocha": "^2.2.43",
"@types/pure-render-decorator": "^0.2.28",
"@types/react": "^16.0.14",
"@types/react-addons-css-transition-group": "^15.0.3",
"@types/react-addons-transition-group": "^15.0.1",
"@types/react-dom": "^16.0.1",
"@types/react": "^16.0.28",
"@types/react-transition-group": "^2.0.6",
"@types/react-dom": "^16.0.3",
"@types/sinon": "^2.3.7",
"@types/tether": "^1.4.3",
"@types/webpack": "^3.8.0",
Expand Down
15 changes: 7 additions & 8 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@
"classnames": "^2.2",
"dom4": "^1.8",
"normalize.css": "4.1.1",
"pure-render-decorator": "^1.1",
"tether": "^1.4",
"tslib": "^1.5.0"
},
"peerDependencies": {
"react": "^16.0.0 || ^15.0.1 || ^0.14",
"react-addons-css-transition-group": "^15.0.1 || ^0.14",
"react-dom": "^16.0.0 || ^15.0.1 || ^0.14"
"react": "^16.0.0",
"react-transition-group" :"^2.2.1",
"react-dom": "^16.0.0"
},
"devDependencies": {
"@blueprintjs/karma-build-scripts": "^0.2.0",
Expand All @@ -53,10 +52,10 @@
"mocha": "^4.0.1",
"node-sass": "^4.7.2",
"npm-run-all": "^4.1.1",
"react": "^15.6.1",
"react-addons-css-transition-group": "^15.6.1",
"react-dom": "^15.6.1",
"react-test-renderer": "^15.6.1",
"react": "^16.2.0",
"react-transition-group": "^2.2.1",
"react-dom": "^16.2.0",
"react-test-renderer": "^16.2.0",
"tslint": "^5.8.0",
"typescript": "~2.4.2",
"webpack": "^3.9.1"
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/common/_react-transition.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
// Licensed under the terms of the LICENSE file distributed with this project.

/*
A mixin to generate the classes for a React CSSTransitionGroup which animates any number of CSS
A mixin to generate the classes for a React CSSTransition which animates any number of CSS
properties at once.

Transitioned properties are specificed as a map of property names to lists of (inital value, final
value). For enter & appear transitions, each property will transition from its initial to its final
value. For leave transitions, each property will transition in reverse, from final to initial.
value. For exit transitions, each property will transition in reverse, from final to initial.

**Simple example:**
`@include react-transition("pt-popover", (opacity: 0 1), $before: "&");`
Expand Down Expand Up @@ -39,17 +39,17 @@ $after: selector text to insert after transiton name (to select children)
$before, $after
);
@include react-transition-phase(
$name, "leave", $properties,
$name, "exit", $properties,
$duration, $easing, $delay,
$before, $after
);
}

/*
A mixin to generate the classes for one phase of a React CSSTransitionGroup.
`$phase` must be `appear` or `enter` or `leave`.
A mixin to generate the classes for one phase of a React CSSTransition.
`$phase` must be `appear` or `enter` or `exit`.
If `enter` phase is given then `appear` phase will be generated at the same time.
If `leave` phase is given then property values are animated in reverse, from final to initial.
If `exit` phase is given then property values are animated in reverse, from final to initial.

**Example:**
@include react-transition-phase(pt-toast, enter, $enter-translate, $before: "&");
Expand All @@ -68,11 +68,11 @@ If `leave` phase is given then property values are animated in reverse, from fin
$start-index: 1;
$end-index: 2;

@if ($phase == "leave") {
@if ($phase == "exit") {
$start-index: 2;
$end-index: 1;
} @else if ($phase != "enter" and $phase != "appear") {
@error "Unknown transition phase: #{$phase}. Expected appear|enter|leave.";
@error "Unknown transition phase: #{$phase}. Expected appear|enter|exit.";
}

#{transition-name($phase, $name, $before, $after)} {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/common/abstractComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { isNodeEnv } from "./utils";
* An abstract component that Blueprint components can extend
* in order to add some common functionality like runtime props validation.
*/
export abstract class AbstractComponent<P, S> extends React.Component<P, S> {
export abstract class AbstractComponent<P, S> extends React.PureComponent<P, S> {
/** Component displayName should be `public static`. This property exists to prevent incorrect usage. */
protected displayName: never;

Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/button/buttonGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand Down Expand Up @@ -38,8 +37,7 @@ export interface IButtonGroupProps extends IProps, React.HTMLProps<HTMLDivElemen

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class ButtonGroup extends React.Component<IButtonGroupProps, {}> {
export class ButtonGroup extends React.PureComponent<IButtonGroupProps, {}> {
Copy link
Contributor

Choose a reason for hiding this comment

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

we should be able to drop these empty {} state types, as the React types now provide a default: interface Component<P = {}, S = {}>.

though it's fine to not do this now, or ever.

public static displayName = "Blueprint.ButtonGroup";

public render() {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/callout/callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";

import { Classes, IIntentProps, IProps } from "../../common";
Expand All @@ -25,8 +24,7 @@ export interface ICalloutProps extends IIntentProps, IProps {
title?: string;
}

@PureRender
export class Callout extends React.Component<ICalloutProps & React.HTMLAttributes<HTMLDivElement>, {}> {
export class Callout extends React.PureComponent<ICalloutProps & React.HTMLAttributes<HTMLDivElement>, {}> {
public render() {
const { className, children, iconName, intent, title, ...htmlProps } = this.props;
const classes = classNames(
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/card/card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand Down Expand Up @@ -54,8 +53,7 @@ const ELEVATION_CLASSES = [
Classes.ELEVATION_4,
];

@PureRender
export class Card extends React.Component<ICardProps, {}> {
export class Card extends React.PureComponent<ICardProps, {}> {
public static displayName = "Blueprint.Card";
public static defaultProps: ICardProps = {
elevation: Elevation.ZERO,
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/dialog/dialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface IDialogProps extends IOverlayableProps, IBackdropProps, IProps
title?: string | JSX.Element;

/**
* Name of the transition for internal `CSSTransitionGroup`.
* Name of the transition for internal `CSSTransition`.
* Providing your own name here will require defining new CSS transition properties.
*/
transitionName?: string;
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/components/editable-text/editableText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";

import { AbstractComponent } from "../../common/abstractComponent";
Expand Down Expand Up @@ -105,7 +104,6 @@ export interface IEditableTextState {
const BUFFER_WIDTH_EDGE = 5;
const BUFFER_WIDTH_IE = 30;

@PureRender
export class EditableText extends AbstractComponent<IEditableTextProps, IEditableTextState> {
public static defaultProps: IEditableTextProps = {
confirmOnEnterKey: false,
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/forms/controlGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand All @@ -24,8 +23,7 @@ export interface IControlGroupProps extends React.AllHTMLAttributes<HTMLDivEleme

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class ControlGroup extends React.Component<IControlGroupProps, {}> {
export class ControlGroup extends React.PureComponent<IControlGroupProps, {}> {
public static displayName = "Blueprint.ControlGroup";

public render() {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/forms/fileUpload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import { Utils } from "../../common";
import * as Classes from "../../common/classes";
Expand Down Expand Up @@ -57,8 +56,7 @@ export interface IFileUploadProps extends React.AllHTMLAttributes<HTMLLabelEleme

// TODO: write tests (ignoring for now to get a build passing quickly)
/* istanbul ignore next */
@PureRender
export class FileUpload extends React.Component<IFileUploadProps, {}> {
export class FileUpload extends React.PureComponent<IFileUploadProps, {}> {
public static displayName = "Blueprint.FileUpload";

public static defaultProps: IFileUploadProps = {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/forms/formGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IIntentProps, IProps } from "../../common/props";
Expand Down Expand Up @@ -44,8 +43,7 @@ export interface IFormGroupProps extends IIntentProps, IProps {
requiredLabel?: boolean | React.ReactNode;
}

@PureRender
export class FormGroup extends React.Component<IFormGroupProps, {}> {
export class FormGroup extends React.PureComponent<IFormGroupProps, {}> {
/**
* Element used to render `required` message when a boolean value is provided for that prop.
* Modifying the value of this property will change the default globally in your app.
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/forms/inputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";

import * as Classes from "../../common/classes";
Expand Down Expand Up @@ -46,8 +45,7 @@ export interface IInputGroupState {
rightElementWidth?: number;
}

@PureRender
export class InputGroup extends React.Component<HTMLInputProps & IInputGroupProps, IInputGroupState> {
export class InputGroup extends React.PureComponent<HTMLInputProps & IInputGroupProps, IInputGroupState> {
public static displayName = "Blueprint.InputGroup";

public state: IInputGroupState = {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/forms/label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand All @@ -26,8 +25,7 @@ export interface ILabelProps extends React.AllHTMLAttributes<HTMLDivElement>, IP

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class Label extends React.Component<ILabelProps, {}> {
export class Label extends React.PureComponent<ILabelProps, {}> {
public static displayName = "Blueprint.Label";

public render() {
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/components/forms/numericInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";

import {
Expand Down Expand Up @@ -129,7 +128,6 @@ enum IncrementDirection {
UP = +1,
}

@PureRender
export class NumericInput extends AbstractComponent<HTMLInputProps & INumericInputProps, INumericInputState> {
public static displayName = "Blueprint.NumericInput";

Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/forms/textArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IIntentProps, IProps } from "../../common/props";
Expand All @@ -24,8 +23,7 @@ export interface ITextAreaProps extends React.AllHTMLAttributes<HTMLTextAreaElem

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class TextArea extends React.Component<ITextAreaProps, {}> {
export class TextArea extends React.PureComponent<ITextAreaProps, {}> {
public static displayName = "Blueprint.TextArea";

public render() {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/icon/icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";

import { Classes, IIntentProps, IProps } from "../../common";
Expand All @@ -31,8 +30,7 @@ export interface IIconProps extends IIntentProps, IProps {
iconSize?: 16 | 20 | "inherit";
}

@PureRender
export class Icon extends React.Component<IIconProps & React.HTMLAttributes<HTMLSpanElement>, never> {
export class Icon extends React.PureComponent<IIconProps & React.HTMLAttributes<HTMLSpanElement>, never> {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove never, or make it {} like all the others

public static displayName = "Blueprint.Icon";

public static readonly SIZE_STANDARD = 16 as 16;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/navbar/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand All @@ -23,8 +22,7 @@ export interface INavbarProps extends React.HTMLProps<HTMLDivElement>, IProps {

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class Navbar extends React.Component<INavbarProps, {}> {
export class Navbar extends React.PureComponent<INavbarProps, {}> {
public static displayName = "Blueprint.Navbar";

public static Divider = NavbarDivider;
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/navbar/navbarDivider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand All @@ -18,8 +17,7 @@ export interface INavbarDividerProps extends React.HTMLProps<HTMLDivElement>, IP

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class NavbarDivider extends React.Component<INavbarDividerProps, {}> {
export class NavbarDivider extends React.PureComponent<INavbarDividerProps, {}> {
public static displayName = "Blueprint.NavbarDivider";

public render() {
Expand Down
4 changes: 1 addition & 3 deletions packages/core/src/components/navbar/navbarGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import * as classNames from "classnames";
import * as PureRender from "pure-render-decorator";
import * as React from "react";
import * as Classes from "../../common/classes";
import { IProps } from "../../common/props";
Expand All @@ -20,8 +19,7 @@ export interface INavbarGroupProps extends React.HTMLProps<HTMLDivElement>, IPro

// this component is simple enough that tests would be purely tautological.
/* istanbul ignore next */
@PureRender
export class NavbarGroup extends React.Component<INavbarGroupProps, {}> {
export class NavbarGroup extends React.PureComponent<INavbarGroupProps, {}> {
public static displayName = "Blueprint.NavbarGroup";

public static defaultProps: INavbarGroupProps = {
Expand Down
Loading