-
Notifications
You must be signed in to change notification settings - Fork 2.2k
What's new in Blueprint 2.0
Adi Dahiya edited this page Mar 9, 2022
·
7 revisions
Blueprint 2.0 features JavaScript API refactors, smaller & more modular packages, and very few changes to the CSS API.
Keep reading below for the highlights, a full changelog, and a recommended migration path.
- The minimum version of React is now 16.2.
- The minimum version of TypeScript for the declaration files is now 2.3.
-
Portal
now uses React 16's built-in Portal functionality instead ofReactDOM.unstable_renderSubtreeIntoContainer
. -
Icon
now renders SVG elements and is used in all Blueprint components.- This also means that you can provide your own SVG icons for all components.
- Support for the icon font remains, but will be removed in the next major version.
- Icon styles and fonts have moved to a new @blueprintjs/icons package
- Core depends on this package, so you will have to import its CSS alongside
blueprint.css
<link href="path/to/node_modules/@blueprintjs/core/lib/css/blueprint.css" rel="stylesheet" /> + <link href="path/to/node_modules/@blueprintjs/icons/lib/css/blueprint-icons.css" rel="stylesheet" />
- Core depends on this package, so you will have to import its CSS alongside
-
Popover2
is now the defaultPopover
. It uses Popper.js instead of Tether, which provides much better auto-positioning capabilities and solves a number of outstanding bugs out-of-the-box. - All Labs components (in
@blueprintjs/labs
) have been moved into separate packages so that you no longer have to deal with the0.x
version range for many components that are used widely in production.
Breaking changes are highlighted with icons:
- 🔥 indicates new breaks that will likely require your attention during the upgrade.
- Many of these are renames which are handled automatically by the 2.0 upgrade script.
⚠️ indicates deprecations which produced warnings in Blueprint 1.x.- 🎨 indicates CSS layout breaks which may affect you if you have customized the styling & layout of Blueprint components directly.
- 🔥 A small set of ES6 features are used by all Blueprint libraries:
Map
,Set
,Array.from
,Array.fill
(similar to React 16 itself)- If you need to support older browsers that don't have these features built-in, you will need to polyfill them. See an example of this here: test-commmons/polyfill.js
- 🔥
.css
,.js
,.sass
, and.less
files are now output in the/lib/
folder in the distributed packages instead of/dist/
(#2002)- Note: the web-ready bundles (e.g.
core.bundle.js
) for unpkg CDN consumption are still output in/dist/
- Note: the web-ready bundles (e.g.
- 🔥 React component factories (
DialogFactory
) have been removed for all components (#1938) - 🔥 Support for long icon names (those prefixed with
pt-icon-
) has been removed in all component APIs (#2072)- 🛠 This refactor is handled by the upgrade script
- SVG files in the root
resources/icons/
directory have also been stripped of thept-icon-
prefix in their filenames
- 🔥 Prop rename:
iconName
→icon
(#2070)- 🛠 This refactor is handled by the upgrade script
-
icon
prop now acceptsJSX.Element
in addition to anIconName
string so you can provide your own SVG icon set
- 🌟 Run published CSS files through postcss to remove comments and run Autoprefixer (#2241)
- 🌟 Publish correct ES module files using new TypeScript compiler flags (#2200)
- Enable
esModuleInterop
andallowSyntheticDefaultImports
compiler flags to emit valid ES import statements for modules such asclassnames
andmoment
.
- Enable
- All component displayNames use
Blueprint2
prefix for easier debugging (#2052) - Add
sideEffects: "false"
topackage.json
manifests for Webpack 4 tree-shaking support (#2051) - Ensure
className
prop is supported for all components (#1950) - Most enums now use string values to ease debugging (#1921)
- in TypeScript, the enum types are still required (
intent="primary"
will produce a compiler error)
- in TypeScript, the enum types are still required (
- Publish the 2.0.0 upgrade script which renames most symbols. (#2230)
- 📦 Dependency changes
- 🌟
Portal
supports SSR now - it renders nothing on the server (#2205)- 🔥 the DOM element created by
Portal
is now treated as its root, soclassName
is applied to this element. this also means that no dummy element is created inside the portal, making it one level shallower. - 🔥 Removed
containerRef
prop as it no longer makes sense given note above. Users can simply apply refs to the elements they render in the portal.
- 🔥 the DOM element created by
-
Button
&ButtonGroup
-
Icon
renders SVG paths- 🔥 Component now renders
svg.pt-icon
instead ofspan.pt-icon-standard
(#2028) - 🔥 support for "long" icon names
pt-icon-<name>
has been removed; only the short<name>
syntax is supported (#2072) - ⭐
iconName
⇒icon
and now acceptsJSX.Element | IconName
for custom icons (#2070) -
standard
/large
size switching is now automatic based oniconSize
prop value- Constants are provided for common sizes:
Icon.SIZE_STANDARD
,Icon.SIZE_LARGE
.
- Constants are provided for common sizes:
- All Blueprint components now render
Icon
components instead of CSS classes (#20365) - See
@blueprintjs/icons
section below for more information
- 🔥 Component now renders
-
MenuItem
- 🔥 Removed
submenuViewportMargins
anduseSmartPositioning
prop (#2053)- their functionality is enabled by default
- 🔥 Removed rarely-used
submenu
prop (#2087)- now the only way to create a submenu is to nest
<MenuItem>
children
- now the only way to create a submenu is to nest
- ⭐ smart submenu positioning is now handled by
Popover
and it is much better (#2053) - support for all HTML
<a>
props (#2087) - add
multiline
prop to disable ellipsis truncation (#2077) -
text
prop now acceptsReact.ReactNode
(any single React renderable) instead ofstring
(#2088) - 🎨 CSS refactor to use flex box (#2075)
- this fixes many layout problems; most notably the text will never cover the label!
- 🔥 Removed
-
Popover
- The component formerly known as
Popover2
is now the defaultPopover
(#1891) - Tether has been replaced with Popper.js which provides much better auto-positioning capabilities and solves a number of outstanding positioning bugs out-of-the-box.
⚠️ All the classicPopover
features are still supported with the same names except...-
isModal
⇒hasBackdrop
to match corresponding prop onOverlay
-
isDisabled
⇒disabled
for consistency with HTML elements -
tetherOptions: ITetherOptions
has been replaced withmodifiers: PopperJS.Modifiers
-
- Add
targetElementTag
prop a larootElementTag
(#2276)
- The component formerly known as
-
TagInput
- 🔥 Moved component into core from labs package (#1881)
- Added
inputRef
prop for consistency withInputGroup
(#2034) - Added
addOnBlur
prop to invokedonAdd
when input is blurred (in addition toenter
key) (#1966) - 🎨
TagInput
CSS refactor to use flex box (#2086)- Custom CSS will likely be required for anything other than a button or spinner in
rightElement
- Custom CSS will likely be required for anything other than a button or spinner in
-
Toaster
-
Toast
-
message
now accepts JSX -
children
can be used instead ofmessage
(and accepts JSX) - 🎨 CSS refactor to use better flex box (#2069)
-
- 🔥 Prop rename:
inline=X
→usePortal=!X
(#2045)- affects
Dialog
,Overlay
,Popover
,Tooltip
,Toaster
- note that the semantics of this prop have been reversed:
inline={true}
is nowusePortal={false}
, and vice-versa - the purpose of this rename is to make its meaning obvious, and to de-conflict with CSS's
inline
term meaning "on the same line"
- affects
- 🔥
Callout
andDialog
title now use<h4>
instead of<h5>
(#2134)- This is non-breaking if you use the React components.
- 🔥
NavbarGroup
align
prop uses newAlignment
enum (#2096) - 🔥
.pt-table
is now.pt-html-table
(see note in table package below) (#1906)- 🛠 This refactor is handled by the upgrade script.
- its modifiers are also scoped:
.pt-html-table-striped
and.pt-html-table-bordered
-
Classes
constants have also changed:Classes.HTML_TABLE
, etc.
⚠️ Tabs2
components have become the defaultTabs
(#1900)-
Alert
addedcanEscapeKeyCancel
,canOutsideClickCancel
,onClose
,transitionDuration
props (#2102) -
KeyCombo
addedminimal
prop to render icon and text only (#2256) -
Label
renders a<label>
instead of a<div>
(#1972) -
HotkeysTarget
andContextMenuTarget
decorators no longer mutate existing classes but rather act as higher-order components (#1914) -
Overlay
improved support for nested Overlays (#2033) -
NumericInput
supports continuous value change by holding down the button (#2174) -
Tag
addedinteractive
modifier support (through.pt-interactive
class) (#2251) -
Tree
nodes now support genericnodeData
property for attaching arbitrary data (#2132)-
Tree.ofType<T>()
static method can be used to create a non-genericTree
component for a givennodeData
type
-
- 🎨
Breadcrumbs
CSS refactor to removefloat
and use flex box (#2065) - Hide
.pt-skeleton
nested content such as items (#2284)
- 🌟
TimePicker
newuseAmPm
prop adds support for 12-hour format (#2151) - 🌟 Remove moment dependency! But...
- 🔥
DateInput
andDateRangeInput
new requiredformatDate
andparseDate
callback props (#2117)- 🔥
format
prop is now just an optional string that is passed to callbacks above - 🔥
placeholder
prop is now on the component itself (formerlyformat.placeholder
)
- 🔥
⚠️ DateInput
removed support for deprecatedopenOnFocus
andpopoverPosition
props (#1917 #2073)-
DateRangePicker
shows new shortcuts "Yesterday" and "Today" whenallowSingleDayRange
is enabled (#2025) - 🎨 Upgrade
react-day-picker
dependency to7.x
(#2055) - 🎨 Remove
TimePicker
outside padding (#2271) -
DateInput
popover closes after tabbing out of the popover (#2093)
- 📦 New package for icon resources and CSS.
- 🔥 Make sure to import
@blueprintjs/icons/lib/css/blueprint-icons.css
to retain icons support during the upgrade. - 🔥
IconClasses
has been replaced withIconNames
(and now lives in this new package) (#2097)- className={IconClasses.AIRPLANE} + className={Classes.iconClass(IconNames.AIRPLANE)}
- 🔥 support for "long" icon names
pt-icon-<name>
has been removed fromIconName
union type; only the short<name>
syntax is supported (#2072)- iconName={IconClasses.GLOBE} + icon={IconNames.GLOBE}
- This package exports the following symbols:
-
IconContents
map ofNAME
to unicode character -
IconName
string literal union type of all known icon names -
IconNames
map ofNAME
toIconName
string literal -
IconSvgPaths16
andIconSvgPaths20
for SVG icons (used by core'sIcon
component)
-
- Renamed some keys in
resources/icons.json
(#2084)- see PR for details if you use this file
- 📦 This package no longer contains any components of its own as they've all moved to core, select, or timezone.
⚠️ This package still re-exports former labs components until its next minor version release (to ease migration).
- 🔥 This package no longer imports
es6-shim
automatically, so you may polyfill the necessary ES features however you wish (see the Usage section on the documentation home page for more details). - 🔥
.bp-
prefix changed to.pt-
for consistency with other packages (#1906) - 🔥 Various prop renames for consistency and clarity (#1890)
⚠️ Removed deprecated props (#2073)-
ColumnHeaderCell
enableColumnInteractionBar
-
HeaderCell
menu
-
ColumnHeaderCell
enableColumnInteractionBar
: deprecated since blueprintjs/table v1.27.0; pass this prop toTable
instead. -
HeaderCell
menu
: deprecated since v1.17.0; usemenuRenderer
instead.
-
⚠️ Removed deprecated top-level utility functions. These should be imported from@blueprintjs/core
instead (#2073)arraysEqual
deepCompareKeys
getDeepUnequalKeyValues
getShallowUnequalKeyValues
shallowCompareKeys
⚠️ Removed obsolete (unused but exported)RoundSize
component (#1997)
-
New package for
Select
,MultiSelect
,QueryList
, andOmnibar
(formerlyOmnibox
) components from labs - 🔥
Omnibox
renamed toOmnibar
(#1882) - 🔥 Major refactor to
itemRenderer
syntax:(item: T, itemProps: IItemRendererProps) => JSX.Element | null
(#1877)- prop definition moved to
QueryList
so all select components support it in the same way - two arguments instead of one allowed for removal of generic argument on
itemProps
-
itemRenderer
receivesmodifiers
object which containsactive
,disabled
,matchesPredicate
flags (with more to come in the future)
- prop definition moved to
- 🌟 Add
itemListRenderer
prop to allselect
components (#2252)- Pull
initialContent
,noResults
,itemListRenderer
up toQueryList
props (other components extend this shared interface) -
QueryList
renderer
receives rendereditemList
ReactNode. -
itemListRenderer
is now the only one with access toitems
/itemsParentRef
/renderItem
props. - The default
itemListRenderer
produces aMenu
usingfilteredItems
(to preserve arrow keys order). - New utility function
renderFilteredItems()
exported from package.
- Pull
- Added type aliases for
ItemRenderer<T>
,ItemPredicate<T>
andItemListPredicate<T>
(#2090) - Add
filteredItems
torenderer
props (#2213) - Add
query
toitemRenderer
props (#2245) - Fix so many small issues: #2135, #2212, #2216, #2209
-
New package for timezone-related datetime components.
- Currently contains only
TimezonePicker
(which used to live in labs)
- Currently contains only
- 🔥
TimezonePicker
now only supports controlled usage (#2127)- 🔥 remove
defaultValue
prop - 🔥
value
andonChange
are required - Uncontrolled support was not fully implemented and was not widely used (not even in example)
- 🔥 remove
- Remove fuzzaldrin-plus dependency for filtering (#2127)
- Renamed from
@blueprintjs/docs
to more accurately reflect the package contents. - Known code entities in prop documentation automatically become links to view that interface in a new API browser dialog (#2041)
-
Use the provided migration script to refactor Sass, JS, and TS code automatically to address some of the API breaks.
# After installing the latest v1.x version of Blueprint, # the following script will now appear in your `npm bin` directory. # run it with --help for full usage instructions. ./node_modules/.bin/upgrade-blueprint-2.0.0-rename --help
-
Import the @blueprintjs/icons CSS file alongside blueprint.css
- <link href="path/to/node_modules/@blueprintjs/core/lib/css/blueprint.css" rel="stylesheet" /> + <link href="path/to/node_modules/@blueprintjs/icons/lib/css/blueprint-icons.css" rel="stylesheet" />
-
Update other import paths, like the variables file.
- @import "~@blueprintjs/core/dist/variables"; + @import "~@blueprintjs/core/lib/scss/variables"; (use lib/less/ in Less-based apps)
-
If you are using labs components:
- First upgrade to
@blueprintjs/labs@~0.15.3
, which re-exports all the components which have been moved to other packages. - Then refactor your
@blueprintjs/labs
imports statements to import from@blueprintjs/core
or@blueprintjs/select
accordingly.
- First upgrade to
-
If you publish a library that depends on Blueprint:
- You are recommended to upgrade your minimum dependencies to React 16 and Blueprint 2 and release a major version of your library.
- react-day-picker v8 migration
- HotkeysTarget & useHotkeys migration
- PanelStack2 migration
- Table 6.0 changes