Skip to content

Commit

Permalink
Prepare release (#3939)
Browse files Browse the repository at this point in the history
  • Loading branch information
adidahiya authored Jan 23, 2020
1 parent 6189839 commit 753a7e3
Show file tree
Hide file tree
Showing 17 changed files with 117 additions and 58 deletions.
5 changes: 5 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules
dist
fixtures
coverage
__snapshots__
4 changes: 1 addition & 3 deletions packages/core/src/common/constructor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@
* Generic interface defining constructor types, such as classes. This is used to type the class
* itself in meta-programming situations such as decorators.
*/
export interface IConstructor<T> {
new (...args: any[]): T;
}
export type IConstructor<T> = new (...args: any[]) => T;
4 changes: 2 additions & 2 deletions packages/core/src/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,5 @@ export const DRAWER_VERTICAL_IS_IGNORED = ns + ` <Drawer> vertical is ignored if
export const DRAWER_ANGLE_POSITIONS_ARE_CASTED =
ns + ` <Drawer> all angle positions are casted into pure position (TOP, BOTTOM, LEFT or RIGHT)`;

export const TOASTER_MAX_TOASTS_INVALID = ns + ` <Toaster> maxToasts is set to an invalid number, must be greater than 0`;

export const TOASTER_MAX_TOASTS_INVALID =
ns + ` <Toaster> maxToasts is set to an invalid number, must be greater than 0`;
12 changes: 2 additions & 10 deletions packages/core/src/common/position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,15 @@ export function isPositionVertical(position: Position) {
}

export function getPositionIgnoreAngles(position: Position) {
if (
position === Position.TOP ||
position === Position.TOP_LEFT ||
position === Position.TOP_RIGHT
) {
if (position === Position.TOP || position === Position.TOP_LEFT || position === Position.TOP_RIGHT) {
return Position.TOP;
} else if (
position === Position.BOTTOM ||
position === Position.BOTTOM_LEFT ||
position === Position.BOTTOM_RIGHT
) {
return Position.BOTTOM;
} else if (
position === Position.LEFT ||
position === Position.LEFT_TOP ||
position === Position.LEFT_BOTTOM
) {
} else if (position === Position.LEFT || position === Position.LEFT_TOP || position === Position.LEFT_BOTTOM) {
return Position.LEFT;
} else {
return Position.RIGHT;
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ export function countDecimalPlaces(num: number) {
if (!isFinite(num)) {
return 0;
}
let e = 1,
p = 0;
let e = 1;
let p = 0;
while (Math.round(num * e) / e !== num) {
e *= 10;
p++;
Expand Down
5 changes: 4 additions & 1 deletion packages/core/test/common/utils/compareUtilsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ describe("CompareUtils", () => {

describe("returns unequal key/values if any specified values are not deeply equal", () => {
runTest(
[{ key: "a", valueA: 2, valueB: 1 }, { key: "b", valueA: [2, 3, 4], valueB: [1, 2, 3] }],
[
{ key: "a", valueA: 2, valueB: 1 },
{ key: "b", valueA: [2, 3, 4], valueB: [1, 2, 3] },
],
{ a: 2, b: [2, 3, 4], c: "3" },
{ b: [1, 2, 3], a: 1, c: "3" },
["a", "b"],
Expand Down
20 changes: 20 additions & 0 deletions packages/core/test/overlay/overlayTests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,26 @@ describe("<Overlay>", () => {
assertFocus("button", done);
});

it("does not crash while trying to return focus to overlay if user clicks outside the document", () => {
mountWrapper(
<Overlay enforceFocus={true} canOutsideClickClose={false} isOpen={true} usePortal={false}>
{createOverlayContents()}
</Overlay>,
);

// this is a fairly custom / nonstandard event dispatch, trying to simulate what happens in some browsers when a user clicks
// on the browser toolbar (outside the document), but a focus event is still dispatched to document
// see https://github.com/palantir/blueprint/issues/3928
const event = new FocusEvent("focus");
Object.defineProperty(event, "target", { value: window });

try {
document.dispatchEvent(event);
} catch (e) {
assert.fail("threw uncaught error");
}
});

function assertFocus(selector: string | (() => void), done: MochaDone) {
// the behavior being tested relies on requestAnimationFrame.
// setTimeout for a few frames later to let things settle (to reduce flakes).
Expand Down
13 changes: 10 additions & 3 deletions packages/core/test/popover/popperUtilTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import { arrowOffsetModifier, getAlignment, getOppositePosition } from "../../sr

describe("Popper utils", () => {
it("getOppositePosition returns opposite", () => {
[["top", "bottom"], ["left", "right"]].map(([a, b]) => {
[
["top", "bottom"],
["left", "right"],
].map(([a, b]) => {
expect(getOppositePosition(a as Position)).to.equal(b);
expect(getOppositePosition(b as Position)).to.equal(a);
});
Expand All @@ -34,12 +37,16 @@ describe("Popper utils", () => {

describe("arrow offset modifier shifts away from popover", () => {
it("right", () => {
const { offsets: { popper, arrow } } = arrowOffsetModifier(getPopperData("right"), {});
const {
offsets: { popper, arrow },
} = arrowOffsetModifier(getPopperData("right"), {});
expect(popper.left).to.be.greaterThan(arrow.left);
});

it("left", () => {
const { offsets: { popper, arrow } } = arrowOffsetModifier(getPopperData("left"), {});
const {
offsets: { popper, arrow },
} = arrowOffsetModifier(getPopperData("left"), {});
expect(popper.left).to.be.lessThan(arrow.left);
});

Expand Down
5 changes: 4 additions & 1 deletion packages/core/test/toast/toasterTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ describe("Toaster", () => {
const key = toaster.show({ message: "two" });
toaster.show({ message: "six" });
toaster.dismiss(key);
assert.deepEqual(toaster.getToasts().map(t => t.message), ["six", "one"]);
assert.deepEqual(
toaster.getToasts().map(t => t.message),
["six", "one"],
);
});

it("clear() removes all toasts", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/icons/src/iconName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
import * as IconNames from "./generated/iconNames";

/** String literal union type of all Blueprint UI icon names. */
export type IconName = (typeof IconNames)[keyof typeof IconNames];
export type IconName = typeof IconNames[keyof typeof IconNames];
20 changes: 15 additions & 5 deletions packages/landing-app/src/logo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,11 @@ export type ISegment = [Point, Point];
export class Corner extends Transformable<Corner> {
public static CORNER() {
return new Corner(
[[P(), P().translate(-1, 0, 0)], [P(), P().translate(0, 1, 0)], [P(), P().translate(0, 0, -1)]],
[
[P(), P().translate(-1, 0, 0)],
[P(), P().translate(0, 1, 0)],
[P(), P().translate(0, 0, -1)],
],
P(),
);
}
Expand Down Expand Up @@ -520,7 +524,7 @@ export const T = {
return t => callback(t === 0 ? 0 : Math.pow(e, 10 * (t - 1)));
},
EASE_IN_OUT: (callback: IAnimatedCallback): IAnimatedCallback => {
return t => callback((t *= 2) < 1 ? 1 / 2 * t * t * t * t : -1 / 2 * ((t -= 2) * t * t * t - 2));
return t => callback((t *= 2) < 1 ? (1 / 2) * t * t * t * t : (-1 / 2) * ((t -= 2) * t * t * t - 2));
},
EASE_IN_OUT_EXP: (e: number, callback: IAnimatedCallback): IAnimatedCallback => {
return t => {
Expand All @@ -529,9 +533,9 @@ export const T = {
} else if (t === 1) {
callback(1);
} else if ((t *= 2) < 1) {
callback(1 / 2 * Math.pow(e, 10 * (t - 1)));
callback((1 / 2) * Math.pow(e, 10 * (t - 1)));
} else {
callback(1 / 2 * (-Math.pow(e, -10 * --t) + 2));
callback((1 / 2) * (-Math.pow(e, -10 * --t) + 2));
}
};
},
Expand Down Expand Up @@ -1100,7 +1104,13 @@ export function initializeLogo(canvas: HTMLCanvasElement, canvasBackground: HTML
.timeline()
.tween(0, () => model.restore().translate(0, -8, 0))
.tween(offset + 100)
.tween(1000, T.EASE_OUT_EXP(2, T.INTERPOLATE(-8, 0, (t: number) => model.restore().translate(0, t, 0))));
.tween(
1000,
T.EASE_OUT_EXP(
2,
T.INTERPOLATE(-8, 0, (t: number) => model.restore().translate(0, t, 0)),
),
);
};

slideDownAnimation(0, slideInGroups[0]);
Expand Down
2 changes: 1 addition & 1 deletion packages/node-build-scripts/es-lint.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (process.argv.includes("--fix")) {
}

// ESLint will fail if provided with no files, so we expand the glob before running it
const fileGlob = "{src,test}/**/*.tsx";
const fileGlob = "{src,test}/**/*.{ts,tsx}";
const absoluteFileGlob = path.resolve(process.cwd(), fileGlob);
const anyFilesToLint = glob.sync(absoluteFileGlob)
if (anyFilesToLint.length === 0) {
Expand Down
43 changes: 21 additions & 22 deletions packages/select/test/listItemsPropsTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,39 @@ import { assert } from "chai";
import * as sinon from "sinon";
import { executeItemsEqual } from "../src/common/listItemsProps";


describe("IListItemsProps Utils", () => {
describe("executeItemsEqual", () => {
// interface for a non-primitive item value
interface ItemObject {
interface IItemObject {
id: string;
label: string;
listOfValues: number[];
nullField: null;
}

const ITEM_OBJECT_A: ItemObject = {
const ITEM_OBJECT_A: IItemObject = {
id: "A",
label: "Item A",
listOfValues: [1, 2],
nullField: null,
};

// Exactly the same contents as ITEM_OBJECT_A, but a different object
const ITEM_OBJECT_A_DUPLICATE: ItemObject = {
const ITEM_OBJECT_A_DUPLICATE: IItemObject = {
id: "A",
label: "Item A",
listOfValues: [1, 2],
nullField: null,
};

const ITEM_OBJECT_A_EQUIVALENT: ItemObject = {
const ITEM_OBJECT_A_EQUIVALENT: IItemObject = {
id: "A",
label: "Equivalent to item A based on 'id'",
listOfValues: [3, 4],
nullField: null,
};

const ITEM_OBJECT_B: ItemObject = {
const ITEM_OBJECT_B: IItemObject = {
id: "B",
label: "Item B",
listOfValues: [5, 6],
Expand Down Expand Up @@ -83,10 +82,10 @@ describe("IListItemsProps Utils", () => {

describe("itemsEqual is a property name", () => {
it("treats null and undefined as distinctly different", () => {
assert.isTrue(executeItemsEqual<ItemObject>("id", null, null));
assert.isTrue(executeItemsEqual<ItemObject>("id", undefined, undefined));
assert.isFalse(executeItemsEqual<ItemObject>("id", null, undefined));
assert.isFalse(executeItemsEqual<ItemObject>("id", undefined, null));
assert.isTrue(executeItemsEqual<IItemObject>("id", null, null));
assert.isTrue(executeItemsEqual<IItemObject>("id", undefined, undefined));
assert.isFalse(executeItemsEqual<IItemObject>("id", null, undefined));
assert.isFalse(executeItemsEqual<IItemObject>("id", undefined, null));
});

it("compares primitives correctly", () => {
Expand All @@ -102,13 +101,13 @@ describe("IListItemsProps Utils", () => {
});

it("does not incorrectly compare null to a property with a null value", () => {
assert.isFalse(executeItemsEqual<ItemObject>("nullField", ITEM_OBJECT_A, null));
assert.isFalse(executeItemsEqual<IItemObject>("nullField", ITEM_OBJECT_A, null));
});
});

describe("itemsEqual is a function", () => {
// Simple equality comparator that compares IDs of ItemObjects.
const equalityComparator = sinon.spy((itemA: ItemObject, itemB: ItemObject): boolean => {
const equalityComparator = sinon.spy((itemA: IItemObject, itemB: IItemObject): boolean => {
return itemA.id === itemB.id;
});

Expand All @@ -117,33 +116,33 @@ describe("IListItemsProps Utils", () => {
});

it("treats null and undefined as distinctly different", () => {
assert.isTrue(executeItemsEqual<ItemObject>(equalityComparator, null, null));
assert.isTrue(executeItemsEqual<ItemObject>(equalityComparator, undefined, undefined));
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, null, undefined));
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, undefined, null));
assert.isTrue(executeItemsEqual<IItemObject>(equalityComparator, null, null));
assert.isTrue(executeItemsEqual<IItemObject>(equalityComparator, undefined, undefined));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, null, undefined));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, undefined, null));

assert(!equalityComparator.called);
});

it("calls the function and uses its result (true)", () => {
assert.isTrue(
executeItemsEqual<ItemObject>(equalityComparator, ITEM_OBJECT_A, ITEM_OBJECT_A_EQUIVALENT),
executeItemsEqual<IItemObject>(equalityComparator, ITEM_OBJECT_A, ITEM_OBJECT_A_EQUIVALENT),
);
assert(equalityComparator.calledWith(ITEM_OBJECT_A, ITEM_OBJECT_A_EQUIVALENT));
assert(equalityComparator.returned(true));
});

it("calls the function and uses its result (false)", () => {
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, ITEM_OBJECT_A, ITEM_OBJECT_B));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, ITEM_OBJECT_A, ITEM_OBJECT_B));
assert(equalityComparator.calledWith(ITEM_OBJECT_A, ITEM_OBJECT_B));
assert(equalityComparator.returned(false));
});

it("does not call the function if one param is null/undefined", () => {
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, ITEM_OBJECT_A, null));
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, ITEM_OBJECT_A, undefined));
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, null, ITEM_OBJECT_A));
assert.isFalse(executeItemsEqual<ItemObject>(equalityComparator, undefined, ITEM_OBJECT_A));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, ITEM_OBJECT_A, null));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, ITEM_OBJECT_A, undefined));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, null, ITEM_OBJECT_A));
assert.isFalse(executeItemsEqual<IItemObject>(equalityComparator, undefined, ITEM_OBJECT_A));

assert(!equalityComparator.called);
});
Expand Down
6 changes: 4 additions & 2 deletions packages/table/src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* limitations under the License.
*/

import { Icon } from "@blueprintjs/core";

// used to exclude icons from column header measure
export const CLASSNAME_EXCLUDED_FROM_TEXT_MEASUREMENT = "bp-table-text-no-measure";
// supposed width of the icons placeholder
const EXCLUDED_ICON_PLACEHOLDER_WIDTH = 16;
const EXCLUDED_ICON_PLACEHOLDER_WIDTH = Icon.SIZE_STANDARD;

/**
* Since Firefox doesn't provide a computed "font" property, we manually
Expand Down Expand Up @@ -356,7 +358,7 @@ function measureTextContentWithExclusions(context: CanvasRenderingContext2D, ele
const elementsToExclude = element.querySelectorAll(`.${CLASSNAME_EXCLUDED_FROM_TEXT_MEASUREMENT}`);
let excludedElementsWidth = 0;
if (elementsToExclude && elementsToExclude.length) {
elementsToExclude.forEach((e) => {
elementsToExclude.forEach(e => {
const excludedMetrics = context.measureText(e.textContent);
excludedElementsWidth += excludedMetrics.width - EXCLUDED_ICON_PLACEHOLDER_WIDTH;
});
Expand Down
3 changes: 2 additions & 1 deletion packages/table/src/interactions/resizeSensor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ export class ResizeSensor {
};
}

private static RESIZE_SENSOR_STYLE = "position: absolute; left: 0; top: 0; right: 0; " +
private static RESIZE_SENSOR_STYLE =
"position: absolute; left: 0; top: 0; right: 0; " +
"bottom: 0; overflow: hidden; z-index: -1; visibility: hidden;";

private static RESIZE_SENSOR_HTML = `<div class="${Classes.TABLE_RESIZE_SENSOR_EXPAND}"
Expand Down
5 changes: 4 additions & 1 deletion packages/table/test/clipboardTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import { Clipboard } from "../src/common/clipboard";

describe("Clipboard", () => {
it("copies cells", () => {
const success = Clipboard.copyCells([["A", "B", "C"], ["D", "E", "F"]]);
const success = Clipboard.copyCells([
["A", "B", "C"],
["D", "E", "F"],
]);
expect(success).to.be.false;
});

Expand Down
Loading

1 comment on commit 753a7e3

@blueprint-bot
Copy link

Choose a reason for hiding this comment

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

Prepare release (#3939)

Previews: documentation | landing | table

Please sign in to comment.