@itwin/core-react 3.4.0-dev.9 → 3.5.0-dev.5

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +26 -1
  2. package/lib/cjs/core-react/_z-index.scss +1 -1
  3. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +1 -1
  4. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  5. package/lib/cjs/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
  6. package/lib/cjs/core-react/hocs/withOnOutsideClick.js +3 -0
  7. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  8. package/lib/cjs/core-react/icons/IconComponent.d.ts.map +1 -1
  9. package/lib/cjs/core-react/icons/IconComponent.js +6 -2
  10. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  11. package/lib/cjs/core-react/select/ThemedSelect.js +1 -1
  12. package/lib/cjs/core-react/select/ThemedSelect.js.map +1 -1
  13. package/lib/cjs/core-react/utils/IconWebComponent.d.ts.map +1 -1
  14. package/lib/cjs/core-react/utils/IconWebComponent.js +22 -1
  15. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  16. package/lib/cjs/core-react/utils/getCssVariable.d.ts.map +1 -1
  17. package/lib/cjs/core-react/utils/getCssVariable.js +0 -2
  18. package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
  19. package/lib/esm/core-react/_z-index.scss +1 -1
  20. package/lib/esm/core-react/contextmenu/ContextSubMenu.js +2 -2
  21. package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  22. package/lib/esm/core-react/hocs/withOnOutsideClick.d.ts.map +1 -1
  23. package/lib/esm/core-react/hocs/withOnOutsideClick.js +3 -0
  24. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  25. package/lib/esm/core-react/icons/IconComponent.d.ts.map +1 -1
  26. package/lib/esm/core-react/icons/IconComponent.js +6 -2
  27. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  28. package/lib/esm/core-react/select/ThemedSelect.js +1 -1
  29. package/lib/esm/core-react/select/ThemedSelect.js.map +1 -1
  30. package/lib/esm/core-react/utils/IconWebComponent.d.ts.map +1 -1
  31. package/lib/esm/core-react/utils/IconWebComponent.js +22 -1
  32. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  33. package/lib/esm/core-react/utils/getCssVariable.d.ts.map +1 -1
  34. package/lib/esm/core-react/utils/getCssVariable.js +0 -2
  35. package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
  36. package/package.json +13 -21
package/CHANGELOG.md CHANGED
@@ -1,6 +1,31 @@
1
1
  # Change Log - @itwin/core-react
2
2
 
3
- This log was last generated on Tue, 09 Aug 2022 15:52:41 GMT and should not be manually modified.
3
+ This log was last generated on Thu, 01 Sep 2022 14:37:22 GMT and should not be manually modified.
4
+
5
+ ## 3.3.2
6
+ Thu, 01 Sep 2022 14:37:22 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 3.3.1
11
+ Fri, 26 Aug 2022 15:40:02 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 3.3.0
16
+ Thu, 18 Aug 2022 19:08:02 GMT
17
+
18
+ ### Updates
19
+
20
+ - upgrade mocha to version 10.0.0
21
+ - Fix svg-loader to only fetch svg data once. Also update buic-background-panel to use buic-background-1 so disabled itwin-ui components are properly displayed.
22
+ - Add drop-target stacking context layer.
23
+ - Update iTwinUI-react to 1.38.1
24
+
25
+ ## 3.2.9
26
+ Fri, 26 Aug 2022 14:21:40 GMT
27
+
28
+ _Version update only_
4
29
 
5
30
  ## 3.2.8
6
31
  Tue, 09 Aug 2022 15:52:41 GMT
@@ -35,7 +35,7 @@ $uicore-internal-z-index-layers: view-overlay,
35
35
  $uicore-z-index-step: 1000;
36
36
 
37
37
  @function uicore-internal-get-next-z-index-step($counter) {
38
- @return $counter +$uicore-z-index-step;
38
+ @return $counter + $uicore-z-index-step;
39
39
  }
40
40
 
41
41
  $uicore-internal-z-index-layer-map: uicore-map-from-array-with-result-arg($uicore-internal-z-index-layers, get-function(uicore-internal-get-next-z-index-step), 0);
