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

upgrade popper & react-popper for latest typings #2247

Merged
merged 2 commits into from
Mar 15, 2018
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
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
"classnames": "^2.2",
"dom4": "^2.0.1",
"normalize.css": "^7.0.0",
"popper.js": "^1.12.6",
"react-popper": "~0.7.4",
"popper.js": "^1.14.1",
"react-popper": "^0.8.2",
"tslib": "^1.9.0"
},
"peerDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/menu/menuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import classNames from "classnames";
import * as React from "react";

import { Modifiers } from "popper.js";
import * as Classes from "../../common/classes";
import { Position } from "../../common/position";
import { IActionProps, ILinkProps } from "../../common/props";
Expand Down Expand Up @@ -153,7 +154,7 @@ export class MenuItem extends React.PureComponent<IMenuItemProps & React.AnchorH
}
}

const SUBMENU_POPOVER_MODIFIERS: Popper.Modifiers = {
const SUBMENU_POPOVER_MODIFIERS: Modifiers = {
// 20px padding - scrollbar width + a bit
flip: { boundariesElement: "viewport", padding: 20 },
// shift popover up 5px so MenuItems align
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/popover/arrow.tsx
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 PopperJS from "popper.js";
import { Placement } from "popper.js";
import * as React from "react";
import { Arrow } from "react-popper";

Expand All @@ -21,7 +21,7 @@ const SVG_ARROW_PATH =
"c0-1.654-.983-3.9-2.21-5.03l-7.183-6.616c-.81-.746-.802-1.96 0-2.7l7.183-6.614z";

/** Modifier helper function to compute arrow rotate() transform */
export function getArrowAngle(placement: PopperJS.Placement) {
export function getArrowAngle(placement: Placement) {
// can only be top/left/bottom/right - auto is resolved internally
switch (getPosition(placement)) {
case "top":
Expand Down
9 changes: 5 additions & 4 deletions packages/core/src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@
*/

import classNames from "classnames";
import PopperJS from "popper.js";
import { ModifierFn, Modifiers as PopperModifiers } from "popper.js";
import * as React from "react";
import { Manager, Popper, Target } from "react-popper";

export type PopperModifiers = PopperJS.Modifiers;

import { AbstractPureComponent } from "../../common/abstractPureComponent";
import * as Classes from "../../common/classes";
import * as Errors from "../../common/errors";
Expand All @@ -23,6 +21,9 @@ import { getArrowAngle, PopoverArrow } from "./arrow";
import { positionToPlacement } from "./popoverMigrationUtils";
import { arrowOffsetModifier, getTransformOrigin } from "./popperUtils";

// re-export this symbol for library consumers
export { PopperModifiers };

export enum PopoverInteractionKind {
CLICK = "click",
CLICK_TARGET_ONLY = "click-target",
Expand Down Expand Up @@ -602,7 +603,7 @@ export class Popover extends AbstractPureComponent<IPopoverProps, IPopoverState>
}

/** Popper modifier that updates React state (for style properties) based on latest data. */
private updatePopoverState: PopperJS.ModifierFn = data => {
private updatePopoverState: ModifierFn = data => {
// pretty sure it's safe to always set these (and let sCU determine) because they're both strings
this.setState({
arrowRotation: getArrowAngle(data.placement),
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/components/popover/popoverMigrationUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* Licensed under the terms of the LICENSE file distributed with this project.
*/

import PopperJS from "popper.js";
import { Placement } from "popper.js";
import { Position } from "../../common/position";

/**
* Convert a position to a placement.
* @param position the position to convert
*/
export function positionToPlacement(position: Position | "auto"): PopperJS.Placement {
export function positionToPlacement(position: Position | "auto"): Placement {
/* istanbul ignore next */
switch (position) {
case Position.TOP_LEFT:
Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/components/tooltip/tooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
*/

import classNames from "classnames";
import PopperJS from "popper.js";
import * as React from "react";

import * as Classes from "../../common/classes";
import { Position } from "../../common/position";
import { IIntentProps, IProps } from "../../common/props";
import { Popover, PopoverInteractionKind } from "../popover/popover";
import { Popover, PopoverInteractionKind, PopperModifiers } from "../popover/popover";

export interface ITooltipProps extends IProps, IIntentProps {
/**
Expand Down Expand Up @@ -64,7 +63,7 @@ export interface ITooltipProps extends IProps, IIntentProps {
* Popper modifier options, passed directly to internal Popper instance.
* See https://popper.js.org/popper-documentation.html#modifiers for complete details.
*/
modifiers?: PopperJS.Modifiers;
modifiers?: PopperModifiers;

/**
* Callback invoked in controlled mode when the tooltip open state *would* change due to
Expand Down
2 changes: 1 addition & 1 deletion packages/select/src/common/menuRenderer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface IMenuRendererProps<T> {
* A ref handler that should be attached to the menu's outermost HTML element.
* This is required for the active item to scroll into view automatically.
*/
itemsParentRef: (ref: HTMLElement) => void;
itemsParentRef: (ref: HTMLElement | null) => void;

/**
* Call this function to render an item.
Expand Down
18 changes: 11 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5968,10 +5968,14 @@ plur@^2.0.0, plur@^2.1.2:
dependencies:
irregular-plurals "^1.0.0"

popper.js@^1.12.5, popper.js@^1.12.6:
popper.js@^1.12.6:
version "1.12.9"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.12.9.tgz#0dfbc2dff96c451bb332edcfcfaaf566d331d5b3"

popper.js@^1.12.9, popper.js@^1.14.1:
version "1.14.1"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.1.tgz#b8815e5cda6f62fc2042e47618649f75866e6753"

portfinder@^1.0.13, portfinder@^1.0.9:
version "1.0.13"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.13.tgz#bb32ecd87c27104ae6ee44b5a3ccbf0ebb1aede9"
Expand Down Expand Up @@ -6429,7 +6433,7 @@ promise@^7.1.1:
dependencies:
asap "~2.0.3"

prop-types@^15.5.10, prop-types@^15.5.8, prop-types@^15.6.0:
prop-types@^15.5.8, prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
Expand Down Expand Up @@ -6635,12 +6639,12 @@ react-dom@^16.2.0:
object-assign "^4.1.1"
prop-types "^15.6.0"

react-popper@~0.7.4:
version "0.7.5"
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-0.7.5.tgz#71c25946f291db381231281f6b95729e8b801596"
react-popper@^0.8.2:
version "0.8.2"
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-0.8.2.tgz#092095ff13933211d3856d9f325511ec3a42f12c"
dependencies:
popper.js "^1.12.5"
prop-types "^15.5.10"
popper.js "^1.12.9"
prop-types "^15.6.0"

react-reconciler@^0.7.0:
version "0.7.0"
Expand Down