@blueprintjs/icons 5.1.2 → 5.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/svgIconContainer.d.ts +12 -2
- package/lib/cjs/svgIconContainer.js +1 -0
- package/lib/cjs/svgIconContainer.js.map +1 -1
- package/lib/cjs/svgIconProps.d.ts +38 -7
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/svgIconContainer.d.ts +12 -2
- package/lib/esm/svgIconContainer.js +1 -0
- package/lib/esm/svgIconContainer.js.map +1 -1
- package/lib/esm/svgIconProps.d.ts +38 -7
- package/lib/esnext/index.d.ts +2 -2
- package/lib/esnext/index.js.map +1 -1
- package/lib/esnext/svgIconContainer.d.ts +12 -2
- package/lib/esnext/svgIconContainer.js +2 -1
- package/lib/esnext/svgIconContainer.js.map +1 -1
- package/lib/esnext/svgIconProps.d.ts +38 -7
- package/package.json +1 -1
- package/src/icons-list.md +1 -0
- package/src/index.md +1 -0
- package/src/index.ts +2 -2
- package/src/loading-icons.md +1 -0
- package/src/svgIconContainer.tsx +71 -53
- package/src/svgIconProps.ts +49 -8
package/lib/cjs/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { IconSvgPaths16, IconSvgPaths20, getIconPaths } from "./allPaths";
|
|
2
2
|
export { Icons, IconLoaderOptions, IconPathsLoader } from "./iconLoader";
|
|
3
|
-
export { SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
4
|
-
export { SVGIconContainer, SVGIconContainerProps } from "./svgIconContainer";
|
|
3
|
+
export { DefaultSVGIconAttributes, DefaultSVGIconProps, SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
4
|
+
export { SVGIconContainer, SVGIconContainerComponent, SVGIconContainerProps } from "./svgIconContainer";
|
|
5
5
|
export { getIconContentString, IconCodepoints } from "./iconCodepoints";
|
|
6
6
|
export { IconName, IconNames } from "./iconNames";
|
|
7
7
|
export { IconSize, IconPaths } from "./iconTypes";
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2FAA2F;AAC3F,uCAA0E;AAAjE,0GAAA,cAAc,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,wGAAA,YAAY,OAAA;AAErD,2CAAyE;AAAhE,mGAAA,KAAK,OAAA;AAEd,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,2FAA2F;AAC3F,uCAA0E;AAAjE,0GAAA,cAAc,OAAA;AAAE,0GAAA,cAAc,OAAA;AAAE,wGAAA,YAAY,OAAA;AAErD,2CAAyE;AAAhE,mGAAA,KAAK,OAAA;AAEd,uDAAwG;AAA/F,oHAAA,gBAAgB,OAAA;AACzB,mDAAwE;AAA/D,sHAAA,oBAAoB,OAAA;AAAE,gHAAA,cAAc,OAAA;AAC7C,yCAAkD;AAA/B,sGAAA,SAAS,OAAA;AAC5B,yCAAkD;AAAzC,qGAAA,QAAQ,OAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { IconName } from "./iconNames";
|
|
3
3
|
import type { SVGIconProps } from "./svgIconProps";
|
|
4
|
-
export
|
|
4
|
+
export type SVGIconContainerProps<T extends Element> = Omit<SVGIconProps<T>, "children"> & {
|
|
5
5
|
/**
|
|
6
6
|
* Icon name.
|
|
7
7
|
*/
|
|
@@ -10,5 +10,15 @@ export interface SVGIconContainerProps extends Omit<SVGIconProps, "children"> {
|
|
|
10
10
|
* Icon contents, loaded via `IconLoader` and specified as `<path>` elements.
|
|
11
11
|
*/
|
|
12
12
|
children: JSX.Element | JSX.Element[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generic icon container component type. This is essentially a type hack required to make forwardRef work with generic
|
|
16
|
+
* components. Note that this slows down TypeScript compilation, but it better than the alternative of globally
|
|
17
|
+
* augmenting "@types/react".
|
|
18
|
+
*
|
|
19
|
+
* @see https://stackoverflow.com/a/73795494/7406866
|
|
20
|
+
*/
|
|
21
|
+
export interface SVGIconContainerComponent extends React.FC<SVGIconContainerProps<Element>> {
|
|
22
|
+
<T extends Element = Element>(props: SVGIconContainerProps<T>): React.ReactElement | null;
|
|
13
23
|
}
|
|
14
|
-
export declare const SVGIconContainer:
|
|
24
|
+
export declare const SVGIconContainer: SVGIconContainerComponent;
|
|
@@ -21,6 +21,7 @@ var React = tslib_1.__importStar(require("react"));
|
|
|
21
21
|
var Classes = tslib_1.__importStar(require("./classes"));
|
|
22
22
|
var iconTypes_1 = require("./iconTypes");
|
|
23
23
|
var jsUtils_1 = require("./jsUtils");
|
|
24
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
24
25
|
exports.SVGIconContainer = React.forwardRef(function (props, ref) {
|
|
25
26
|
var children = props.children, className = props.className, color = props.color, htmlTitle = props.htmlTitle, iconName = props.iconName, _a = props.size, size = _a === void 0 ? iconTypes_1.IconSize.STANDARD : _a, svgProps = props.svgProps, _b = props.tagName, tagName = _b === void 0 ? "span" : _b, title = props.title, htmlProps = tslib_1.__rest(props, ["children", "className", "color", "htmlTitle", "iconName", "size", "svgProps", "tagName", "title"]);
|
|
26
27
|
var isLarge = size >= iconTypes_1.IconSize.LARGE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svgIconContainer.js","sourceRoot":"","sources":["../../src/svgIconContainer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;AAEH,kEAAoC;AACpC,mDAA+B;AAE/B,yDAAqC;AAErC,yCAAuC;AACvC,qCAAqC;
|
|
1
|
+
{"version":3,"file":"svgIconContainer.js","sourceRoot":"","sources":["../../src/svgIconContainer.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;AAEH,kEAAoC;AACpC,mDAA+B;AAE/B,yDAAqC;AAErC,yCAAuC;AACvC,qCAAqC;AA0BrC,iDAAiD;AACpC,QAAA,gBAAgB,GAA8B,KAAK,CAAC,UAAU,CAAC,UACxE,KAA+B,EAC/B,GAAiB;IAGb,IAAA,QAAQ,GAUR,KAAK,SAVG,EACR,SAAS,GAST,KAAK,UATI,EACT,KAAK,GAQL,KAAK,MARA,EACL,SAAS,GAOT,KAAK,UAPI,EACT,QAAQ,GAMR,KAAK,SANG,EACR,KAKA,KAAK,KALmB,EAAxB,IAAI,mBAAG,oBAAQ,CAAC,QAAQ,KAAA,EACxB,QAAQ,GAIR,KAAK,SAJG,EACR,KAGA,KAAK,QAHW,EAAhB,OAAO,mBAAG,MAAM,KAAA,EAChB,KAAK,GAEL,KAAK,MAFA,EACF,SAAS,kBACZ,KAAK,EAXH,mGAWL,CADe,CACN;IAEV,IAAM,OAAO,GAAG,IAAI,IAAI,oBAAQ,CAAC,KAAK,CAAC;IACvC,IAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,oBAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAQ,CAAC,QAAQ,CAAC;IACnE,IAAM,OAAO,GAAG,cAAO,aAAa,cAAI,aAAa,CAAE,CAAC;IACxD,IAAM,OAAO,GAAG,IAAA,kBAAQ,EAAC,WAAW,CAAC,CAAC;IACtC,IAAM,cAAc,sBAChB,WAAW,EAAE,QAAQ,EACrB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,KAAK,EACX,OAAO,SAAA,EACP,KAAK,EAAE,IAAI,IACR,QAAQ,CACd,CAAC;IAEF,IAAI,OAAO,KAAK,IAAI,EAAE;QAClB,OAAO,CACH,iEACqB,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC5C,GAAG,EAAE,GAA+B,IAChC,cAAc,EACd,SAAS;YAEZ,KAAK,IAAI,+BAAO,EAAE,EAAE,OAAO,IAAG,KAAK,CAAS;YAC5C,QAAQ,CACP,CACT,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC,aAAa,CACtB,OAAO,wCAEA,SAAS,KACZ,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EACvC,SAAS,EAAE,IAAA,oBAAU,EAAC,OAAO,CAAC,IAAI,EAAE,UAAG,OAAO,CAAC,IAAI,cAAI,QAAQ,CAAE,EAAE,SAAS,CAAC,EAC7E,GAAG,KAAA,EACH,KAAK,EAAE,SAAS,KAEpB,gDAAS,cAAc;YAClB,KAAK,IAAI,mCAAQ,KAAK,CAAS;YAC/B,QAAQ,CACP,CACT,CAAC;KACL;AACL,CAAC,CAAC,CAAC;AACH,wBAAgB,CAAC,WAAW,GAAG,6BAA6B,CAAC"}
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
type OmittedDOMAttributes = "children" | "dangerouslySetInnerHTML";
|
|
2
3
|
/**
|
|
3
|
-
* DOM attributes assignable as props to the root element rendered by an
|
|
4
|
-
*
|
|
4
|
+
* Default set of DOM attributes which are assignable as props to the root element rendered by an
|
|
5
|
+
* SVG icon component. This limited set of attributes is assignable to any `<Icon>` component regardless
|
|
6
|
+
* of its `tagName` prop (it works for both HTML and SVG elements).
|
|
5
7
|
*/
|
|
6
|
-
export type
|
|
8
|
+
export type DefaultSVGIconAttributes = React.AriaAttributes & Omit<React.DOMAttributes<Element>, OmittedDOMAttributes> & Pick<React.HTMLAttributes<Element>, "id" | "style" | "tabIndex" | "role">;
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* DOM attributes which are assignable as props to the root element rendered by an SVG icon component.
|
|
11
|
+
* Specify a type parameter to narrow this type and allow more attributes to be passed to the root element.
|
|
12
|
+
*
|
|
13
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.dom-attributes
|
|
14
|
+
*
|
|
15
|
+
* When `tagName` is specified, either:
|
|
16
|
+
* - as a custom HTML element tag name,
|
|
17
|
+
* - as `null` to signfiy that there should be no wrapper around the `<svg>` element,
|
|
18
|
+
* - or its default value of "span" is used,
|
|
19
|
+
* then it may be useful to narrow this type to pass along additional attributes which not supported by
|
|
20
|
+
* the more general `DefaultSVGIconAttributes` interface. You can do this by specifying a generic type param
|
|
21
|
+
* on `<Icon>` components, for example:
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* <Icon<HTMLSpanElement> icon="drag-handle-horizontal" draggable="false" />
|
|
25
|
+
* ```
|
|
10
26
|
*/
|
|
11
|
-
export
|
|
27
|
+
export type SVGIconAttributes<T extends Element = Element> = T extends SVGElement ? Omit<React.SVGAttributes<T>, OmittedDOMAttributes> : T extends HTMLElement ? Omit<React.HTMLAttributes<T>, OmittedDOMAttributes> : DefaultSVGIconAttributes;
|
|
28
|
+
export interface SVGIconOwnProps {
|
|
12
29
|
/** A space-delimited list of class names to pass along to the SVG element. */
|
|
13
30
|
className?: string;
|
|
14
|
-
/** This component does not support
|
|
31
|
+
/** This component does not support child nodes. */
|
|
15
32
|
children?: never;
|
|
16
33
|
/**
|
|
17
34
|
* Color of icon. This is used as the `fill` attribute on the `<svg>` image
|
|
@@ -56,3 +73,17 @@ export interface SVGIconProps extends React.RefAttributes<any>, SVGIconAttribute
|
|
|
56
73
|
/** Props to apply to the `SVG` element */
|
|
57
74
|
svgProps?: React.HTMLAttributes<SVGElement>;
|
|
58
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Interface for generated icon components which have their name and icon paths statically defined
|
|
78
|
+
* inside their JS implementation.
|
|
79
|
+
*
|
|
80
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.static-components
|
|
81
|
+
*/
|
|
82
|
+
export type SVGIconProps<T extends Element = Element> = React.RefAttributes<T> & SVGIconAttributes<T> & SVGIconOwnProps;
|
|
83
|
+
/**
|
|
84
|
+
* The default SVG icon props interface, equivalent to `SVGIconProps` with its default type parameter.
|
|
85
|
+
* This is primarly exported for documentation purposes; users should reference `SVGIconProps<T>` instead.
|
|
86
|
+
*/
|
|
87
|
+
export interface DefaultSVGIconProps extends React.RefAttributes<Element>, SVGIconAttributes<Element>, SVGIconOwnProps {
|
|
88
|
+
}
|
|
89
|
+
export {};
|
package/lib/esm/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { IconSvgPaths16, IconSvgPaths20, getIconPaths } from "./allPaths";
|
|
2
2
|
export { Icons, IconLoaderOptions, IconPathsLoader } from "./iconLoader";
|
|
3
|
-
export { SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
4
|
-
export { SVGIconContainer, SVGIconContainerProps } from "./svgIconContainer";
|
|
3
|
+
export { DefaultSVGIconAttributes, DefaultSVGIconProps, SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
4
|
+
export { SVGIconContainer, SVGIconContainerComponent, SVGIconContainerProps } from "./svgIconContainer";
|
|
5
5
|
export { getIconContentString, IconCodepoints } from "./iconCodepoints";
|
|
6
6
|
export { IconName, IconNames } from "./iconNames";
|
|
7
7
|
export { IconSize, IconPaths } from "./iconTypes";
|
package/lib/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2FAA2F;AAC3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAsC,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2FAA2F;AAC3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAsC,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAoD,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAY,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAa,MAAM,aAAa,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { IconName } from "./iconNames";
|
|
3
3
|
import type { SVGIconProps } from "./svgIconProps";
|
|
4
|
-
export
|
|
4
|
+
export type SVGIconContainerProps<T extends Element> = Omit<SVGIconProps<T>, "children"> & {
|
|
5
5
|
/**
|
|
6
6
|
* Icon name.
|
|
7
7
|
*/
|
|
@@ -10,5 +10,15 @@ export interface SVGIconContainerProps extends Omit<SVGIconProps, "children"> {
|
|
|
10
10
|
* Icon contents, loaded via `IconLoader` and specified as `<path>` elements.
|
|
11
11
|
*/
|
|
12
12
|
children: JSX.Element | JSX.Element[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generic icon container component type. This is essentially a type hack required to make forwardRef work with generic
|
|
16
|
+
* components. Note that this slows down TypeScript compilation, but it better than the alternative of globally
|
|
17
|
+
* augmenting "@types/react".
|
|
18
|
+
*
|
|
19
|
+
* @see https://stackoverflow.com/a/73795494/7406866
|
|
20
|
+
*/
|
|
21
|
+
export interface SVGIconContainerComponent extends React.FC<SVGIconContainerProps<Element>> {
|
|
22
|
+
<T extends Element = Element>(props: SVGIconContainerProps<T>): React.ReactElement | null;
|
|
13
23
|
}
|
|
14
|
-
export declare const SVGIconContainer:
|
|
24
|
+
export declare const SVGIconContainer: SVGIconContainerComponent;
|
|
@@ -18,6 +18,7 @@ import * as React from "react";
|
|
|
18
18
|
import * as Classes from "./classes";
|
|
19
19
|
import { IconSize } from "./iconTypes";
|
|
20
20
|
import { uniqueId } from "./jsUtils";
|
|
21
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
21
22
|
export var SVGIconContainer = React.forwardRef(function (props, ref) {
|
|
22
23
|
var children = props.children, className = props.className, color = props.color, htmlTitle = props.htmlTitle, iconName = props.iconName, _a = props.size, size = _a === void 0 ? IconSize.STANDARD : _a, svgProps = props.svgProps, _b = props.tagName, tagName = _b === void 0 ? "span" : _b, title = props.title, htmlProps = __rest(props, ["children", "className", "color", "htmlTitle", "iconName", "size", "svgProps", "tagName", "title"]);
|
|
23
24
|
var isLarge = size >= IconSize.LARGE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svgIconContainer.js","sourceRoot":"","sources":["../../src/svgIconContainer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"svgIconContainer.js","sourceRoot":"","sources":["../../src/svgIconContainer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AA0BrC,iDAAiD;AACjD,MAAM,CAAC,IAAM,gBAAgB,GAA8B,KAAK,CAAC,UAAU,CAAC,UACxE,KAA+B,EAC/B,GAAiB;IAGb,IAAA,QAAQ,GAUR,KAAK,SAVG,EACR,SAAS,GAST,KAAK,UATI,EACT,KAAK,GAQL,KAAK,MARA,EACL,SAAS,GAOT,KAAK,UAPI,EACT,QAAQ,GAMR,KAAK,SANG,EACR,KAKA,KAAK,KALmB,EAAxB,IAAI,mBAAG,QAAQ,CAAC,QAAQ,KAAA,EACxB,QAAQ,GAIR,KAAK,SAJG,EACR,KAGA,KAAK,QAHW,EAAhB,OAAO,mBAAG,MAAM,KAAA,EAChB,KAAK,GAEL,KAAK,MAFA,EACF,SAAS,UACZ,KAAK,EAXH,mGAWL,CADe,CACN;IAEV,IAAM,OAAO,GAAG,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC;IACvC,IAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACnE,IAAM,OAAO,GAAG,cAAO,aAAa,cAAI,aAAa,CAAE,CAAC;IACxD,IAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,IAAM,cAAc,cAChB,WAAW,EAAE,QAAQ,EACrB,IAAI,EAAE,KAAK,EACX,MAAM,EAAE,IAAI,EACZ,IAAI,EAAE,KAAK,EACX,OAAO,SAAA,EACP,KAAK,EAAE,IAAI,IACR,QAAQ,CACd,CAAC;IAEF,IAAI,OAAO,KAAK,IAAI,EAAE;QAClB,OAAO,CACH,yDACqB,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC5C,GAAG,EAAE,GAA+B,IAChC,cAAc,EACd,SAAS;YAEZ,KAAK,IAAI,+BAAO,EAAE,EAAE,OAAO,IAAG,KAAK,CAAS;YAC5C,QAAQ,CACP,CACT,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC,aAAa,CACtB,OAAO,wBAEA,SAAS,KACZ,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,EACvC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,UAAG,OAAO,CAAC,IAAI,cAAI,QAAQ,CAAE,EAAE,SAAS,CAAC,EAC7E,GAAG,KAAA,EACH,KAAK,EAAE,SAAS,KAEpB,wCAAS,cAAc;YAClB,KAAK,IAAI,mCAAQ,KAAK,CAAS;YAC/B,QAAQ,CACP,CACT,CAAC;KACL;AACL,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,6BAA6B,CAAC"}
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
type OmittedDOMAttributes = "children" | "dangerouslySetInnerHTML";
|
|
2
3
|
/**
|
|
3
|
-
* DOM attributes assignable as props to the root element rendered by an
|
|
4
|
-
*
|
|
4
|
+
* Default set of DOM attributes which are assignable as props to the root element rendered by an
|
|
5
|
+
* SVG icon component. This limited set of attributes is assignable to any `<Icon>` component regardless
|
|
6
|
+
* of its `tagName` prop (it works for both HTML and SVG elements).
|
|
5
7
|
*/
|
|
6
|
-
export type
|
|
8
|
+
export type DefaultSVGIconAttributes = React.AriaAttributes & Omit<React.DOMAttributes<Element>, OmittedDOMAttributes> & Pick<React.HTMLAttributes<Element>, "id" | "style" | "tabIndex" | "role">;
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* DOM attributes which are assignable as props to the root element rendered by an SVG icon component.
|
|
11
|
+
* Specify a type parameter to narrow this type and allow more attributes to be passed to the root element.
|
|
12
|
+
*
|
|
13
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.dom-attributes
|
|
14
|
+
*
|
|
15
|
+
* When `tagName` is specified, either:
|
|
16
|
+
* - as a custom HTML element tag name,
|
|
17
|
+
* - as `null` to signfiy that there should be no wrapper around the `<svg>` element,
|
|
18
|
+
* - or its default value of "span" is used,
|
|
19
|
+
* then it may be useful to narrow this type to pass along additional attributes which not supported by
|
|
20
|
+
* the more general `DefaultSVGIconAttributes` interface. You can do this by specifying a generic type param
|
|
21
|
+
* on `<Icon>` components, for example:
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* <Icon<HTMLSpanElement> icon="drag-handle-horizontal" draggable="false" />
|
|
25
|
+
* ```
|
|
10
26
|
*/
|
|
11
|
-
export
|
|
27
|
+
export type SVGIconAttributes<T extends Element = Element> = T extends SVGElement ? Omit<React.SVGAttributes<T>, OmittedDOMAttributes> : T extends HTMLElement ? Omit<React.HTMLAttributes<T>, OmittedDOMAttributes> : DefaultSVGIconAttributes;
|
|
28
|
+
export interface SVGIconOwnProps {
|
|
12
29
|
/** A space-delimited list of class names to pass along to the SVG element. */
|
|
13
30
|
className?: string;
|
|
14
|
-
/** This component does not support
|
|
31
|
+
/** This component does not support child nodes. */
|
|
15
32
|
children?: never;
|
|
16
33
|
/**
|
|
17
34
|
* Color of icon. This is used as the `fill` attribute on the `<svg>` image
|
|
@@ -56,3 +73,17 @@ export interface SVGIconProps extends React.RefAttributes<any>, SVGIconAttribute
|
|
|
56
73
|
/** Props to apply to the `SVG` element */
|
|
57
74
|
svgProps?: React.HTMLAttributes<SVGElement>;
|
|
58
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Interface for generated icon components which have their name and icon paths statically defined
|
|
78
|
+
* inside their JS implementation.
|
|
79
|
+
*
|
|
80
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.static-components
|
|
81
|
+
*/
|
|
82
|
+
export type SVGIconProps<T extends Element = Element> = React.RefAttributes<T> & SVGIconAttributes<T> & SVGIconOwnProps;
|
|
83
|
+
/**
|
|
84
|
+
* The default SVG icon props interface, equivalent to `SVGIconProps` with its default type parameter.
|
|
85
|
+
* This is primarly exported for documentation purposes; users should reference `SVGIconProps<T>` instead.
|
|
86
|
+
*/
|
|
87
|
+
export interface DefaultSVGIconProps extends React.RefAttributes<Element>, SVGIconAttributes<Element>, SVGIconOwnProps {
|
|
88
|
+
}
|
|
89
|
+
export {};
|
package/lib/esnext/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { IconSvgPaths16, IconSvgPaths20, getIconPaths } from "./allPaths";
|
|
2
2
|
export { Icons, IconLoaderOptions, IconPathsLoader } from "./iconLoader";
|
|
3
|
-
export { SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
4
|
-
export { SVGIconContainer, SVGIconContainerProps } from "./svgIconContainer";
|
|
3
|
+
export { DefaultSVGIconAttributes, DefaultSVGIconProps, SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
4
|
+
export { SVGIconContainer, SVGIconContainerComponent, SVGIconContainerProps } from "./svgIconContainer";
|
|
5
5
|
export { getIconContentString, IconCodepoints } from "./iconCodepoints";
|
|
6
6
|
export { IconName, IconNames } from "./iconNames";
|
|
7
7
|
export { IconSize, IconPaths } from "./iconTypes";
|
package/lib/esnext/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2FAA2F;AAC3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAsC,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,2FAA2F;AAC3F,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1E,OAAO,EAAE,KAAK,EAAsC,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,gBAAgB,EAAoD,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAY,SAAS,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAa,MAAM,aAAa,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { IconName } from "./iconNames";
|
|
3
3
|
import type { SVGIconProps } from "./svgIconProps";
|
|
4
|
-
export
|
|
4
|
+
export type SVGIconContainerProps<T extends Element> = Omit<SVGIconProps<T>, "children"> & {
|
|
5
5
|
/**
|
|
6
6
|
* Icon name.
|
|
7
7
|
*/
|
|
@@ -10,5 +10,15 @@ export interface SVGIconContainerProps extends Omit<SVGIconProps, "children"> {
|
|
|
10
10
|
* Icon contents, loaded via `IconLoader` and specified as `<path>` elements.
|
|
11
11
|
*/
|
|
12
12
|
children: JSX.Element | JSX.Element[];
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Generic icon container component type. This is essentially a type hack required to make forwardRef work with generic
|
|
16
|
+
* components. Note that this slows down TypeScript compilation, but it better than the alternative of globally
|
|
17
|
+
* augmenting "@types/react".
|
|
18
|
+
*
|
|
19
|
+
* @see https://stackoverflow.com/a/73795494/7406866
|
|
20
|
+
*/
|
|
21
|
+
export interface SVGIconContainerComponent extends React.FC<SVGIconContainerProps<Element>> {
|
|
22
|
+
<T extends Element = Element>(props: SVGIconContainerProps<T>): React.ReactElement | null;
|
|
13
23
|
}
|
|
14
|
-
export declare const SVGIconContainer:
|
|
24
|
+
export declare const SVGIconContainer: SVGIconContainerComponent;
|
|
@@ -17,7 +17,8 @@ import * as React from "react";
|
|
|
17
17
|
import * as Classes from "./classes";
|
|
18
18
|
import { IconSize } from "./iconTypes";
|
|
19
19
|
import { uniqueId } from "./jsUtils";
|
|
20
|
-
|
|
20
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
21
|
+
export const SVGIconContainer = React.forwardRef(function (props, ref) {
|
|
21
22
|
const { children, className, color, htmlTitle, iconName, size = IconSize.STANDARD, svgProps, tagName = "span", title, ...htmlProps } = props;
|
|
22
23
|
const isLarge = size >= IconSize.LARGE;
|
|
23
24
|
const pixelGridSize = isLarge ? IconSize.LARGE : IconSize.STANDARD;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svgIconContainer.js","sourceRoot":"","sources":["../../src/svgIconContainer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"svgIconContainer.js","sourceRoot":"","sources":["../../src/svgIconContainer.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AA0BrC,iDAAiD;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAA8B,KAAK,CAAC,UAAU,CAAC,UACxE,KAA+B,EAC/B,GAAiB;IAEjB,MAAM,EACF,QAAQ,EACR,SAAS,EACT,KAAK,EACL,SAAS,EACT,QAAQ,EACR,IAAI,GAAG,QAAQ,CAAC,QAAQ,EACxB,QAAQ,EACR,OAAO,GAAG,MAAM,EAChB,KAAK,EACL,GAAG,SAAS,EACf,GAAG,KAAK,CAAC;IAEV,MAAM,OAAO,GAAG,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC;IACvC,MAAM,aAAa,GAAG,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC;IACnE,MAAM,OAAO,GAAG,OAAO,aAAa,IAAI,aAAa,EAAE,CAAC;IACxD,MAAM,OAAO,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;IACtC,MAAM,cAAc,GAAG;QACnB,WAAW,EAAE,QAAQ;QACrB,IAAI,EAAE,KAAK;QACX,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,KAAK;QACX,OAAO;QACP,KAAK,EAAE,IAAI;QACX,GAAG,QAAQ;KACd,CAAC;IAEF,IAAI,OAAO,KAAK,IAAI,EAAE;QAClB,OAAO,CACH,gDACqB,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,EAC5C,GAAG,EAAE,GAA+B,KAChC,cAAc,KACd,SAAS;YAEZ,KAAK,IAAI,+BAAO,EAAE,EAAE,OAAO,IAAG,KAAK,CAAS;YAC5C,QAAQ,CACP,CACT,CAAC;KACL;SAAM;QACH,OAAO,KAAK,CAAC,aAAa,CACtB,OAAO,EACP;YACI,GAAG,SAAS;YACZ,aAAa,EAAE,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI;YACvC,SAAS,EAAE,UAAU,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,OAAO,CAAC,IAAI,IAAI,QAAQ,EAAE,EAAE,SAAS,CAAC;YAC7E,GAAG;YACH,KAAK,EAAE,SAAS;SACnB,EACD,gCAAS,cAAc;YAClB,KAAK,IAAI,mCAAQ,KAAK,CAAS;YAC/B,QAAQ,CACP,CACT,CAAC;KACL;AACL,CAAC,CAAC,CAAC;AACH,gBAAgB,CAAC,WAAW,GAAG,6BAA6B,CAAC"}
|
|
@@ -1,17 +1,34 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
type OmittedDOMAttributes = "children" | "dangerouslySetInnerHTML";
|
|
2
3
|
/**
|
|
3
|
-
* DOM attributes assignable as props to the root element rendered by an
|
|
4
|
-
*
|
|
4
|
+
* Default set of DOM attributes which are assignable as props to the root element rendered by an
|
|
5
|
+
* SVG icon component. This limited set of attributes is assignable to any `<Icon>` component regardless
|
|
6
|
+
* of its `tagName` prop (it works for both HTML and SVG elements).
|
|
5
7
|
*/
|
|
6
|
-
export type
|
|
8
|
+
export type DefaultSVGIconAttributes = React.AriaAttributes & Omit<React.DOMAttributes<Element>, OmittedDOMAttributes> & Pick<React.HTMLAttributes<Element>, "id" | "style" | "tabIndex" | "role">;
|
|
7
9
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
+
* DOM attributes which are assignable as props to the root element rendered by an SVG icon component.
|
|
11
|
+
* Specify a type parameter to narrow this type and allow more attributes to be passed to the root element.
|
|
12
|
+
*
|
|
13
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.dom-attributes
|
|
14
|
+
*
|
|
15
|
+
* When `tagName` is specified, either:
|
|
16
|
+
* - as a custom HTML element tag name,
|
|
17
|
+
* - as `null` to signfiy that there should be no wrapper around the `<svg>` element,
|
|
18
|
+
* - or its default value of "span" is used,
|
|
19
|
+
* then it may be useful to narrow this type to pass along additional attributes which not supported by
|
|
20
|
+
* the more general `DefaultSVGIconAttributes` interface. You can do this by specifying a generic type param
|
|
21
|
+
* on `<Icon>` components, for example:
|
|
22
|
+
*
|
|
23
|
+
* ```
|
|
24
|
+
* <Icon<HTMLSpanElement> icon="drag-handle-horizontal" draggable="false" />
|
|
25
|
+
* ```
|
|
10
26
|
*/
|
|
11
|
-
export
|
|
27
|
+
export type SVGIconAttributes<T extends Element = Element> = T extends SVGElement ? Omit<React.SVGAttributes<T>, OmittedDOMAttributes> : T extends HTMLElement ? Omit<React.HTMLAttributes<T>, OmittedDOMAttributes> : DefaultSVGIconAttributes;
|
|
28
|
+
export interface SVGIconOwnProps {
|
|
12
29
|
/** A space-delimited list of class names to pass along to the SVG element. */
|
|
13
30
|
className?: string;
|
|
14
|
-
/** This component does not support
|
|
31
|
+
/** This component does not support child nodes. */
|
|
15
32
|
children?: never;
|
|
16
33
|
/**
|
|
17
34
|
* Color of icon. This is used as the `fill` attribute on the `<svg>` image
|
|
@@ -56,3 +73,17 @@ export interface SVGIconProps extends React.RefAttributes<any>, SVGIconAttribute
|
|
|
56
73
|
/** Props to apply to the `SVG` element */
|
|
57
74
|
svgProps?: React.HTMLAttributes<SVGElement>;
|
|
58
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Interface for generated icon components which have their name and icon paths statically defined
|
|
78
|
+
* inside their JS implementation.
|
|
79
|
+
*
|
|
80
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.static-components
|
|
81
|
+
*/
|
|
82
|
+
export type SVGIconProps<T extends Element = Element> = React.RefAttributes<T> & SVGIconAttributes<T> & SVGIconOwnProps;
|
|
83
|
+
/**
|
|
84
|
+
* The default SVG icon props interface, equivalent to `SVGIconProps` with its default type parameter.
|
|
85
|
+
* This is primarly exported for documentation purposes; users should reference `SVGIconProps<T>` instead.
|
|
86
|
+
*/
|
|
87
|
+
export interface DefaultSVGIconProps extends React.RefAttributes<Element>, SVGIconAttributes<Element>, SVGIconOwnProps {
|
|
88
|
+
}
|
|
89
|
+
export {};
|
package/package.json
CHANGED
package/src/icons-list.md
CHANGED
|
@@ -7,6 +7,7 @@ Be sure to check out the docs on [loading icons](#icons/loading-icons) and how t
|
|
|
7
7
|
<div class="@ns-callout @ns-intent-primary @ns-icon-info-sign">
|
|
8
8
|
|
|
9
9
|
See the [**`Icon` component documentation**](#core/components/icon) (in the `@blueprintjs/core` package) for React API details.
|
|
10
|
+
|
|
10
11
|
</div>
|
|
11
12
|
|
|
12
13
|
@reactDocs Icons
|
package/src/index.md
CHANGED
|
@@ -10,6 +10,7 @@ provides provides over 500 vector UI icons in two sizes (16px and 20px) and two
|
|
|
10
10
|
<div class="@ns-callout @ns-intent-primary @ns-icon-info-sign">
|
|
11
11
|
|
|
12
12
|
See the [**`Icon` component documentation**](#core/components/icon) (in the `@blueprintjs/core` package) for React API details.
|
|
13
|
+
|
|
13
14
|
</div>
|
|
14
15
|
|
|
15
16
|
```sh
|
package/src/index.ts
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
export { IconSvgPaths16, IconSvgPaths20, getIconPaths } from "./allPaths";
|
|
19
19
|
|
|
20
20
|
export { Icons, IconLoaderOptions, IconPathsLoader } from "./iconLoader";
|
|
21
|
-
export { SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
22
|
-
export { SVGIconContainer, SVGIconContainerProps } from "./svgIconContainer";
|
|
21
|
+
export { DefaultSVGIconAttributes, DefaultSVGIconProps, SVGIconAttributes, SVGIconProps } from "./svgIconProps";
|
|
22
|
+
export { SVGIconContainer, SVGIconContainerComponent, SVGIconContainerProps } from "./svgIconContainer";
|
|
23
23
|
export { getIconContentString, IconCodepoints } from "./iconCodepoints";
|
|
24
24
|
export { IconName, IconNames } from "./iconNames";
|
|
25
25
|
export { IconSize, IconPaths } from "./iconTypes";
|
package/src/loading-icons.md
CHANGED
package/src/svgIconContainer.tsx
CHANGED
|
@@ -22,7 +22,7 @@ import { IconSize } from "./iconTypes";
|
|
|
22
22
|
import { uniqueId } from "./jsUtils";
|
|
23
23
|
import type { SVGIconProps } from "./svgIconProps";
|
|
24
24
|
|
|
25
|
-
export
|
|
25
|
+
export type SVGIconContainerProps<T extends Element> = Omit<SVGIconProps<T>, "children"> & {
|
|
26
26
|
/**
|
|
27
27
|
* Icon name.
|
|
28
28
|
*/
|
|
@@ -32,60 +32,78 @@ export interface SVGIconContainerProps extends Omit<SVGIconProps, "children"> {
|
|
|
32
32
|
* Icon contents, loaded via `IconLoader` and specified as `<path>` elements.
|
|
33
33
|
*/
|
|
34
34
|
children: JSX.Element | JSX.Element[];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Generic icon container component type. This is essentially a type hack required to make forwardRef work with generic
|
|
39
|
+
* components. Note that this slows down TypeScript compilation, but it better than the alternative of globally
|
|
40
|
+
* augmenting "@types/react".
|
|
41
|
+
*
|
|
42
|
+
* @see https://stackoverflow.com/a/73795494/7406866
|
|
43
|
+
*/
|
|
44
|
+
export interface SVGIconContainerComponent extends React.FC<SVGIconContainerProps<Element>> {
|
|
45
|
+
<T extends Element = Element>(props: SVGIconContainerProps<T>): React.ReactElement | null;
|
|
35
46
|
}
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
// eslint-disable-next-line prefer-arrow-callback
|
|
49
|
+
export const SVGIconContainer: SVGIconContainerComponent = React.forwardRef(function <T extends Element>(
|
|
50
|
+
props: SVGIconContainerProps<T>,
|
|
51
|
+
ref: React.Ref<T>,
|
|
52
|
+
) {
|
|
53
|
+
const {
|
|
54
|
+
children,
|
|
55
|
+
className,
|
|
56
|
+
color,
|
|
57
|
+
htmlTitle,
|
|
58
|
+
iconName,
|
|
59
|
+
size = IconSize.STANDARD,
|
|
60
|
+
svgProps,
|
|
61
|
+
tagName = "span",
|
|
62
|
+
title,
|
|
63
|
+
...htmlProps
|
|
64
|
+
} = props;
|
|
51
65
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
const isLarge = size >= IconSize.LARGE;
|
|
67
|
+
const pixelGridSize = isLarge ? IconSize.LARGE : IconSize.STANDARD;
|
|
68
|
+
const viewBox = `0 0 ${pixelGridSize} ${pixelGridSize}`;
|
|
69
|
+
const titleId = uniqueId("iconTitle");
|
|
70
|
+
const sharedSvgProps = {
|
|
71
|
+
"data-icon": iconName,
|
|
72
|
+
fill: color,
|
|
73
|
+
height: size,
|
|
74
|
+
role: "img",
|
|
75
|
+
viewBox,
|
|
76
|
+
width: size,
|
|
77
|
+
...svgProps,
|
|
78
|
+
};
|
|
65
79
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
80
|
+
if (tagName === null) {
|
|
81
|
+
return (
|
|
82
|
+
<svg
|
|
83
|
+
aria-labelledby={title ? titleId : undefined}
|
|
84
|
+
ref={ref as React.Ref<SVGSVGElement>}
|
|
85
|
+
{...sharedSvgProps}
|
|
86
|
+
{...htmlProps}
|
|
87
|
+
>
|
|
88
|
+
{title && <title id={titleId}>{title}</title>}
|
|
89
|
+
{children}
|
|
90
|
+
</svg>
|
|
91
|
+
);
|
|
92
|
+
} else {
|
|
93
|
+
return React.createElement(
|
|
94
|
+
tagName,
|
|
95
|
+
{
|
|
96
|
+
...htmlProps,
|
|
97
|
+
"aria-hidden": title ? undefined : true,
|
|
98
|
+
className: classNames(Classes.ICON, `${Classes.ICON}-${iconName}`, className),
|
|
99
|
+
ref,
|
|
100
|
+
title: htmlTitle,
|
|
101
|
+
},
|
|
102
|
+
<svg {...sharedSvgProps}>
|
|
103
|
+
{title && <title>{title}</title>}
|
|
104
|
+
{children}
|
|
105
|
+
</svg>,
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
91
109
|
SVGIconContainer.displayName = "Blueprint5.SVGIconContainer";
|
package/src/svgIconProps.ts
CHANGED
|
@@ -15,23 +15,46 @@
|
|
|
15
15
|
|
|
16
16
|
import * as React from "react";
|
|
17
17
|
|
|
18
|
+
type OmittedDOMAttributes = "children" | "dangerouslySetInnerHTML";
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
|
-
* DOM attributes assignable as props to the root element rendered by an
|
|
20
|
-
*
|
|
21
|
+
* Default set of DOM attributes which are assignable as props to the root element rendered by an
|
|
22
|
+
* SVG icon component. This limited set of attributes is assignable to any `<Icon>` component regardless
|
|
23
|
+
* of its `tagName` prop (it works for both HTML and SVG elements).
|
|
21
24
|
*/
|
|
22
|
-
export type
|
|
23
|
-
Omit<React.DOMAttributes<Element>,
|
|
25
|
+
export type DefaultSVGIconAttributes = React.AriaAttributes &
|
|
26
|
+
Omit<React.DOMAttributes<Element>, OmittedDOMAttributes> &
|
|
24
27
|
Pick<React.HTMLAttributes<Element>, "id" | "style" | "tabIndex" | "role">;
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
|
-
*
|
|
28
|
-
*
|
|
30
|
+
* DOM attributes which are assignable as props to the root element rendered by an SVG icon component.
|
|
31
|
+
* Specify a type parameter to narrow this type and allow more attributes to be passed to the root element.
|
|
32
|
+
*
|
|
33
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.dom-attributes
|
|
34
|
+
*
|
|
35
|
+
* When `tagName` is specified, either:
|
|
36
|
+
* - as a custom HTML element tag name,
|
|
37
|
+
* - as `null` to signfiy that there should be no wrapper around the `<svg>` element,
|
|
38
|
+
* - or its default value of "span" is used,
|
|
39
|
+
* then it may be useful to narrow this type to pass along additional attributes which not supported by
|
|
40
|
+
* the more general `DefaultSVGIconAttributes` interface. You can do this by specifying a generic type param
|
|
41
|
+
* on `<Icon>` components, for example:
|
|
42
|
+
*
|
|
43
|
+
* ```
|
|
44
|
+
* <Icon<HTMLSpanElement> icon="drag-handle-horizontal" draggable="false" />
|
|
45
|
+
* ```
|
|
29
46
|
*/
|
|
30
|
-
export
|
|
47
|
+
export type SVGIconAttributes<T extends Element = Element> = T extends SVGElement
|
|
48
|
+
? Omit<React.SVGAttributes<T>, OmittedDOMAttributes>
|
|
49
|
+
: T extends HTMLElement
|
|
50
|
+
? Omit<React.HTMLAttributes<T>, OmittedDOMAttributes>
|
|
51
|
+
: DefaultSVGIconAttributes;
|
|
52
|
+
|
|
53
|
+
export interface SVGIconOwnProps {
|
|
31
54
|
/** A space-delimited list of class names to pass along to the SVG element. */
|
|
32
55
|
className?: string;
|
|
33
56
|
|
|
34
|
-
/** This component does not support
|
|
57
|
+
/** This component does not support child nodes. */
|
|
35
58
|
children?: never;
|
|
36
59
|
|
|
37
60
|
/**
|
|
@@ -83,3 +106,21 @@ export interface SVGIconProps extends React.RefAttributes<any>, SVGIconAttribute
|
|
|
83
106
|
/** Props to apply to the `SVG` element */
|
|
84
107
|
svgProps?: React.HTMLAttributes<SVGElement>;
|
|
85
108
|
}
|
|
109
|
+
|
|
110
|
+
// N.B. the following inteface is defined as a type alias instead of an interface due to a TypeScript limitation
|
|
111
|
+
// where interfaces cannot extend conditionally-defined union types.
|
|
112
|
+
/**
|
|
113
|
+
* Interface for generated icon components which have their name and icon paths statically defined
|
|
114
|
+
* inside their JS implementation.
|
|
115
|
+
*
|
|
116
|
+
* @see https://blueprintjs.com/docs/#core/components/icon.static-components
|
|
117
|
+
*/
|
|
118
|
+
export type SVGIconProps<T extends Element = Element> = React.RefAttributes<T> & SVGIconAttributes<T> & SVGIconOwnProps;
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The default SVG icon props interface, equivalent to `SVGIconProps` with its default type parameter.
|
|
122
|
+
* This is primarly exported for documentation purposes; users should reference `SVGIconProps<T>` instead.
|
|
123
|
+
*/
|
|
124
|
+
export interface DefaultSVGIconProps extends React.RefAttributes<Element>, SVGIconAttributes<Element>, SVGIconOwnProps {
|
|
125
|
+
// empty interface for documentation purposes (documentalist handles this better than the SVGIconProps<T> type alias)
|
|
126
|
+
}
|