@@ -106,7 +106,7 @@ class ContextSubMenu extends React.Component {
106
106
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
107
107
  React.createElement("div", { className: (0, classnames_1.default)("core-context-submenu", ContextMenu_1.ContextMenu.getCSSClassNameFromDirection(renderDirection), className), onMouseOver: this._handleMouseOver, ref: (el) => { this._subMenuElement = el; }, "data-testid": "core-context-submenu", ...props },
108
108
  React.createElement("div", { onClick: this._handleClick, ref: (el) => { this._menuButtonElement = el; }, className: (0, classnames_1.default)("core-context-menu-item", "core-context-submenu-container", isDisabled && "core-context-menu-disabled", isHidden && "core-context-menu-hidden", isSelected && "core-context-menu-is-selected"), "data-testid": "core-context-submenu-container", role: "menuitem", tabIndex: isSelected ? 0 : -1, "aria-disabled": isDisabled, "aria-hidden": isHidden, "aria-haspopup": true },
109
- React.createElement("div", { className: (0, classnames_1.default)("core-context-menu-icon", "icon", icon) }),
109
+ React.createElement("div", { className: (0, classnames_1.default)("core-context-menu-icon", "icon", icon instanceof appui_abstract_1.ConditionalStringValue && icon.value, typeof icon === "string" && icon) }),
110
110
  React.createElement("div", { className: "core-context-menu-content" }, this._parsedLabel),
111
111
  React.createElement("div", { className: (0, classnames_1.default)("core-context-submenu-arrow", "icon", "icon-caret-right") }),
112
112
  badge &&
@@ -1 +1 @@
1
- {"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,2CAAoC;AACpC,0DAAgE;AAEhE,+CAA8D;AAE9D,iEAA8D;AAC9D,+CAA4C;AAC5C,4DAAyD;AAmBzD;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK,CAAC,SAAmD;IAmB3F,YAAY,KAA0B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AC;IACpC,CAAC;IAEO,oBAAoB;QAC1B,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC3C,uBAAuB;QACvB,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE;YACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,yBAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;YACrH,uBAAuB;YACvB,IAAI,eAAe,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS;gBAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;SACjD;IACH,CAAC;;AA9HH,wCAkMC;AA1Le,2BAAY,GAAiC;IACzD,SAAS,EAAE,2CAAoB,CAAC,WAAW;IAC3C,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,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 ContextMenu\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\r\nimport { ContextMenuItemProps } from \"./ContextMenuItem\";\r\nimport { ContextMenu, ContextMenuProps } from \"./ContextMenu\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\r\nimport { TildeFinder } from \"./TildeFinder\";\r\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\r\n\r\n/** Properties for the [[ContextSubMenu]] component\r\n * @public\r\n */\r\nexport interface ContextSubMenuProps extends Omit<ContextMenuItemProps, \"label\">, Omit<ContextMenuProps, \"label\">, CommonProps {\r\n /** Text/jsx to display in the list item */\r\n label: string | JSX.Element;\r\n /** @internal */\r\n onHotKeyParsed?: (hotKey: string) => void;\r\n}\r\n\r\n/** @internal */\r\ninterface ContextSubMenuState {\r\n opened: boolean;\r\n direction: ContextMenuDirection;\r\n hotKey?: string;\r\n}\r\n\r\n/**\r\n * Submenu wrapper class for use within a [[ContextMenu]] component.\r\n * @public\r\n */\r\nexport class ContextSubMenu extends React.Component<ContextSubMenuProps, ContextSubMenuState> {\r\n private _menuElement: ContextMenu | null = null;\r\n private _subMenuElement: HTMLElement | null = null;\r\n private _menuButtonElement: HTMLElement | null = null;\r\n\r\n private _lastLabel: React.ReactNode;\r\n private _parsedLabel: React.ReactNode;\r\n\r\n public static defaultProps: Partial<ContextSubMenuProps> = {\r\n direction: ContextMenuDirection.BottomRight,\r\n disabled: false,\r\n hidden: false,\r\n autoflip: true,\r\n isSelected: false,\r\n selectedIndex: 0,\r\n };\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<ContextSubMenuState>;\r\n constructor(props: ContextSubMenuProps) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n direction: props.direction!,\r\n };\r\n }\r\n\r\n public override render(): JSX.Element {\r\n const {\r\n label,\r\n opened, direction, onOutsideClick, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu, parentSubmenu, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n onSelect, icon, disabled, hidden, onHover, isSelected, onHotKeyParsed, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n children, onClick, className, badgeType, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n const contextMenuProps = { onOutsideClick, onSelect, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu };\r\n const badge = BadgeUtilities.getComponentForBadgeType(badgeType);\r\n const renderDirection = this.state.direction;\r\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(hidden);\r\n\r\n if (this._lastLabel !== label) {\r\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\r\n this._lastLabel = label;\r\n }\r\n return (\r\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\r\n <div className={classnames(\"core-context-submenu\", ContextMenu.getCSSClassNameFromDirection(renderDirection), className)}\r\n onMouseOver={this._handleMouseOver}\r\n ref={(el) => { this._subMenuElement = el; }}\r\n data-testid=\"core-context-submenu\"\r\n {...props} >\r\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\r\n <div\r\n onClick={this._handleClick}\r\n ref={(el) => { this._menuButtonElement = el; }}\r\n className={classnames(\"core-context-menu-item\",\r\n \"core-context-submenu-container\",\r\n isDisabled && \"core-context-menu-disabled\",\r\n isHidden && \"core-context-menu-hidden\",\r\n isSelected && \"core-context-menu-is-selected\")}\r\n data-testid=\"core-context-submenu-container\"\r\n role=\"menuitem\"\r\n tabIndex={isSelected ? 0 : -1}\r\n aria-disabled={isDisabled}\r\n aria-hidden={isHidden}\r\n aria-haspopup={true}\r\n >\r\n <div className={classnames(\"core-context-menu-icon\", \"icon\", icon)} />\r\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\r\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\", \"icon-caret-right\")} />\r\n {badge &&\r\n <div className=\"core-context-menu-badge\">\r\n {badge}\r\n </div>\r\n }\r\n </div>\r\n <ContextMenu\r\n ref={(el) => { this._menuElement = el; }}\r\n className=\"core-context-submenu-popup\"\r\n opened={this.state.opened}\r\n direction={renderDirection}\r\n parentSubmenu={this}\r\n {...contextMenuProps} >\r\n {children}\r\n </ContextMenu>\r\n </div>\r\n );\r\n }\r\n\r\n public override componentDidMount() {\r\n document.addEventListener(\"click\", this._handleClickGlobal);\r\n this._updateHotkey(this.props.label);\r\n\r\n this.checkRenderDirection();\r\n }\r\n\r\n public override componentWillUnmount() {\r\n document.removeEventListener(\"click\", this._handleClickGlobal);\r\n }\r\n\r\n public override componentDidUpdate(prevProps: ContextSubMenuProps, prevState: ContextSubMenuState) {\r\n const direction = this.props.direction!;\r\n if ((this.state.opened !== prevState.opened && direction !== this.state.direction) || prevProps.direction !== direction)\r\n this.checkRenderDirection();\r\n if (this.props.label !== prevProps.label) {\r\n this._updateHotkey(this.props.label);\r\n }\r\n }\r\n\r\n private getWindow() {\r\n const el = this._subMenuElement;\r\n const parentDocument = el!.ownerDocument;\r\n return parentDocument.defaultView;\r\n }\r\n\r\n private checkRenderDirection() {\r\n const { autoflip } = this.props;\r\n const parentWindow = this.getWindow();\r\n let renderDirection = this.state.direction;\r\n // istanbul ignore else\r\n if (parentWindow && autoflip && this._menuElement) {\r\n const menuRect = this._menuElement.getRect();\r\n renderDirection = ContextMenu.autoFlip(renderDirection, menuRect, parentWindow.innerWidth, parentWindow.innerHeight);\r\n // istanbul ignore next\r\n if (renderDirection !== this.state.direction)\r\n this.setState({ direction: renderDirection });\r\n }\r\n }\r\n\r\n private _updateHotkey = (node: React.ReactNode) => {\r\n let hotKey: string | undefined;\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\r\n if (!isDisabled && !isHidden)\r\n hotKey = TildeFinder.findAfterTilde(node).character;\r\n else\r\n hotKey = undefined;\r\n if (hotKey && hotKey !== this.state.hotKey) {\r\n this.setState({ hotKey });\r\n if (this.props.onHotKeyParsed)\r\n this.props.onHotKeyParsed(hotKey);\r\n }\r\n };\r\n\r\n public select = () => {\r\n this.setState({ opened: true }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.focus();\r\n if (this.props.onSelect !== undefined)\r\n this.props.onSelect(undefined);\r\n });\r\n };\r\n\r\n public close = (propagate?: boolean) => {\r\n this.setState({ opened: false }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.blur();\r\n });\r\n // istanbul ignore next\r\n if (propagate && this.props.parentMenu && this.props.parentMenu.props.parentSubmenu) {\r\n this.props.parentMenu.props.parentSubmenu.close(true);\r\n }\r\n };\r\n\r\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\r\n // istanbul ignore else\r\n if (this._menuButtonElement && this._menuButtonElement.style.visibility !== \"hidden\" && this.props.onHover) {\r\n this.props.onHover();\r\n }\r\n };\r\n\r\n private _handleClick = (event: any) => {\r\n event.stopPropagation();\r\n\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n\r\n // istanbul ignore else\r\n if (!isDisabled) {\r\n // istanbul ignore else\r\n if (this.props.onClick !== undefined)\r\n this.props.onClick(event);\r\n // istanbul ignore next\r\n if (this.props.opened)\r\n this.close();\r\n else\r\n this.select();\r\n }\r\n };\r\n\r\n private _handleClickGlobal = (event: any) => {\r\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\r\n this.setState((_prevState) => ({ opened: false }));\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"ContextSubMenu.js","sourceRoot":"","sources":["../../../../src/core-react/contextmenu/ContextSubMenu.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAC/B,2CAAoC;AACpC,0DAAwF;AAExF,+CAA8D;AAE9D,iEAA8D;AAC9D,+CAA4C;AAC5C,4DAAyD;AAmBzD;;;GAGG;AACH,MAAa,cAAe,SAAQ,KAAK,CAAC,SAAmD;IAmB3F,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAnBP,iBAAY,GAAuB,IAAI,CAAC;QACxC,oBAAe,GAAuB,IAAI,CAAC;QAC3C,uBAAkB,GAAuB,IAAI,CAAC;QA6H9C,kBAAa,GAAG,CAAC,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AK,CAAC;QAChC,MAAM,YAAY,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QACtC,IAAI,eAAe,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC;QAC3C,uBAAuB;QACvB,IAAI,YAAY,IAAI,QAAQ,IAAI,IAAI,CAAC,YAAY,EAAE;YACjD,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC7C,eAAe,GAAG,yBAAW,CAAC,QAAQ,CAAC,eAAe,EAAE,QAAQ,EAAE,YAAY,CAAC,UAAU,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;YACrH,uBAAuB;YACvB,IAAI,eAAe,KAAK,IAAI,CAAC,KAAK,CAAC,SAAS;gBAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;SACjD;IACH,CAAC;;AA9HH,wCAkMC;AA1Le,2BAAY,GAAiC;IACzD,SAAS,EAAE,2CAAoB,CAAC,WAAW;IAC3C,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,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 ContextMenu\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ConditionalBooleanValue, ConditionalStringValue } from \"@itwin/appui-abstract\";\r\nimport { ContextMenuItemProps } from \"./ContextMenuItem\";\r\nimport { ContextMenu, ContextMenuProps } from \"./ContextMenu\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\r\nimport { TildeFinder } from \"./TildeFinder\";\r\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\r\n\r\n/** Properties for the [[ContextSubMenu]] component\r\n * @public\r\n */\r\nexport interface ContextSubMenuProps extends Omit<ContextMenuItemProps, \"label\">, Omit<ContextMenuProps, \"label\">, CommonProps {\r\n /** Text/jsx to display in the list item */\r\n label: string | JSX.Element;\r\n /** @internal */\r\n onHotKeyParsed?: (hotKey: string) => void;\r\n}\r\n\r\n/** @internal */\r\ninterface ContextSubMenuState {\r\n opened: boolean;\r\n direction: ContextMenuDirection;\r\n hotKey?: string;\r\n}\r\n\r\n/**\r\n * Submenu wrapper class for use within a [[ContextMenu]] component.\r\n * @public\r\n */\r\nexport class ContextSubMenu extends React.Component<ContextSubMenuProps, ContextSubMenuState> {\r\n private _menuElement: ContextMenu | null = null;\r\n private _subMenuElement: HTMLElement | null = null;\r\n private _menuButtonElement: HTMLElement | null = null;\r\n\r\n private _lastLabel: React.ReactNode;\r\n private _parsedLabel: React.ReactNode;\r\n\r\n public static defaultProps: Partial<ContextSubMenuProps> = {\r\n direction: ContextMenuDirection.BottomRight,\r\n disabled: false,\r\n hidden: false,\r\n autoflip: true,\r\n isSelected: false,\r\n selectedIndex: 0,\r\n };\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<ContextSubMenuState>;\r\n constructor(props: ContextSubMenuProps) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n direction: props.direction!,\r\n };\r\n }\r\n\r\n public override render(): JSX.Element {\r\n const {\r\n label,\r\n opened, direction, onOutsideClick, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu, parentSubmenu, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n onSelect, icon, disabled, hidden, onHover, isSelected, onHotKeyParsed, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n children, onClick, className, badgeType, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n const contextMenuProps = { onOutsideClick, onSelect, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu };\r\n const badge = BadgeUtilities.getComponentForBadgeType(badgeType);\r\n const renderDirection = this.state.direction;\r\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(hidden);\r\n\r\n if (this._lastLabel !== label) {\r\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\r\n this._lastLabel = label;\r\n }\r\n return (\r\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\r\n <div className={classnames(\"core-context-submenu\", ContextMenu.getCSSClassNameFromDirection(renderDirection), className)}\r\n onMouseOver={this._handleMouseOver}\r\n ref={(el) => { this._subMenuElement = el; }}\r\n data-testid=\"core-context-submenu\"\r\n {...props} >\r\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\r\n <div\r\n onClick={this._handleClick}\r\n ref={(el) => { this._menuButtonElement = el; }}\r\n className={classnames(\"core-context-menu-item\",\r\n \"core-context-submenu-container\",\r\n isDisabled && \"core-context-menu-disabled\",\r\n isHidden && \"core-context-menu-hidden\",\r\n isSelected && \"core-context-menu-is-selected\")}\r\n data-testid=\"core-context-submenu-container\"\r\n role=\"menuitem\"\r\n tabIndex={isSelected ? 0 : -1}\r\n aria-disabled={isDisabled}\r\n aria-hidden={isHidden}\r\n aria-haspopup={true}\r\n >\r\n <div className={classnames(\"core-context-menu-icon\", \"icon\", icon instanceof ConditionalStringValue && icon.value, typeof icon === \"string\" && icon)} />\r\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\r\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\", \"icon-caret-right\")} />\r\n {badge &&\r\n <div className=\"core-context-menu-badge\">\r\n {badge}\r\n </div>\r\n }\r\n </div>\r\n <ContextMenu\r\n ref={(el) => { this._menuElement = el; }}\r\n className=\"core-context-submenu-popup\"\r\n opened={this.state.opened}\r\n direction={renderDirection}\r\n parentSubmenu={this}\r\n {...contextMenuProps} >\r\n {children}\r\n </ContextMenu>\r\n </div>\r\n );\r\n }\r\n\r\n public override componentDidMount() {\r\n document.addEventListener(\"click\", this._handleClickGlobal);\r\n this._updateHotkey(this.props.label);\r\n\r\n this.checkRenderDirection();\r\n }\r\n\r\n public override componentWillUnmount() {\r\n document.removeEventListener(\"click\", this._handleClickGlobal);\r\n }\r\n\r\n public override componentDidUpdate(prevProps: ContextSubMenuProps, prevState: ContextSubMenuState) {\r\n const direction = this.props.direction!;\r\n if ((this.state.opened !== prevState.opened && direction !== this.state.direction) || prevProps.direction !== direction)\r\n this.checkRenderDirection();\r\n if (this.props.label !== prevProps.label) {\r\n this._updateHotkey(this.props.label);\r\n }\r\n }\r\n\r\n private getWindow() {\r\n const el = this._subMenuElement;\r\n const parentDocument = el!.ownerDocument;\r\n return parentDocument.defaultView;\r\n }\r\n\r\n private checkRenderDirection() {\r\n const { autoflip } = this.props;\r\n const parentWindow = this.getWindow();\r\n let renderDirection = this.state.direction;\r\n // istanbul ignore else\r\n if (parentWindow && autoflip && this._menuElement) {\r\n const menuRect = this._menuElement.getRect();\r\n renderDirection = ContextMenu.autoFlip(renderDirection, menuRect, parentWindow.innerWidth, parentWindow.innerHeight);\r\n // istanbul ignore next\r\n if (renderDirection !== this.state.direction)\r\n this.setState({ direction: renderDirection });\r\n }\r\n }\r\n\r\n private _updateHotkey = (node: React.ReactNode) => {\r\n let hotKey: string | undefined;\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\r\n if (!isDisabled && !isHidden)\r\n hotKey = TildeFinder.findAfterTilde(node).character;\r\n else\r\n hotKey = undefined;\r\n if (hotKey && hotKey !== this.state.hotKey) {\r\n this.setState({ hotKey });\r\n if (this.props.onHotKeyParsed)\r\n this.props.onHotKeyParsed(hotKey);\r\n }\r\n };\r\n\r\n public select = () => {\r\n this.setState({ opened: true }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.focus();\r\n if (this.props.onSelect !== undefined)\r\n this.props.onSelect(undefined);\r\n });\r\n };\r\n\r\n public close = (propagate?: boolean) => {\r\n this.setState({ opened: false }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.blur();\r\n });\r\n // istanbul ignore next\r\n if (propagate && this.props.parentMenu && this.props.parentMenu.props.parentSubmenu) {\r\n this.props.parentMenu.props.parentSubmenu.close(true);\r\n }\r\n };\r\n\r\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\r\n // istanbul ignore else\r\n if (this._menuButtonElement && this._menuButtonElement.style.visibility !== \"hidden\" && this.props.onHover) {\r\n this.props.onHover();\r\n }\r\n };\r\n\r\n private _handleClick = (event: any) => {\r\n event.stopPropagation();\r\n\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n\r\n // istanbul ignore else\r\n if (!isDisabled) {\r\n // istanbul ignore else\r\n if (this.props.onClick !== undefined)\r\n this.props.onClick(event);\r\n // istanbul ignore next\r\n if (this.props.opened)\r\n this.close();\r\n else\r\n this.select();\r\n }\r\n };\r\n\r\n private _handleClickGlobal = (event: any) => {\r\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\r\n this.setState((_prevState) => ({ opened: false }));\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"withOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;IAC5C,8HAA8H;IAC9H,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,+GAGG,UAAU,KAAK,GAAG,4BACtC,OAAO,qBACD,OAAO;;QAGvB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;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cnD,gBAAgB;0BACS,UAAU;QAcnC,gBAAgB;iCACiB,UAAU;QAO3C,gBAAgB;uCACuB,YAAY;QASnD,gBAAgB;qCACqB,YAAY;sEAaqB,cAAc,GAAG,IAAI;;;QAkB3F,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC"}
@@ -31,6 +31,7 @@ Component, defaultOnOutsideClick, useCapture = true, usePointerEvents = true) =>
31
31
  /** @internal */
32
32
  this.handleDocumentPointerDown = (e) => {
33
33
  this.isDownOutside = true;
34
+ // istanbul ignore else
34
35
  if (this.outsideClickContainerDiv) {
35
36
  // typically e.target test for instance of Node, but this is not working from pop out windows
36
37
  this.isDownOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target);
@@ -39,6 +40,7 @@ Component, defaultOnOutsideClick, useCapture = true, usePointerEvents = true) =>
39
40
  /** @internal */
40
41
  this.handleDocumentPointerUp = (e) => {
41
42
  let isUpOutside = true;
43
+ // istanbul ignore else
42
44
  if (this.outsideClickContainerDiv) {
43
45
  // typically e.target test for instance of Node, but this is not working from pop out windows
44
46
  isUpOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target);
@@ -81,6 +83,7 @@ Component, defaultOnOutsideClick, useCapture = true, usePointerEvents = true) =>
81
83
  }
82
84
  getParentDocument() {
83
85
  var _a, _b;
86
+ // istanbul ignore next
84
87
  return (_b = (_a = this.outsideClickContainerDiv) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
85
88
  }
86
89
  componentDidMount() {
@@ -1 +1 @@
1
- {"version":3,"file":"withOnOutsideClick.js","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAY/B;;GAEG;AACI,MAAM,kBAAkB,GAAG;AAChC,gEAAgE;AAChE,SAA8C,EAC9C,qBAAkD,EAClD,aAAsB,IAAI,EAC1B,mBAA4B,IAAI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CAAI,QAAQ,CAAC;QAClE,CAAC;QAEe,iBAAiB;YAC/B,MAAM,0BAA0B,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5D,IAAI,gBAAgB,EAAE;gBACpB,0BAA0B,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;gBACvG,0BAA0B,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;aACpG;;gBACC,0BAA0B,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAC/F,CAAC;QAED,gBAAgB;QACA,oBAAoB;YAClC,MAAM,0BAA0B,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5D,IAAI,gBAAgB,EAAE;gBACpB,0BAA0B,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;gBAC1G,0BAA0B,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;aACvG;;gBACC,0BAA0B,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAClG,CAAC;QAEe,MAAM;YACpB,MAAM,EAAE,cAAc,EAAE,8BAA8B,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,wDAAwD;YACzI,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAK,KAAuB,GAAI,CACtC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AA7GW,QAAA,kBAAkB,sBA6G7B","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 Common\r\n */\r\n\r\nimport * as React from \"react\";\r\n\r\n/** Properties for [[withOnOutsideClick]] React higher-order component\r\n * @public\r\n */\r\nexport interface WithOnOutsideClickProps {\r\n /** Outside click callback function */\r\n onOutsideClick?: (event: MouseEvent) => any;\r\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\r\n closeOnNestedPopupOutsideClick?: boolean;\r\n}\r\n\r\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\r\n * @public\r\n */\r\nexport const withOnOutsideClick = <ComponentProps extends {}>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Component: React.ComponentType<ComponentProps>,\r\n defaultOnOutsideClick?: (event: MouseEvent) => any,\r\n useCapture: boolean = true,\r\n usePointerEvents: boolean = true,\r\n) => {\r\n return class WithOnOutsideClick extends React.PureComponent<ComponentProps & WithOnOutsideClickProps> {\r\n /** @internal */\r\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\r\n /** @internal */\r\n public isDownOutside = false;\r\n\r\n /** @internal */\r\n public isInCorePopup(element: HTMLElement): boolean {\r\n if (element.nodeName === \"DIV\") {\r\n if (element.classList && element.classList.contains(\"core-popup\"))\r\n return true;\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n } else {\r\n // istanbul ignore else\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public onOutsideClick(e: MouseEvent) {\r\n // istanbul ignore else\r\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\r\n // istanbul ignore else\r\n if (!this.props.closeOnNestedPopupOutsideClick && this.isInCorePopup(e.target as HTMLElement))\r\n return;\r\n }\r\n\r\n if (this.props.onOutsideClick)\r\n return this.props.onOutsideClick(e);\r\n else if (defaultOnOutsideClick)\r\n return defaultOnOutsideClick(e);\r\n }\r\n\r\n /** @internal */\r\n public handleDocumentClick = (e: MouseEvent) => {\r\n if (!this.outsideClickContainerDiv || !(e.target instanceof Node) || this.outsideClickContainerDiv.contains(e.target))\r\n return;\r\n\r\n return this.onOutsideClick(e);\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerDown = (e: PointerEvent) => {\r\n this.isDownOutside = true;\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n this.isDownOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerUp = (e: PointerEvent) => {\r\n let isUpOutside = true;\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n isUpOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n\r\n const isOutsideClick = isUpOutside && this.isDownOutside;\r\n this.isDownOutside = false;\r\n isOutsideClick && this.onOutsideClick(e);\r\n };\r\n\r\n public handleOutsideClickContainerDivSet = (outsideClickContainerDiv: HTMLDivElement | null) => {\r\n this.outsideClickContainerDiv = outsideClickContainerDiv;\r\n };\r\n\r\n public getParentDocument() {\r\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\r\n }\r\n\r\n public override componentDidMount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.addEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.addEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.addEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.removeEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.removeEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.removeEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n public override render() {\r\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <div ref={this.handleOutsideClickContainerDivSet}>\r\n <Component {...props as ComponentProps} />\r\n </div>\r\n );\r\n }\r\n };\r\n};\r\n"]}
1
+ {"version":3,"file":"withOnOutsideClick.js","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,+BAA+B;AAY/B;;GAEG;AACI,MAAM,kBAAkB,GAAG;AAChC,gEAAgE;AAChE,SAA8C,EAC9C,qBAAkD,EAClD,aAAsB,IAAI,EAC1B,mBAA4B,IAAI,EAChC,EAAE;IACF,OAAO,MAAM,kBAAmB,SAAQ,KAAK,CAAC,aAAuD;QAA9F;;YACL,gBAAgB;YACT,6BAAwB,GAA2B,IAAI,CAAC;YAC/D,gBAAgB;YACT,kBAAa,GAAG,KAAK,CAAC;YAgC7B,gBAAgB;YACT,wBAAmB,GAAG,CAAC,CAAa,EAAE,EAAE;gBAC7C,IAAI,CAAC,IAAI,CAAC,wBAAwB,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;oBACnH,OAAO;gBAET,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAChC,CAAC,CAAC;YAEF,gBAAgB;YACT,8BAAyB,GAAG,CAAC,CAAe,EAAE,EAAE;gBACrD,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;gBAC1B,uBAAuB;gBACvB,IAAI,IAAI,CAAC,wBAAwB,EAAE;oBACjC,6FAA6F;oBAC7F,IAAI,CAAC,aAAa,GAAG,CAAC,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1G,0BAA0B,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;aACvG;;gBACC,0BAA0B,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAClG,CAAC;QAEe,MAAM;YACpB,MAAM,EAAE,cAAc,EAAE,8BAA8B,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,wDAAwD;YACzI,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAK,KAAuB,GAAI,CACtC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAhHW,QAAA,kBAAkB,sBAgH7B","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 Common\r\n */\r\n\r\nimport * as React from \"react\";\r\n\r\n/** Properties for [[withOnOutsideClick]] React higher-order component\r\n * @public\r\n */\r\nexport interface WithOnOutsideClickProps {\r\n /** Outside click callback function */\r\n onOutsideClick?: (event: MouseEvent) => any;\r\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\r\n closeOnNestedPopupOutsideClick?: boolean;\r\n}\r\n\r\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\r\n * @public\r\n */\r\nexport const withOnOutsideClick = <ComponentProps extends {}>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Component: React.ComponentType<ComponentProps>,\r\n defaultOnOutsideClick?: (event: MouseEvent) => any,\r\n useCapture: boolean = true,\r\n usePointerEvents: boolean = true,\r\n) => {\r\n return class WithOnOutsideClick extends React.PureComponent<ComponentProps & WithOnOutsideClickProps> {\r\n /** @internal */\r\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\r\n /** @internal */\r\n public isDownOutside = false;\r\n\r\n /** @internal */\r\n public isInCorePopup(element: HTMLElement): boolean {\r\n if (element.nodeName === \"DIV\") {\r\n if (element.classList && element.classList.contains(\"core-popup\"))\r\n return true;\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n } else {\r\n // istanbul ignore else\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public onOutsideClick(e: MouseEvent) {\r\n // istanbul ignore else\r\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\r\n // istanbul ignore else\r\n if (!this.props.closeOnNestedPopupOutsideClick && this.isInCorePopup(e.target as HTMLElement))\r\n return;\r\n }\r\n\r\n if (this.props.onOutsideClick)\r\n return this.props.onOutsideClick(e);\r\n else if (defaultOnOutsideClick)\r\n return defaultOnOutsideClick(e);\r\n }\r\n\r\n /** @internal */\r\n public handleDocumentClick = (e: MouseEvent) => {\r\n if (!this.outsideClickContainerDiv || !(e.target instanceof Node) || this.outsideClickContainerDiv.contains(e.target))\r\n return;\r\n\r\n return this.onOutsideClick(e);\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerDown = (e: PointerEvent) => {\r\n this.isDownOutside = true;\r\n // istanbul ignore else\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n this.isDownOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerUp = (e: PointerEvent) => {\r\n let isUpOutside = true;\r\n // istanbul ignore else\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n isUpOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n\r\n const isOutsideClick = isUpOutside && this.isDownOutside;\r\n this.isDownOutside = false;\r\n isOutsideClick && this.onOutsideClick(e);\r\n };\r\n\r\n public handleOutsideClickContainerDivSet = (outsideClickContainerDiv: HTMLDivElement | null) => {\r\n this.outsideClickContainerDiv = outsideClickContainerDiv;\r\n };\r\n\r\n public getParentDocument() {\r\n // istanbul ignore next\r\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\r\n }\r\n\r\n public override componentDidMount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.addEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.addEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.addEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.removeEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.removeEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.removeEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n public override render() {\r\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <div ref={this.handleOutsideClickContainerDivSet}>\r\n <Component {...props as ComponentProps} />\r\n </div>\r\n );\r\n }\r\n };\r\n};\r\n"]}
@@ -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,sBA0CpC"}
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,sBAgDpC"}
@@ -31,13 +31,17 @@ function Icon(props) {
31
31
  React.createElement(SvgSprite_1.SvgSprite, { src: svgSource })));
32
32
  const webComponentString = appui_abstract_1.IconSpecUtilities.getWebComponentSource(iconString);
