Skip to content

Commit

Permalink
Update upstream (#16)
Browse files Browse the repository at this point in the history
* [DateInput] Add support for datepicker clearButtonText and todayButtonText props. (palantir#3020)

* [DateInput] Add datepicker clearButtonText and todayButtonText props support.

* [DateInput] Add unit test for clearButtonText and todayButtonText props.

* include integrity hashes in yarn lock (palantir#3035)

* Publish

 - @blueprintjs/docs-theme@3.0.2

* Publish

 - @blueprintjs/docs-theme@3.0.3
 - @blueprintjs/karma-build-scripts@0.9.0
 - @blueprintjs/node-build-scripts@0.8.0
 - @blueprintjs/webpack-build-scripts@0.7.0

* Fix reset of active item when query hasn't changed (palantir#3072)

* Fix reset active item when query hasn't changed

* Address comments

* [DateInput] close on tab key press (palantir#3038)

* Publish

 - @blueprintjs/datetime@3.3.1
 - @blueprintjs/select@3.2.1

* Correct Table reference to HTMLTable (palantir#3075)

Also correct link to html-table page.

* 🔧 fix dependencies (palantir#3078)

* node-gyp resolution

* * dep for build-scripts packages

* yarn.lock

* preview script won't fail build without GH_AUTH_TOKEN

* update yarn min version in readme

* fix icons alignment (palantir#3102)

* [Breadcrumb] Add current prop (palantir#3104)

* Render breadcrumb children (palantir#3105)

* fix checkbox indicator display (palantir#3113)

* Only set default font-family on body selector (palantir#3115)

* [FormGroup] add contentClassName and style props (palantir#3120)

* add contentClassName prop

* add style prop

* [Portal] add container prop (palantir#3045)

* [Portal] add container prop

* [Overlay] add container prop

* [Popover] add container prop

* [Tooltip] add container prop

* [Dialog] add container prop

* [Alert] add container prop

* fix test failed

* [portal] avoid possible crash on componentDidMount

* rename container to portalContainer for overlay components

* chore: remove useless code

* add isotest for className prop (palantir#3119)

* four args become two. add className isotest.

refactor generateIsomorphicTests() to use config object in mapped type

* refactor isotest suites to new config object

* [Tag] fix line-height for centering (palantir#3117)

* fix lint error

* set tag line-height to icon size

* $tag-line-height(-large) vars

* fix label documentation example (palantir#3087)

* fix label documentation example

* Use class constants

* remove first id

* Label B

* added new icon (palantir#3052)

* [table] Perf improvements with selections (palantir#2005)

* table performance improvements - reducing rerendering where possible

* reinstate enum strings

* fix compile errors

* fix lint errors

* fix test

* cell: revert changes

* code review suggestions; add forceRerenderOnSelectionChange flag

* lint

* default to false

* remove unused logo styles from navbar (palantir#3123)

* [Breadcrumbs] Add new component (palantir#3106)

* Add breadcrumbs component

* Use lambda syntax

* Add overflow list props

* Disable overflow menu items

* Add missing prop docs

* Document new Breadcrumb special case

* Add Breadcrumbs prop docs

* Use ul tag

* Add test to OverflowList

* Add tests to Breadcrumb

* Add tests for Breadcrumbs

* Fix docstring

Co-Authored-By: invliD <mail@invlid.com>

* Improve docstring

Co-Authored-By: invliD <mail@invlid.com>

* Fix Breadcrumb docs

* Fix linebreak

* Default breadcrumbRenderer

* Explain why the menu is reversed

* Add link to OL

* Add code example

* Re-use breadcrumbs example using different name

* docs edits

* Publish

 - @blueprintjs/core@3.8.0
 - @blueprintjs/icons@3.3.0
 - @blueprintjs/table@3.3.0

* fix disappearing caret on focus of HTMLSelect in ControlGroup (fixes palantir#3003) (palantir#3150)

* Single Month Only Prop in DateRangePicker (palantir#3142)

* allow singleMonthlyOnly in DateRangePicker

* updated docs comment

* added singleMonthOnly props in DateRangeInput

* added DateRangeInput test to ensure prop is passed

* updated documentation and example labels

* Allow users to browse omnibar options without query (palantir#3130)

* Using tagName JSX variable for MenuItem (palantir#3061)

* Using tagName JSX variable for MenuItem

* Fixed minnor default issues as per the requests on PR

* [Overlay] add portalClassName to IOverlayableProps (palantir#3148)

* add portalClassName to IOverlayableProps

* fix overlay test

* unmount dialog test

* fix HTML_TABLE_CONDENSED name (reverts 3.x break) (palantir#3147)

* Don't clear TagInput inputValue state if controlled (palantir#3137)

* Don't clear TagInput inputValue state if controlled

Fixes palantir#3134

* Address PR comments

* Revert fixes

* remove margin on heading-only callouts (palantir#3157)

* PopoverPosition = Position + auto values (palantir#3156)

* [Select] Flag to optionally scroll to active item for select components (palantir#3096)

* Flag to optionally scroll to active item for select components

* Respect click and keyboard interactions

* Change docs

* edit prop docs

* add uncontrolled note

* docs edits (palantir#3161)

* [tslint] blueprint-html-components fixer! (palantir#3162)

* enable strict mode in tslint-config

* sort imports before adding

* blueprint-html-components fixes imports

* refactors

* replaceTagName util

* test formatting

* add test for all imports

* h2/h5

* ts-lint --fix (palantir#3159)

* relaxed typings for optional JSX.Elements (palantir#3118)

* export type OptionalElement = JSX.Element | boolean | null | undefined;

use it in `icon` props

* more uses of OptionalElement

* Icons docs uses props

* MaybeElement, false

* [Popover] add boundary prop for easier modifiers (palantir#3149)

* Popover add boundariesElement prop for easier modifiers

* rename to boundary

* rename type to PopperBoundary

* fix examples

* Publish

 - @blueprintjs/core@3.9.0
 - @blueprintjs/datetime@3.4.0
 - @blueprintjs/select@3.3.0
 - @blueprintjs/tslint-config@1.7.0
  • Loading branch information
crispamares authored Nov 23, 2018
1 parent f0a93bf commit ee5bbd4
Show file tree
Hide file tree
Showing 121 changed files with 2,976 additions and 811 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ then [check out the "help wanted" label](https://github.com/palantir/blueprint/l
[Lerna](https://lernajs.io/) manages inter-package dependencies in this monorepo.
Builds are orchestrated via `lerna run` and NPM scripts.

__Prerequisites__: Node.js v8+, Yarn v1.0+
__Prerequisites__: Node.js v8+, Yarn v1.10+

### One-time setup

Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
"engines": {
"node": ">=6.1"
},
"resolutions": {
"node-gyp": "^3.6.3"
},
"repository": {
"type": "git",
"url": "git@github.com:palantir/blueprint.git"
Expand Down
8 changes: 4 additions & 4 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blueprintjs/core",
"version": "3.7.0",
"version": "3.9.0",
"description": "Core styles & components",
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",
Expand Down Expand Up @@ -39,7 +39,7 @@
"verify": "npm-run-all compile -p dist test lint"
},
"dependencies": {
"@blueprintjs/icons": "^3.2.0",
"@blueprintjs/icons": "^3.3.0",
"@types/dom4": "^2.0.0",
"classnames": "^2.2",
"dom4": "^2.0.1",
Expand All @@ -55,8 +55,8 @@
"react-dom": "^15.3.0 || 16"
},
"devDependencies": {
"@blueprintjs/karma-build-scripts": "^0.8.0",
"@blueprintjs/node-build-scripts": "^0.7.0",
"@blueprintjs/karma-build-scripts": "*",
"@blueprintjs/node-build-scripts": "*",
"@blueprintjs/test-commons": "^0.8.0",
"enzyme": "^3.3.0",
"karma": "^1.7.1",
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ html {
body {
@include base-typography();
color: $pt-text-color;
font-family: $pt-font-family;
}

p {
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/common/_flex.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@

// CSS API support
&::before,
// space after all children
> * {
// space after all children
#{$margin-prop}: $margin;
}

Expand Down
1 change: 0 additions & 1 deletion packages/core/src/common/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ $pt-dark-intent-text-colors: (
text-transform: none;
line-height: $pt-line-height;
letter-spacing: 0;
font-family: $pt-font-family;
font-size: $pt-font-size;
font-weight: 400;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/common/classes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const NS = process.env.BLUEPRINT_NAMESPACE || "bp3";
export const ACTIVE = `${NS}-active`;
export const ALIGN_LEFT = `${NS}-align-left`;
export const ALIGN_RIGHT = `${NS}-align-right`;
export const CONDENSED = `${NS}-condensed`;
export const DARK = `${NS}-dark`;
export const DISABLED = `${NS}-disabled`;
export const FILL = `${NS}-fill`;
Expand Down Expand Up @@ -116,8 +115,9 @@ export const HTML_SELECT = `${NS}-html-select`;
export const SELECT = `${NS}-select`;

export const HTML_TABLE = `${NS}-html-table`;
export const HTML_TABLE_STRIPED = `${HTML_TABLE}-striped`;
export const HTML_TABLE_BORDERED = `${HTML_TABLE}-bordered`;
export const HTML_TABLE_CONDENSED = `${HTML_TABLE}-condensed`;
export const HTML_TABLE_STRIPED = `${HTML_TABLE}-striped`;

export const INPUT = `${NS}-input`;
export const INPUT_GHOST = `${INPUT}-ghost`;
Expand Down
9 changes: 8 additions & 1 deletion packages/core/src/common/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ export type HTMLDivProps = React.HTMLAttributes<HTMLDivElement>;
*/
export type HTMLInputProps = React.InputHTMLAttributes<HTMLInputElement>;

/**
* Alias for a `JSX.Element` or a value that renders nothing.
*
* In React, `boolean`, `null`, and `undefined` do not produce any output.
*/
export type MaybeElement = JSX.Element | false | null | undefined;

/**
* A shared base interface for all Blueprint component props.
*/
Expand All @@ -45,7 +52,7 @@ export interface IActionProps extends IIntentProps, IProps {
disabled?: boolean;

/** Name of a Blueprint UI icon (or an icon element) to render before the text. */
icon?: IconName | JSX.Element;
icon?: IconName | MaybeElement;

/** Click event handler. */
onClick?: (event: React.MouseEvent<HTMLElement>) => void;
Expand Down
12 changes: 10 additions & 2 deletions packages/core/src/components/alert/alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import classNames from "classnames";
import * as React from "react";

import { AbstractPureComponent, Classes, DISPLAYNAME_PREFIX, Intent, IProps } from "../../common";
import { AbstractPureComponent, Classes, DISPLAYNAME_PREFIX, Intent, IProps, MaybeElement } from "../../common";
import {
ALERT_WARN_CANCEL_ESCAPE_KEY,
ALERT_WARN_CANCEL_OUTSIDE_CLICK,
Expand Down Expand Up @@ -48,7 +48,7 @@ export interface IAlertProps extends IOverlayLifecycleProps, IProps {
confirmButtonText?: string;

/** Name of a Blueprint UI icon (or an icon element) to display on the left side. */
icon?: IconName | JSX.Element;
icon?: IconName | MaybeElement;

/**
* The intent to be applied to the confirm (right-most) button.
Expand All @@ -75,6 +75,13 @@ export interface IAlertProps extends IOverlayLifecycleProps, IProps {
*/
transitionDuration?: number;

/**
* The container element into which the overlay renders its contents, when `usePortal` is `true`.
* This prop is ignored if `usePortal` is `false`.
* @default document.body
*/
portalContainer?: HTMLElement;

/**
* Handler invoked when the alert is canceled. Alerts can be **canceled** in the following ways:
* - clicking the cancel button (if `cancelButtonText` is defined)
Expand Down Expand Up @@ -130,6 +137,7 @@ export class Alert extends AbstractPureComponent<IAlertProps, {}> {
canEscapeKeyClose={canEscapeKeyCancel}
canOutsideClickClose={canOutsideClickCancel}
onClose={this.handleCancel}
portalContainer={this.props.portalContainer}
>
<div className={Classes.ALERT_BODY}>
<Icon icon={icon} iconSize={40} intent={intent} />
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/components/breadcrumbs/_breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Styleguide breadcrumbs
background: $light-gray1;
cursor: pointer;
padding: 1px ($pt-grid-size / 2);
vertical-align: text-bottom;

&::before {
display: block;
Expand Down
15 changes: 14 additions & 1 deletion packages/core/src/components/breadcrumbs/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,28 @@ import * as React from "react";
import * as Classes from "../../common/classes";
import { IActionProps, ILinkProps } from "../../common/props";

export interface IBreadcrumbProps extends IActionProps, ILinkProps {}
export interface IBreadcrumbProps extends IActionProps, ILinkProps {
/** Whether this breadcrumb is the current breadcrumb. */
current?: boolean;
}

export const Breadcrumb: React.SFC<IBreadcrumbProps> = breadcrumbProps => {
const classes = classNames(
Classes.BREADCRUMB,
{
[Classes.BREADCRUMB_CURRENT]: breadcrumbProps.current,
[Classes.DISABLED]: breadcrumbProps.disabled,
},
breadcrumbProps.className,
);
if (breadcrumbProps.href == null && breadcrumbProps.onClick == null) {
return (
<span className={classes}>
{breadcrumbProps.text}
{breadcrumbProps.children}
</span>
);
}
return (
<a
className={classes}
Expand All @@ -29,6 +41,7 @@ export const Breadcrumb: React.SFC<IBreadcrumbProps> = breadcrumbProps => {
target={breadcrumbProps.target}
>
{breadcrumbProps.text}
{breadcrumbProps.children}
</a>
);
};
49 changes: 44 additions & 5 deletions packages/core/src/components/breadcrumbs/breadcrumbs.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
@# Breadcrumbs

Breadcrumbs identify the current resource in an application.
Breadcrumbs identify the path to the current resource in an application.

@css breadcrumbs
@reactExample BreadcrumbsExample

@## Props

The component renders an `a.@ns-breadcrumb`. You are responsible for constructing
the `ul.@ns-breadcrumbs` list. [`CollapsibleList`](#core/components/collapsible-list)
works nicely with this component because its props are a subset of `IMenuItemProps`.
@### Breadcrumbs

The `Breadcrumbs` component requires an `items` array of
[breadcrumb props](#core/components/breadcrumbs.breadcrumb) and renders them in
an [`OverflowList`](#core/components/overflow-list) to automatically collapse
breadcrumbs that do not fit in the available space.

```tsx
const { Breadcrumbs, IBreadcrumbProps, Icon } = "@blueprintjs/core";

const BREADCRUMBS: IBreadcrumbProps[] = [
{ href: "/users", icon: "folder-close", text: "Users" },
{ href: "/users/janet", icon: "folder-close", text: "Janet" },
{ icon: "document", text: "image.jpg" },
];

export class BreadcrumbsExample extends React.Component {
public render() {
return (
<Breadcrumbs
currentBreadcrumbRenderer={this.renderCurrentBreadcrumb}
items={BREADCRUMBS}
/>
);
}
private renderCurrentBreadcrumb = ({ text, ...restProps }: IBreadcrumbProps) => {
// customize rendering of last breadcrumb
return <Breadcrumb {...restProps}>{text} <Icon icon="star" /></Breadcrumb>;
};
}
```

@interface IBreadcrumbsProps

@### Breadcrumb

The `Breadcrumb` component renders an `a.@ns-breadcrumb` if given an `href` or
`onClick` and a `span.@ns-breadcrumb` otherwise. Typically you will supply an
array of `IBreadcrumbProps` to the `<Breadcrumbs items>` prop and only render
this component directly when defining a custom `breadcrumbRenderer`.

@interface IBreadcrumbProps

Expand All @@ -27,3 +64,5 @@ user to that resource.
containing breadcrumbs that are collapsed due to layout constraints.
* When adding another element (such as a [tooltip](#core/components/tooltip) or
[popover](#core/components/popover)) to a breadcrumb, wrap it around the contents of the `li`.

@css breadcrumbs
130 changes: 130 additions & 0 deletions packages/core/src/components/breadcrumbs/breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/*
* Copyright 2018 Palantir Technologies, Inc. All rights reserved.
*
* Licensed under the terms of the LICENSE file distributed with this project.
*/

import classNames from "classnames";
import * as React from "react";

import { Boundary } from "../../common/boundary";
import * as Classes from "../../common/classes";
import { Position } from "../../common/position";
import { IProps } from "../../common/props";
import { Menu } from "../menu/menu";
import { MenuItem } from "../menu/menuItem";
import { IOverflowListProps, OverflowList } from "../overflow-list/overflowList";
import { IPopoverProps, Popover } from "../popover/popover";
import { Breadcrumb, IBreadcrumbProps } from "./breadcrumb";

export interface IBreadcrumbsProps extends IProps {
/**
* Callback invoked to render visible breadcrumbs. Best practice is to
* render a `<Breadcrumb>` element. If `currentBreadcrumbRenderer` is also
* supplied, that callback will be used for the current breadcrumb instead.
* @default Breadcrumb
*/
breadcrumbRenderer?: (props: IBreadcrumbProps) => JSX.Element;

/**
* Which direction the breadcrumbs should collapse from: start or end.
* @default Boundary.START
*/
collapseFrom?: Boundary;

/**
* Callback invoked to render the current breadcrumb, which is the last
* element in the `items` array.
*
* If this prop is omitted, `breadcrumbRenderer` will be invoked for the
* current breadcrumb instead.
*/
currentBreadcrumbRenderer?: (props: IBreadcrumbProps) => JSX.Element;

/**
* All breadcrumbs to display. Breadcrumbs that do not fit in the container
* will be rendered in an overflow menu instead.
*/
items: IBreadcrumbProps[];

/**
* The minimum number of visible breadcrumbs that should never collapse into
* the overflow menu, regardless of DOM dimensions.
* @default 0
*/
minVisibleItems?: number;

/**
* Props to spread to `OverflowList`. Note that `items`,
* `overflowRenderer`, and `visibleItemRenderer` cannot be changed.
*/
overflowListProps?: Partial<IOverflowListProps<IBreadcrumbProps>>;

/**
* Props to spread to the `Popover` showing the overflow menu.
*/
popoverProps?: IPopoverProps;
}

export class Breadcrumbs extends React.PureComponent<IBreadcrumbsProps> {
public static defaultProps: Partial<IBreadcrumbsProps> = {
collapseFrom: Boundary.START,
};

public render() {
const { className, collapseFrom, items, minVisibleItems, overflowListProps = {} } = this.props;
return (
<OverflowList
collapseFrom={collapseFrom}
minVisibleItems={minVisibleItems}
tagName="ul"
{...overflowListProps}
className={classNames(Classes.BREADCRUMBS, overflowListProps.className, className)}
items={items}
overflowRenderer={this.renderOverflow}
visibleItemRenderer={this.renderBreadcrumbWrapper}
/>
);
}

private renderOverflow = (items: IBreadcrumbProps[]) => {
const { collapseFrom } = this.props;
const position = collapseFrom === Boundary.END ? Position.BOTTOM_RIGHT : Position.BOTTOM_LEFT;
let orderedItems = items;
if (collapseFrom === Boundary.START) {
// If we're collapsing from the start, the menu should be read from the bottom to the
// top, continuing with the breadcrumbs to the right. Since this means the first
// breadcrumb in the props must be the last in the menu, we need to reverse the overlow
// order.
orderedItems = items.slice().reverse();
}
return (
<li>
<Popover position={position} {...this.props.popoverProps}>
<span className={Classes.BREADCRUMBS_COLLAPSED} />
<Menu>{orderedItems.map(this.renderOverflowBreadcrumb)}</Menu>
</Popover>
</li>
);
};

private renderOverflowBreadcrumb = (props: IBreadcrumbProps, index: number) => {
const isClickable = props.href != null || props.onClick != null;
return <MenuItem disabled={!isClickable} {...props} text={props.text} key={index} />;
};

private renderBreadcrumbWrapper = (props: IBreadcrumbProps, index: number) => {
const isCurrent = this.props.items[this.props.items.length - 1] === props;
return <li key={index}>{this.renderBreadcrumb(props, isCurrent)}</li>;
};

private renderBreadcrumb(props: IBreadcrumbProps, isCurrent: boolean) {
if (isCurrent && this.props.currentBreadcrumbRenderer != null) {
return this.props.currentBreadcrumbRenderer(props);
} else if (this.props.breadcrumbRenderer != null) {
return this.props.breadcrumbRenderer(props);
} else {
return <Breadcrumb {...props} current={isCurrent} />;
}
}
}
Loading

0 comments on commit ee5bbd4

Please sign in to comment.