@itwin/core-react 3.2.0-dev.22 → 3.2.0-dev.25
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/CHANGELOG.md +6 -1
- package/lib/cjs/core-react/icons/IconComponent.d.ts.map +1 -1
- package/lib/cjs/core-react/icons/IconComponent.js +6 -2
- package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.d.ts.map +1 -1
- package/lib/cjs/core-react/notification/MessageRenderer.js +7 -4
- package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/cjs/core-react/utils/IconHelper.d.ts +2 -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/hooks/useResizeObserver.d.ts +1 -1
- package/lib/cjs/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.d.ts.map +1 -1
- package/lib/esm/core-react/icons/IconComponent.js +6 -2
- package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.d.ts.map +1 -1
- package/lib/esm/core-react/notification/MessageRenderer.js +7 -4
- package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
- package/lib/esm/core-react/utils/IconHelper.d.ts +2 -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/hooks/useResizeObserver.d.ts +1 -1
- package/lib/esm/core-react/utils/hooks/useResizeObserver.d.ts.map +1 -1
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
# Change Log - @itwin/core-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 25 Mar 2022 15:10:02 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 3.0.3
|
|
6
|
+
Fri, 25 Mar 2022 15:10:02 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
4
9
|
|
|
5
10
|
## 3.0.2
|
|
6
11
|
Thu, 10 Mar 2022 21:18:13 GMT
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,sBA0CpC"}
|
|
@@ -14,7 +14,7 @@ const React = require("react");
|
|
|
14
14
|
const classnames_1 = require("classnames");
|
|
15
15
|
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
16
16
|
const SvgSprite_1 = require("./SvgSprite");
|
|
17
|
-
const dompurify_1 = require("dompurify");
|
|
17
|
+
const dompurify_1 = require("dompurify"), DOMPurifyNS = dompurify_1;
|
|
18
18
|
/** Icon Functional component displays an icon based on an [[IconSpec]].
|
|
19
19
|
* @public
|
|
20
20
|
*/
|
|
@@ -33,7 +33,11 @@ function Icon(props) {
|
|
|
33
33
|
if (webComponentString) {
|
|
34
34
|
const svgLoader = `<svg-loader src=${webComponentString} id="svg-id"></svg-loader>`;
|
|
35
35
|
const svgDiv = `<div>${svgLoader}</div>`;
|
|
36
|
-
|
|
36
|
+
// the esm build of dompurify has a default import but the cjs build does not
|
|
37
|
+
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
38
|
+
// istanbul ignore next
|
|
39
|
+
const sanitizer = dompurify_1.default !== null && dompurify_1.default !== void 0 ? dompurify_1.default : DOMPurifyNS;
|
|
40
|
+
const sanitizedIconString = sanitizer.sanitize(svgDiv, { ALLOWED_TAGS: ["svg-loader"] });
|
|
37
41
|
// we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
|
|
38
42
|
// eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
|
|
39
43
|
const webComponentNode = React.createElement("div", { dangerouslySetInnerHTML: { __html: sanitizedIconString } });
|
|
@@ -1 +1 @@
|
|
|
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,
|
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C,MAAM,mBAAmB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAC,YAAY,EAAE,CAAC,YAAY,CAAC,EAAC,CAAC,CAAC;YACvF,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;AA1CD,oBA0CC","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 DOMPurify, * as DOMPurifyNS 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 // the esm build of dompurify has a default import but the cjs build does not\r\n // if there is a default export, use it (likely esm), otherwise use the namespace\r\n // istanbul ignore next\r\n const sanitizer = DOMPurify ?? DOMPurifyNS;\r\n const sanitizedIconString = sanitizer.sanitize(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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAiC,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,wBAAwB;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"MessageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAiC,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,wBAAwB;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sBAmE1D"}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
10
|
exports.MessageRenderer = void 0;
|
|
11
11
|
const React = require("react");
|
|
12
|
-
const
|
|
12
|
+
const dompurify_1 = require("dompurify"), DOMPurifyNS = dompurify_1;
|
|
13
13
|
const MessageType_1 = require("./MessageType");
|
|
14
14
|
/** React component renders a string, HTMLElement or React node in a `div` or `span`
|
|
15
15
|
* @public
|
|
@@ -21,7 +21,10 @@ function MessageRenderer(props) {
|
|
|
21
21
|
messageNode = React.createElement(OutElement, { className: props.className }, props.message);
|
|
22
22
|
}
|
|
23
23
|
else if ((0, MessageType_1.isHTMLElement)(props.message)) {
|
|
24
|
-
|
|
24
|
+
// the esm build of dompurify has a default import but the cjs build does not
|
|
25
|
+
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
26
|
+
// istanbul ignore next
|
|
27
|
+
const sanitizer = dompurify_1.default !== null && dompurify_1.default !== void 0 ? dompurify_1.default : DOMPurifyNS; // `sanitizer` is default function name for "jam3/no-sanitizer-with-danger" ESLint rule
|
|
25
28
|
let validAnchors = false;
|
|
26
29
|
let hasAnchors = false;
|
|
27
30
|
// verify that the tag has proper relationships
|
|
@@ -59,10 +62,10 @@ function MessageRenderer(props) {
|
|
|
59
62
|
let sanitizedHtml;
|
|
60
63
|
if (hasAnchors && validAnchors) {
|
|
61
64
|
// all anchors are valid. do not remove the target attr
|
|
62
|
-
sanitizedHtml = sanitizer(props.message.outerHTML, { ADD_ATTR: ["target"] });
|
|
65
|
+
sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, { ADD_ATTR: ["target"] });
|
|
63
66
|
}
|
|
64
67
|
else {
|
|
65
|
-
sanitizedHtml = sanitizer(props.message.outerHTML);
|
|
68
|
+
sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);
|
|
66
69
|
}
|
|
67
70
|
// we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
|
|
68
71
|
// eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B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AAI,IAAA,4BAAc,EAAC,KAAK,CAAC,OAAO,CAAC;YAC/B,WAAW,GAAG,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAc,CAAC;KAChG;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAnED,0CAmEC","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 Notification\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\r\nimport { isHTMLElement, isReactMessage, MessageType } from \"./MessageType\";\r\nimport { ClassNameProps } from \"../utils/Props\";\r\n\r\n// cSpell:ignore dompurify\r\n\r\n/** Properties for the [[MessageRenderer]] component\r\n * @public\r\n */\r\nexport interface MessageRendererProps extends ClassNameProps {\r\n /** Message to render */\r\n message: MessageType;\r\n /** Indicates whether to use a `span` or `div` element for rendering */\r\n useSpan?: boolean;\r\n}\r\n\r\n/** React component renders a string, HTMLElement or React node in a `div` or `span`\r\n * @public\r\n */\r\nexport function MessageRenderer(props: MessageRendererProps) {\r\n let messageNode = null;\r\n const OutElement = props.useSpan ? \"span\" : \"div\";\r\n\r\n if (typeof props.message === \"string\") {\r\n messageNode = <OutElement className={props.className}>{props.message}</OutElement>;\r\n } else if (isHTMLElement(props.message)) {\r\n // the esm build of dompurify has a default import but the cjs build does not\r\n // if there is a default export, use it (likely esm), otherwise use the namespace\r\n // istanbul ignore next\r\n const sanitizer = DOMPurify ?? DOMPurifyNS; // `sanitizer` is default function name for \"jam3/no-sanitizer-with-danger\" ESLint rule\r\n\r\n let validAnchors = false;\r\n let hasAnchors = false;\r\n\r\n // verify that the tag has proper relationships\r\n const isAnchorValid = (anchor: HTMLAnchorElement): boolean => {\r\n return anchor.hasAttribute(\"rel\") && (anchor.rel.includes(\"noopener\") || anchor.rel.includes(\"noreferrer\"));\r\n };\r\n\r\n // recursively check child elements for valid anchor tags\r\n const checkChildAnchors = (parent: Element) => {\r\n const children = Array.from(parent.children);\r\n for (const child of children){\r\n if (child.hasAttribute(\"target\") && (child as HTMLAnchorElement).target === \"_blank\") {\r\n hasAnchors = true;\r\n validAnchors = isAnchorValid(child as HTMLAnchorElement);\r\n if (!validAnchors) {\r\n return;\r\n }\r\n }\r\n checkChildAnchors(child);\r\n }\r\n };\r\n\r\n // check for anchor tags in the message that have target _blank also have a relationship that avoids security holes\r\n // https://web.dev/external-anchors-use-rel-noopener/\r\n // first check the message element\r\n /* istanbul ignore else */\r\n if (props.message.hasAttribute(\"target\") && (props.message as HTMLAnchorElement).target === \"_blank\") {\r\n hasAnchors = true;\r\n validAnchors = isAnchorValid(props.message as HTMLAnchorElement);\r\n } else {\r\n // if the message element is not an anchor, recursively verify it's children\r\n if (props.message.children) {\r\n checkChildAnchors(props.message);\r\n }\r\n }\r\n\r\n let sanitizedHtml;\r\n if (hasAnchors && validAnchors) {\r\n // all anchors are valid. do not remove the target attr\r\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, {ADD_ATTR: [\"target\"]});\r\n } else {\r\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);\r\n }\r\n\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 messageNode = <OutElement className={props.className} dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />;\r\n } else {\r\n /* istanbul ignore else */\r\n if (isReactMessage(props.message))\r\n messageNode = <OutElement className={props.className}>{props.message.reactNode}</OutElement>;\r\n }\r\n\r\n return messageNode;\r\n}\r\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { ConditionalStringValue } from "@itwin/appui-abstract";
|
|
6
|
+
import { IconSpec } from "../icons/IconComponent";
|
|
6
7
|
/** Icon Helper Class used to store the data needed to generate an <Icon> for use in any control that shows an icon.
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
@@ -18,6 +19,6 @@ export declare class IconHelper {
|
|
|
18
19
|
* @param iconSpec any supported variations of how an icon can be defined in an abstract item or IconProps.
|
|
19
20
|
* @param internalData a map supplied by the caller to store away react element if React.ReactNode
|
|
20
21
|
*/
|
|
21
|
-
static getIconData(iconSpec:
|
|
22
|
+
static getIconData(iconSpec: IconSpec, internalData?: Map<string, any>): string | ConditionalStringValue;
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=IconHelper.d.ts.map
|
|
@@ -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;
|
|
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;AAC/D,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAExD;;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,QAAQ,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,sBAAsB;CAYhH"}
|
|
@@ -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,
|
|
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,0DAAwD;AAExD;;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,QAAkB,EAAE,YAA+B;QAC3E,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, IconSpec } 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: IconSpec, 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"]}
|
|
@@ -5,7 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
/** Uses ResizeObserver API to notify about element bound changes.
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export declare function useResizeObserver<T extends Element>(onResize?: (width: number, height: number) => void): (instance:
|
|
8
|
+
export declare function useResizeObserver<T extends Element>(onResize?: (width: number, height: number) => void): (instance: Element | null) => void;
|
|
9
9
|
/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector
|
|
10
10
|
* width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly
|
|
11
11
|
* handles observing element in pop-out/child windows.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;IAEI;AACJ,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;IAEI;AACJ,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCAiFtG;AAED;;;;IAII;AACJ,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BAgF1H;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE;IAAE,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,GAAG,CAAC,OAAO,CAAA;CAAE,eAGxJ;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eA6BnJ"}
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,sBA0CpC"}
|
|
@@ -11,7 +11,7 @@ import * as React from "react";
|
|
|
11
11
|
import classnames from "classnames";
|
|
12
12
|
import { ConditionalStringValue, IconSpecUtilities } from "@itwin/appui-abstract";
|
|
13
13
|
import { SvgSprite } from "./SvgSprite";
|
|
14
|
-
import
|
|
14
|
+
import DOMPurify, * as DOMPurifyNS from "dompurify";
|
|
15
15
|
/** Icon Functional component displays an icon based on an [[IconSpec]].
|
|
16
16
|
* @public
|
|
17
17
|
*/
|
|
@@ -30,7 +30,11 @@ export function Icon(props) {
|
|
|
30
30
|
if (webComponentString) {
|
|
31
31
|
const svgLoader = `<svg-loader src=${webComponentString} id="svg-id"></svg-loader>`;
|
|
32
32
|
const svgDiv = `<div>${svgLoader}</div>`;
|
|
33
|
-
|
|
33
|
+
// the esm build of dompurify has a default import but the cjs build does not
|
|
34
|
+
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
35
|
+
// istanbul ignore next
|
|
36
|
+
const sanitizer = DOMPurify !== null && DOMPurify !== void 0 ? DOMPurify : DOMPurifyNS;
|
|
37
|
+
const sanitizedIconString = sanitizer.sanitize(svgDiv, { ALLOWED_TAGS: ["svg-loader"] });
|
|
34
38
|
// we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
|
|
35
39
|
// eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
|
|
36
40
|
const webComponentNode = React.createElement("div", { dangerouslySetInnerHTML: { __html: sanitizedIconString } });
|
|
@@ -1 +1 @@
|
|
|
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,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iB,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,6EAA6E;YAC7E,iFAAiF;YACjF,uBAAuB;YACvB,MAAM,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,WAAW,CAAC;YAC3C,MAAM,mBAAmB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAC,YAAY,EAAE,CAAC,YAAY,CAAC,EAAC,CAAC,CAAC;YACvF,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 DOMPurify, * as DOMPurifyNS 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 // the esm build of dompurify has a default import but the cjs build does not\r\n // if there is a default export, use it (likely esm), otherwise use the namespace\r\n // istanbul ignore next\r\n const sanitizer = DOMPurify ?? DOMPurifyNS;\r\n const sanitizedIconString = sanitizer.sanitize(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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAiC,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,wBAAwB;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"MessageRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAIA;;GAEG;;AAIH,OAAO,EAAiC,WAAW,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIhD;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,wBAAwB;IACxB,OAAO,EAAE,WAAW,CAAC;IACrB,uEAAuE;IACvE,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,sBAmE1D"}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @module Notification
|
|
7
7
|
*/
|
|
8
8
|
import * as React from "react";
|
|
9
|
-
import * as
|
|
9
|
+
import DOMPurify, * as DOMPurifyNS from "dompurify";
|
|
10
10
|
import { isHTMLElement, isReactMessage } from "./MessageType";
|
|
11
11
|
/** React component renders a string, HTMLElement or React node in a `div` or `span`
|
|
12
12
|
* @public
|
|
@@ -18,7 +18,10 @@ export function MessageRenderer(props) {
|
|
|
18
18
|
messageNode = React.createElement(OutElement, { className: props.className }, props.message);
|
|
19
19
|
}
|
|
20
20
|
else if (isHTMLElement(props.message)) {
|
|
21
|
-
|
|
21
|
+
// the esm build of dompurify has a default import but the cjs build does not
|
|
22
|
+
// if there is a default export, use it (likely esm), otherwise use the namespace
|
|
23
|
+
// istanbul ignore next
|
|
24
|
+
const sanitizer = DOMPurify !== null && DOMPurify !== void 0 ? DOMPurify : DOMPurifyNS; // `sanitizer` is default function name for "jam3/no-sanitizer-with-danger" ESLint rule
|
|
22
25
|
let validAnchors = false;
|
|
23
26
|
let hasAnchors = false;
|
|
24
27
|
// verify that the tag has proper relationships
|
|
@@ -56,10 +59,10 @@ export function MessageRenderer(props) {
|
|
|
56
59
|
let sanitizedHtml;
|
|
57
60
|
if (hasAnchors && validAnchors) {
|
|
58
61
|
// all anchors are valid. do not remove the target attr
|
|
59
|
-
sanitizedHtml = sanitizer(props.message.outerHTML, { ADD_ATTR: ["target"] });
|
|
62
|
+
sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, { ADD_ATTR: ["target"] });
|
|
60
63
|
}
|
|
61
64
|
else {
|
|
62
|
-
sanitizedHtml = sanitizer(props.message.outerHTML);
|
|
65
|
+
sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);
|
|
63
66
|
}
|
|
64
67
|
// we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
|
|
65
68
|
// eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS,EAAE,KAAK,WAAW,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,cAAc,EAAe,MAAM,eAAe,CAAC;AAe3E;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAElD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QACrC,WAAW,GAAG,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,OAAO,CAAc,CAAC;KACpF;SAAM,IAAI,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACvC,6EAA6E;QAC7E,iFAAiF;QACjF,uBAAuB;QACvB,MAAM,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,WAAW,CAAC,CAAC,uFAAuF;QAEnI,IAAI,YAAY,GAAG,KAAK,CAAC;QACzB,IAAI,UAAU,GAAG,KAAK,CAAC;QAEvB,+CAA+C;QAC/C,MAAM,aAAa,GAAG,CAAC,MAAyB,EAAW,EAAE;YAC3D,OAAO,MAAM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AC,QAAQ,EAAE,CAAC,QAAQ,CAAC,EAAC,CAAC,CAAC;SACrF;aAAM;YACL,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SAC7D;QAED,iFAAiF;QACjF,+FAA+F;QAC/F,WAAW,GAAG,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,GAAI,CAAC;KAC9G;SAAM;QACL,0BAA0B;QAC1B,IAAI,cAAc,CAAC,KAAK,CAAC,OAAO,CAAC;YAC/B,WAAW,GAAG,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,OAAO,CAAC,SAAS,CAAc,CAAC;KAChG;IAED,OAAO,WAAW,CAAC;AACrB,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 Notification\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\r\nimport { isHTMLElement, isReactMessage, MessageType } from \"./MessageType\";\r\nimport { ClassNameProps } from \"../utils/Props\";\r\n\r\n// cSpell:ignore dompurify\r\n\r\n/** Properties for the [[MessageRenderer]] component\r\n * @public\r\n */\r\nexport interface MessageRendererProps extends ClassNameProps {\r\n /** Message to render */\r\n message: MessageType;\r\n /** Indicates whether to use a `span` or `div` element for rendering */\r\n useSpan?: boolean;\r\n}\r\n\r\n/** React component renders a string, HTMLElement or React node in a `div` or `span`\r\n * @public\r\n */\r\nexport function MessageRenderer(props: MessageRendererProps) {\r\n let messageNode = null;\r\n const OutElement = props.useSpan ? \"span\" : \"div\";\r\n\r\n if (typeof props.message === \"string\") {\r\n messageNode = <OutElement className={props.className}>{props.message}</OutElement>;\r\n } else if (isHTMLElement(props.message)) {\r\n // the esm build of dompurify has a default import but the cjs build does not\r\n // if there is a default export, use it (likely esm), otherwise use the namespace\r\n // istanbul ignore next\r\n const sanitizer = DOMPurify ?? DOMPurifyNS; // `sanitizer` is default function name for \"jam3/no-sanitizer-with-danger\" ESLint rule\r\n\r\n let validAnchors = false;\r\n let hasAnchors = false;\r\n\r\n // verify that the tag has proper relationships\r\n const isAnchorValid = (anchor: HTMLAnchorElement): boolean => {\r\n return anchor.hasAttribute(\"rel\") && (anchor.rel.includes(\"noopener\") || anchor.rel.includes(\"noreferrer\"));\r\n };\r\n\r\n // recursively check child elements for valid anchor tags\r\n const checkChildAnchors = (parent: Element) => {\r\n const children = Array.from(parent.children);\r\n for (const child of children){\r\n if (child.hasAttribute(\"target\") && (child as HTMLAnchorElement).target === \"_blank\") {\r\n hasAnchors = true;\r\n validAnchors = isAnchorValid(child as HTMLAnchorElement);\r\n if (!validAnchors) {\r\n return;\r\n }\r\n }\r\n checkChildAnchors(child);\r\n }\r\n };\r\n\r\n // check for anchor tags in the message that have target _blank also have a relationship that avoids security holes\r\n // https://web.dev/external-anchors-use-rel-noopener/\r\n // first check the message element\r\n /* istanbul ignore else */\r\n if (props.message.hasAttribute(\"target\") && (props.message as HTMLAnchorElement).target === \"_blank\") {\r\n hasAnchors = true;\r\n validAnchors = isAnchorValid(props.message as HTMLAnchorElement);\r\n } else {\r\n // if the message element is not an anchor, recursively verify it's children\r\n if (props.message.children) {\r\n checkChildAnchors(props.message);\r\n }\r\n }\r\n\r\n let sanitizedHtml;\r\n if (hasAnchors && validAnchors) {\r\n // all anchors are valid. do not remove the target attr\r\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, {ADD_ATTR: [\"target\"]});\r\n } else {\r\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);\r\n }\r\n\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 messageNode = <OutElement className={props.className} dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />;\r\n } else {\r\n /* istanbul ignore else */\r\n if (isReactMessage(props.message))\r\n messageNode = <OutElement className={props.className}>{props.message.reactNode}</OutElement>;\r\n }\r\n\r\n return messageNode;\r\n}\r\n"]}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as React from "react";
|
|
5
5
|
import { ConditionalStringValue } from "@itwin/appui-abstract";
|
|
6
|
+
import { IconSpec } from "../icons/IconComponent";
|
|
6
7
|
/** Icon Helper Class used to store the data needed to generate an <Icon> for use in any control that shows an icon.
|
|
7
8
|
* @public
|
|
8
9
|
*/
|
|
@@ -18,6 +19,6 @@ export declare class IconHelper {
|
|
|
18
19
|
* @param iconSpec any supported variations of how an icon can be defined in an abstract item or IconProps.
|
|
19
20
|
* @param internalData a map supplied by the caller to store away react element if React.ReactNode
|
|
20
21
|
*/
|
|
21
|
-
static getIconData(iconSpec:
|
|
22
|
+
static getIconData(iconSpec: IconSpec, internalData?: Map<string, any>): string | ConditionalStringValue;
|
|
22
23
|
}
|
|
23
24
|
//# sourceMappingURL=IconHelper.d.ts.map
|
|
@@ -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;
|
|
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;AAC/D,OAAO,EAAQ,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAExD;;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,QAAQ,EAAE,YAAY,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,GAAG,sBAAsB;CAYhH"}
|
|
@@ -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,
|
|
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,EAAY,MAAM,wBAAwB,CAAC;AAExD;;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,QAAkB,EAAE,YAA+B;QAC3E,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, IconSpec } 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: IconSpec, 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"]}
|
|
@@ -5,7 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
/** Uses ResizeObserver API to notify about element bound changes.
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export declare function useResizeObserver<T extends Element>(onResize?: (width: number, height: number) => void): (instance:
|
|
8
|
+
export declare function useResizeObserver<T extends Element>(onResize?: (width: number, height: number) => void): (instance: Element | null) => void;
|
|
9
9
|
/** React hook that uses ResizeObserver API to notify about element bound changes. Note: to work similar to ReactResizeDetector
|
|
10
10
|
* width and height are initialized as undefined and only set during after mount if bounds are non-zero. This implementation properly
|
|
11
11
|
* handles observing element in pop-out/child windows.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;IAEI;AACJ,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,
|
|
1
|
+
{"version":3,"file":"useResizeObserver.d.ts","sourceRoot":"","sources":["../../../../../src/core-react/utils/hooks/useResizeObserver.tsx"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAK/B;;IAEI;AACJ,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,sCAiFtG;AAED;;;;IAII;AACJ,wBAAgB,uBAAuB,CAAC,SAAS,EAAE,WAAW,GAAG,IAAI,EAAE,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,KAAK,IAAI,0BAgF1H;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,cAAc,EAAE,MAAM,EAAE,EAAE;IAAE,cAAc,EAAE,WAAW,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,GAAG,CAAC,OAAO,CAAA;CAAE,eAGxJ;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC;IAAC,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,eA6BnJ"}
|
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.25",
|
|
4
4
|
"description": "iTwin.js UI core components",
|
|
5
5
|
"main": "lib/cjs/core-react.js",
|
|
6
6
|
"module": "lib/esm/core-react.js",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
"url": "http://www.bentley.com"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@itwin/appui-abstract": "^3.2.0-dev.
|
|
26
|
-
"@itwin/core-bentley": "^3.2.0-dev.
|
|
25
|
+
"@itwin/appui-abstract": "^3.2.0-dev.25",
|
|
26
|
+
"@itwin/core-bentley": "^3.2.0-dev.25",
|
|
27
27
|
"react": "^17.0.0",
|
|
28
28
|
"react-dom": "^17.0.0"
|
|
29
29
|
},
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies"
|
|
33
33
|
],
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@itwin/appui-abstract": "3.2.0-dev.
|
|
36
|
-
"@itwin/build-tools": "3.2.0-dev.
|
|
37
|
-
"@itwin/core-bentley": "3.2.0-dev.
|
|
38
|
-
"@itwin/core-common": "3.2.0-dev.
|
|
39
|
-
"@itwin/core-i18n": "3.2.0-dev.
|
|
40
|
-
"@itwin/eslint-plugin": "3.2.0-dev.
|
|
35
|
+
"@itwin/appui-abstract": "3.2.0-dev.25",
|
|
36
|
+
"@itwin/build-tools": "3.2.0-dev.25",
|
|
37
|
+
"@itwin/core-bentley": "3.2.0-dev.25",
|
|
38
|
+
"@itwin/core-common": "3.2.0-dev.25",
|
|
39
|
+
"@itwin/core-i18n": "3.2.0-dev.25",
|
|
40
|
+
"@itwin/eslint-plugin": "3.2.0-dev.25",
|
|
41
41
|
"@testing-library/react": "^12.0.0",
|
|
42
42
|
"@testing-library/react-hooks": "^7.0.2",
|
|
43
43
|
"@testing-library/user-event": "^13.2.1",
|