33
33
  if (webComponentString) {
34
- const svgLoader = `<svg-loader src=${webComponentString}></svg-loader>`;
34
+ const svgLoader = `<svg-loader src="${webComponentString}"></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
37
  // if there is a default export, use it (likely esm), otherwise use the namespace
38
38
  // istanbul ignore next
39
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"] });
40
+ const sanitizerConfig = {
41
+ ALLOWED_TAGS: ["svg-loader"],
42
+ ADD_URI_SAFE_ATTR: webComponentString.startsWith("data:") ? ["src"] : [],
43
+ };
44
+ const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);
41
45
  // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
42
46
  // eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
43
47
  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,oEAAoD;AAiBpD;;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,EAAE;YACtB,MAAM,SAAS,GAAG,mBAAmB,kBAAkB,gBAAgB,CAAC;YACxE,MAAM,MAAM,GAAG,QAAQ,SAAS,QAAQ,CAAC;YACzC,6EAA6E;YAC7E,iFAAiF;YACjF,uBAAuB;YACvB,MAAM,SAAS,GAAG,mBAAS,aAAT,mBAAS,cAAT,mBAAS,GAAI,WAAW,CAAC;YAC3C,MAAM,mBAAmB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YACzF,iFAAiF;YACjF,+FAA+F;YAC/F,MAAM,gBAAgB,GAAG,6BAAK,uBAAuB,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAQ,CAAC;YAC/F,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}></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
+ {"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,oEAAoD;AAiBpD;;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,I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AS,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;AAhDD,oBAgDC","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}\"></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\r\n const sanitizerConfig = {\r\n ALLOWED_TAGS: [\"svg-loader\"],\r\n ADD_URI_SAFE_ATTR: webComponentString.startsWith(\"data:\") ? [\"src\"] : [],\r\n };\r\n\r\n const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);\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"]}
@@ -30,7 +30,7 @@ function ThemedSelect(props) {
30
30
  const noOptionLabel = React.useRef();
31
31
  const defaultOptionMessage = React.useCallback(() => {
32
32
  if (!noOptionLabel.current) {
33
- noOptionLabel.current = UiCore_1.UiCore.translate("reactelect.noSelectOption");
33
+ noOptionLabel.current = UiCore_1.UiCore.translate("reactselect.noSelectOption");
34
34
  }
35
35
  return noOptionLabel.current;
36
36
  }, [noOptionLabel]);
@@ -1 +1 @@
1
- {"version":3,"file":"ThemedSelect.js","sourceRoot":"","sources":["../../../../src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AAqB;MACpC,GAAG,KAAY,CAAC;IACjB,MAAM,YAAY,GAAG;QACnB,GAAG,KAAK,CAAC,MAAM;QACf,UAAU,EAAE,CAAC,IAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;KACjE,CAAC;IAEF,MAAM,MAAM,GAAG,IAAA,uCAAsB,EAAC,+BAA+B,CAAC,CAAC;IACvE,OAAO,CACL,6BAAK,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM;QAC1C,oBAAC,sBAAS,IACR,GAAG,EAAE,GAAG,EACR,eAAe,EAAC,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,YAAY,EAC9B,MAAM,EAAE,YAAY;YACpB,gEAAgE;YAChE,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,KACjD,UAAU,GACd,CACE,CACP,CAAC;AACJ,CAAC;AArCD,oCAqCC","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 Select\r\n */\r\n\r\nimport \"./themed-select.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport Component, { components } from \"react-select\";\r\nimport { formatGroupLabel, getOptionLabel, getOptionValue } from \"react-select/src/builtins\";\r\nimport { SelectComponentsConfig } from \"react-select/src/components/index\";\r\nimport { MenuProps } from \"react-select/src/components/Menu\";\r\nimport { ActionMeta, FocusEventHandler, InputActionMeta, KeyboardEventHandler, ValueType } from \"react-select/src/types\";\r\nimport { UiCore } from \"../UiCore\";\r\nimport { getCssVariableAsNumber } from \"../utils/getCssVariable\";\r\nimport { getParentSelector } from \"./modalHelper\";\r\n\r\n// cspell:ignore reactselect builtins\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow, @typescript-eslint/consistent-type-definitions, @typescript-eslint/array-type */\r\ntype FormatOptionLabelContext = \"menu\" | \"value\";\r\ntype FormatOptionLabelMeta = {\r\n context: FormatOptionLabelContext;\r\n inputValue: string;\r\n selectValue: ValueType<OptionType>;\r\n};\r\n\r\n/** OptionType for react-select 2.0 and above. which only accepts pairs of value & label strings\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport interface OptionType {\r\n value: any;\r\n label: string;\r\n}\r\n/** OptionsType to match label/value pair OptionType\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n*/\r\nexport type OptionsType = Array<OptionType>;\r\n\r\n/** ThemedSelectProps to control specific features of ThemedSelect\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport type ThemedSelectProps = {\r\n /* Aria label (for assistive tech) */\r\n \"aria-label\"?: string;\r\n /* HTML ID of an element that should be used as the label (for assistive tech) */\r\n \"aria-labelledby\"?: string;\r\n /* Focus the control when it is mounted */\r\n autoFocus?: boolean;\r\n /* Remove the currently focused option when the user presses backspace */\r\n backspaceRemovesValue?: boolean;\r\n /* Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) */\r\n blurInputOnSelect?: boolean;\r\n /* When the user reaches the top/bottom of the menu, prevent scroll on the scroll-parent */\r\n captureMenuScroll?: boolean;\r\n /* Sets a className attribute on the outer component */\r\n className?: string;\r\n /* Close the select menu when the user selects an option */\r\n closeMenuOnSelect?: boolean;\r\n /*\r\n If `true`, close the select menu when the user scrolls the document/body.\r\n\r\n If a function, takes a standard javascript `ScrollEvent` you return a boolean:\r\n\r\n `true` => The menu closes\r\n\r\n `false` => The menu stays open\r\n\r\n This is useful when you have a scrollable modal and want to portal the menu out,\r\n but want to avoid graphical issues.\r\n */\r\n closeMenuOnScroll?: boolean | EventListener;\r\n /*\r\n This complex object includes all the compositional components that are used\r\n in `react-select`. If you wish to overwrite a component, pass in an object\r\n with the appropriate namespace.\r\n\r\n If you only wish to restyle a component, we recommend using the `styles` prop\r\n instead. For a list of the components that can be passed in, and the shape\r\n that will be passed to them, see [the components docs](/components)\r\n */\r\n components?: SelectComponentsConfig<OptionType>;\r\n /* Whether the value of the select, e.g. SingleValue, should be displayed in the control. */\r\n controlShouldRenderValue?: boolean;\r\n /* Ff true, the menu is open immediately */\r\n defaultMenuIsOpen?: boolean;\r\n /* Value set in the control by default */\r\n defaultValue?: ValueType<OptionType>;\r\n /** Provides ability to return reference to the outer HTMLDivElement */\r\n divRef?: React.Ref<HTMLDivElement>;\r\n /* Clear all values when the user presses escape AND the menu is closed */\r\n escapeClearsValue?: boolean;\r\n /* Custom method to filter whether an option should be displayed in the menu */\r\n filterOption?: ((\r\n option: OptionType,\r\n rawInput: string,\r\n ) => boolean) | null;\r\n /*\r\n Formats group labels in the menu as React components\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n*/\r\n formatGroupLabel?: typeof formatGroupLabel;\r\n /* Formats option labels in the menu and control as React components */\r\n formatOptionLabel?: (optionType: OptionType, formatLabelMeta: FormatOptionLabelMeta) => React.ReactNode;\r\n /* Resolves option data to a string to be displayed as the label by components */\r\n getOptionLabel?: typeof getOptionLabel;\r\n /* Resolves option data to a string to compare options and specify value attributes */\r\n getOptionValue?: typeof getOptionValue;\r\n /* Hide the selected option from the menu */\r\n hideSelectedOptions?: boolean;\r\n /* The id to set on the SelectContainer component. */\r\n id?: string;\r\n /* The value of the search input */\r\n inputValue?: string;\r\n /* The id of the search input */\r\n inputId?: string;\r\n /* Define an id prefix for the select components e.g. {your-id}-value */\r\n instanceId?: number | string;\r\n /* Is the select value clearable */\r\n isClearable?: boolean;\r\n /* Is the select disabled */\r\n isDisabled?: boolean;\r\n /* Is the select in a state of loading (async) */\r\n isLoading?: boolean;\r\n /*\r\n Override the built-in logic to detect whether an option is disabled\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n */\r\n isOptionDisabled?: (option: OptionType, options: OptionsType) => boolean | false;\r\n /* Support multiple selected options */\r\n isMulti?: boolean;\r\n /* If true, menu will not be opened in a portal */\r\n isMenuFixed?: boolean;\r\n /* Is the select direction right-to-left */\r\n isRtl?: boolean;\r\n /* Whether to enable search functionality */\r\n isSearchable?: boolean;\r\n /* Minimum height of the menu before flipping */\r\n minMenuHeight?: number;\r\n /* Maximum height of the menu before scrolling */\r\n maxMenuHeight?: number;\r\n /* Whether the menu is open */\r\n menuIsOpen?: boolean;\r\n /* Whether to block scroll events when the menu is open */\r\n menuShouldBlockScroll?: boolean;\r\n /* Whether the menu should be scrolled into view when it opens */\r\n menuShouldScrollIntoView?: boolean;\r\n /* Name of the HTML Input (optional - without this, no input will be rendered) */\r\n name?: string;\r\n /* Text to display when there are no options */\r\n noOptionsMessage?: (obj: { inputValue: string }) => string | null;\r\n /* Handle blur events on the control */\r\n onBlur?: FocusEventHandler;\r\n /* Handle change events on the select */\r\n onChange?: (value: ValueType<OptionType>, action: ActionMeta<OptionType>) => void;\r\n /* Handle focus events on the control */\r\n onFocus?: FocusEventHandler;\r\n /* Handle change events on the input */\r\n onInputChange?: (newValue: string, actionMeta?: InputActionMeta) => void;\r\n /* Handle key down events on the select */\r\n onKeyDown?: KeyboardEventHandler;\r\n /* Handle the menu opening */\r\n onMenuOpen?: () => void;\r\n /* Handle the menu closing */\r\n onMenuClose?: () => void;\r\n /* Fired when the user scrolls to the top of the menu */\r\n onMenuScrollToTop?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Fired when the user scrolls to the bottom of the menu */\r\n onMenuScrollToBottom?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Allows control of whether the menu is opened when the Select is focused */\r\n openMenuOnFocus?: boolean;\r\n /* Allows control of whether the menu is opened when the Select is clicked */\r\n openMenuOnClick?: boolean;\r\n /* Array of options that populate the select menu */\r\n options: OptionsType;\r\n /* Number of options to jump in menu when page{up|down} keys are used */\r\n pageSize?: number;\r\n /* Placeholder for the select value */\r\n placeholder?: string;\r\n /** Provides ability to return reference to the ThemedSelect */\r\n ref?: React.Ref<Component>;\r\n /* Sets additional styling */\r\n styles?: React.CSSProperties;\r\n /* Sets the tabIndex attribute on the input */\r\n tabIndex?: string;\r\n /* Select the currently focused option when the user presses tab */\r\n tabSelectsValue?: boolean;\r\n /* The value of the select; reflected by the selected option */\r\n value?: ValueType<OptionType>;\r\n};\r\n\r\nconst ThemedMenu = (props: MenuProps<any>) => { // eslint-disable-line @typescript-eslint/naming-convention\r\n return (\r\n <div className=\"uicore-reactSelectTop\">\r\n <components.Menu {...props} />\r\n </div>\r\n );\r\n};\r\n/** ThemedSelect is a wrapper for react-select with iTwin.js UI theming applied\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function ThemedSelect(props: ThemedSelectProps) {\r\n const noOptionLabel = React.useRef<string | undefined>();\r\n const defaultOptionMessage = React.useCallback(() => {\r\n if (!noOptionLabel.current) {\r\n noOptionLabel.current = UiCore.translate(\"reactelect.noSelectOption\");\r\n }\r\n return noOptionLabel.current;\r\n }, [noOptionLabel]);\r\n const noOptionFunction = props.noOptionsMessage ?? defaultOptionMessage;\r\n const selectClassName = classnames(\"uicore-reactSelectTop\", props.className);\r\n const portalTarget = !!props.isMenuFixed ? undefined : getParentSelector();\r\n const {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n classNamePrefix, className, noOptionsMessage, menuPortalTarget, isMenuFixed, styles, components, divRef, ref,\r\n // eslint-disable-next-line comma-dangle\r\n ...otherProps // pass-through props\r\n } = props as any;\r\n const selectStyles = {\r\n ...props.styles,\r\n menuPortal: (base: React.CSSProperties) => ({ ...base, zIndex }),\r\n };\r\n\r\n const zIndex = getCssVariableAsNumber(\"--uicore-z-index-dialog-popup\");\r\n return (\r\n <div className={selectClassName} ref={divRef}>\r\n <Component\r\n ref={ref}\r\n classNamePrefix=\"react-select\"\r\n noOptionsMessage={noOptionFunction}\r\n menuPortalTarget={portalTarget}\r\n styles={selectStyles}\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n components={{ Menu: ThemedMenu, ...props.components }}\r\n {...otherProps}\r\n />\r\n </div>\r\n );\r\n}\r\n"]}
1
+ {"version":3,"file":"ThemedSelect.js","sourceRoot":"","sources":["../../../../src/core-react/select/ThemedSelect.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;;;AAEH,gCAA8B;AAC9B,2CAAoC;AACpC,+BAA+B;AAC/B,+CAAqD;AAKrD,sCAAmC;AACnC,4DAAiE;AACjE,+CAAkD;AAqLlD,MAAM,UAAU,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3C,OAAO,CACL,6BAAK,SAAS,EAAC,uBAAuB;QACpC,oBAAC,yBAAU,CAAC,IAAI,OAAK,KAAK,GAAI,CAC1B,CACP,CAAC;AACJ,CAAC,CAAC;AACF;;;GAGG;AACH,gEAAgE;AAChE,SAAgB,YAAY,CAAC,KAAwB;;IACnD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAsB,CAAC;IACzD,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAClD,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;YAC1B,aAAa,CAAC,OAAO,GAAG,eAAM,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;SACxE;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACpB,MAAM,gBAAgB,GAAG,MAAA,KAAK,CAAC,gBAAgB,mCAAI,oBAAoB,CAAC;IACxE,MAAM,eAAe,GAAG,IAAA,oBAAU,EAAC,uBAAuB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7E,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAA,+BAAiB,GAAE,CAAC;IAC3E,MAAM;IACJ,6DAA6D;IAC7D,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG;IAC5G,wCAAwC;IACxC,GAAG,UAAU,CAAC,qBAAqB;MACpC,GAAG,KAAY,CAAC;IACjB,MAAM,YAAY,GAAG;QACnB,GAAG,KAAK,CAAC,MAAM;QACf,UAAU,EAAE,CAAC,IAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;KACjE,CAAC;IAEF,MAAM,MAAM,GAAG,IAAA,uCAAsB,EAAC,+BAA+B,CAAC,CAAC;IACvE,OAAO,CACL,6BAAK,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM;QAC1C,oBAAC,sBAAS,IACR,GAAG,EAAE,GAAG,EACR,eAAe,EAAC,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,YAAY,EAC9B,MAAM,EAAE,YAAY;YACpB,gEAAgE;YAChE,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,KACjD,UAAU,GACd,CACE,CACP,CAAC;AACJ,CAAC;AArCD,oCAqCC","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 Select\r\n */\r\n\r\nimport \"./themed-select.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport Component, { components } from \"react-select\";\r\nimport { formatGroupLabel, getOptionLabel, getOptionValue } from \"react-select/src/builtins\";\r\nimport { SelectComponentsConfig } from \"react-select/src/components/index\";\r\nimport { MenuProps } from \"react-select/src/components/Menu\";\r\nimport { ActionMeta, FocusEventHandler, InputActionMeta, KeyboardEventHandler, ValueType } from \"react-select/src/types\";\r\nimport { UiCore } from \"../UiCore\";\r\nimport { getCssVariableAsNumber } from \"../utils/getCssVariable\";\r\nimport { getParentSelector } from \"./modalHelper\";\r\n\r\n// cspell:ignore reactselect builtins\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow, @typescript-eslint/consistent-type-definitions, @typescript-eslint/array-type */\r\ntype FormatOptionLabelContext = \"menu\" | \"value\";\r\ntype FormatOptionLabelMeta = {\r\n context: FormatOptionLabelContext;\r\n inputValue: string;\r\n selectValue: ValueType<OptionType>;\r\n};\r\n\r\n/** OptionType for react-select 2.0 and above. which only accepts pairs of value & label strings\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport interface OptionType {\r\n value: any;\r\n label: string;\r\n}\r\n/** OptionsType to match label/value pair OptionType\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n*/\r\nexport type OptionsType = Array<OptionType>;\r\n\r\n/** ThemedSelectProps to control specific features of ThemedSelect\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport type ThemedSelectProps = {\r\n /* Aria label (for assistive tech) */\r\n \"aria-label\"?: string;\r\n /* HTML ID of an element that should be used as the label (for assistive tech) */\r\n \"aria-labelledby\"?: string;\r\n /* Focus the control when it is mounted */\r\n autoFocus?: boolean;\r\n /* Remove the currently focused option when the user presses backspace */\r\n backspaceRemovesValue?: boolean;\r\n /* Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) */\r\n blurInputOnSelect?: boolean;\r\n /* When the user reaches the top/bottom of the menu, prevent scroll on the scroll-parent */\r\n captureMenuScroll?: boolean;\r\n /* Sets a className attribute on the outer component */\r\n className?: string;\r\n /* Close the select menu when the user selects an option */\r\n closeMenuOnSelect?: boolean;\r\n /*\r\n If `true`, close the select menu when the user scrolls the document/body.\r\n\r\n If a function, takes a standard javascript `ScrollEvent` you return a boolean:\r\n\r\n `true` => The menu closes\r\n\r\n `false` => The menu stays open\r\n\r\n This is useful when you have a scrollable modal and want to portal the menu out,\r\n but want to avoid graphical issues.\r\n */\r\n closeMenuOnScroll?: boolean | EventListener;\r\n /*\r\n This complex object includes all the compositional components that are used\r\n in `react-select`. If you wish to overwrite a component, pass in an object\r\n with the appropriate namespace.\r\n\r\n If you only wish to restyle a component, we recommend using the `styles` prop\r\n instead. For a list of the components that can be passed in, and the shape\r\n that will be passed to them, see [the components docs](/components)\r\n */\r\n components?: SelectComponentsConfig<OptionType>;\r\n /* Whether the value of the select, e.g. SingleValue, should be displayed in the control. */\r\n controlShouldRenderValue?: boolean;\r\n /* Ff true, the menu is open immediately */\r\n defaultMenuIsOpen?: boolean;\r\n /* Value set in the control by default */\r\n defaultValue?: ValueType<OptionType>;\r\n /** Provides ability to return reference to the outer HTMLDivElement */\r\n divRef?: React.Ref<HTMLDivElement>;\r\n /* Clear all values when the user presses escape AND the menu is closed */\r\n escapeClearsValue?: boolean;\r\n /* Custom method to filter whether an option should be displayed in the menu */\r\n filterOption?: ((\r\n option: OptionType,\r\n rawInput: string,\r\n ) => boolean) | null;\r\n /*\r\n Formats group labels in the menu as React components\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n*/\r\n formatGroupLabel?: typeof formatGroupLabel;\r\n /* Formats option labels in the menu and control as React components */\r\n formatOptionLabel?: (optionType: OptionType, formatLabelMeta: FormatOptionLabelMeta) => React.ReactNode;\r\n /* Resolves option data to a string to be displayed as the label by components */\r\n getOptionLabel?: typeof getOptionLabel;\r\n /* Resolves option data to a string to compare options and specify value attributes */\r\n getOptionValue?: typeof getOptionValue;\r\n /* Hide the selected option from the menu */\r\n hideSelectedOptions?: boolean;\r\n /* The id to set on the SelectContainer component. */\r\n id?: string;\r\n /* The value of the search input */\r\n inputValue?: string;\r\n /* The id of the search input */\r\n inputId?: string;\r\n /* Define an id prefix for the select components e.g. {your-id}-value */\r\n instanceId?: number | string;\r\n /* Is the select value clearable */\r\n isClearable?: boolean;\r\n /* Is the select disabled */\r\n isDisabled?: boolean;\r\n /* Is the select in a state of loading (async) */\r\n isLoading?: boolean;\r\n /*\r\n Override the built-in logic to detect whether an option is disabled\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n */\r\n isOptionDisabled?: (option: OptionType, options: OptionsType) => boolean | false;\r\n /* Support multiple selected options */\r\n isMulti?: boolean;\r\n /* If true, menu will not be opened in a portal */\r\n isMenuFixed?: boolean;\r\n /* Is the select direction right-to-left */\r\n isRtl?: boolean;\r\n /* Whether to enable search functionality */\r\n isSearchable?: boolean;\r\n /* Minimum height of the menu before flipping */\r\n minMenuHeight?: number;\r\n /* Maximum height of the menu before scrolling */\r\n maxMenuHeight?: number;\r\n /* Whether the menu is open */\r\n menuIsOpen?: boolean;\r\n /* Whether to block scroll events when the menu is open */\r\n menuShouldBlockScroll?: boolean;\r\n /* Whether the menu should be scrolled into view when it opens */\r\n menuShouldScrollIntoView?: boolean;\r\n /* Name of the HTML Input (optional - without this, no input will be rendered) */\r\n name?: string;\r\n /* Text to display when there are no options */\r\n noOptionsMessage?: (obj: { inputValue: string }) => string | null;\r\n /* Handle blur events on the control */\r\n onBlur?: FocusEventHandler;\r\n /* Handle change events on the select */\r\n onChange?: (value: ValueType<OptionType>, action: ActionMeta<OptionType>) => void;\r\n /* Handle focus events on the control */\r\n onFocus?: FocusEventHandler;\r\n /* Handle change events on the input */\r\n onInputChange?: (newValue: string, actionMeta?: InputActionMeta) => void;\r\n /* Handle key down events on the select */\r\n onKeyDown?: KeyboardEventHandler;\r\n /* Handle the menu opening */\r\n onMenuOpen?: () => void;\r\n /* Handle the menu closing */\r\n onMenuClose?: () => void;\r\n /* Fired when the user scrolls to the top of the menu */\r\n onMenuScrollToTop?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Fired when the user scrolls to the bottom of the menu */\r\n onMenuScrollToBottom?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Allows control of whether the menu is opened when the Select is focused */\r\n openMenuOnFocus?: boolean;\r\n /* Allows control of whether the menu is opened when the Select is clicked */\r\n openMenuOnClick?: boolean;\r\n /* Array of options that populate the select menu */\r\n options: OptionsType;\r\n /* Number of options to jump in menu when page{up|down} keys are used */\r\n pageSize?: number;\r\n /* Placeholder for the select value */\r\n placeholder?: string;\r\n /** Provides ability to return reference to the ThemedSelect */\r\n ref?: React.Ref<Component>;\r\n /* Sets additional styling */\r\n styles?: React.CSSProperties;\r\n /* Sets the tabIndex attribute on the input */\r\n tabIndex?: string;\r\n /* Select the currently focused option when the user presses tab */\r\n tabSelectsValue?: boolean;\r\n /* The value of the select; reflected by the selected option */\r\n value?: ValueType<OptionType>;\r\n};\r\n\r\nconst ThemedMenu = (props: MenuProps<any>) => { // eslint-disable-line @typescript-eslint/naming-convention\r\n return (\r\n <div className=\"uicore-reactSelectTop\">\r\n <components.Menu {...props} />\r\n </div>\r\n );\r\n};\r\n/** ThemedSelect is a wrapper for react-select with iTwin.js UI theming applied\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function ThemedSelect(props: ThemedSelectProps) {\r\n const noOptionLabel = React.useRef<string | undefined>();\r\n const defaultOptionMessage = React.useCallback(() => {\r\n if (!noOptionLabel.current) {\r\n noOptionLabel.current = UiCore.translate(\"reactselect.noSelectOption\");\r\n }\r\n return noOptionLabel.current;\r\n }, [noOptionLabel]);\r\n const noOptionFunction = props.noOptionsMessage ?? defaultOptionMessage;\r\n const selectClassName = classnames(\"uicore-reactSelectTop\", props.className);\r\n const portalTarget = !!props.isMenuFixed ? undefined : getParentSelector();\r\n const {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n classNamePrefix, className, noOptionsMessage, menuPortalTarget, isMenuFixed, styles, components, divRef, ref,\r\n // eslint-disable-next-line comma-dangle\r\n ...otherProps // pass-through props\r\n } = props as any;\r\n const selectStyles = {\r\n ...props.styles,\r\n menuPortal: (base: React.CSSProperties) => ({ ...base, zIndex }),\r\n };\r\n\r\n const zIndex = getCssVariableAsNumber(\"--uicore-z-index-dialog-popup\");\r\n return (\r\n <div className={selectClassName} ref={divRef}>\r\n <Component\r\n ref={ref}\r\n classNamePrefix=\"react-select\"\r\n noOptionsMessage={noOptionFunction}\r\n menuPortalTarget={portalTarget}\r\n styles={selectStyles}\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n components={{ Menu: ThemedMenu, ...props.components }}\r\n {...otherProps}\r\n />\r\n </div>\r\n );\r\n}\r\n"]}
@@ -1 +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;CAwBtB"}
1
+ {"version":3,"file":"IconWebComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":"AAMA;;GAEG;AAOH;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;YACjC,iBAAiB;YAKjB,OAAO;CAmDtB"}
@@ -13,6 +13,7 @@ exports.IconWebComponent = void 0;
13
13
  const appui_abstract_1 = require("@itwin/appui-abstract");
14
14
  const core_bentley_1 = require("@itwin/core-bentley");
15
15
  const UiCore_1 = require("../UiCore");
16
+ const dompurify_1 = require("dompurify"), DOMPurifyNS = dompurify_1;
16
17
  /**
17
18
  * IconWebComponent loads icon from an svg path
18
19
  */
@@ -25,7 +26,27 @@ class IconWebComponent extends HTMLElement {
25
26
  // if svg was already appended don't request it again
26
27
  if (this.childNodes.length)
27
28
  return;
28
- await fetch(this.getAttribute("src") || "")
29
+ const src = this.getAttribute("src") || "";
30
+ if (src.startsWith("data:")) {
31
+ const dataUriParts = src.split(",");
32
+ if (dataUriParts.length !== 2 || "data:image/svg+xml;base64" !== dataUriParts[0]) {
33
+ core_bentley_1.Logger.logError(UiCore_1.UiCore.loggerCategory(this), "Unable to load icon.");
34
+ }
35
+ // the esm build of dompurify has a default import but the cjs build does not
36
+ // if there is a default export, use it (likely esm), otherwise use the namespace
37
+ // istanbul ignore next
38
+ const sanitizer = dompurify_1.default !== null && dompurify_1.default !== void 0 ? dompurify_1.default : DOMPurifyNS;
39
+ // eslint-disable-next-line deprecation/deprecation
40
+ const sanitizedSvg = sanitizer.sanitize(atob(dataUriParts[1]));
41
+ const parsedSvg = new window.DOMParser().parseFromString(sanitizedSvg, "text/xml");
42
+ const errorNode = parsedSvg.querySelector("parsererror");
43
+ if (errorNode || "svg" !== parsedSvg.documentElement.nodeName.toLowerCase()) {
44
+ throw new appui_abstract_1.UiError(UiCore_1.UiCore.loggerCategory(this), "Unable to load icon.");
45
+ }
46
+ !this.childNodes.length && this.append(parsedSvg.documentElement);
47
+ return;
48
+ }
49
+ await fetch(src)
29
50
  .catch((_error) => {
30
51
  core_bentley_1.Logger.logError(UiCore_1.UiCore.loggerCategory(this), "Unable to load icon.");
31
52
  })
@@ -1 +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,qDAAqD;QACrD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM;YACxB,OAAO;QACT,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,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,CAAC;CACF;AA9BD,4CA8BC","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 // if svg was already appended don't request it again\r\n if (this.childNodes.length)\r\n return;\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.childNodes.length && this.append(data.documentElement));\r\n }\r\n}\r\n"]}
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;AACnC,oEAAoD;AAEpD;;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,qDAAqD;QACrD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM;YACxB,OAAO;QAET,MAAM,GAAG,GAAG,IAAI,CAAC,YAAY,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,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,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,CAAC;CACF;AAzDD,4CAyDC","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\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\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 // if svg was already appended don't request it again\r\n if (this.childNodes.length)\r\n return;\r\n\r\n const src = this.getAttribute(\"src\") || \"\";\r\n\r\n if (src.startsWith(\"data:\")) {\r\n const dataUriParts = src.split(\",\");\r\n\r\n if (dataUriParts.length !== 2 || \"data:image/svg+xml;base64\" !== dataUriParts[0]) {\r\n Logger.logError(UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n\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 // eslint-disable-next-line deprecation/deprecation\r\n const sanitizedSvg = sanitizer.sanitize(atob(dataUriParts[1]));\r\n\r\n const parsedSvg = new window.DOMParser().parseFromString(sanitizedSvg, \"text/xml\");\r\n const errorNode = parsedSvg.querySelector(\"parsererror\");\r\n if (errorNode || \"svg\" !== parsedSvg.documentElement.nodeName.toLowerCase()) {\r\n throw new UiError (UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n\r\n !this.childNodes.length && this.append(parsedSvg.documentElement);\r\n return;\r\n }\r\n\r\n await fetch(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.childNodes.length && this.append(data.documentElement));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getCssVariable.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAKtF;AAGD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAM9F"}
1
+ {"version":3,"file":"getCssVariable.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAKtF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAM9F"}
@@ -8,7 +8,6 @@
8
8
  */
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.getCssVariableAsNumber = exports.getCssVariable = void 0;
11
- /* istanbul ignore next */
12
11
  /** Get CSS variable
13
12
  * @public
14
13
  */
@@ -19,7 +18,6 @@ function getCssVariable(variableName, htmlElement) {
19
18
  return cssVal;
20
19
  }
21
20
  exports.getCssVariable = getCssVariable;
22
- /* istanbul ignore next */
23
21
  /** Get CSS variable as number
24
22
  * @public
25
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getCssVariable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,0BAA0B;AAC1B;;GAEG;AACH,SAAgB,cAAc,CAAC,YAAoB,EAAE,WAAyB;IAC5E,MAAM,OAAO,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,eAAe,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AALD,wCAKC;AAED,0BAA0B;AAC1B;;GAEG;AACH,SAAgB,sBAAsB,CAAC,YAAoB,EAAE,WAAyB;IACpF,IAAI,SAAS,GAAW,GAAG,CAAC;IAC5B,MAAM,SAAS,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,IAAI,SAAS;QACX,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,wDAMC","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/* istanbul ignore next */\r\n/** Get CSS variable\r\n * @public\r\n */\r\nexport function getCssVariable(variableName: string, htmlElement?: HTMLElement): string {\r\n const element = htmlElement ?? document.documentElement;\r\n const cssStyles = getComputedStyle(element, null);\r\n const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();\r\n return cssVal;\r\n}\r\n\r\n/* istanbul ignore next */\r\n/** Get CSS variable as number\r\n * @public\r\n */\r\nexport function getCssVariableAsNumber(variableName: string, htmlElement?: HTMLElement): number {\r\n let cssValNum: number = NaN;\r\n const cssValStr = getCssVariable(variableName, htmlElement);\r\n if (cssValStr)\r\n cssValNum = parseFloat(cssValStr);\r\n return cssValNum;\r\n}\r\n"]}
1
+ {"version":3,"file":"getCssVariable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;GAEG;AACH,SAAgB,cAAc,CAAC,YAAoB,EAAE,WAAyB;IAC5E,MAAM,OAAO,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,eAAe,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AALD,wCAKC;AAED;;GAEG;AACH,SAAgB,sBAAsB,CAAC,YAAoB,EAAE,WAAyB;IACpF,IAAI,SAAS,GAAW,GAAG,CAAC;IAC5B,MAAM,SAAS,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,IAAI,SAAS;QACX,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,wDAMC","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/** Get CSS variable\r\n * @public\r\n */\r\nexport function getCssVariable(variableName: string, htmlElement?: HTMLElement): string {\r\n const element = htmlElement ?? document.documentElement;\r\n const cssStyles = getComputedStyle(element, null);\r\n const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();\r\n return cssVal;\r\n}\r\n\r\n/** Get CSS variable as number\r\n * @public\r\n */\r\nexport function getCssVariableAsNumber(variableName: string, htmlElement?: HTMLElement): number {\r\n let cssValNum: number = NaN;\r\n const cssValStr = getCssVariable(variableName, htmlElement);\r\n if (cssValStr)\r\n cssValNum = parseFloat(cssValStr);\r\n return cssValNum;\r\n}\r\n"]}
@@ -35,7 +35,7 @@ $uicore-internal-z-index-layers: view-overlay,
35
35
  $uicore-z-index-step: 1000;
36
36
 
37
37
  @function uicore-internal-get-next-z-index-step($counter) {
38
- @return $counter +$uicore-z-index-step;
38
+ @return $counter + $uicore-z-index-step;
39
39
  }
40
40
 
41
41
  $uicore-internal-z-index-layer-map: uicore-map-from-array-with-result-arg($uicore-internal-z-index-layers, get-function(uicore-internal-get-next-z-index-step), 0);
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import * as React from "react";
9
9
  import classnames from "classnames";
10
- import { ConditionalBooleanValue } from "@itwin/appui-abstract";
10
+ import { ConditionalBooleanValue, ConditionalStringValue } from "@itwin/appui-abstract";
11
11
  import { ContextMenu } from "./ContextMenu";
12
12
  import { ContextMenuDirection } from "./ContextMenuDirection";
13
13
  import { TildeFinder } from "./TildeFinder";
@@ -103,7 +103,7 @@ export class ContextSubMenu extends React.Component {
103
103
  // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events
104
104
  React.createElement("div", { className: classnames("core-context-submenu", ContextMenu.getCSSClassNameFromDirection(renderDirection), className), onMouseOver: this._handleMouseOver, ref: (el) => { this._subMenuElement = el; }, "data-testid": "core-context-submenu", ...props },
105
105
  React.createElement("div", { onClick: this._handleClick, ref: (el) => { this._menuButtonElement = el; }, className: classnames("core-context-menu-item", "core-context-submenu-container", isDisabled && "core-context-menu-disabled", isHidden && "core-context-menu-hidden", isSelected && "core-context-menu-is-selected"), "data-testid": "core-context-submenu-container", role: "menuitem", tabIndex: isSelected ? 0 : -1, "aria-disabled": isDisabled, "aria-hidden": isHidden, "aria-haspopup": true },
106
- React.createElement("div", { className: classnames("core-context-menu-icon", "icon", icon) }),
106
+ React.createElement("div", { className: classnames("core-context-menu-icon", "icon", icon instanceof ConditionalStringValue && icon.value, typeof icon === "string" && icon) }),
107
107
  React.createElement("div", { className: "core-context-menu-content" }, this._parsedLabel),
108
108
  React.createElement("div", { className: classnames("core-context-submenu-arrow", "icon", "icon-caret-right") }),
109
109
  badge &&
@@ -1 +1 @@
1
- {"version":3,"file":"ContextSubMenu.js","sourceR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,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,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 ContextMenu\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\r\nimport { ContextMenuItemProps } from \"./ContextMenuItem\";\r\nimport { ContextMenu, ContextMenuProps } from \"./ContextMenu\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\r\nimport { TildeFinder } from \"./TildeFinder\";\r\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\r\n\r\n/** Properties for the [[ContextSubMenu]] component\r\n * @public\r\n */\r\nexport interface ContextSubMenuProps extends Omit<ContextMenuItemProps, \"label\">, Omit<ContextMenuProps, \"label\">, CommonProps {\r\n /** Text/jsx to display in the list item */\r\n label: string | JSX.Element;\r\n /** @internal */\r\n onHotKeyParsed?: (hotKey: string) => void;\r\n}\r\n\r\n/** @internal */\r\ninterface ContextSubMenuState {\r\n opened: boolean;\r\n direction: ContextMenuDirection;\r\n hotKey?: string;\r\n}\r\n\r\n/**\r\n * Submenu wrapper class for use within a [[ContextMenu]] component.\r\n * @public\r\n */\r\nexport class ContextSubMenu extends React.Component<ContextSubMenuProps, ContextSubMenuState> {\r\n private _menuElement: ContextMenu | null = null;\r\n private _subMenuElement: HTMLElement | null = null;\r\n private _menuButtonElement: HTMLElement | null = null;\r\n\r\n private _lastLabel: React.ReactNode;\r\n private _parsedLabel: React.ReactNode;\r\n\r\n public static defaultProps: Partial<ContextSubMenuProps> = {\r\n direction: ContextMenuDirection.BottomRight,\r\n disabled: false,\r\n hidden: false,\r\n autoflip: true,\r\n isSelected: false,\r\n selectedIndex: 0,\r\n };\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<ContextSubMenuState>;\r\n constructor(props: ContextSubMenuProps) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n direction: props.direction!,\r\n };\r\n }\r\n\r\n public override render(): JSX.Element {\r\n const {\r\n label,\r\n opened, direction, onOutsideClick, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu, parentSubmenu, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n onSelect, icon, disabled, hidden, onHover, isSelected, onHotKeyParsed, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n children, onClick, className, badgeType, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n const contextMenuProps = { onOutsideClick, onSelect, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu };\r\n const badge = BadgeUtilities.getComponentForBadgeType(badgeType);\r\n const renderDirection = this.state.direction;\r\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(hidden);\r\n\r\n if (this._lastLabel !== label) {\r\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\r\n this._lastLabel = label;\r\n }\r\n return (\r\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\r\n <div className={classnames(\"core-context-submenu\", ContextMenu.getCSSClassNameFromDirection(renderDirection), className)}\r\n onMouseOver={this._handleMouseOver}\r\n ref={(el) => { this._subMenuElement = el; }}\r\n data-testid=\"core-context-submenu\"\r\n {...props} >\r\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\r\n <div\r\n onClick={this._handleClick}\r\n ref={(el) => { this._menuButtonElement = el; }}\r\n className={classnames(\"core-context-menu-item\",\r\n \"core-context-submenu-container\",\r\n isDisabled && \"core-context-menu-disabled\",\r\n isHidden && \"core-context-menu-hidden\",\r\n isSelected && \"core-context-menu-is-selected\")}\r\n data-testid=\"core-context-submenu-container\"\r\n role=\"menuitem\"\r\n tabIndex={isSelected ? 0 : -1}\r\n aria-disabled={isDisabled}\r\n aria-hidden={isHidden}\r\n aria-haspopup={true}\r\n >\r\n <div className={classnames(\"core-context-menu-icon\", \"icon\", icon)} />\r\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\r\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\", \"icon-caret-right\")} />\r\n {badge &&\r\n <div className=\"core-context-menu-badge\">\r\n {badge}\r\n </div>\r\n }\r\n </div>\r\n <ContextMenu\r\n ref={(el) => { this._menuElement = el; }}\r\n className=\"core-context-submenu-popup\"\r\n opened={this.state.opened}\r\n direction={renderDirection}\r\n parentSubmenu={this}\r\n {...contextMenuProps} >\r\n {children}\r\n </ContextMenu>\r\n </div>\r\n );\r\n }\r\n\r\n public override componentDidMount() {\r\n document.addEventListener(\"click\", this._handleClickGlobal);\r\n this._updateHotkey(this.props.label);\r\n\r\n this.checkRenderDirection();\r\n }\r\n\r\n public override componentWillUnmount() {\r\n document.removeEventListener(\"click\", this._handleClickGlobal);\r\n }\r\n\r\n public override componentDidUpdate(prevProps: ContextSubMenuProps, prevState: ContextSubMenuState) {\r\n const direction = this.props.direction!;\r\n if ((this.state.opened !== prevState.opened && direction !== this.state.direction) || prevProps.direction !== direction)\r\n this.checkRenderDirection();\r\n if (this.props.label !== prevProps.label) {\r\n this._updateHotkey(this.props.label);\r\n }\r\n }\r\n\r\n private getWindow() {\r\n const el = this._subMenuElement;\r\n const parentDocument = el!.ownerDocument;\r\n return parentDocument.defaultView;\r\n }\r\n\r\n private checkRenderDirection() {\r\n const { autoflip } = this.props;\r\n const parentWindow = this.getWindow();\r\n let renderDirection = this.state.direction;\r\n // istanbul ignore else\r\n if (parentWindow && autoflip && this._menuElement) {\r\n const menuRect = this._menuElement.getRect();\r\n renderDirection = ContextMenu.autoFlip(renderDirection, menuRect, parentWindow.innerWidth, parentWindow.innerHeight);\r\n // istanbul ignore next\r\n if (renderDirection !== this.state.direction)\r\n this.setState({ direction: renderDirection });\r\n }\r\n }\r\n\r\n private _updateHotkey = (node: React.ReactNode) => {\r\n let hotKey: string | undefined;\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\r\n if (!isDisabled && !isHidden)\r\n hotKey = TildeFinder.findAfterTilde(node).character;\r\n else\r\n hotKey = undefined;\r\n if (hotKey && hotKey !== this.state.hotKey) {\r\n this.setState({ hotKey });\r\n if (this.props.onHotKeyParsed)\r\n this.props.onHotKeyParsed(hotKey);\r\n }\r\n };\r\n\r\n public select = () => {\r\n this.setState({ opened: true }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.focus();\r\n if (this.props.onSelect !== undefined)\r\n this.props.onSelect(undefined);\r\n });\r\n };\r\n\r\n public close = (propagate?: boolean) => {\r\n this.setState({ opened: false }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.blur();\r\n });\r\n // istanbul ignore next\r\n if (propagate && this.props.parentMenu && this.props.parentMenu.props.parentSubmenu) {\r\n this.props.parentMenu.props.parentSubmenu.close(true);\r\n }\r\n };\r\n\r\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\r\n // istanbul ignore else\r\n if (this._menuButtonElement && this._menuButtonElement.style.visibility !== \"hidden\" && this.props.onHover) {\r\n this.props.onHover();\r\n }\r\n };\r\n\r\n private _handleClick = (event: any) => {\r\n event.stopPropagation();\r\n\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n\r\n // istanbul ignore else\r\n if (!isDisabled) {\r\n // istanbul ignore else\r\n if (this.props.onClick !== undefined)\r\n this.props.onClick(event);\r\n // istanbul ignore next\r\n if (this.props.opened)\r\n this.close();\r\n else\r\n this.select();\r\n }\r\n };\r\n\r\n private _handleClickGlobal = (event: any) => {\r\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\r\n this.setState((_prevState) => ({ opened: false }));\r\n };\r\n}\r\n"]}
1
+ {"version":3,"file":"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;AAtHa,2BAAY,GAAiC;IACzD,SAAS,EAAE,oBAAoB,CAAC,WAAW;IAC3C,QAAQ,EAAE,KAAK;IACf,MAAM,EAAE,KAAK;IACb,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,KAAK;IACjB,aAAa,EAAE,CAAC;CACjB,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 ContextMenu\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport classnames from \"classnames\";\r\nimport { ConditionalBooleanValue, ConditionalStringValue } from \"@itwin/appui-abstract\";\r\nimport { ContextMenuItemProps } from \"./ContextMenuItem\";\r\nimport { ContextMenu, ContextMenuProps } from \"./ContextMenu\";\r\nimport { CommonProps } from \"../utils/Props\";\r\nimport { ContextMenuDirection } from \"./ContextMenuDirection\";\r\nimport { TildeFinder } from \"./TildeFinder\";\r\nimport { BadgeUtilities } from \"../badge/BadgeUtilities\";\r\n\r\n/** Properties for the [[ContextSubMenu]] component\r\n * @public\r\n */\r\nexport interface ContextSubMenuProps extends Omit<ContextMenuItemProps, \"label\">, Omit<ContextMenuProps, \"label\">, CommonProps {\r\n /** Text/jsx to display in the list item */\r\n label: string | JSX.Element;\r\n /** @internal */\r\n onHotKeyParsed?: (hotKey: string) => void;\r\n}\r\n\r\n/** @internal */\r\ninterface ContextSubMenuState {\r\n opened: boolean;\r\n direction: ContextMenuDirection;\r\n hotKey?: string;\r\n}\r\n\r\n/**\r\n * Submenu wrapper class for use within a [[ContextMenu]] component.\r\n * @public\r\n */\r\nexport class ContextSubMenu extends React.Component<ContextSubMenuProps, ContextSubMenuState> {\r\n private _menuElement: ContextMenu | null = null;\r\n private _subMenuElement: HTMLElement | null = null;\r\n private _menuButtonElement: HTMLElement | null = null;\r\n\r\n private _lastLabel: React.ReactNode;\r\n private _parsedLabel: React.ReactNode;\r\n\r\n public static defaultProps: Partial<ContextSubMenuProps> = {\r\n direction: ContextMenuDirection.BottomRight,\r\n disabled: false,\r\n hidden: false,\r\n autoflip: true,\r\n isSelected: false,\r\n selectedIndex: 0,\r\n };\r\n\r\n /** @internal */\r\n public override readonly state: Readonly<ContextSubMenuState>;\r\n constructor(props: ContextSubMenuProps) {\r\n super(props);\r\n this.state = {\r\n opened: false,\r\n direction: props.direction!,\r\n };\r\n }\r\n\r\n public override render(): JSX.Element {\r\n const {\r\n label,\r\n opened, direction, onOutsideClick, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu, parentSubmenu, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n onSelect, icon, disabled, hidden, onHover, isSelected, onHotKeyParsed, // eslint-disable-line @typescript-eslint/no-unused-vars\r\n children, onClick, className, badgeType, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n const contextMenuProps = { onOutsideClick, onSelect, onEsc, autoflip, edgeLimit, selectedIndex, floating, parentMenu };\r\n const badge = BadgeUtilities.getComponentForBadgeType(badgeType);\r\n const renderDirection = this.state.direction;\r\n const isDisabled = ConditionalBooleanValue.getValue(disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(hidden);\r\n\r\n if (this._lastLabel !== label) {\r\n this._parsedLabel = TildeFinder.findAfterTilde(label).node;\r\n this._lastLabel = label;\r\n }\r\n return (\r\n // eslint-disable-next-line jsx-a11y/mouse-events-have-key-events\r\n <div className={classnames(\"core-context-submenu\", ContextMenu.getCSSClassNameFromDirection(renderDirection), className)}\r\n onMouseOver={this._handleMouseOver}\r\n ref={(el) => { this._subMenuElement = el; }}\r\n data-testid=\"core-context-submenu\"\r\n {...props} >\r\n {/* eslint-disable-next-line jsx-a11y/click-events-have-key-events */}\r\n <div\r\n onClick={this._handleClick}\r\n ref={(el) => { this._menuButtonElement = el; }}\r\n className={classnames(\"core-context-menu-item\",\r\n \"core-context-submenu-container\",\r\n isDisabled && \"core-context-menu-disabled\",\r\n isHidden && \"core-context-menu-hidden\",\r\n isSelected && \"core-context-menu-is-selected\")}\r\n data-testid=\"core-context-submenu-container\"\r\n role=\"menuitem\"\r\n tabIndex={isSelected ? 0 : -1}\r\n aria-disabled={isDisabled}\r\n aria-hidden={isHidden}\r\n aria-haspopup={true}\r\n >\r\n <div className={classnames(\"core-context-menu-icon\", \"icon\", icon instanceof ConditionalStringValue && icon.value, typeof icon === \"string\" && icon)} />\r\n <div className={\"core-context-menu-content\"}>{this._parsedLabel}</div>\r\n <div className={classnames(\"core-context-submenu-arrow\", \"icon\", \"icon-caret-right\")} />\r\n {badge &&\r\n <div className=\"core-context-menu-badge\">\r\n {badge}\r\n </div>\r\n }\r\n </div>\r\n <ContextMenu\r\n ref={(el) => { this._menuElement = el; }}\r\n className=\"core-context-submenu-popup\"\r\n opened={this.state.opened}\r\n direction={renderDirection}\r\n parentSubmenu={this}\r\n {...contextMenuProps} >\r\n {children}\r\n </ContextMenu>\r\n </div>\r\n );\r\n }\r\n\r\n public override componentDidMount() {\r\n document.addEventListener(\"click\", this._handleClickGlobal);\r\n this._updateHotkey(this.props.label);\r\n\r\n this.checkRenderDirection();\r\n }\r\n\r\n public override componentWillUnmount() {\r\n document.removeEventListener(\"click\", this._handleClickGlobal);\r\n }\r\n\r\n public override componentDidUpdate(prevProps: ContextSubMenuProps, prevState: ContextSubMenuState) {\r\n const direction = this.props.direction!;\r\n if ((this.state.opened !== prevState.opened && direction !== this.state.direction) || prevProps.direction !== direction)\r\n this.checkRenderDirection();\r\n if (this.props.label !== prevProps.label) {\r\n this._updateHotkey(this.props.label);\r\n }\r\n }\r\n\r\n private getWindow() {\r\n const el = this._subMenuElement;\r\n const parentDocument = el!.ownerDocument;\r\n return parentDocument.defaultView;\r\n }\r\n\r\n private checkRenderDirection() {\r\n const { autoflip } = this.props;\r\n const parentWindow = this.getWindow();\r\n let renderDirection = this.state.direction;\r\n // istanbul ignore else\r\n if (parentWindow && autoflip && this._menuElement) {\r\n const menuRect = this._menuElement.getRect();\r\n renderDirection = ContextMenu.autoFlip(renderDirection, menuRect, parentWindow.innerWidth, parentWindow.innerHeight);\r\n // istanbul ignore next\r\n if (renderDirection !== this.state.direction)\r\n this.setState({ direction: renderDirection });\r\n }\r\n }\r\n\r\n private _updateHotkey = (node: React.ReactNode) => {\r\n let hotKey: string | undefined;\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n const isHidden = ConditionalBooleanValue.getValue(this.props.hidden);\r\n if (!isDisabled && !isHidden)\r\n hotKey = TildeFinder.findAfterTilde(node).character;\r\n else\r\n hotKey = undefined;\r\n if (hotKey && hotKey !== this.state.hotKey) {\r\n this.setState({ hotKey });\r\n if (this.props.onHotKeyParsed)\r\n this.props.onHotKeyParsed(hotKey);\r\n }\r\n };\r\n\r\n public select = () => {\r\n this.setState({ opened: true }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.focus();\r\n if (this.props.onSelect !== undefined)\r\n this.props.onSelect(undefined);\r\n });\r\n };\r\n\r\n public close = (propagate?: boolean) => {\r\n this.setState({ opened: false }, () => {\r\n // istanbul ignore else\r\n if (this._menuElement)\r\n this._menuElement.blur();\r\n });\r\n // istanbul ignore next\r\n if (propagate && this.props.parentMenu && this.props.parentMenu.props.parentSubmenu) {\r\n this.props.parentMenu.props.parentSubmenu.close(true);\r\n }\r\n };\r\n\r\n private _handleMouseOver = (_event: React.MouseEvent<HTMLDivElement>) => {\r\n // istanbul ignore else\r\n if (this._menuButtonElement && this._menuButtonElement.style.visibility !== \"hidden\" && this.props.onHover) {\r\n this.props.onHover();\r\n }\r\n };\r\n\r\n private _handleClick = (event: any) => {\r\n event.stopPropagation();\r\n\r\n const isDisabled = ConditionalBooleanValue.getValue(this.props.disabled);\r\n\r\n // istanbul ignore else\r\n if (!isDisabled) {\r\n // istanbul ignore else\r\n if (this.props.onClick !== undefined)\r\n this.props.onClick(event);\r\n // istanbul ignore next\r\n if (this.props.opened)\r\n this.close();\r\n else\r\n this.select();\r\n }\r\n };\r\n\r\n private _handleClickGlobal = (event: any) => {\r\n if (this._subMenuElement && !this._subMenuElement.contains(event.target))\r\n this.setState((_prevState) => ({ opened: false }));\r\n };\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"withOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;IAC5C,8HAA8H;IAC9H,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,+GAGG,UAAU,KAAK,GAAG,4BACtC,OAAO,qBACD,OAAO;;QAGvB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAcnD,gBAAgB;0BACS,UAAU;QAcnC,gBAAgB;iCACiB,UAAU;QAO3C,gBAAgB;uCACuB,YAAY;QAQnD,gBAAgB;qCACqB,YAAY;sEAYqB,cAAc,GAAG,IAAI;;;QAiB3F,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;QAlFhB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAcnD,gBAAgB;0BACS,UAAU;QAcnC,gBAAgB;iCACiB,UAAU;QAO3C,gBAAgB;uCACuB,YAAY;QAQnD,gBAAgB;qCACqB,YAAY;sEAYqB,cAAc,GAAG,IAAI;;;QAiB3F,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC"}
1
+ {"version":3,"file":"withOnOutsideClick.d.ts","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC,sCAAsC;IACtC,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,GAAG,CAAC;IAC5C,8HAA8H;IAC9H,8BAA8B,CAAC,EAAE,OAAO,CAAC;CAC1C;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB,+GAGG,UAAU,KAAK,GAAG,4BACtC,OAAO,qBACD,OAAO;;QAGvB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAcnD,gBAAgB;0BACS,UAAU;QAcnC,gBAAgB;iCACiB,UAAU;QAO3C,gBAAgB;uCACuB,YAAY;QASnD,gBAAgB;qCACqB,YAAY;sEAaqB,cAAc,GAAG,IAAI;;;QAkB3F,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;QArFhB,gBAAgB;;QAEhB,gBAAgB;;QAGhB,gBAAgB;+BACc,WAAW,GAAG,OAAO;QAcnD,gBAAgB;0BACS,UAAU;QAcnC,gBAAgB;iCACiB,UAAU;QAO3C,gBAAgB;uCACuB,YAAY;QASnD,gBAAgB;qCACqB,YAAY;sEAaqB,cAAc,GAAG,IAAI;;;QAkB3F,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;CAmBnB,CAAC"}
@@ -28,6 +28,7 @@ Component, defaultOnOutsideClick, useCapture = true, usePointerEvents = true) =>
28
28
  /** @internal */
29
29
  this.handleDocumentPointerDown = (e) => {
30
30
  this.isDownOutside = true;
31
+ // istanbul ignore else
31
32
  if (this.outsideClickContainerDiv) {
32
33
  // typically e.target test for instance of Node, but this is not working from pop out windows
33
34
  this.isDownOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target);
@@ -36,6 +37,7 @@ Component, defaultOnOutsideClick, useCapture = true, usePointerEvents = true) =>
36
37
  /** @internal */
37
38
  this.handleDocumentPointerUp = (e) => {
38
39
  let isUpOutside = true;
40
+ // istanbul ignore else
39
41
  if (this.outsideClickContainerDiv) {
40
42
  // typically e.target test for instance of Node, but this is not working from pop out windows
41
43
  isUpOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target);
@@ -78,6 +80,7 @@ Component, defaultOnOutsideClick, useCapture = true, usePointerEvents = true) =>
78
80
  }
79
81
  getParentDocument() {
80
82
  var _a, _b;
83
+ // istanbul ignore next
81
84
  return (_b = (_a = this.outsideClickContainerDiv) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
82
85
  }
83
86
  componentDidMount() {
@@ -1 +1 @@
1
- {"version":3,"file":"withOnOutsideClick.js","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;AAChC,gEAAgE;AAChE,SAA8C,EAC9C,qBAAkD,EAClD,aAAsB,IAAI,EAC1B,mBAA4B,IAAI,EAChC,EAAE;IACF,OAAO,MAAM,kBAAmB,SAAQ,KAAK,CAAC,aAAuD;QAA9F;;YACL,gBAAgB;YACT,6BAAwB,GAA2B,IAAI,CAAC;YAC/D,gBAAgB;YACT,kBAAa,GAAG,KAAK,CAAC;YAgC7B,gBAAgB;YACT,wBAAmB,GAAG,CAAC,CAAa,EAAE,EAAE;gBAC7C,IAAI,CAAC,IAAI,CAAC,wBAAwB,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;oBACnH,OAAO;gBAET,OAAO,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAChC,CAAC,CAAC;YAEF,gBAAgB;YACT,8BAAyB,GAAG,CAAC,CAAe,EAAE,EAAE;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AgB,EAAE;gBACpB,0BAA0B,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;gBAC1G,0BAA0B,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;aACvG;;gBACC,0BAA0B,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAClG,CAAC;QAEe,MAAM;YACpB,MAAM,EAAE,cAAc,EAAE,8BAA8B,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,wDAAwD;YACzI,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAK,KAAuB,GAAI,CACtC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,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 Common\r\n */\r\n\r\nimport * as React from \"react\";\r\n\r\n/** Properties for [[withOnOutsideClick]] React higher-order component\r\n * @public\r\n */\r\nexport interface WithOnOutsideClickProps {\r\n /** Outside click callback function */\r\n onOutsideClick?: (event: MouseEvent) => any;\r\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\r\n closeOnNestedPopupOutsideClick?: boolean;\r\n}\r\n\r\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\r\n * @public\r\n */\r\nexport const withOnOutsideClick = <ComponentProps extends {}>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Component: React.ComponentType<ComponentProps>,\r\n defaultOnOutsideClick?: (event: MouseEvent) => any,\r\n useCapture: boolean = true,\r\n usePointerEvents: boolean = true,\r\n) => {\r\n return class WithOnOutsideClick extends React.PureComponent<ComponentProps & WithOnOutsideClickProps> {\r\n /** @internal */\r\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\r\n /** @internal */\r\n public isDownOutside = false;\r\n\r\n /** @internal */\r\n public isInCorePopup(element: HTMLElement): boolean {\r\n if (element.nodeName === \"DIV\") {\r\n if (element.classList && element.classList.contains(\"core-popup\"))\r\n return true;\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n } else {\r\n // istanbul ignore else\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public onOutsideClick(e: MouseEvent) {\r\n // istanbul ignore else\r\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\r\n // istanbul ignore else\r\n if (!this.props.closeOnNestedPopupOutsideClick && this.isInCorePopup(e.target as HTMLElement))\r\n return;\r\n }\r\n\r\n if (this.props.onOutsideClick)\r\n return this.props.onOutsideClick(e);\r\n else if (defaultOnOutsideClick)\r\n return defaultOnOutsideClick(e);\r\n }\r\n\r\n /** @internal */\r\n public handleDocumentClick = (e: MouseEvent) => {\r\n if (!this.outsideClickContainerDiv || !(e.target instanceof Node) || this.outsideClickContainerDiv.contains(e.target))\r\n return;\r\n\r\n return this.onOutsideClick(e);\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerDown = (e: PointerEvent) => {\r\n this.isDownOutside = true;\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n this.isDownOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerUp = (e: PointerEvent) => {\r\n let isUpOutside = true;\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n isUpOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n\r\n const isOutsideClick = isUpOutside && this.isDownOutside;\r\n this.isDownOutside = false;\r\n isOutsideClick && this.onOutsideClick(e);\r\n };\r\n\r\n public handleOutsideClickContainerDivSet = (outsideClickContainerDiv: HTMLDivElement | null) => {\r\n this.outsideClickContainerDiv = outsideClickContainerDiv;\r\n };\r\n\r\n public getParentDocument() {\r\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\r\n }\r\n\r\n public override componentDidMount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.addEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.addEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.addEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.removeEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.removeEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.removeEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n public override render() {\r\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <div ref={this.handleOutsideClickContainerDivSet}>\r\n <Component {...props as ComponentProps} />\r\n </div>\r\n );\r\n }\r\n };\r\n};\r\n"]}
1
+ {"version":3,"file":"withOnOutsideClick.js","sourceRoot":"","sources":["../../../../src/core-react/hocs/withOnOutsideClick.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAY/B;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;AAChC,gEAAgE;AAChE,SAA8C,EAC9C,qBAAkD,EAClD,aAAsB,IAAI,EA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AuB;YACvB,OAAO,MAAA,MAAA,IAAI,CAAC,wBAAwB,0CAAE,aAAa,mCAAI,QAAQ,CAAC;QAClE,CAAC;QAEe,iBAAiB;YAC/B,MAAM,0BAA0B,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5D,IAAI,gBAAgB,EAAE;gBACpB,0BAA0B,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;gBACvG,0BAA0B,CAAC,gBAAgB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;aACpG;;gBACC,0BAA0B,CAAC,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAC/F,CAAC;QAED,gBAAgB;QACA,oBAAoB;YAClC,MAAM,0BAA0B,GAAG,IAAI,CAAC,iBAAiB,EAAE,CAAC;YAC5D,IAAI,gBAAgB,EAAE;gBACpB,0BAA0B,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAI,CAAC,yBAAyB,EAAE,UAAU,CAAC,CAAC;gBAC1G,0BAA0B,CAAC,mBAAmB,CAAC,WAAW,EAAE,IAAI,CAAC,uBAAuB,EAAE,UAAU,CAAC,CAAC;aACvG;;gBACC,0BAA0B,CAAC,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,mBAAmB,EAAE,UAAU,CAAC,CAAC;QAClG,CAAC;QAEe,MAAM;YACpB,MAAM,EAAE,cAAc,EAAE,8BAA8B,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,wDAAwD;YACzI,OAAO,CACL,6BAAK,GAAG,EAAE,IAAI,CAAC,iCAAiC;gBAC9C,oBAAC,SAAS,OAAK,KAAuB,GAAI,CACtC,CACP,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC,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 Common\r\n */\r\n\r\nimport * as React from \"react\";\r\n\r\n/** Properties for [[withOnOutsideClick]] React higher-order component\r\n * @public\r\n */\r\nexport interface WithOnOutsideClickProps {\r\n /** Outside click callback function */\r\n onOutsideClick?: (event: MouseEvent) => any;\r\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\r\n closeOnNestedPopupOutsideClick?: boolean;\r\n}\r\n\r\n/** withOnOutsideClick is a React higher-order component that adds outside click support.\r\n * @public\r\n */\r\nexport const withOnOutsideClick = <ComponentProps extends {}>(\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n Component: React.ComponentType<ComponentProps>,\r\n defaultOnOutsideClick?: (event: MouseEvent) => any,\r\n useCapture: boolean = true,\r\n usePointerEvents: boolean = true,\r\n) => {\r\n return class WithOnOutsideClick extends React.PureComponent<ComponentProps & WithOnOutsideClickProps> {\r\n /** @internal */\r\n public outsideClickContainerDiv?: HTMLDivElement | null = null;\r\n /** @internal */\r\n public isDownOutside = false;\r\n\r\n /** @internal */\r\n public isInCorePopup(element: HTMLElement): boolean {\r\n if (element.nodeName === \"DIV\") {\r\n if (element.classList && element.classList.contains(\"core-popup\"))\r\n return true;\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n } else {\r\n // istanbul ignore else\r\n if (element.parentElement && this.isInCorePopup(element.parentElement))\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public onOutsideClick(e: MouseEvent) {\r\n // istanbul ignore else\r\n if (e.target instanceof Node && e.target.nodeType === Node.ELEMENT_NODE) {\r\n // istanbul ignore else\r\n if (!this.props.closeOnNestedPopupOutsideClick && this.isInCorePopup(e.target as HTMLElement))\r\n return;\r\n }\r\n\r\n if (this.props.onOutsideClick)\r\n return this.props.onOutsideClick(e);\r\n else if (defaultOnOutsideClick)\r\n return defaultOnOutsideClick(e);\r\n }\r\n\r\n /** @internal */\r\n public handleDocumentClick = (e: MouseEvent) => {\r\n if (!this.outsideClickContainerDiv || !(e.target instanceof Node) || this.outsideClickContainerDiv.contains(e.target))\r\n return;\r\n\r\n return this.onOutsideClick(e);\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerDown = (e: PointerEvent) => {\r\n this.isDownOutside = true;\r\n // istanbul ignore else\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n this.isDownOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n };\r\n\r\n /** @internal */\r\n public handleDocumentPointerUp = (e: PointerEvent) => {\r\n let isUpOutside = true;\r\n // istanbul ignore else\r\n if (this.outsideClickContainerDiv) {\r\n // typically e.target test for instance of Node, but this is not working from pop out windows\r\n isUpOutside = !!e.target && !this.outsideClickContainerDiv.contains(e.target as any);\r\n }\r\n\r\n const isOutsideClick = isUpOutside && this.isDownOutside;\r\n this.isDownOutside = false;\r\n isOutsideClick && this.onOutsideClick(e);\r\n };\r\n\r\n public handleOutsideClickContainerDivSet = (outsideClickContainerDiv: HTMLDivElement | null) => {\r\n this.outsideClickContainerDiv = outsideClickContainerDiv;\r\n };\r\n\r\n public getParentDocument() {\r\n // istanbul ignore next\r\n return this.outsideClickContainerDiv?.ownerDocument ?? document;\r\n }\r\n\r\n public override componentDidMount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.addEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.addEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.addEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n /** @internal */\r\n public override componentWillUnmount() {\r\n const outsideClickParentDocument = this.getParentDocument();\r\n if (usePointerEvents) {\r\n outsideClickParentDocument.removeEventListener(\"pointerdown\", this.handleDocumentPointerDown, useCapture);\r\n outsideClickParentDocument.removeEventListener(\"pointerup\", this.handleDocumentPointerUp, useCapture);\r\n } else\r\n outsideClickParentDocument.removeEventListener(\"click\", this.handleDocumentClick, useCapture);\r\n }\r\n\r\n public override render() {\r\n const { onOutsideClick, closeOnNestedPopupOutsideClick, ...props } = this.props; // eslint-disable-line @typescript-eslint/no-unused-vars\r\n return (\r\n <div ref={this.handleOutsideClickContainerDivSet}>\r\n <Component {...props as ComponentProps} />\r\n </div>\r\n );\r\n }\r\n };\r\n};\r\n"]}
@@ -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,sBA0CpC"}
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,sBAgDpC"}
@@ -28,13 +28,17 @@ export function Icon(props) {
28
28
  React.createElement(SvgSprite, { src: svgSource })));
29
29
  const webComponentString = IconSpecUtilities.getWebComponentSource(iconString);
30
30
  if (webComponentString) {
31
- const svgLoader = `<svg-loader src=${webComponentString}></svg-loader>`;
31
+ const svgLoader = `<svg-loader src="${webComponentString}"></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
34
  // if there is a default export, use it (likely esm), otherwise use the namespace
35
35
  // istanbul ignore next
36
36
  const sanitizer = DOMPurify !== null && DOMPurify !== void 0 ? DOMPurify : DOMPurifyNS;
37
- const sanitizedIconString = sanitizer.sanitize(svgDiv, { ALLOWED_TAGS: ["svg-loader"] });
37
+ const sanitizerConfig = {
38
+ ALLOWED_TAGS: ["svg-loader"],
39
+ ADD_URI_SAFE_ATTR: webComponentString.startsWith("data:") ? ["src"] : [],
40
+ };
41
+ const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);
38
42
  // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above
