From a0cad80e9258ad4fba163c2895ba049a418a9aa2 Mon Sep 17 00:00:00 2001 From: Greg Douglas Date: Tue, 7 Apr 2026 17:16:45 -0400 Subject: [PATCH 1/3] Add non-breaking *Icon aliases for static icon exports --- packages/core/src/components/icon/icon.mdx | 2 +- packages/icons/scripts/componentsIndex.ts.hbs | 2 ++ packages/icons/scripts/index.ts.hbs | 2 ++ packages/icons/src/generatedIcons.test.tsx | 19 ++++++++++++++++++- packages/icons/src/loading-icons.mdx | 8 ++++++-- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/packages/core/src/components/icon/icon.mdx b/packages/core/src/components/icon/icon.mdx index e0cc445af3e..ad1326bdeb8 100644 --- a/packages/core/src/components/icon/icon.mdx +++ b/packages/core/src/components/icon/icon.mdx @@ -131,7 +131,7 @@ function Example() { The `` component loads icon paths via dynamic module imports by default. An alternative API is available in the **@blueprintjs/icons** package which provides static imports of each icon as -a React component. The example below uses the `` component. +a React component. The example below uses the `` component. Note that some `` props are not yet supported for these components, such as `intent`. diff --git a/packages/icons/scripts/componentsIndex.ts.hbs b/packages/icons/scripts/componentsIndex.ts.hbs index b09e416c8ff..e612ba94a41 100644 --- a/packages/icons/scripts/componentsIndex.ts.hbs +++ b/packages/icons/scripts/componentsIndex.ts.hbs @@ -14,5 +14,7 @@ */ {{#each iconNames}} +export { {{pascalCase this}} as {{pascalCase this}}Icon } from "./{{this}}"; +/** @deprecated use `{{pascalCase this}}Icon` instead. */ export { {{pascalCase this}} } from "./{{this}}"; {{/each}} diff --git a/packages/icons/scripts/index.ts.hbs b/packages/icons/scripts/index.ts.hbs index 4286ae11dd4..5579f5757af 100644 --- a/packages/icons/scripts/index.ts.hbs +++ b/packages/icons/scripts/index.ts.hbs @@ -17,5 +17,7 @@ export * from "../index"; {{#each iconNames}} +export { {{pascalCase this}} as {{pascalCase this}}Icon } from "./components/{{this}}"; +/** @deprecated use `{{pascalCase this}}Icon` instead. */ export { {{pascalCase this}} } from "./components/{{this}}"; {{/each}} diff --git a/packages/icons/src/generatedIcons.test.tsx b/packages/icons/src/generatedIcons.test.tsx index 729a0d4c935..deb6e9fac0a 100644 --- a/packages/icons/src/generatedIcons.test.tsx +++ b/packages/icons/src/generatedIcons.test.tsx @@ -5,7 +5,7 @@ import { render } from "@testing-library/react"; import { describe, it } from "vitest"; -import { Add } from "./generated/components"; +import { Add, AddIcon } from "./generated/components"; describe(" icon component", () => { it("allows attaching an event handler", () => { @@ -23,3 +23,20 @@ describe(" icon component", () => { ); }); }); + +describe(" alias component", () => { + it("allows attaching an event handler", () => { + const handleClick: React.MouseEventHandler = () => undefined; + render(); + }); + + it("disallows child elements", () => { + const handleClick: React.MouseEventHandler = () => undefined; + render( + + {/* @ts-expect-error */} + + , + ); + }); +}); diff --git a/packages/icons/src/loading-icons.mdx b/packages/icons/src/loading-icons.mdx index da96f4a15a5..8e47f32973b 100644 --- a/packages/icons/src/loading-icons.mdx +++ b/packages/icons/src/loading-icons.mdx @@ -21,13 +21,13 @@ from the icons package. ```tsx import { Button } from "@blueprintjs/core"; -import { Download } from "@blueprintjs/icons"; +import { DownloadIcon } from "@blueprintjs/icons"; import * as React from "react"; import * as ReactDOM from "react-dom/client"; const root = ReactDOM.createRoot(document.getElementById("root")); -root.render( ); }; diff --git a/packages/core/src/components/toast/toast.tsx b/packages/core/src/components/toast/toast.tsx index fb3742de948..8e1fed74616 100644 --- a/packages/core/src/components/toast/toast.tsx +++ b/packages/core/src/components/toast/toast.tsx @@ -17,7 +17,7 @@ import classNames from "classnames"; import { forwardRef, useCallback, useEffect, useState } from "react"; -import { Cross } from "@blueprintjs/icons"; +import { CrossIcon } from "@blueprintjs/icons"; import { Classes } from "../../common"; import { DISPLAYNAME_PREFIX } from "../../common/props"; @@ -99,7 +99,7 @@ export const Toast = forwardRef((props, ref) => { {action && } - {isCloseButtonShown &&