@itwin/core-react 3.2.0-dev.12 → 3.2.0-dev.15
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/core-react/UiCore.d.ts.map +1 -1
- package/lib/cjs/core-react/UiCore.js +3 -0
- package/lib/cjs/core-react/UiCore.js.map +1 -1
- package/lib/cjs/core-react/badge/Badge.d.ts.map +1 -1
- package/lib/cjs/core-react/badge/Badge.js +4 -2
- package/lib/cjs/core-react/badge/Badge.js.map +1 -1
- package/lib/cjs/core-react/badge/BetaBadge.js +2 -2
- package/lib/cjs/core-react/badge/BetaBadge.js.map +1 -1
- package/lib/cjs/core-react/badge/NewBadge.js +2 -2
- package/lib/cjs/core-react/badge/NewBadge.js.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.d.ts.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js +12 -0
- package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
- package/lib/cjs/core-react/icons/SvgSprite.d.ts +3 -2
- package/lib/cjs/core-react/icons/SvgSprite.d.ts.map +1 -1
- package/lib/cjs/core-react/icons/SvgSprite.js +3 -1
- package/lib/cjs/core-react/icons/SvgSprite.js.map +1 -1
- package/lib/cjs/core-react/utils/IconHelper.d.ts.map +1 -1
- package/lib/cjs/core-react/utils/IconHelper.js.map +1 -1
- package/lib/cjs/core-react/utils/IconWebComponent.d.ts +11 -0
- package/lib/cjs/core-react/utils/IconWebComponent.d.ts.map +1 -0
- package/lib/cjs/core-react/utils/IconWebComponent.js +49 -0
- package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -0
- package/lib/esm/core-react/UiCore.d.ts.map +1 -1
- package/lib/esm/core-react/UiCore.js +3 -0
- package/lib/esm/core-react/UiCore.js.map +1 -1
- package/lib/esm/core-react/badge/Badge.d.ts.map +1 -1
- package/lib/esm/core-react/badge/Badge.js +4 -2
- package/lib/esm/core-react/badge/Badge.js.map +1 -1
- package/lib/esm/core-react/badge/BetaBadge.js +1 -1
- package/lib/esm/core-react/badge/BetaBadge.js.map +1 -1
- package/lib/esm/core-react/badge/NewBadge.js +1 -1
- package/lib/esm/core-react/badge/NewBadge.js.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.d.ts.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.js +12 -0
- package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
- package/lib/esm/core-react/icons/SvgSprite.d.ts +3 -2
- package/lib/esm/core-react/icons/SvgSprite.d.ts.map +1 -1
- package/lib/esm/core-react/icons/SvgSprite.js +3 -1
- package/lib/esm/core-react/icons/SvgSprite.js.map +1 -1
- package/lib/esm/core-react/utils/IconHelper.d.ts.map +1 -1
- package/lib/esm/core-react/utils/IconHelper.js.map +1 -1
- package/lib/esm/core-react/utils/IconWebComponent.d.ts +11 -0
- package/lib/esm/core-react/utils/IconWebComponent.d.ts.map +1 -0
- package/lib/esm/core-react/utils/IconWebComponent.js +45 -0
- package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -0
- package/package.json +9 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiCore.d.ts","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"UiCore.d.ts","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,oDAAoD;WACtC,SAAS;IAQvB,gDAAgD;IAChD,WAAkB,WAAW,IAAI,OAAO,CAAgC;IAExE;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAM7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQvD,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
|
|
@@ -15,6 +15,7 @@ require("./layout-variables.scss");
|
|
|
15
15
|
require("./classes.scss");
|
|
16
16
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
17
17
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
18
|
+
const IconWebComponent_1 = require("./utils/IconWebComponent");
|
|
18
19
|
// cSpell:ignore colorthemes colorvariables
|
|
19
20
|
/**
|
|
20
21
|
* Manages the Localization service for the core-react package.
|
|
@@ -32,6 +33,8 @@ class UiCore {
|
|
|
32
33
|
}
|
|
33
34
|
UiCore._localization = localization;
|
|
34
35
|
await UiCore._localization.registerNamespace(UiCore.localizationNamespace);
|
|
36
|
+
if (window.customElements.get("svg-loader") === undefined)
|
|
37
|
+
window.customElements.define("svg-loader", IconWebComponent_1.IconWebComponent);
|
|
35
38
|
UiCore._initialized = true;
|
|
36
39
|
}
|
|
37
40
|
/** Unregisters the UiCore localization namespace */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4EAA4E;AAC5E,8BAA4B;AAC5B,iCAA+B;AAC/B,mCAAiC;AACjC,0BAAwB;AAExB,sDAA6C;AAE7C,0DAA8D;
|
|
1
|
+
{"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4EAA4E;AAC5E,8BAA4B;AAC5B,iCAA+B;AAC/B,mCAAiC;AACjC,0BAAwB;AAExB,sDAA6C;AAE7C,0DAA8D;AAC9D,+DAA4D;AAC5D,2CAA2C;AAE3C;;;GAGG;AACH,MAAa,MAAM;IAIjB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,MAAM,CAAC,YAAY,EAAE;YACvB,qBAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,kCAAkC,CAAC,CAAC;YAClF,OAAO;SACR;QAED,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC;QACpC,MAAM,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,SAAS;YACvD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,mCAAgB,CAAC,CAAC;QAE/D,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,oDAAoD;IAC7C,MAAM,CAAC,SAAS;QACrB,IAAI,MAAM,CAAC,aAAa;YACtB,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;QAEjC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,gDAAgD;IACzC,MAAM,KAAK,WAAW,KAAc,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAExE;;OAEG;IACI,MAAM,KAAK,YAAY;QAC5B,uBAAuB;QACvB,IAAI,CAAC,MAAM,CAAC,aAAa;YACvB,MAAM,IAAI,wBAAO,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,4FAA4F,CAAC,CAAC;QAC/I,uBAAuB;QACvB,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;YACzB,qBAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,4FAA4F,CAAC,CAAC;YAC3I,OAAO,EAAE,CAAC;SACX;QACD,OAAO,MAAM,CAAC,aAAa,CAAC,+BAA+B,CAAC,MAAM,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IACjG,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,IAAA,6BAAY,EAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAvEH,wBAyEC;AAxEgB,mBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\n/** Import color variables, layout variables and Sass classes barrel file */\r\nimport \"./colorthemes.scss\";\r\nimport \"./colorvariables.scss\";\r\nimport \"./layout-variables.scss\";\r\nimport \"./classes.scss\";\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport type { Localization } from \"@itwin/core-common\";\r\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\r\nimport { IconWebComponent } from \"./utils/IconWebComponent\";\r\n// cSpell:ignore colorthemes colorvariables\r\n\r\n/**\r\n * Manages the Localization service for the core-react package.\r\n * @public\r\n */\r\nexport class UiCore {\r\n private static _initialized = false;\r\n private static _localization?: Localization;\r\n\r\n /**\r\n * Registers the Localization service namespace for UiCore.\r\n * @param localization The internationalization service created by the host application.\r\n */\r\n public static async initialize(localization: Localization): Promise<void> {\r\n if (UiCore._initialized) {\r\n Logger.logInfo(UiCore.loggerCategory(UiCore), `UiCore.initialize already called`);\r\n return;\r\n }\r\n\r\n UiCore._localization = localization;\r\n await UiCore._localization.registerNamespace(UiCore.localizationNamespace);\r\n if (window.customElements.get(\"svg-loader\") === undefined)\r\n window.customElements.define(\"svg-loader\", IconWebComponent);\r\n\r\n UiCore._initialized = true;\r\n }\r\n\r\n /** Unregisters the UiCore localization namespace */\r\n public static terminate() {\r\n if (UiCore._localization)\r\n UiCore._localization.unregisterNamespace(UiCore.localizationNamespace);\r\n UiCore._localization = undefined;\r\n\r\n UiCore._initialized = false;\r\n }\r\n\r\n /** Determines if UiCore has been initialized */\r\n public static get initialized(): boolean { return UiCore._initialized; }\r\n\r\n /** The internationalization service created by the host application.\r\n * @internal\r\n */\r\n public static get localization(): Localization {\r\n // istanbul ignore else\r\n if (!UiCore._localization)\r\n throw new UiError(UiCore.loggerCategory(this), \"localization: UiCore.initialize has not been called. Unable to return Localization object.\");\r\n // istanbul ignore next\r\n return UiCore._localization;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return \"UiCore\";\r\n }\r\n\r\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiCore\" namespace. Do NOT include the namespace in the key.\r\n * @internal\r\n */\r\n public static translate(key: string | string[]): string {\r\n if (!UiCore._localization) {\r\n Logger.logError(UiCore.loggerCategory(this), `translate: UiCore must be initialize with a localization provider. Returning blank string.`);\r\n return \"\";\r\n }\r\n return UiCore._localization.getLocalizedStringWithNamespace(UiCore.localizationNamespace, key);\r\n }\r\n\r\n /** @internal */\r\n public static get packageName(): string {\r\n return \"core-react\";\r\n }\r\n\r\n /** @internal */\r\n public static loggerCategory(obj: any): string {\r\n const className = getClassName(obj);\r\n const category = UiCore.packageName + (className ? `.${className}` : \"\");\r\n return category;\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC7C,GAAG,EAAE,GAAG,CAAC;CACV;AAED;;GAEG;AACH,qBAAa,KAAM,SAAQ,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC;IACxC,MAAM,IAAI,GAAG,CAAC,OAAO;CAQtC"}
|
|
@@ -11,14 +11,16 @@ exports.Badge = void 0;
|
|
|
11
11
|
require("./Badge.scss");
|
|
12
12
|
const classnames_1 = require("classnames");
|
|
13
13
|
const React = require("react");
|
|
14
|
-
const
|
|
14
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
15
|
+
const IconComponent_1 = require("../icons/IconComponent");
|
|
15
16
|
/** Beta Badge React component
|
|
16
17
|
* @internal
|
|
17
18
|
*/
|
|
18
19
|
class Badge extends React.PureComponent {
|
|
19
20
|
render() {
|
|
21
|
+
const iconSpec = appui_abstract_1.IconSpecUtilities.createWebComponentIconSpec(this.props.svg);
|
|
20
22
|
return (React.createElement("div", { className: (0, classnames_1.default)("core-badge", this.props.className), style: this.props.style },
|
|
21
|
-
React.createElement(
|
|
23
|
+
React.createElement(IconComponent_1.Icon, { iconSpec: iconSpec })));
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
exports.Badge = Badge;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wBAAsB;AACtB,2CAAoC;AACpC,+BAA+B;
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wBAAsB;AACtB,2CAAoC;AACpC,+BAA+B;AAE/B,0DAA0D;AAC1D,0DAA8C;AAS9C;;GAEG;AACH,MAAa,KAAM,SAAQ,KAAK,CAAC,aAAyB;IACxC,MAAM;QACpB,MAAM,QAAQ,GAAG,kCAAiB,CAAC,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9E,OAAO,CACL,6BAAK,SAAS,EAAE,IAAA,oBAAU,EAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YACrF,oBAAC,oBAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACxB,CACP,CAAC;IACJ,CAAC;CACF;AATD,sBASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport \"./Badge.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { IconSpecUtilities } from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"../icons/IconComponent\";\r\n\r\n/** Properties for the [[Badge]] React component\r\n * @internal\r\n */\r\nexport interface BadgeProps extends CommonProps {\r\n svg: any;\r\n}\r\n\r\n/** Beta Badge React component\r\n * @internal\r\n */\r\nexport class Badge extends React.PureComponent<BadgeProps> {\r\n public override render(): JSX.Element {\r\n const iconSpec = IconSpecUtilities.createWebComponentIconSpec(this.props.svg);\r\n return (\r\n <div className={classnames(\"core-badge\", this.props.className)} style={this.props.style}>\r\n <Icon iconSpec={iconSpec} />\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -12,13 +12,13 @@ require("./BetaBadge.scss");
|
|
|
12
12
|
const classnames_1 = require("classnames");
|
|
13
13
|
const React = require("react");
|
|
14
14
|
const Badge_1 = require("./Badge");
|
|
15
|
-
const
|
|
15
|
+
const technical_preview_badge_svg_1 = require("./technical-preview-badge.svg");
|
|
16
16
|
/** Beta Badge React component
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
function BetaBadge(props) {
|
|
20
20
|
const className = (0, classnames_1.default)("core-badge-betaBadge", props.className);
|
|
21
|
-
return React.createElement(Badge_1.Badge, { ...props, svg:
|
|
21
|
+
return React.createElement(Badge_1.Badge, { ...props, svg: technical_preview_badge_svg_1.default, className: className });
|
|
22
22
|
}
|
|
23
23
|
exports.BetaBadge = BetaBadge;
|
|
24
24
|
//# sourceMappingURL=BetaBadge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BetaBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/BetaBadge.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4BAA0B;AAC1B,2CAAoC;AACpC,+BAA+B;AAE/B,mCAAgC;AAChC
|
|
1
|
+
{"version":3,"file":"BetaBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/BetaBadge.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4BAA0B;AAC1B,2CAAoC;AACpC,+BAA+B;AAE/B,mCAAgC;AAChC,+EAA0D;AAE1D;;GAEG;AACH,SAAgB,SAAS,CAAC,KAAkB;IAC1C,MAAM,SAAS,GAAG,IAAA,oBAAU,EAAC,sBAAsB,EACjD,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,oBAAC,aAAK,OACP,KAAK,EACT,GAAG,EAAE,qCAAa,EAClB,SAAS,EAAE,SAAS,GACpB,CAAC;AACL,CAAC;AATD,8BASC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport \"./BetaBadge.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { Badge } from \"./Badge\";\r\nimport betaBadgeIcon from \"./technical-preview-badge.svg\";\r\n\r\n/** Beta Badge React component\r\n * @internal\r\n */\r\nexport function BetaBadge(props: CommonProps) {\r\n const className = classnames(\"core-badge-betaBadge\",\r\n props.className,\r\n );\r\n return <Badge\r\n {...props}\r\n svg={betaBadgeIcon}\r\n className={className}\r\n />;\r\n}\r\n"]}
|
|
@@ -12,13 +12,13 @@ require("./NewBadge.scss");
|
|
|
12
12
|
const classnames_1 = require("classnames");
|
|
13
13
|
const React = require("react");
|
|
14
14
|
const Badge_1 = require("./Badge");
|
|
15
|
-
const
|
|
15
|
+
const new_feature_badge_svg_1 = require("./new-feature-badge.svg");
|
|
16
16
|
/** New Badge React component
|
|
17
17
|
* @internal
|
|
18
18
|
*/
|
|
19
19
|
function NewBadge(props) {
|
|
20
20
|
const { className, ...badgeProps } = props;
|
|
21
|
-
return React.createElement(Badge_1.Badge, { ...badgeProps, className: (0, classnames_1.default)("core-new-badge", className), svg:
|
|
21
|
+
return React.createElement(Badge_1.Badge, { ...badgeProps, className: (0, classnames_1.default)("core-new-badge", className), svg: new_feature_badge_svg_1.default });
|
|
22
22
|
}
|
|
23
23
|
exports.NewBadge = NewBadge;
|
|
24
24
|
//# sourceMappingURL=NewBadge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/NewBadge.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2BAAyB;AACzB,2CAAoC;AACpC,+BAA+B;AAE/B,mCAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"NewBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/NewBadge.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,2BAAyB;AACzB,2CAAoC;AACpC,+BAA+B;AAE/B,mCAAgC;AAChC,mEAAmD;AAEnD;;GAEG;AACH,SAAgB,QAAQ,CAAC,KAAkB;IACzC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,oBAAC,aAAK,OAAK,UAAU,EAAE,SAAS,EAAE,IAAA,oBAAU,EAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,+BAAY,GAAI,CAAC;AAC1G,CAAC;AAHD,4BAGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport \"./NewBadge.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { Badge } from \"./Badge\";\r\nimport newBadgeIcon from \"./new-feature-badge.svg\";\r\n\r\n/** New Badge React component\r\n * @internal\r\n */\r\nexport function NewBadge(props: CommonProps) {\r\n const { className, ...badgeProps } = props;\r\n return <Badge {...badgeProps} className={classnames(\"core-new-badge\", className)} svg={newBadgeIcon} />;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IconComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAqB,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;GAEG;AACH,oBAAY,QAAQ,GAAG,MAAM,GAAG,sBAAsB,GAAG,KAAK,CAAC,SAAS,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,sBAsCpC"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/* eslint-disable deprecation/deprecation */
|
|
6
7
|
/** @packageDocumentation
|
|
7
8
|
* @module Icon
|
|
8
9
|
*/
|
|
@@ -13,6 +14,7 @@ const React = require("react");
|
|
|
13
14
|
const classnames_1 = require("classnames");
|
|
14
15
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
15
16
|
const SvgSprite_1 = require("./SvgSprite");
|
|
17
|
+
const dompurify_1 = require("dompurify");
|
|
16
18
|
/** Icon Functional component displays an icon based on an [[IconSpec]].
|
|
17
19
|
* @public
|
|
18
20
|
*/
|
|
@@ -27,6 +29,16 @@ function Icon(props) {
|
|
|
27
29
|
if (svgSource !== undefined)
|
|
28
30
|
return (React.createElement("i", { className: (0, classnames_1.default)("icon", "core-svg-icon", props.className), style: props.style },
|
|
29
31
|
React.createElement(SvgSprite_1.SvgSprite, { src: svgSource })));
|
|
32
|
+
const webComponentString = appui_abstract_1.IconSpecUtilities.getWebComponentSource(iconString);
|
|
33
|
+
if (webComponentString) {
|
|
34
|
+
const svgLoader = `<svg-loader src=${webComponentString} id="svg-id"></svg-loader>`;
|
|
35
|
+
const svgDiv = `<div>${svgLoader}</div>`;
|
|
36
|
+
const sanitizedIconString = (0, dompurify_1.sanitize)(svgDiv, { ALLOWED_TAGS: ["svg-loader"] });
|
|
37
|
+
// we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
|
|
39
|
+
const webComponentNode = React.createElement("div", { dangerouslySetInnerHTML: { __html: sanitizedIconString } });
|
|
40
|
+
return (React.createElement("i", { className: (0, classnames_1.default)("icon", "core-svg-icon", props.className) }, webComponentNode));
|
|
41
|
+
}
|
|
30
42
|
return (React.createElement("i", { className: (0, classnames_1.default)("icon", iconString, props.className), style: props.style }));
|
|
31
43
|
}
|
|
32
44
|
return (React.createElement("i", { className: (0, classnames_1.default)("icon", "core-svg-icon", props.className), style: props.style }, props.iconSpec));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,gCAA8B;AAC9B,+BAA+B;AAC/B,2CAAoC;AACpC,0DAAkF;AAClF,2CAAwC;
|
|
1
|
+
{"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;;;AAEH,gCAA8B;AAC9B,+BAA+B;AAC/B,2CAAoC;AACpC,0DAAkF;AAClF,2CAAwC;AAExC,yCAAkD;AAiBlD;;GAEG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,IAAI,CAAC,KAAK,CAAC,QAAQ;QACjB,OAAO,IAAI,CAAC;IAEd,MAAM,UAAU,GAAG,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,YAAY,uCAAsB,CAAC,CAAC,CAAC;QAC3G,uCAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9D,IAAI,UAAU,EAAE;QACd,MAAM,SAAS,GAAG,kCAAiB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7D,kIAAkI;QAClI,IAAI,SAAS,KAAK,SAAS;YACzB,OAAO,CACL,2BAAG,SAAS,EAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK;gBACpF,oBAAC,qBAAS,IAAC,GAAG,EAAE,SAAS,GAAI,CAC3B,CACL,CAAC;QACJ,MAAM,kBAAkB,GAAG,kCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,kBAAkB,EAAC;YACrB,MAAM,SAAS,GAAG,mBAAmB,kBAAkB,4BAA4B,CAAC;YACpF,MAAM,MAAM,GAAG,QAAQ,SAAS,QAAQ,CAAC;YACzC,MAAM,mBAAmB,GAAG,IAAA,oBAAS,EAAC,MAAM,EAAE,EAAC,YAAY,EAAE,CAAC,YAAY,CAAC,EAAC,CAAC,CAAC;YAC9E,iFAAiF;YACjF,+FAA+F;YAC/F,MAAM,gBAAgB,GAAG,6BAAK,uBAAuB,EAAE,EAAC,MAAM,EAAC,mBAAmB,EAAC,GAAQ,CAAC;YAC5F,OAAO,CACL,2BAAG,SAAS,EAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,IAC/D,gBAAgB,CACf,CACL,CAAC;SACH;QACD,OAAO,CAAC,2BAAG,SAAS,EAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAAC,CAAC;KAChG;IAED,OAAO,CACL,2BAAG,SAAS,EAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IACnF,KAAK,CAAC,QAAQ,CACb,CACL,CAAC;AACJ,CAAC;AAtCD,oBAsCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/* eslint-disable deprecation/deprecation */\r\n/** @packageDocumentation\r\n * @module Icon\r\n */\r\n\r\nimport \"./IconComponent.scss\";\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ConditionalStringValue, IconSpecUtilities } from \"@itwin/appui-abstract\";\r\nimport { SvgSprite } from \"./SvgSprite\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { sanitize as sanitizer } from \"dompurify\";\r\n\r\n/** Prototype for an IconSpec which can be a string, ReactNode or ConditionalStringValue.\r\n * @public\r\n */\r\nexport type IconSpec = string | ConditionalStringValue | React.ReactNode;\r\n\r\n/** Properties for the [[Icon]] React component\r\n * @public\r\n */\r\nexport interface IconProps extends CommonProps {\r\n /** CSS class name or SvgSprite/SvgPath for icon. This is optional because it is improperly\r\n * used to extend other interfaces and changing it would break existing API.\r\n */\r\n iconSpec?: IconSpec;\r\n}\r\n\r\n/** Icon Functional component displays an icon based on an [[IconSpec]].\r\n * @public\r\n */\r\nexport function Icon(props: IconProps) {\r\n if (!props.iconSpec)\r\n return null;\r\n\r\n const iconString = (typeof props.iconSpec === \"string\" || props.iconSpec instanceof ConditionalStringValue) ?\r\n ConditionalStringValue.getValue(props.iconSpec) : undefined;\r\n\r\n if (iconString) {\r\n const svgSource = IconSpecUtilities.getSvgSource(iconString);\r\n // if string begins with \"svg:\" then we assume it was imported (into extension source file) using webpack loader svg-sprite-loader\r\n if (svgSource !== undefined)\r\n return (\r\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)} style={props.style}>\r\n <SvgSprite src={svgSource} />\r\n </i>\r\n );\r\n const webComponentString = IconSpecUtilities.getWebComponentSource(iconString);\r\n if (webComponentString){\r\n const svgLoader = `<svg-loader src=${webComponentString} id=\"svg-id\"></svg-loader>`;\r\n const svgDiv = `<div>${svgLoader}</div>`;\r\n const sanitizedIconString = sanitizer(svgDiv, {ALLOWED_TAGS: [\"svg-loader\"]});\r\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger\r\n const webComponentNode = <div dangerouslySetInnerHTML={{__html:sanitizedIconString}}></div>;\r\n return (\r\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)} >\r\n {webComponentNode}\r\n </i>\r\n );\r\n }\r\n return (<i className={classnames(\"icon\", iconString, props.className)} style={props.style} />);\r\n }\r\n\r\n return (\r\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)} style={props.style}>\r\n {props.iconSpec}\r\n </i>\r\n );\r\n}\r\n"]}
|
|
@@ -5,14 +5,15 @@ import "./SvgSprite.scss";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { CommonProps } from "../utils/Props";
|
|
7
7
|
/** Properties of [[SvgSprite]] component.
|
|
8
|
-
* @public
|
|
8
|
+
* @public @deprecated
|
|
9
9
|
*/
|
|
10
10
|
export interface SvgSpriteProps extends CommonProps {
|
|
11
11
|
/** Source for the Svg */
|
|
12
12
|
src: string;
|
|
13
13
|
}
|
|
14
14
|
/** Svg element wrapper.
|
|
15
|
-
*
|
|
15
|
+
* This component is deprecate -- use IconComponent
|
|
16
|
+
* @public @deprecated
|
|
16
17
|
*/
|
|
17
18
|
export declare class SvgSprite extends React.PureComponent<SvgSpriteProps> {
|
|
18
19
|
render(): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SvgSprite.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SvgSprite.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC;IAChD,MAAM;CAYvB"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
5
|
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/* eslint-disable deprecation/deprecation */
|
|
6
7
|
/** @packageDocumentation
|
|
7
8
|
* @module Icon
|
|
8
9
|
*/
|
|
@@ -12,7 +13,8 @@ require("./SvgSprite.scss");
|
|
|
12
13
|
const classnames_1 = require("classnames");
|
|
13
14
|
const React = require("react");
|
|
14
15
|
/** Svg element wrapper.
|
|
15
|
-
*
|
|
16
|
+
* This component is deprecate -- use IconComponent
|
|
17
|
+
* @public @deprecated
|
|
16
18
|
*/
|
|
17
19
|
class SvgSprite extends React.PureComponent {
|
|
18
20
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SvgSprite.js","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,4BAA0B;AAC1B,2CAAoC;AACpC,+BAA+B;AAW/B
|
|
1
|
+
{"version":3,"file":"SvgSprite.js","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;;;AAEH,4BAA0B;AAC1B,2CAAoC;AACpC,+BAA+B;AAW/B;;;GAGG;AACH,MAAa,SAAU,SAAQ,KAAK,CAAC,aAA6B;IAChD,MAAM;QACpB,MAAM,SAAS,GAAG,IAAA,oBAAU,EAC1B,sBAAsB,EACtB,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,CAAC;QAEF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM;YAC5E,6BAAK,UAAU,EAAC,8BAA8B,EAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAI,CACxE,CACP,CAAC;IACJ,CAAC;CACF;AAbD,8BAaC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/* eslint-disable deprecation/deprecation */\r\n/** @packageDocumentation\r\n * @module Icon\r\n */\r\n\r\nimport \"./SvgSprite.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\n\r\n/** Properties of [[SvgSprite]] component.\r\n * @public @deprecated\r\n */\r\nexport interface SvgSpriteProps extends CommonProps {\r\n /** Source for the Svg */\r\n src: string;\r\n}\r\n\r\n/** Svg element wrapper.\r\n * This component is deprecate -- use IconComponent\r\n * @public @deprecated\r\n */\r\nexport class SvgSprite extends React.PureComponent<SvgSpriteProps> {\r\n public override render() {\r\n const className = classnames(\r\n \"core-icons-svgSprite\",\r\n this.props.className,\r\n );\r\n\r\n return (\r\n <svg className={className} style={this.props.style} width=\"100%\" height=\"100%\">\r\n <use xmlnsXlink=\"http://www.w3.org/1999/xlink\" xlinkHref={this.props.src} />\r\n </svg>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconHelper.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D;;GAEG;AACH,qBAAa,UAAU;IACrB,WAAkB,YAAY,IAAI,MAAM,CAEvC;
|
|
1
|
+
{"version":3,"file":"IconHelper.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D;;GAEG;AACH,qBAAa,UAAU;IACrB,WAAkB,YAAY,IAAI,MAAM,CAEvC;IACD;;;OAGG;WACW,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,GAAG,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS;IA2BzI;;;;OAIG;WACW,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,GAAG,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,sBAAsB;CAYzJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconHelper.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,0DAA+D;AAC/D,0DAA8C;AAE9C;;GAEG;AACH,MAAa,UAAU;IACd,MAAM,KAAK,YAAY;QAC5B,OAAO,yBAAyB,CAAC;IACnC,CAAC;
|
|
1
|
+
{"version":3,"file":"IconHelper.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,0DAA+D;AAC/D,0DAA8C;AAE9C;;GAEG;AACH,MAAa,UAAU;IACd,MAAM,KAAK,YAAY;QAC5B,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAuD,EAAE,YAA+B;QACrH,uBAAuB;QACvB,IAAI,CAAC,IAAI;YACP,OAAO,IAAI,CAAC;QAEd,uBAAuB;QACvB,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;YAC5B,OAAO,oBAAC,oBAAI,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;QAElC,qBAAqB;QACrB,IAAI,CAAC,CAAC,IAAI,YAAY,uCAAsB,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ;YACvE,OAAO,IAAI,CAAC;QAEd,MAAM,UAAU,GAAG,uCAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU;YACb,OAAO,IAAI,CAAC;QAEd,uBAAuB;QACvB,IAAI,UAAU,KAAK,UAAU,CAAC,YAAY,EAAE;YAC1C,uBAAuB;YACvB,IAAI,YAAY;gBACd,OAAO,oBAAC,oBAAI,IAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAoB,GAAI,CAAC;YAC1F,OAAO,IAAI,CAAC;SACb;QACD,OAAO,oBAAC,oBAAI,IAAC,QAAQ,EAAE,UAAU,GAAI,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,QAA2D,EAAE,YAA+B;QACpH,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEnF,IAAI,YAAY,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,CAAC,YAAY,EAAE;YAChF,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;SACrD;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,YAAY,uCAAsB;YACpE,OAAO,IAAI,CAAC;QAEd,OAAO,EAAE,CAAC;IACZ,CAAC;CACF;AApDD,gCAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { ConditionalStringValue } from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"../icons/IconComponent\";\r\n\r\n/** Icon Helper Class used to store the data needed to generate an <Icon> for use in any control that shows an icon.\r\n * @public\r\n */\r\nexport class IconHelper {\r\n public static get reactIconKey(): string {\r\n return \"#-react-iconspec-node-#\";\r\n }\r\n /** Returns an <Icon> ReactNode from the many ways an icon can be specified.\r\n * @param icon abstract icon specification.\r\n * @param internalData a map that may hold a React.ReactNode stored in an abstract item definition.\r\n */\r\n public static getIconReactNode(icon: string | ConditionalStringValue | React.ReactNode, internalData?: Map<string, any>): React.ReactNode {\r\n // istanbul ignore else\r\n if (!icon)\r\n return null;\r\n\r\n // istanbul ignore else\r\n if (React.isValidElement(icon))\r\n return <Icon iconSpec={icon} />;\r\n\r\n // istanbul ignore if\r\n if (!(icon instanceof ConditionalStringValue) && typeof icon !== \"string\")\r\n return null;\r\n\r\n const iconString = ConditionalStringValue.getValue(icon);\r\n if (!iconString)\r\n return null;\r\n\r\n // istanbul ignore else\r\n if (iconString === IconHelper.reactIconKey) {\r\n // istanbul ignore else\r\n if (internalData)\r\n return <Icon iconSpec={internalData.get(IconHelper.reactIconKey) as React.ReactNode} />;\r\n return null;\r\n }\r\n return <Icon iconSpec={iconString} />;\r\n }\r\n\r\n /** Returns an icon definition that can be stored in an abstract item definition. If the iconSpec specifies a ReactNode\r\n * then the react data is stored in the internalData map and the key to the react data is returned.\r\n * @param iconSpec any supported variations of how an icon can be defined in an abstract item or IconProps.\r\n * @param internalData a map supplied by the caller to store away react element if React.ReactNode\r\n */\r\n public static getIconData(iconSpec: string | ConditionalStringValue | React.ReactNode, internalData?: Map<string, any>): string | ConditionalStringValue {\r\n const icon = (React.isValidElement(iconSpec)) ? IconHelper.reactIconKey : iconSpec;\r\n\r\n if (internalData && typeof icon === \"string\" && icon === IconHelper.reactIconKey) {\r\n internalData.set(IconHelper.reactIconKey, iconSpec);\r\n }\r\n\r\n if (typeof icon === \"string\" || icon instanceof ConditionalStringValue)\r\n return icon;\r\n\r\n return \"\";\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* IconWebComponent loads icon from an svg path
|
|
6
|
+
*/
|
|
7
|
+
export declare class IconWebComponent extends HTMLElement {
|
|
8
|
+
private connectedCallback;
|
|
9
|
+
private loadSvg;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IconWebComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconWebComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":"AAMA;;GAEG;AAMH;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;YACjC,iBAAiB;YAKjB,OAAO;CAqBtB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
// istanbul ignore file
|
|
7
|
+
// IconWebComponent requires in-browser testing
|
|
8
|
+
/** @packageDocumentation
|
|
9
|
+
* @module Utilities
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.IconWebComponent = void 0;
|
|
13
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
14
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
15
|
+
const UiCore_1 = require("../UiCore");
|
|
16
|
+
/**
|
|
17
|
+
* IconWebComponent loads icon from an svg path
|
|
18
|
+
*/
|
|
19
|
+
class IconWebComponent extends HTMLElement {
|
|
20
|
+
async connectedCallback() {
|
|
21
|
+
await this.loadSvg();
|
|
22
|
+
this.dispatchEvent(new CustomEvent("load"));
|
|
23
|
+
}
|
|
24
|
+
async loadSvg() {
|
|
25
|
+
await fetch(this.getAttribute("src") || "")
|
|
26
|
+
.catch((_error) => {
|
|
27
|
+
core_bentley_1.Logger.logError(UiCore_1.UiCore.loggerCategory(this), "Unable to load icon.");
|
|
28
|
+
})
|
|
29
|
+
.then(async (response) => {
|
|
30
|
+
if (response && response.ok) {
|
|
31
|
+
return response.text();
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw new appui_abstract_1.UiError(UiCore_1.UiCore.loggerCategory(this), "Unable to load icon.");
|
|
35
|
+
}
|
|
36
|
+
})
|
|
37
|
+
.then((str) => {
|
|
38
|
+
if (str !== undefined) {
|
|
39
|
+
return (new window.DOMParser()).parseFromString(str, "text/xml");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw new appui_abstract_1.UiError(UiCore_1.UiCore.loggerCategory(this), "Unable to load icon.");
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.then((data) => this.append(data.documentElement));
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.IconWebComponent = IconWebComponent;
|
|
49
|
+
//# sourceMappingURL=IconWebComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconWebComponent.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,uBAAuB;AACvB,+CAA+C;AAC/C;;GAEG;;;AAEH,0DAAgD;AAChD,sDAA6C;AAC7C,sCAAmC;AAEnC;;GAEG;AACH,MAAa,gBAAiB,SAAQ,WAAW;IACvC,KAAK,CAAC,iBAAiB;QAC7B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aACxC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;YAChB,qBAAM,CAAC,QAAQ,CAAC,eAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;QACvE,CAAC,CAAC;aACD,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YACvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,EAAE,EAAE;gBAC3B,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;aACxB;iBAAM;gBACL,MAAM,IAAI,wBAAO,CAAE,eAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;aACzE;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,GAAG,KAAK,SAAS,EAAE;gBACrB,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;aAClE;iBAAM;gBACL,MAAM,IAAI,wBAAO,CAAE,eAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;aACzE;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IACvD,CAAC;CACF;AA3BD,4CA2BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n// istanbul ignore file\r\n// IconWebComponent requires in-browser testing\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport { UiError } from \"@itwin/appui-abstract\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { UiCore } from \"../UiCore\";\r\n\r\n/**\r\n * IconWebComponent loads icon from an svg path\r\n */\r\nexport class IconWebComponent extends HTMLElement {\r\n private async connectedCallback() {\r\n await this.loadSvg();\r\n this.dispatchEvent(new CustomEvent(\"load\"));\r\n }\r\n\r\n private async loadSvg() {\r\n await fetch(this.getAttribute(\"src\") || \"\")\r\n .catch((_error) => {\r\n Logger.logError(UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n })\r\n .then(async (response) => {\r\n if (response && response.ok) {\r\n return response.text();\r\n } else {\r\n throw new UiError (UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n })\r\n .then((str) => {\r\n if (str !== undefined) {\r\n return (new window.DOMParser()).parseFromString(str, \"text/xml\");\r\n } else {\r\n throw new UiError (UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n })\r\n .then((data) => this.append(data.documentElement));\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiCore.d.ts","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"UiCore.d.ts","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKvD;;;GAGG;AACH,qBAAa,MAAM;IACjB,OAAO,CAAC,MAAM,CAAC,YAAY,CAAS;IACpC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAe;IAE5C;;;OAGG;WACiB,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAczE,oDAAoD;WACtC,SAAS;IAQvB,gDAAgD;IAChD,WAAkB,WAAW,IAAI,OAAO,CAAgC;IAExE;;OAEG;IACH,WAAkB,YAAY,IAAI,YAAY,CAM7C;IAED,kDAAkD;IAClD,WAAkB,qBAAqB,IAAI,MAAM,CAEhD;IAED;;OAEG;WACW,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM;IAQvD,gBAAgB;IAChB,WAAkB,WAAW,IAAI,MAAM,CAEtC;IAED,gBAAgB;WACF,cAAc,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM;CAM/C"}
|
|
@@ -12,6 +12,7 @@ import "./layout-variables.scss";
|
|
|
12
12
|
import "./classes.scss";
|
|
13
13
|
import { Logger } from "@itwin/core-bentley";
|
|
14
14
|
import { getClassName, UiError } from "@itwin/appui-abstract";
|
|
15
|
+
import { IconWebComponent } from "./utils/IconWebComponent";
|
|
15
16
|
// cSpell:ignore colorthemes colorvariables
|
|
16
17
|
/**
|
|
17
18
|
* Manages the Localization service for the core-react package.
|
|
@@ -29,6 +30,8 @@ export class UiCore {
|
|
|
29
30
|
}
|
|
30
31
|
UiCore._localization = localization;
|
|
31
32
|
await UiCore._localization.registerNamespace(UiCore.localizationNamespace);
|
|
33
|
+
if (window.customElements.get("svg-loader") === undefined)
|
|
34
|
+
window.customElements.define("svg-loader", IconWebComponent);
|
|
32
35
|
UiCore._initialized = true;
|
|
33
36
|
}
|
|
34
37
|
/** Unregisters the UiCore localization namespace */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"UiCore.js","sourceRoot":"","sources":["../../../src/core-react/UiCore.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,4EAA4E;AAC5E,OAAO,oBAAoB,CAAC;AAC5B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,yBAAyB,CAAC;AACjC,OAAO,gBAAgB,CAAC;AAExB,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAE7C,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,2CAA2C;AAE3C;;;GAGG;AACH,MAAM,OAAO,MAAM;IAIjB;;;OAGG;IACI,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAA0B;QACvD,IAAI,MAAM,CAAC,YAAY,EAAE;YACvB,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,EAAE,kCAAkC,CAAC,CAAC;YAClF,OAAO;SACR;QAED,MAAM,CAAC,aAAa,GAAG,YAAY,CAAC;QACpC,MAAM,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QAC3E,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,KAAK,SAAS;YACvD,MAAM,CAAC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;QAE/D,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC;IAC7B,CAAC;IAED,oDAAoD;IAC7C,MAAM,CAAC,SAAS;QACrB,IAAI,MAAM,CAAC,aAAa;YACtB,MAAM,CAAC,aAAa,CAAC,mBAAmB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;QACzE,MAAM,CAAC,aAAa,GAAG,SAAS,CAAC;QAEjC,MAAM,CAAC,YAAY,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED,gDAAgD;IACzC,MAAM,KAAK,WAAW,KAAc,OAAO,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAExE;;OAEG;IACI,MAAM,KAAK,YAAY;QAC5B,uBAAuB;QACvB,IAAI,CAAC,MAAM,CAAC,aAAa;YACvB,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,4FAA4F,CAAC,CAAC;QAC/I,uBAAuB;QACvB,OAAO,MAAM,CAAC,aAAa,CAAC;IAC9B,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE;YACzB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,4FAA4F,CAAC,CAAC;YAC3I,OAAO,EAAE,CAAC;SACX;QACD,OAAO,MAAM,CAAC,aAAa,CAAC,+BAA+B,CAAC,MAAM,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAC;IACjG,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,GAAQ;QACnC,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;QACpC,MAAM,QAAQ,GAAG,MAAM,CAAC,WAAW,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzE,OAAO,QAAQ,CAAC;IAClB,CAAC;;AAtEc,mBAAY,GAAG,KAAK,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\n/** Import color variables, layout variables and Sass classes barrel file */\r\nimport \"./colorthemes.scss\";\r\nimport \"./colorvariables.scss\";\r\nimport \"./layout-variables.scss\";\r\nimport \"./classes.scss\";\r\n\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport type { Localization } from \"@itwin/core-common\";\r\nimport { getClassName, UiError } from \"@itwin/appui-abstract\";\r\nimport { IconWebComponent } from \"./utils/IconWebComponent\";\r\n// cSpell:ignore colorthemes colorvariables\r\n\r\n/**\r\n * Manages the Localization service for the core-react package.\r\n * @public\r\n */\r\nexport class UiCore {\r\n private static _initialized = false;\r\n private static _localization?: Localization;\r\n\r\n /**\r\n * Registers the Localization service namespace for UiCore.\r\n * @param localization The internationalization service created by the host application.\r\n */\r\n public static async initialize(localization: Localization): Promise<void> {\r\n if (UiCore._initialized) {\r\n Logger.logInfo(UiCore.loggerCategory(UiCore), `UiCore.initialize already called`);\r\n return;\r\n }\r\n\r\n UiCore._localization = localization;\r\n await UiCore._localization.registerNamespace(UiCore.localizationNamespace);\r\n if (window.customElements.get(\"svg-loader\") === undefined)\r\n window.customElements.define(\"svg-loader\", IconWebComponent);\r\n\r\n UiCore._initialized = true;\r\n }\r\n\r\n /** Unregisters the UiCore localization namespace */\r\n public static terminate() {\r\n if (UiCore._localization)\r\n UiCore._localization.unregisterNamespace(UiCore.localizationNamespace);\r\n UiCore._localization = undefined;\r\n\r\n UiCore._initialized = false;\r\n }\r\n\r\n /** Determines if UiCore has been initialized */\r\n public static get initialized(): boolean { return UiCore._initialized; }\r\n\r\n /** The internationalization service created by the host application.\r\n * @internal\r\n */\r\n public static get localization(): Localization {\r\n // istanbul ignore else\r\n if (!UiCore._localization)\r\n throw new UiError(UiCore.loggerCategory(this), \"localization: UiCore.initialize has not been called. Unable to return Localization object.\");\r\n // istanbul ignore next\r\n return UiCore._localization;\r\n }\r\n\r\n /** The internationalization service namespace. */\r\n public static get localizationNamespace(): string {\r\n return \"UiCore\";\r\n }\r\n\r\n /** Calls localization.getLocalizedStringWithNamespace with the \"UiCore\" namespace. Do NOT include the namespace in the key.\r\n * @internal\r\n */\r\n public static translate(key: string | string[]): string {\r\n if (!UiCore._localization) {\r\n Logger.logError(UiCore.loggerCategory(this), `translate: UiCore must be initialize with a localization provider. Returning blank string.`);\r\n return \"\";\r\n }\r\n return UiCore._localization.getLocalizedStringWithNamespace(UiCore.localizationNamespace, key);\r\n }\r\n\r\n /** @internal */\r\n public static get packageName(): string {\r\n return \"core-react\";\r\n }\r\n\r\n /** @internal */\r\n public static loggerCategory(obj: any): string {\r\n const className = getClassName(obj);\r\n const category = UiCore.packageName + (className ? `.${className}` : \"\");\r\n return category;\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Badge.d.ts","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,cAAc,CAAC;AAEtB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAI7C;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,WAAW;IAC7C,GAAG,EAAE,GAAG,CAAC;CACV;AAED;;GAEG;AACH,qBAAa,KAAM,SAAQ,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC;IACxC,MAAM,IAAI,GAAG,CAAC,OAAO;CAQtC"}
|
|
@@ -8,14 +8,16 @@
|
|
|
8
8
|
import "./Badge.scss";
|
|
9
9
|
import classnames from "classnames";
|
|
10
10
|
import * as React from "react";
|
|
11
|
-
import {
|
|
11
|
+
import { IconSpecUtilities } from "@itwin/appui-abstract";
|
|
12
|
+
import { Icon } from "../icons/IconComponent";
|
|
12
13
|
/** Beta Badge React component
|
|
13
14
|
* @internal
|
|
14
15
|
*/
|
|
15
16
|
export class Badge extends React.PureComponent {
|
|
16
17
|
render() {
|
|
18
|
+
const iconSpec = IconSpecUtilities.createWebComponentIconSpec(this.props.svg);
|
|
17
19
|
return (React.createElement("div", { className: classnames("core-badge", this.props.className), style: this.props.style },
|
|
18
|
-
React.createElement(
|
|
20
|
+
React.createElement(Icon, { iconSpec: iconSpec })));
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
//# sourceMappingURL=Badge.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,cAAc,CAAC;AACtB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Badge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/Badge.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,cAAc,CAAC;AACtB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAS9C;;GAEG;AACH,MAAM,OAAO,KAAM,SAAQ,KAAK,CAAC,aAAyB;IACxC,MAAM;QACpB,MAAM,QAAQ,GAAG,iBAAiB,CAAC,0BAA0B,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9E,OAAO,CACL,6BAAK,SAAS,EAAE,UAAU,CAAC,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YACrF,oBAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACxB,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport \"./Badge.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { IconSpecUtilities } from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"../icons/IconComponent\";\r\n\r\n/** Properties for the [[Badge]] React component\r\n * @internal\r\n */\r\nexport interface BadgeProps extends CommonProps {\r\n svg: any;\r\n}\r\n\r\n/** Beta Badge React component\r\n * @internal\r\n */\r\nexport class Badge extends React.PureComponent<BadgeProps> {\r\n public override render(): JSX.Element {\r\n const iconSpec = IconSpecUtilities.createWebComponentIconSpec(this.props.svg);\r\n return (\r\n <div className={classnames(\"core-badge\", this.props.className)} style={this.props.style}>\r\n <Icon iconSpec={iconSpec} />\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -9,7 +9,7 @@ import "./BetaBadge.scss";
|
|
|
9
9
|
import classnames from "classnames";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { Badge } from "./Badge";
|
|
12
|
-
import betaBadgeIcon from "./technical-preview-badge.svg
|
|
12
|
+
import betaBadgeIcon from "./technical-preview-badge.svg";
|
|
13
13
|
/** Beta Badge React component
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BetaBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/BetaBadge.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,aAAa,MAAM,
|
|
1
|
+
{"version":3,"file":"BetaBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/BetaBadge.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAE1D;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,KAAkB;IAC1C,MAAM,SAAS,GAAG,UAAU,CAAC,sBAAsB,EACjD,KAAK,CAAC,SAAS,CAChB,CAAC;IACF,OAAO,oBAAC,KAAK,OACP,KAAK,EACT,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,SAAS,GACpB,CAAC;AACL,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport \"./BetaBadge.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { Badge } from \"./Badge\";\r\nimport betaBadgeIcon from \"./technical-preview-badge.svg\";\r\n\r\n/** Beta Badge React component\r\n * @internal\r\n */\r\nexport function BetaBadge(props: CommonProps) {\r\n const className = classnames(\"core-badge-betaBadge\",\r\n props.className,\r\n );\r\n return <Badge\r\n {...props}\r\n svg={betaBadgeIcon}\r\n className={className}\r\n />;\r\n}\r\n"]}
|
|
@@ -9,7 +9,7 @@ import "./NewBadge.scss";
|
|
|
9
9
|
import classnames from "classnames";
|
|
10
10
|
import * as React from "react";
|
|
11
11
|
import { Badge } from "./Badge";
|
|
12
|
-
import newBadgeIcon from "./new-feature-badge.svg
|
|
12
|
+
import newBadgeIcon from "./new-feature-badge.svg";
|
|
13
13
|
/** New Badge React component
|
|
14
14
|
* @internal
|
|
15
15
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NewBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/NewBadge.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,iBAAiB,CAAC;AACzB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,YAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"NewBadge.js","sourceRoot":"","sources":["../../../../src/core-react/badge/NewBadge.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,iBAAiB,CAAC;AACzB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,YAAY,MAAM,yBAAyB,CAAC;AAEnD;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAkB;IACzC,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,OAAO,oBAAC,KAAK,OAAK,UAAU,EAAE,SAAS,EAAE,UAAU,CAAC,gBAAgB,EAAE,SAAS,CAAC,EAAE,GAAG,EAAE,YAAY,GAAI,CAAC;AAC1G,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport \"./NewBadge.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { Badge } from \"./Badge\";\r\nimport newBadgeIcon from \"./new-feature-badge.svg\";\r\n\r\n/** New Badge React component\r\n * @internal\r\n */\r\nexport function NewBadge(props: CommonProps) {\r\n const { className, ...badgeProps } = props;\r\n return <Badge {...badgeProps} className={classnames(\"core-new-badge\", className)} svg={newBadgeIcon} />;\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"IconComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,sBAAsB,EAAqB,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAG7C;;GAEG;AACH,oBAAY,QAAQ,GAAG,MAAM,GAAG,sBAAsB,GAAG,KAAK,CAAC,SAAS,CAAC;AAEzE;;GAEG;AACH,MAAM,WAAW,SAAU,SAAQ,WAAW;IAC5C;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;CACrB;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,sBAsCpC"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/* eslint-disable deprecation/deprecation */
|
|
5
6
|
/** @packageDocumentation
|
|
6
7
|
* @module Icon
|
|
7
8
|
*/
|
|
@@ -10,6 +11,7 @@ import * as React from "react";
|
|
|
10
11
|
import classnames from "classnames";
|
|
11
12
|
import { ConditionalStringValue, IconSpecUtilities } from "@itwin/appui-abstract";
|
|
12
13
|
import { SvgSprite } from "./SvgSprite";
|
|
14
|
+
import { sanitize as sanitizer } from "dompurify";
|
|
13
15
|
/** Icon Functional component displays an icon based on an [[IconSpec]].
|
|
14
16
|
* @public
|
|
15
17
|
*/
|
|
@@ -24,6 +26,16 @@ export function Icon(props) {
|
|
|
24
26
|
if (svgSource !== undefined)
|
|
25
27
|
return (React.createElement("i", { className: classnames("icon", "core-svg-icon", props.className), style: props.style },
|
|
26
28
|
React.createElement(SvgSprite, { src: svgSource })));
|
|
29
|
+
const webComponentString = IconSpecUtilities.getWebComponentSource(iconString);
|
|
30
|
+
if (webComponentString) {
|
|
31
|
+
const svgLoader = `<svg-loader src=${webComponentString} id="svg-id"></svg-loader>`;
|
|
32
|
+
const svgDiv = `<div>${svgLoader}</div>`;
|
|
33
|
+
const sanitizedIconString = sanitizer(svgDiv, { ALLOWED_TAGS: ["svg-loader"] });
|
|
34
|
+
// we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
|
|
35
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
|
|
36
|
+
const webComponentNode = React.createElement("div", { dangerouslySetInnerHTML: { __html: sanitizedIconString } });
|
|
37
|
+
return (React.createElement("i", { className: classnames("icon", "core-svg-icon", props.className) }, webComponentNode));
|
|
38
|
+
}
|
|
27
39
|
return (React.createElement("i", { className: classnames("icon", iconString, props.className), style: props.style }));
|
|
28
40
|
}
|
|
29
41
|
return (React.createElement("i", { className: classnames("icon", "core-svg-icon", props.className), style: props.style }, props.iconSpec));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,WAAW,CAAC;AAiBlD;;GAEG;AACH,MAAM,UAAU,IAAI,CAAC,KAAgB;IACnC,IAAI,CAAC,KAAK,CAAC,QAAQ;QACjB,OAAO,IAAI,CAAC;IAEd,MAAM,UAAU,GAAG,CAAC,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,QAAQ,YAAY,sBAAsB,CAAC,CAAC,CAAC;QAC3G,sBAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAE9D,IAAI,UAAU,EAAE;QACd,MAAM,SAAS,GAAG,iBAAiB,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC;QAC7D,kIAAkI;QAClI,IAAI,SAAS,KAAK,SAAS;YACzB,OAAO,CACL,2BAAG,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK;gBACpF,oBAAC,SAAS,IAAC,GAAG,EAAE,SAAS,GAAI,CAC3B,CACL,CAAC;QACJ,MAAM,kBAAkB,GAAG,iBAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QAC/E,IAAI,kBAAkB,EAAC;YACrB,MAAM,SAAS,GAAG,mBAAmB,kBAAkB,4BAA4B,CAAC;YACpF,MAAM,MAAM,GAAG,QAAQ,SAAS,QAAQ,CAAC;YACzC,MAAM,mBAAmB,GAAG,SAAS,CAAC,MAAM,EAAE,EAAC,YAAY,EAAE,CAAC,YAAY,CAAC,EAAC,CAAC,CAAC;YAC9E,iFAAiF;YACjF,+FAA+F;YAC/F,MAAM,gBAAgB,GAAG,6BAAK,uBAAuB,EAAE,EAAC,MAAM,EAAC,mBAAmB,EAAC,GAAQ,CAAC;YAC5F,OAAO,CACL,2BAAG,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,IAC/D,gBAAgB,CACf,CACL,CAAC;SACH;QACD,OAAO,CAAC,2BAAG,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAAC,CAAC;KAChG;IAED,OAAO,CACL,2BAAG,SAAS,EAAE,UAAU,CAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,IACnF,KAAK,CAAC,QAAQ,CACb,CACL,CAAC;AACJ,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/* eslint-disable deprecation/deprecation */\r\n/** @packageDocumentation\r\n * @module Icon\r\n */\r\n\r\nimport \"./IconComponent.scss\";\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ConditionalStringValue, IconSpecUtilities } from \"@itwin/appui-abstract\";\r\nimport { SvgSprite } from \"./SvgSprite\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { sanitize as sanitizer } from \"dompurify\";\r\n\r\n/** Prototype for an IconSpec which can be a string, ReactNode or ConditionalStringValue.\r\n * @public\r\n */\r\nexport type IconSpec = string | ConditionalStringValue | React.ReactNode;\r\n\r\n/** Properties for the [[Icon]] React component\r\n * @public\r\n */\r\nexport interface IconProps extends CommonProps {\r\n /** CSS class name or SvgSprite/SvgPath for icon. This is optional because it is improperly\r\n * used to extend other interfaces and changing it would break existing API.\r\n */\r\n iconSpec?: IconSpec;\r\n}\r\n\r\n/** Icon Functional component displays an icon based on an [[IconSpec]].\r\n * @public\r\n */\r\nexport function Icon(props: IconProps) {\r\n if (!props.iconSpec)\r\n return null;\r\n\r\n const iconString = (typeof props.iconSpec === \"string\" || props.iconSpec instanceof ConditionalStringValue) ?\r\n ConditionalStringValue.getValue(props.iconSpec) : undefined;\r\n\r\n if (iconString) {\r\n const svgSource = IconSpecUtilities.getSvgSource(iconString);\r\n // if string begins with \"svg:\" then we assume it was imported (into extension source file) using webpack loader svg-sprite-loader\r\n if (svgSource !== undefined)\r\n return (\r\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)} style={props.style}>\r\n <SvgSprite src={svgSource} />\r\n </i>\r\n );\r\n const webComponentString = IconSpecUtilities.getWebComponentSource(iconString);\r\n if (webComponentString){\r\n const svgLoader = `<svg-loader src=${webComponentString} id=\"svg-id\"></svg-loader>`;\r\n const svgDiv = `<div>${svgLoader}</div>`;\r\n const sanitizedIconString = sanitizer(svgDiv, {ALLOWED_TAGS: [\"svg-loader\"]});\r\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\r\n // eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger\r\n const webComponentNode = <div dangerouslySetInnerHTML={{__html:sanitizedIconString}}></div>;\r\n return (\r\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)} >\r\n {webComponentNode}\r\n </i>\r\n );\r\n }\r\n return (<i className={classnames(\"icon\", iconString, props.className)} style={props.style} />);\r\n }\r\n\r\n return (\r\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)} style={props.style}>\r\n {props.iconSpec}\r\n </i>\r\n );\r\n}\r\n"]}
|
|
@@ -5,14 +5,15 @@ import "./SvgSprite.scss";
|
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import { CommonProps } from "../utils/Props";
|
|
7
7
|
/** Properties of [[SvgSprite]] component.
|
|
8
|
-
* @public
|
|
8
|
+
* @public @deprecated
|
|
9
9
|
*/
|
|
10
10
|
export interface SvgSpriteProps extends CommonProps {
|
|
11
11
|
/** Source for the Svg */
|
|
12
12
|
src: string;
|
|
13
13
|
}
|
|
14
14
|
/** Svg element wrapper.
|
|
15
|
-
*
|
|
15
|
+
* This component is deprecate -- use IconComponent
|
|
16
|
+
* @public @deprecated
|
|
16
17
|
*/
|
|
17
18
|
export declare class SvgSprite extends React.PureComponent<SvgSpriteProps> {
|
|
18
19
|
render(): JSX.Element;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SvgSprite.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SvgSprite.d.ts","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":"AAKA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;CACb;AAED;;;GAGG;AACH,qBAAa,SAAU,SAAQ,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC;IAChD,MAAM;CAYvB"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
/* eslint-disable deprecation/deprecation */
|
|
5
6
|
/** @packageDocumentation
|
|
6
7
|
* @module Icon
|
|
7
8
|
*/
|
|
@@ -9,7 +10,8 @@ import "./SvgSprite.scss";
|
|
|
9
10
|
import classnames from "classnames";
|
|
10
11
|
import * as React from "react";
|
|
11
12
|
/** Svg element wrapper.
|
|
12
|
-
*
|
|
13
|
+
* This component is deprecate -- use IconComponent
|
|
14
|
+
* @public @deprecated
|
|
13
15
|
*/
|
|
14
16
|
export class SvgSprite extends React.PureComponent {
|
|
15
17
|
render() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SvgSprite.js","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B
|
|
1
|
+
{"version":3,"file":"SvgSprite.js","sourceRoot":"","sources":["../../../../src/core-react/icons/SvgSprite.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAW/B;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK,CAAC,aAA6B;IAChD,MAAM;QACpB,MAAM,SAAS,GAAG,UAAU,CAC1B,sBAAsB,EACtB,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,CAAC;QAEF,OAAO,CACL,6BAAK,SAAS,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,EAAC,MAAM,EAAC,MAAM,EAAC,MAAM;YAC5E,6BAAK,UAAU,EAAC,8BAA8B,EAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,GAAI,CACxE,CACP,CAAC;IACJ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/* eslint-disable deprecation/deprecation */\r\n/** @packageDocumentation\r\n * @module Icon\r\n */\r\n\r\nimport \"./SvgSprite.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"../utils/Props\";\r\n\r\n/** Properties of [[SvgSprite]] component.\r\n * @public @deprecated\r\n */\r\nexport interface SvgSpriteProps extends CommonProps {\r\n /** Source for the Svg */\r\n src: string;\r\n}\r\n\r\n/** Svg element wrapper.\r\n * This component is deprecate -- use IconComponent\r\n * @public @deprecated\r\n */\r\nexport class SvgSprite extends React.PureComponent<SvgSpriteProps> {\r\n public override render() {\r\n const className = classnames(\r\n \"core-icons-svgSprite\",\r\n this.props.className,\r\n );\r\n\r\n return (\r\n <svg className={className} style={this.props.style} width=\"100%\" height=\"100%\">\r\n <use xmlnsXlink=\"http://www.w3.org/1999/xlink\" xlinkHref={this.props.src} />\r\n </svg>\r\n );\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconHelper.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D;;GAEG;AACH,qBAAa,UAAU;IACrB,WAAkB,YAAY,IAAI,MAAM,CAEvC;
|
|
1
|
+
{"version":3,"file":"IconHelper.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAG/D;;GAEG;AACH,qBAAa,UAAU;IACrB,WAAkB,YAAY,IAAI,MAAM,CAEvC;IACD;;;OAGG;WACW,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,sBAAsB,GAAG,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,SAAS;IA2BzI;;;;OAIG;WACW,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,sBAAsB,GAAG,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,sBAAsB;CAYzJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconHelper.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAO,UAAU;IACd,MAAM,KAAK,YAAY;QAC5B,OAAO,yBAAyB,CAAC;IACnC,CAAC;
|
|
1
|
+
{"version":3,"file":"IconHelper.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAO,UAAU;IACd,MAAM,KAAK,YAAY;QAC5B,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAAC,IAAuD,EAAE,YAA+B;QACrH,uBAAuB;QACvB,IAAI,CAAC,IAAI;YACP,OAAO,IAAI,CAAC;QAEd,uBAAuB;QACvB,IAAI,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC;YAC5B,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,GAAI,CAAC;QAElC,qBAAqB;QACrB,IAAI,CAAC,CAAC,IAAI,YAAY,sBAAsB,CAAC,IAAI,OAAO,IAAI,KAAK,QAAQ;YACvE,OAAO,IAAI,CAAC;QAEd,MAAM,UAAU,GAAG,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACzD,IAAI,CAAC,UAAU;YACb,OAAO,IAAI,CAAC;QAEd,uBAAuB;QACvB,IAAI,UAAU,KAAK,UAAU,CAAC,YAAY,EAAE;YAC1C,uBAAuB;YACvB,IAAI,YAAY;gBACd,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,CAAoB,GAAI,CAAC;YAC1F,OAAO,IAAI,CAAC;SACb;QACD,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAE,UAAU,GAAI,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CAAC,QAA2D,EAAE,YAA+B;QACpH,MAAM,IAAI,GAAG,CAAC,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEnF,IAAI,YAAY,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,UAAU,CAAC,YAAY,EAAE;YAChF,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;SACrD;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,YAAY,sBAAsB;YACpE,OAAO,IAAI,CAAC;QAEd,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { ConditionalStringValue } from \"@itwin/appui-abstract\";\r\nimport { Icon } from \"../icons/IconComponent\";\r\n\r\n/** Icon Helper Class used to store the data needed to generate an <Icon> for use in any control that shows an icon.\r\n * @public\r\n */\r\nexport class IconHelper {\r\n public static get reactIconKey(): string {\r\n return \"#-react-iconspec-node-#\";\r\n }\r\n /** Returns an <Icon> ReactNode from the many ways an icon can be specified.\r\n * @param icon abstract icon specification.\r\n * @param internalData a map that may hold a React.ReactNode stored in an abstract item definition.\r\n */\r\n public static getIconReactNode(icon: string | ConditionalStringValue | React.ReactNode, internalData?: Map<string, any>): React.ReactNode {\r\n // istanbul ignore else\r\n if (!icon)\r\n return null;\r\n\r\n // istanbul ignore else\r\n if (React.isValidElement(icon))\r\n return <Icon iconSpec={icon} />;\r\n\r\n // istanbul ignore if\r\n if (!(icon instanceof ConditionalStringValue) && typeof icon !== \"string\")\r\n return null;\r\n\r\n const iconString = ConditionalStringValue.getValue(icon);\r\n if (!iconString)\r\n return null;\r\n\r\n // istanbul ignore else\r\n if (iconString === IconHelper.reactIconKey) {\r\n // istanbul ignore else\r\n if (internalData)\r\n return <Icon iconSpec={internalData.get(IconHelper.reactIconKey) as React.ReactNode} />;\r\n return null;\r\n }\r\n return <Icon iconSpec={iconString} />;\r\n }\r\n\r\n /** Returns an icon definition that can be stored in an abstract item definition. If the iconSpec specifies a ReactNode\r\n * then the react data is stored in the internalData map and the key to the react data is returned.\r\n * @param iconSpec any supported variations of how an icon can be defined in an abstract item or IconProps.\r\n * @param internalData a map supplied by the caller to store away react element if React.ReactNode\r\n */\r\n public static getIconData(iconSpec: string | ConditionalStringValue | React.ReactNode, internalData?: Map<string, any>): string | ConditionalStringValue {\r\n const icon = (React.isValidElement(iconSpec)) ? IconHelper.reactIconKey : iconSpec;\r\n\r\n if (internalData && typeof icon === \"string\" && icon === IconHelper.reactIconKey) {\r\n internalData.set(IconHelper.reactIconKey, iconSpec);\r\n }\r\n\r\n if (typeof icon === \"string\" || icon instanceof ConditionalStringValue)\r\n return icon;\r\n\r\n return \"\";\r\n }\r\n}\r\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module Utilities
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* IconWebComponent loads icon from an svg path
|
|
6
|
+
*/
|
|
7
|
+
export declare class IconWebComponent extends HTMLElement {
|
|
8
|
+
private connectedCallback;
|
|
9
|
+
private loadSvg;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=IconWebComponent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconWebComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":"AAMA;;GAEG;AAMH;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;YACjC,iBAAiB;YAKjB,OAAO;CAqBtB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
3
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
// istanbul ignore file
|
|
6
|
+
// IconWebComponent requires in-browser testing
|
|
7
|
+
/** @packageDocumentation
|
|
8
|
+
* @module Utilities
|
|
9
|
+
*/
|
|
10
|
+
import { UiError } from "@itwin/appui-abstract";
|
|
11
|
+
import { Logger } from "@itwin/core-bentley";
|
|
12
|
+
import { UiCore } from "../UiCore";
|
|
13
|
+
/**
|
|
14
|
+
* IconWebComponent loads icon from an svg path
|
|
15
|
+
*/
|
|
16
|
+
export class IconWebComponent extends HTMLElement {
|
|
17
|
+
async connectedCallback() {
|
|
18
|
+
await this.loadSvg();
|
|
19
|
+
this.dispatchEvent(new CustomEvent("load"));
|
|
20
|
+
}
|
|
21
|
+
async loadSvg() {
|
|
22
|
+
await fetch(this.getAttribute("src") || "")
|
|
23
|
+
.catch((_error) => {
|
|
24
|
+
Logger.logError(UiCore.loggerCategory(this), "Unable to load icon.");
|
|
25
|
+
})
|
|
26
|
+
.then(async (response) => {
|
|
27
|
+
if (response && response.ok) {
|
|
28
|
+
return response.text();
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw new UiError(UiCore.loggerCategory(this), "Unable to load icon.");
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
.then((str) => {
|
|
35
|
+
if (str !== undefined) {
|
|
36
|
+
return (new window.DOMParser()).parseFromString(str, "text/xml");
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new UiError(UiCore.loggerCategory(this), "Unable to load icon.");
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
.then((data) => this.append(data.documentElement));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=IconWebComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconWebComponent.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,uBAAuB;AACvB,+CAA+C;AAC/C;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAEnC;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IACvC,KAAK,CAAC,iBAAiB;QAC7B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,OAAO;QACnB,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;aACxC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE;YAChB,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;QACvE,CAAC,CAAC;aACD,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE;YACvB,IAAI,QAAQ,IAAI,QAAQ,CAAC,EAAE,EAAE;gBAC3B,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;aACxB;iBAAM;gBACL,MAAM,IAAI,OAAO,CAAE,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;aACzE;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;YACZ,IAAI,GAAG,KAAK,SAAS,EAAE;gBACrB,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;aAClE;iBAAM;gBACL,MAAM,IAAI,OAAO,CAAE,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,sBAAsB,CAAC,CAAC;aACzE;QACH,CAAC,CAAC;aACD,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IACvD,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n// istanbul ignore file\r\n// IconWebComponent requires in-browser testing\r\n/** @packageDocumentation\r\n * @module Utilities\r\n */\r\n\r\nimport { UiError } from \"@itwin/appui-abstract\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { UiCore } from \"../UiCore\";\r\n\r\n/**\r\n * IconWebComponent loads icon from an svg path\r\n */\r\nexport class IconWebComponent extends HTMLElement {\r\n private async connectedCallback() {\r\n await this.loadSvg();\r\n this.dispatchEvent(new CustomEvent(\"load\"));\r\n }\r\n\r\n private async loadSvg() {\r\n await fetch(this.getAttribute(\"src\") || \"\")\r\n .catch((_error) => {\r\n Logger.logError(UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n })\r\n .then(async (response) => {\r\n if (response && response.ok) {\r\n return response.text();\r\n } else {\r\n throw new UiError (UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n })\r\n .then((str) => {\r\n if (str !== undefined) {\r\n return (new window.DOMParser()).parseFromString(str, \"text/xml\");\r\n } else {\r\n throw new UiError (UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n })\r\n .then((data) => this.append(data.documentElement));\r\n }\r\n}\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-react",
|
|
3
|
-
"version": "3.2.0-dev.
|
|
3
|
+
"version": "3.2.0-dev.15",
|
|
4
4
|
"description": "iTwin.js UI core components",
|
|
5
5
|
"main": "lib/cjs/core-react.js",
|
|
6
6
|
"module": "lib/esm/core-react.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"url": "http://www.bentley.com"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/appui-abstract": "^3.2.0-dev.
|
|
27
|
-
"@itwin/core-bentley": "^3.2.0-dev.
|
|
26
|
+
"@itwin/appui-abstract": "^3.2.0-dev.15",
|
|
27
|
+
"@itwin/core-bentley": "^3.2.0-dev.15",
|
|
28
28
|
"react": "^17.0.0",
|
|
29
29
|
"react-dom": "^17.0.0"
|
|
30
30
|
},
|
|
@@ -33,12 +33,12 @@
|
|
|
33
33
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
34
34
|
],
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@itwin/appui-abstract": "3.2.0-dev.
|
|
37
|
-
"@itwin/build-tools": "3.2.0-dev.
|
|
38
|
-
"@itwin/core-bentley": "3.2.0-dev.
|
|
39
|
-
"@itwin/core-common": "3.2.0-dev.
|
|
40
|
-
"@itwin/core-i18n": "3.2.0-dev.
|
|
41
|
-
"@itwin/eslint-plugin": "3.2.0-dev.
|
|
36
|
+
"@itwin/appui-abstract": "3.2.0-dev.15",
|
|
37
|
+
"@itwin/build-tools": "3.2.0-dev.15",
|
|
38
|
+
"@itwin/core-bentley": "3.2.0-dev.15",
|
|
39
|
+
"@itwin/core-common": "3.2.0-dev.15",
|
|
40
|
+
"@itwin/core-i18n": "3.2.0-dev.15",
|
|
41
|
+
"@itwin/eslint-plugin": "3.2.0-dev.15",
|
|
42
42
|
"@testing-library/react": "^12.0.0",
|
|
43
43
|
"@testing-library/react-hooks": "^7.0.2",
|
|
44
44
|
"@testing-library/user-event": "^13.2.1",
|