39
43
  // eslint-disable-next-line @typescript-eslint/naming-convention, jam3/no-sanitizer-with-danger
40
44
  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,CA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AAS,CAAC,QAAQ,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC;YACzF,iFAAiF;YACjF,+FAA+F;YAC/F,MAAM,gBAAgB,GAAG,6BAAK,uBAAuB,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAQ,CAAC;YAC/F,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}></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
+ {"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,SAAS,EAAE,KAAK,WAAW,MAAM,WAAW,CAAC;AAiBpD;;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,EAAE;YACtB,MAAM,SAAS,GAAG,oBAAoB,kBAAkB,iBAAiB,CAAC;YAC1E,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;YAE3C,MAAM,eAAe,GAAG;gBACtB,YAAY,EAAE,CAAC,YAAY,CAAC;gBAC5B,iBAAiB,EAAE,kBAAkB,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE;aACzE,CAAC;YAEF,MAAM,mBAAmB,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;YACxE,iFAAiF;YACjF,+FAA+F;YAC/F,MAAM,gBAAgB,GAAG,6BAAK,uBAAuB,EAAE,EAAE,MAAM,EAAE,mBAAmB,EAAE,GAAQ,CAAC;YAC/F,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}\"></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\r\n const sanitizerConfig = {\r\n ALLOWED_TAGS: [\"svg-loader\"],\r\n ADD_URI_SAFE_ATTR: webComponentString.startsWith(\"data:\") ? [\"src\"] : [],\r\n };\r\n\r\n const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);\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"]}
@@ -27,7 +27,7 @@ export function ThemedSelect(props) {
27
27
  const noOptionLabel = React.useRef();
28
28
  const defaultOptionMessage = React.useCallback(() => {
29
29
  if (!noOptionLabel.current) {
30
- noOptionLabel.current = UiCore.translate("reactelect.noSelectOption");
30
+ noOptionLabel.current = UiCore.translate("reactselect.noSelectOption");
31
31
  }
32
32
  return noOptionLabel.current;
33
33
  }, [noOptionLabel]);
@@ -1 +1 @@
1
- {"version":3,"file":"ThemedSelect.js","sourceRoot":"","sources":["../../../../src/core-react/select/ThemedSelect.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,s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AE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;KACjE,CAAC;IAEF,MAAM,MAAM,GAAG,sBAAsB,CAAC,+BAA+B,CAAC,CAAC;IACvE,OAAO,CACL,6BAAK,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM;QAC1C,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,EACR,eAAe,EAAC,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,YAAY,EAC9B,MAAM,EAAE,YAAY;YACpB,gEAAgE;YAChE,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,KACjD,UAAU,GACd,CACE,CACP,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 Select\r\n */\r\n\r\nimport \"./themed-select.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport Component, { components } from \"react-select\";\r\nimport { formatGroupLabel, getOptionLabel, getOptionValue } from \"react-select/src/builtins\";\r\nimport { SelectComponentsConfig } from \"react-select/src/components/index\";\r\nimport { MenuProps } from \"react-select/src/components/Menu\";\r\nimport { ActionMeta, FocusEventHandler, InputActionMeta, KeyboardEventHandler, ValueType } from \"react-select/src/types\";\r\nimport { UiCore } from \"../UiCore\";\r\nimport { getCssVariableAsNumber } from \"../utils/getCssVariable\";\r\nimport { getParentSelector } from \"./modalHelper\";\r\n\r\n// cspell:ignore reactselect builtins\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow, @typescript-eslint/consistent-type-definitions, @typescript-eslint/array-type */\r\ntype FormatOptionLabelContext = \"menu\" | \"value\";\r\ntype FormatOptionLabelMeta = {\r\n context: FormatOptionLabelContext;\r\n inputValue: string;\r\n selectValue: ValueType<OptionType>;\r\n};\r\n\r\n/** OptionType for react-select 2.0 and above. which only accepts pairs of value & label strings\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport interface OptionType {\r\n value: any;\r\n label: string;\r\n}\r\n/** OptionsType to match label/value pair OptionType\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n*/\r\nexport type OptionsType = Array<OptionType>;\r\n\r\n/** ThemedSelectProps to control specific features of ThemedSelect\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport type ThemedSelectProps = {\r\n /* Aria label (for assistive tech) */\r\n \"aria-label\"?: string;\r\n /* HTML ID of an element that should be used as the label (for assistive tech) */\r\n \"aria-labelledby\"?: string;\r\n /* Focus the control when it is mounted */\r\n autoFocus?: boolean;\r\n /* Remove the currently focused option when the user presses backspace */\r\n backspaceRemovesValue?: boolean;\r\n /* Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) */\r\n blurInputOnSelect?: boolean;\r\n /* When the user reaches the top/bottom of the menu, prevent scroll on the scroll-parent */\r\n captureMenuScroll?: boolean;\r\n /* Sets a className attribute on the outer component */\r\n className?: string;\r\n /* Close the select menu when the user selects an option */\r\n closeMenuOnSelect?: boolean;\r\n /*\r\n If `true`, close the select menu when the user scrolls the document/body.\r\n\r\n If a function, takes a standard javascript `ScrollEvent` you return a boolean:\r\n\r\n `true` => The menu closes\r\n\r\n `false` => The menu stays open\r\n\r\n This is useful when you have a scrollable modal and want to portal the menu out,\r\n but want to avoid graphical issues.\r\n */\r\n closeMenuOnScroll?: boolean | EventListener;\r\n /*\r\n This complex object includes all the compositional components that are used\r\n in `react-select`. If you wish to overwrite a component, pass in an object\r\n with the appropriate namespace.\r\n\r\n If you only wish to restyle a component, we recommend using the `styles` prop\r\n instead. For a list of the components that can be passed in, and the shape\r\n that will be passed to them, see [the components docs](/components)\r\n */\r\n components?: SelectComponentsConfig<OptionType>;\r\n /* Whether the value of the select, e.g. SingleValue, should be displayed in the control. */\r\n controlShouldRenderValue?: boolean;\r\n /* Ff true, the menu is open immediately */\r\n defaultMenuIsOpen?: boolean;\r\n /* Value set in the control by default */\r\n defaultValue?: ValueType<OptionType>;\r\n /** Provides ability to return reference to the outer HTMLDivElement */\r\n divRef?: React.Ref<HTMLDivElement>;\r\n /* Clear all values when the user presses escape AND the menu is closed */\r\n escapeClearsValue?: boolean;\r\n /* Custom method to filter whether an option should be displayed in the menu */\r\n filterOption?: ((\r\n option: OptionType,\r\n rawInput: string,\r\n ) => boolean) | null;\r\n /*\r\n Formats group labels in the menu as React components\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n*/\r\n formatGroupLabel?: typeof formatGroupLabel;\r\n /* Formats option labels in the menu and control as React components */\r\n formatOptionLabel?: (optionType: OptionType, formatLabelMeta: FormatOptionLabelMeta) => React.ReactNode;\r\n /* Resolves option data to a string to be displayed as the label by components */\r\n getOptionLabel?: typeof getOptionLabel;\r\n /* Resolves option data to a string to compare options and specify value attributes */\r\n getOptionValue?: typeof getOptionValue;\r\n /* Hide the selected option from the menu */\r\n hideSelectedOptions?: boolean;\r\n /* The id to set on the SelectContainer component. */\r\n id?: string;\r\n /* The value of the search input */\r\n inputValue?: string;\r\n /* The id of the search input */\r\n inputId?: string;\r\n /* Define an id prefix for the select components e.g. {your-id}-value */\r\n instanceId?: number | string;\r\n /* Is the select value clearable */\r\n isClearable?: boolean;\r\n /* Is the select disabled */\r\n isDisabled?: boolean;\r\n /* Is the select in a state of loading (async) */\r\n isLoading?: boolean;\r\n /*\r\n Override the built-in logic to detect whether an option is disabled\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n */\r\n isOptionDisabled?: (option: OptionType, options: OptionsType) => boolean | false;\r\n /* Support multiple selected options */\r\n isMulti?: boolean;\r\n /* If true, menu will not be opened in a portal */\r\n isMenuFixed?: boolean;\r\n /* Is the select direction right-to-left */\r\n isRtl?: boolean;\r\n /* Whether to enable search functionality */\r\n isSearchable?: boolean;\r\n /* Minimum height of the menu before flipping */\r\n minMenuHeight?: number;\r\n /* Maximum height of the menu before scrolling */\r\n maxMenuHeight?: number;\r\n /* Whether the menu is open */\r\n menuIsOpen?: boolean;\r\n /* Whether to block scroll events when the menu is open */\r\n menuShouldBlockScroll?: boolean;\r\n /* Whether the menu should be scrolled into view when it opens */\r\n menuShouldScrollIntoView?: boolean;\r\n /* Name of the HTML Input (optional - without this, no input will be rendered) */\r\n name?: string;\r\n /* Text to display when there are no options */\r\n noOptionsMessage?: (obj: { inputValue: string }) => string | null;\r\n /* Handle blur events on the control */\r\n onBlur?: FocusEventHandler;\r\n /* Handle change events on the select */\r\n onChange?: (value: ValueType<OptionType>, action: ActionMeta<OptionType>) => void;\r\n /* Handle focus events on the control */\r\n onFocus?: FocusEventHandler;\r\n /* Handle change events on the input */\r\n onInputChange?: (newValue: string, actionMeta?: InputActionMeta) => void;\r\n /* Handle key down events on the select */\r\n onKeyDown?: KeyboardEventHandler;\r\n /* Handle the menu opening */\r\n onMenuOpen?: () => void;\r\n /* Handle the menu closing */\r\n onMenuClose?: () => void;\r\n /* Fired when the user scrolls to the top of the menu */\r\n onMenuScrollToTop?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Fired when the user scrolls to the bottom of the menu */\r\n onMenuScrollToBottom?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Allows control of whether the menu is opened when the Select is focused */\r\n openMenuOnFocus?: boolean;\r\n /* Allows control of whether the menu is opened when the Select is clicked */\r\n openMenuOnClick?: boolean;\r\n /* Array of options that populate the select menu */\r\n options: OptionsType;\r\n /* Number of options to jump in menu when page{up|down} keys are used */\r\n pageSize?: number;\r\n /* Placeholder for the select value */\r\n placeholder?: string;\r\n /** Provides ability to return reference to the ThemedSelect */\r\n ref?: React.Ref<Component>;\r\n /* Sets additional styling */\r\n styles?: React.CSSProperties;\r\n /* Sets the tabIndex attribute on the input */\r\n tabIndex?: string;\r\n /* Select the currently focused option when the user presses tab */\r\n tabSelectsValue?: boolean;\r\n /* The value of the select; reflected by the selected option */\r\n value?: ValueType<OptionType>;\r\n};\r\n\r\nconst ThemedMenu = (props: MenuProps<any>) => { // eslint-disable-line @typescript-eslint/naming-convention\r\n return (\r\n <div className=\"uicore-reactSelectTop\">\r\n <components.Menu {...props} />\r\n </div>\r\n );\r\n};\r\n/** ThemedSelect is a wrapper for react-select with iTwin.js UI theming applied\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function ThemedSelect(props: ThemedSelectProps) {\r\n const noOptionLabel = React.useRef<string | undefined>();\r\n const defaultOptionMessage = React.useCallback(() => {\r\n if (!noOptionLabel.current) {\r\n noOptionLabel.current = UiCore.translate(\"reactelect.noSelectOption\");\r\n }\r\n return noOptionLabel.current;\r\n }, [noOptionLabel]);\r\n const noOptionFunction = props.noOptionsMessage ?? defaultOptionMessage;\r\n const selectClassName = classnames(\"uicore-reactSelectTop\", props.className);\r\n const portalTarget = !!props.isMenuFixed ? undefined : getParentSelector();\r\n const {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n classNamePrefix, className, noOptionsMessage, menuPortalTarget, isMenuFixed, styles, components, divRef, ref,\r\n // eslint-disable-next-line comma-dangle\r\n ...otherProps // pass-through props\r\n } = props as any;\r\n const selectStyles = {\r\n ...props.styles,\r\n menuPortal: (base: React.CSSProperties) => ({ ...base, zIndex }),\r\n };\r\n\r\n const zIndex = getCssVariableAsNumber(\"--uicore-z-index-dialog-popup\");\r\n return (\r\n <div className={selectClassName} ref={divRef}>\r\n <Component\r\n ref={ref}\r\n classNamePrefix=\"react-select\"\r\n noOptionsMessage={noOptionFunction}\r\n menuPortalTarget={portalTarget}\r\n styles={selectStyles}\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n components={{ Menu: ThemedMenu, ...props.components }}\r\n {...otherProps}\r\n />\r\n </div>\r\n );\r\n}\r\n"]}
1
+ {"version":3,"file":"ThemedSelect.js","sourceRoot":"","sources":["../../../../src/core-react/select/ThemedSelect.tsx"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F,4CAA4C;AAC5C;;GAEG;AAEH,OAAO,sBAAsB,CAAC;AAC9B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,SAAS,EAAE,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAKrD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAqLlD,MAAM,UAAU,GAAG,CAAC,KAAqB,EAAE,EAAE;IAC3C,OAAO,CACL,6BAAK,SAAS,EAAC,uBAAuB;QACpC,oBAAC,UAAU,CAAC,IAAI,OAAK,KAAK,GAAI,CAC1B,CACP,CAAC;AACJ,CAAC,CAAC;AACF;;;GAGG;AACH,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,KAAwB;;IACnD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,EAAsB,CAAC;IACzD,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QAClD,IAAI,CAAC,aAAa,CAAC,OAAO,EAAE;YAC1B,aAAa,CAAC,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;SACxE;QACD,OAAO,aAAa,CAAC,OAAO,CAAC;IAC/B,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IACpB,MAAM,gBAAgB,GAAG,MAAA,KAAK,CAAC,gBAAgB,mCAAI,oBAAoB,CAAC;IACxE,MAAM,eAAe,GAAG,UAAU,CAAC,uBAAuB,EAAE,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7E,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAC3E,MAAM;IACJ,6DAA6D;IAC7D,eAAe,EAAE,SAAS,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG;IAC5G,wCAAwC;IACxC,GAAG,UAAU,CAAC,qBAAqB;MACpC,GAAG,KAAY,CAAC;IACjB,MAAM,YAAY,GAAG;QACnB,GAAG,KAAK,CAAC,MAAM;QACf,UAAU,EAAE,CAAC,IAAyB,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,CAAC;KACjE,CAAC;IAEF,MAAM,MAAM,GAAG,sBAAsB,CAAC,+BAA+B,CAAC,CAAC;IACvE,OAAO,CACL,6BAAK,SAAS,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM;QAC1C,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,EACR,eAAe,EAAC,cAAc,EAC9B,gBAAgB,EAAE,gBAAgB,EAClC,gBAAgB,EAAE,YAAY,EAC9B,MAAM,EAAE,YAAY;YACpB,gEAAgE;YAChE,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC,UAAU,EAAE,KACjD,UAAU,GACd,CACE,CACP,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 Select\r\n */\r\n\r\nimport \"./themed-select.scss\";\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport Component, { components } from \"react-select\";\r\nimport { formatGroupLabel, getOptionLabel, getOptionValue } from \"react-select/src/builtins\";\r\nimport { SelectComponentsConfig } from \"react-select/src/components/index\";\r\nimport { MenuProps } from \"react-select/src/components/Menu\";\r\nimport { ActionMeta, FocusEventHandler, InputActionMeta, KeyboardEventHandler, ValueType } from \"react-select/src/types\";\r\nimport { UiCore } from \"../UiCore\";\r\nimport { getCssVariableAsNumber } from \"../utils/getCssVariable\";\r\nimport { getParentSelector } from \"./modalHelper\";\r\n\r\n// cspell:ignore reactselect builtins\r\n\r\n/* eslint-disable @typescript-eslint/no-shadow, @typescript-eslint/consistent-type-definitions, @typescript-eslint/array-type */\r\ntype FormatOptionLabelContext = \"menu\" | \"value\";\r\ntype FormatOptionLabelMeta = {\r\n context: FormatOptionLabelContext;\r\n inputValue: string;\r\n selectValue: ValueType<OptionType>;\r\n};\r\n\r\n/** OptionType for react-select 2.0 and above. which only accepts pairs of value & label strings\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport interface OptionType {\r\n value: any;\r\n label: string;\r\n}\r\n/** OptionsType to match label/value pair OptionType\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n*/\r\nexport type OptionsType = Array<OptionType>;\r\n\r\n/** ThemedSelectProps to control specific features of ThemedSelect\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\nexport type ThemedSelectProps = {\r\n /* Aria label (for assistive tech) */\r\n \"aria-label\"?: string;\r\n /* HTML ID of an element that should be used as the label (for assistive tech) */\r\n \"aria-labelledby\"?: string;\r\n /* Focus the control when it is mounted */\r\n autoFocus?: boolean;\r\n /* Remove the currently focused option when the user presses backspace */\r\n backspaceRemovesValue?: boolean;\r\n /* Remove focus from the input when the user selects an option (handy for dismissing the keyboard on touch devices) */\r\n blurInputOnSelect?: boolean;\r\n /* When the user reaches the top/bottom of the menu, prevent scroll on the scroll-parent */\r\n captureMenuScroll?: boolean;\r\n /* Sets a className attribute on the outer component */\r\n className?: string;\r\n /* Close the select menu when the user selects an option */\r\n closeMenuOnSelect?: boolean;\r\n /*\r\n If `true`, close the select menu when the user scrolls the document/body.\r\n\r\n If a function, takes a standard javascript `ScrollEvent` you return a boolean:\r\n\r\n `true` => The menu closes\r\n\r\n `false` => The menu stays open\r\n\r\n This is useful when you have a scrollable modal and want to portal the menu out,\r\n but want to avoid graphical issues.\r\n */\r\n closeMenuOnScroll?: boolean | EventListener;\r\n /*\r\n This complex object includes all the compositional components that are used\r\n in `react-select`. If you wish to overwrite a component, pass in an object\r\n with the appropriate namespace.\r\n\r\n If you only wish to restyle a component, we recommend using the `styles` prop\r\n instead. For a list of the components that can be passed in, and the shape\r\n that will be passed to them, see [the components docs](/components)\r\n */\r\n components?: SelectComponentsConfig<OptionType>;\r\n /* Whether the value of the select, e.g. SingleValue, should be displayed in the control. */\r\n controlShouldRenderValue?: boolean;\r\n /* Ff true, the menu is open immediately */\r\n defaultMenuIsOpen?: boolean;\r\n /* Value set in the control by default */\r\n defaultValue?: ValueType<OptionType>;\r\n /** Provides ability to return reference to the outer HTMLDivElement */\r\n divRef?: React.Ref<HTMLDivElement>;\r\n /* Clear all values when the user presses escape AND the menu is closed */\r\n escapeClearsValue?: boolean;\r\n /* Custom method to filter whether an option should be displayed in the menu */\r\n filterOption?: ((\r\n option: OptionType,\r\n rawInput: string,\r\n ) => boolean) | null;\r\n /*\r\n Formats group labels in the menu as React components\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n*/\r\n formatGroupLabel?: typeof formatGroupLabel;\r\n /* Formats option labels in the menu and control as React components */\r\n formatOptionLabel?: (optionType: OptionType, formatLabelMeta: FormatOptionLabelMeta) => React.ReactNode;\r\n /* Resolves option data to a string to be displayed as the label by components */\r\n getOptionLabel?: typeof getOptionLabel;\r\n /* Resolves option data to a string to compare options and specify value attributes */\r\n getOptionValue?: typeof getOptionValue;\r\n /* Hide the selected option from the menu */\r\n hideSelectedOptions?: boolean;\r\n /* The id to set on the SelectContainer component. */\r\n id?: string;\r\n /* The value of the search input */\r\n inputValue?: string;\r\n /* The id of the search input */\r\n inputId?: string;\r\n /* Define an id prefix for the select components e.g. {your-id}-value */\r\n instanceId?: number | string;\r\n /* Is the select value clearable */\r\n isClearable?: boolean;\r\n /* Is the select disabled */\r\n isDisabled?: boolean;\r\n /* Is the select in a state of loading (async) */\r\n isLoading?: boolean;\r\n /*\r\n Override the built-in logic to detect whether an option is disabled\r\n\r\n An example can be found in the [Replacing builtins](/advanced#replacing-builtins) documentation.\r\n */\r\n isOptionDisabled?: (option: OptionType, options: OptionsType) => boolean | false;\r\n /* Support multiple selected options */\r\n isMulti?: boolean;\r\n /* If true, menu will not be opened in a portal */\r\n isMenuFixed?: boolean;\r\n /* Is the select direction right-to-left */\r\n isRtl?: boolean;\r\n /* Whether to enable search functionality */\r\n isSearchable?: boolean;\r\n /* Minimum height of the menu before flipping */\r\n minMenuHeight?: number;\r\n /* Maximum height of the menu before scrolling */\r\n maxMenuHeight?: number;\r\n /* Whether the menu is open */\r\n menuIsOpen?: boolean;\r\n /* Whether to block scroll events when the menu is open */\r\n menuShouldBlockScroll?: boolean;\r\n /* Whether the menu should be scrolled into view when it opens */\r\n menuShouldScrollIntoView?: boolean;\r\n /* Name of the HTML Input (optional - without this, no input will be rendered) */\r\n name?: string;\r\n /* Text to display when there are no options */\r\n noOptionsMessage?: (obj: { inputValue: string }) => string | null;\r\n /* Handle blur events on the control */\r\n onBlur?: FocusEventHandler;\r\n /* Handle change events on the select */\r\n onChange?: (value: ValueType<OptionType>, action: ActionMeta<OptionType>) => void;\r\n /* Handle focus events on the control */\r\n onFocus?: FocusEventHandler;\r\n /* Handle change events on the input */\r\n onInputChange?: (newValue: string, actionMeta?: InputActionMeta) => void;\r\n /* Handle key down events on the select */\r\n onKeyDown?: KeyboardEventHandler;\r\n /* Handle the menu opening */\r\n onMenuOpen?: () => void;\r\n /* Handle the menu closing */\r\n onMenuClose?: () => void;\r\n /* Fired when the user scrolls to the top of the menu */\r\n onMenuScrollToTop?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Fired when the user scrolls to the bottom of the menu */\r\n onMenuScrollToBottom?: (e: React.SyntheticEvent<HTMLElement>) => void;\r\n /* Allows control of whether the menu is opened when the Select is focused */\r\n openMenuOnFocus?: boolean;\r\n /* Allows control of whether the menu is opened when the Select is clicked */\r\n openMenuOnClick?: boolean;\r\n /* Array of options that populate the select menu */\r\n options: OptionsType;\r\n /* Number of options to jump in menu when page{up|down} keys are used */\r\n pageSize?: number;\r\n /* Placeholder for the select value */\r\n placeholder?: string;\r\n /** Provides ability to return reference to the ThemedSelect */\r\n ref?: React.Ref<Component>;\r\n /* Sets additional styling */\r\n styles?: React.CSSProperties;\r\n /* Sets the tabIndex attribute on the input */\r\n tabIndex?: string;\r\n /* Select the currently focused option when the user presses tab */\r\n tabSelectsValue?: boolean;\r\n /* The value of the select; reflected by the selected option */\r\n value?: ValueType<OptionType>;\r\n};\r\n\r\nconst ThemedMenu = (props: MenuProps<any>) => { // eslint-disable-line @typescript-eslint/naming-convention\r\n return (\r\n <div className=\"uicore-reactSelectTop\">\r\n <components.Menu {...props} />\r\n </div>\r\n );\r\n};\r\n/** ThemedSelect is a wrapper for react-select with iTwin.js UI theming applied\r\n * @beta\r\n * @deprecated use Select from @itwin/itwinui-react\r\n */\r\n// eslint-disable-next-line @typescript-eslint/naming-convention\r\nexport function ThemedSelect(props: ThemedSelectProps) {\r\n const noOptionLabel = React.useRef<string | undefined>();\r\n const defaultOptionMessage = React.useCallback(() => {\r\n if (!noOptionLabel.current) {\r\n noOptionLabel.current = UiCore.translate(\"reactselect.noSelectOption\");\r\n }\r\n return noOptionLabel.current;\r\n }, [noOptionLabel]);\r\n const noOptionFunction = props.noOptionsMessage ?? defaultOptionMessage;\r\n const selectClassName = classnames(\"uicore-reactSelectTop\", props.className);\r\n const portalTarget = !!props.isMenuFixed ? undefined : getParentSelector();\r\n const {\r\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\r\n classNamePrefix, className, noOptionsMessage, menuPortalTarget, isMenuFixed, styles, components, divRef, ref,\r\n // eslint-disable-next-line comma-dangle\r\n ...otherProps // pass-through props\r\n } = props as any;\r\n const selectStyles = {\r\n ...props.styles,\r\n menuPortal: (base: React.CSSProperties) => ({ ...base, zIndex }),\r\n };\r\n\r\n const zIndex = getCssVariableAsNumber(\"--uicore-z-index-dialog-popup\");\r\n return (\r\n <div className={selectClassName} ref={divRef}>\r\n <Component\r\n ref={ref}\r\n classNamePrefix=\"react-select\"\r\n noOptionsMessage={noOptionFunction}\r\n menuPortalTarget={portalTarget}\r\n styles={selectStyles}\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n components={{ Menu: ThemedMenu, ...props.components }}\r\n {...otherProps}\r\n />\r\n </div>\r\n );\r\n}\r\n"]}
@@ -1 +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;CAwBtB"}
1
+ {"version":3,"file":"IconWebComponent.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/IconWebComponent.ts"],"names":[],"mappings":"AAMA;;GAEG;AAOH;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,WAAW;YACjC,iBAAiB;YAKjB,OAAO;CAmDtB"}
@@ -10,6 +10,7 @@
10
10
  import { UiError } from "@itwin/appui-abstract";
11
11
  import { Logger } from "@itwin/core-bentley";
12
12
  import { UiCore } from "../UiCore";
13
+ import DOMPurify, * as DOMPurifyNS from "dompurify";
13
14
  /**
14
15
  * IconWebComponent loads icon from an svg path
15
16
  */
@@ -22,7 +23,27 @@ export class IconWebComponent extends HTMLElement {
22
23
  // if svg was already appended don't request it again
23
24
  if (this.childNodes.length)
24
25
  return;
25
- await fetch(this.getAttribute("src") || "")
26
+ const src = this.getAttribute("src") || "";
27
+ if (src.startsWith("data:")) {
28
+ const dataUriParts = src.split(",");
29
+ if (dataUriParts.length !== 2 || "data:image/svg+xml;base64" !== dataUriParts[0]) {
30
+ Logger.logError(UiCore.loggerCategory(this), "Unable to load icon.");
31
+ }
32
+ // the esm build of dompurify has a default import but the cjs build does not
33
+ // if there is a default export, use it (likely esm), otherwise use the namespace
34
+ // istanbul ignore next
35
+ const sanitizer = DOMPurify !== null && DOMPurify !== void 0 ? DOMPurify : DOMPurifyNS;
36
+ // eslint-disable-next-line deprecation/deprecation
37
+ const sanitizedSvg = sanitizer.sanitize(atob(dataUriParts[1]));
38
+ const parsedSvg = new window.DOMParser().parseFromString(sanitizedSvg, "text/xml");
39
+ const errorNode = parsedSvg.querySelector("parsererror");
40
+ if (errorNode || "svg" !== parsedSvg.documentElement.nodeName.toLowerCase()) {
41
+ throw new UiError(UiCore.loggerCategory(this), "Unable to load icon.");
42
+ }
43
+ !this.childNodes.length && this.append(parsedSvg.documentElement);
44
+ return;
45
+ }
46
+ await fetch(src)
26
47
  .catch((_error) => {
27
48
  Logger.logError(UiCore.loggerCategory(this), "Unable to load icon.");
28
49
  })
@@ -1 +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,qDAAqD;QACrD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM;YACxB,OAAO;QACT,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,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,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 // if svg was already appended don't request it again\r\n if (this.childNodes.length)\r\n return;\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.childNodes.length && this.append(data.documentElement));\r\n }\r\n}\r\n"]}
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;AACnC,OAAO,SAAS,EAAE,KAAK,WAAW,MAAM,WAAW,CAAC;AAEpD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,WAAW;IACvC,KAAK,CAAC,iBAAiB;QAC7B,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACrB,IAAI,CAAC,aAAa,CAAC,IAAI,WAA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AClE,OAAO;SACR;QAED,MAAM,KAAK,CAAC,GAAG,CAAC;aACb,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,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC;IAClF,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\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\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 // if svg was already appended don't request it again\r\n if (this.childNodes.length)\r\n return;\r\n\r\n const src = this.getAttribute(\"src\") || \"\";\r\n\r\n if (src.startsWith(\"data:\")) {\r\n const dataUriParts = src.split(\",\");\r\n\r\n if (dataUriParts.length !== 2 || \"data:image/svg+xml;base64\" !== dataUriParts[0]) {\r\n Logger.logError(UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n\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 // eslint-disable-next-line deprecation/deprecation\r\n const sanitizedSvg = sanitizer.sanitize(atob(dataUriParts[1]));\r\n\r\n const parsedSvg = new window.DOMParser().parseFromString(sanitizedSvg, \"text/xml\");\r\n const errorNode = parsedSvg.querySelector(\"parsererror\");\r\n if (errorNode || \"svg\" !== parsedSvg.documentElement.nodeName.toLowerCase()) {\r\n throw new UiError (UiCore.loggerCategory(this), \"Unable to load icon.\");\r\n }\r\n\r\n !this.childNodes.length && this.append(parsedSvg.documentElement);\r\n return;\r\n }\r\n\r\n await fetch(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.childNodes.length && this.append(data.documentElement));\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"getCssVariable.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAKtF;AAGD;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAM9F"}
1
+ {"version":3,"file":"getCssVariable.d.ts","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,wBAAgB,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAKtF;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,WAAW,GAAG,MAAM,CAM9F"}
@@ -5,7 +5,6 @@
5
5
  /** @packageDocumentation
6
6
  * @module Utilities
7
7
  */
8
- /* istanbul ignore next */
9
8
  /** Get CSS variable
10
9
  * @public
11
10
  */
@@ -15,7 +14,6 @@ export function getCssVariable(variableName, htmlElement) {
15
14
  const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();
16
15
  return cssVal;
17
16
  }
18
- /* istanbul ignore next */
19
17
  /** Get CSS variable as number
20
18
  * @public
21
19
  */
@@ -1 +1 @@
1
- {"version":3,"file":"getCssVariable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,0BAA0B;AAC1B;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB,EAAE,WAAyB;IAC5E,MAAM,OAAO,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,eAAe,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,0BAA0B;AAC1B;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAoB,EAAE,WAAyB;IACpF,IAAI,SAAS,GAAW,GAAG,CAAC;IAC5B,MAAM,SAAS,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,IAAI,SAAS;QACX,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC;AACnB,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/* istanbul ignore next */\r\n/** Get CSS variable\r\n * @public\r\n */\r\nexport function getCssVariable(variableName: string, htmlElement?: HTMLElement): string {\r\n const element = htmlElement ?? document.documentElement;\r\n const cssStyles = getComputedStyle(element, null);\r\n const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();\r\n return cssVal;\r\n}\r\n\r\n/* istanbul ignore next */\r\n/** Get CSS variable as number\r\n * @public\r\n */\r\nexport function getCssVariableAsNumber(variableName: string, htmlElement?: HTMLElement): number {\r\n let cssValNum: number = NaN;\r\n const cssValStr = getCssVariable(variableName, htmlElement);\r\n if (cssValStr)\r\n cssValNum = parseFloat(cssValStr);\r\n return cssValNum;\r\n}\r\n"]}
1
+ {"version":3,"file":"getCssVariable.js","sourceRoot":"","sources":["../../../../src/core-react/utils/getCssVariable.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,YAAoB,EAAE,WAAyB;IAC5E,MAAM,OAAO,GAAG,WAAW,aAAX,WAAW,cAAX,WAAW,GAAI,QAAQ,CAAC,eAAe,CAAC;IACxD,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAClD,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,gBAAgB,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IACvE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,sBAAsB,CAAC,YAAoB,EAAE,WAAyB;IACpF,IAAI,SAAS,GAAW,GAAG,CAAC;IAC5B,MAAM,SAAS,GAAG,cAAc,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;IAC5D,IAAI,SAAS;QACX,SAAS,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,SAAS,CAAC;AACnB,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/** Get CSS variable\r\n * @public\r\n */\r\nexport function getCssVariable(variableName: string, htmlElement?: HTMLElement): string {\r\n const element = htmlElement ?? document.documentElement;\r\n const cssStyles = getComputedStyle(element, null);\r\n const cssVal = String(cssStyles.getPropertyValue(variableName)).trim();\r\n return cssVal;\r\n}\r\n\r\n/** Get CSS variable as number\r\n * @public\r\n */\r\nexport function getCssVariableAsNumber(variableName: string, htmlElement?: HTMLElement): number {\r\n let cssValNum: number = NaN;\r\n const cssValStr = getCssVariable(variableName, htmlElement);\r\n if (cssValStr)\r\n cssValNum = parseFloat(cssValStr);\r\n return cssValNum;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/core-react",
3
- "version": "3.4.0-dev.9",
3
+ "version": "3.5.0-dev.5",
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.4.0-dev.9",
26
- "@itwin/core-bentley": "^3.4.0-dev.9",
25
+ "@itwin/appui-abstract": "^3.5.0-dev.5",
26
+ "@itwin/core-bentley": "^3.5.0-dev.5",
27
27
  "react": "^17.0.0",
28
28
  "react-dom": "^17.0.0"
29
29
  },
@@ -32,39 +32,33 @@
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.4.0-dev.9",
36
- "@itwin/build-tools": "3.4.0-dev.9",
37
- "@itwin/core-bentley": "3.4.0-dev.9",
38
- "@itwin/core-common": "3.4.0-dev.9",
39
- "@itwin/core-i18n": "3.4.0-dev.9",
40
- "@itwin/eslint-plugin": "3.4.0-dev.9",
35
+ "@itwin/appui-abstract": "3.5.0-dev.5",
36
+ "@itwin/build-tools": "3.5.0-dev.5",
37
+ "@itwin/core-bentley": "3.5.0-dev.5",
38
+ "@itwin/core-common": "3.5.0-dev.5",
39
+ "@itwin/core-i18n": "3.5.0-dev.5",
40
+ "@itwin/eslint-plugin": "3.5.0-dev.5",
41
41
  "@testing-library/dom": "^8.11.2",
42
42
  "@testing-library/react": "^12.0.0",
43
43
  "@testing-library/react-hooks": "^7.0.2",
44
- "@testing-library/user-event": "^13.2.1",
44
+ "@testing-library/user-event": "^14.4.2",
45
45
  "@types/chai": "4.3.1",
46
46
  "@types/chai-as-promised": "^7",
47
- "@types/chai-jest-snapshot": "^1.3.0",
48
47
  "@types/chai-spies": "^1.0.0",
49
48
  "@types/dompurify": "^2.0.3",
50
- "@types/enzyme": "3.9.3",
51
49
  "@types/lodash": "^4.14.0",
52
50
  "@types/mocha": "^8.2.2",
53
- "@types/node": "16.11.7",
51
+ "@types/node": "16.11.59",
54
52
  "@types/react": "^17.0.37",
55
53
  "@types/react-autosuggest": "10.1.2",
56
54
  "@types/react-dom": "^17.0.0",
57
55
  "@types/react-select": "3.0.26",
58
56
  "@types/sinon": "^9.0.0",
59
57
  "@types/sinon-chai": "^3.2.0",
60
- "@wojtekmaj/enzyme-adapter-react-17": "^0.6.3",
61
58
  "chai": "^4.1.2",
62
59
  "chai-as-promised": "^7",
63
- "chai-jest-snapshot": "^2.0.0",
64
60
  "chai-spies": "1.0.0",
65
61
  "cpx2": "^3.0.0",
66
- "enzyme": "3.10.0",
67
- "enzyme-to-json": "^3.3.4",
68
62
  "eslint": "^7.11.0",
69
63
  "ignore-styles": "^5.0.1",
70
64
  "jsdom": "^19.0.0",
@@ -74,15 +68,13 @@
74
68
  "raf": "^3.4.0",
75
69
  "react": "^17.0.0",
76
70
  "react-dom": "^17.0.0",
77
- "react-dom-instance": "2.0.0",
78
71
  "react-test-renderer": "^17.0.0",
79
72
  "rimraf": "^3.0.2",
80
73
  "sinon": "^9.0.2",
81
74
  "sinon-chai": "^3.2.0",
82
75
  "ts-node": "^10.8.2",
83
76
  "typemoq": "^2.1.0",
84
- "typescript": "~4.4.0",
85
- "xmlhttprequest": "^1.8.0"
77
+ "typescript": "~4.4.0"
86
78
  },
87
79
  "//dependencies": [
88
80
  "NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API",
@@ -91,7 +83,7 @@
91
83
  "dependencies": {
92
84
  "@bentley/icons-generic-webfont": "^1.0.15",
93
85
  "@itwin/itwinui-css": "0.x",
94
- "@itwin/itwinui-react": "^1.38.1",
86
+ "@itwin/itwinui-react": "~1.42.0",
95
87
  "classnames": "^2.3.1",
96
88
  "dompurify": "^2.0.12",
97
89
  "lodash": "^4.17.10",