@itwin/core-react 4.5.0 → 4.6.0

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 (96) hide show
  1. package/CHANGELOG.md +14 -1
  2. package/lib/cjs/core-react/base/Gap.js +1 -1
  3. package/lib/cjs/core-react/base/Gap.js.map +1 -1
  4. package/lib/cjs/core-react/contextmenu/ContextMenu.js +2 -1
  5. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  6. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js +5 -3
  7. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  8. package/lib/cjs/core-react/dialog/Dialog.js +2 -2
  9. package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
  10. package/lib/cjs/core-react/dialog/GlobalDialog.js +2 -1
  11. package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
  12. package/lib/cjs/core-react/elementseparator/ElementSeparator.js +2 -2
  13. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  14. package/lib/cjs/core-react/hocs/withOnOutsideClick.js +2 -1
  15. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  16. package/lib/cjs/core-react/icons/IconComponent.js +1 -1
  17. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  18. package/lib/cjs/core-react/listbox/Listbox.js +3 -2
  19. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  20. package/lib/cjs/core-react/messagebox/MessageBox.d.ts +7 -3
  21. package/lib/cjs/core-react/messagebox/MessageBox.d.ts.map +1 -1
  22. package/lib/cjs/core-react/messagebox/MessageBox.js +2 -7
  23. package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
  24. package/lib/cjs/core-react/notification/MessageRenderer.js +1 -1
  25. package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
  26. package/lib/cjs/core-react/popup/Popup.js +8 -4
  27. package/lib/cjs/core-react/popup/Popup.js.map +1 -1
  28. package/lib/cjs/core-react/tree/Node.js +2 -1
  29. package/lib/cjs/core-react/tree/Node.js.map +1 -1
  30. package/lib/cjs/core-react/utils/IconWebComponent.js +1 -1
  31. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  32. package/lib/cjs/core-react/utils/Point.d.ts +3 -3
  33. package/lib/cjs/core-react/utils/Point.d.ts.map +1 -1
  34. package/lib/cjs/core-react/utils/Point.js +2 -2
  35. package/lib/cjs/core-react/utils/Point.js.map +1 -1
  36. package/lib/cjs/core-react/utils/PointProps.d.ts +9 -0
  37. package/lib/cjs/core-react/utils/PointProps.d.ts.map +1 -0
  38. package/lib/cjs/core-react/utils/PointProps.js +3 -0
  39. package/lib/cjs/core-react/utils/PointProps.js.map +1 -0
  40. package/lib/cjs/core-react/utils/Rectangle.d.ts +1 -1
  41. package/lib/cjs/core-react/utils/Rectangle.d.ts.map +1 -1
  42. package/lib/cjs/core-react/utils/Rectangle.js.map +1 -1
  43. package/lib/cjs/core-react/utils/getCssVariable.js +1 -1
  44. package/lib/cjs/core-react/utils/getCssVariable.js.map +1 -1
  45. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js +2 -1
  46. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  47. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js +14 -8
  48. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  49. package/lib/esm/core-react/base/Gap.js +1 -1
  50. package/lib/esm/core-react/base/Gap.js.map +1 -1
  51. package/lib/esm/core-react/contextmenu/ContextMenu.js +2 -1
  52. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  53. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js +5 -3
  54. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  55. package/lib/esm/core-react/dialog/Dialog.js +2 -2
  56. package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
  57. package/lib/esm/core-react/dialog/GlobalDialog.js +2 -1
  58. package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
  59. package/lib/esm/core-react/elementseparator/ElementSeparator.js +2 -2
  60. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  61. package/lib/esm/core-react/hocs/withOnOutsideClick.js +2 -1
  62. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  63. package/lib/esm/core-react/icons/IconComponent.js +1 -1
  64. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  65. package/lib/esm/core-react/listbox/Listbox.js +3 -2
  66. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  67. package/lib/esm/core-react/messagebox/MessageBox.d.ts +7 -3
  68. package/lib/esm/core-react/messagebox/MessageBox.d.ts.map +1 -1
  69. package/lib/esm/core-react/messagebox/MessageBox.js +2 -7
  70. package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
  71. package/lib/esm/core-react/notification/MessageRenderer.js +1 -1
  72. package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
  73. package/lib/esm/core-react/popup/Popup.js +8 -4
  74. package/lib/esm/core-react/popup/Popup.js.map +1 -1
  75. package/lib/esm/core-react/tree/Node.js +2 -1
  76. package/lib/esm/core-react/tree/Node.js.map +1 -1
  77. package/lib/esm/core-react/utils/IconWebComponent.js +1 -1
  78. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  79. package/lib/esm/core-react/utils/Point.d.ts +3 -3
  80. package/lib/esm/core-react/utils/Point.d.ts.map +1 -1
  81. package/lib/esm/core-react/utils/Point.js +2 -2
  82. package/lib/esm/core-react/utils/Point.js.map +1 -1
  83. package/lib/esm/core-react/utils/PointProps.d.ts +9 -0
  84. package/lib/esm/core-react/utils/PointProps.d.ts.map +1 -0
  85. package/lib/esm/core-react/utils/PointProps.js +2 -0
  86. package/lib/esm/core-react/utils/PointProps.js.map +1 -0
  87. package/lib/esm/core-react/utils/Rectangle.d.ts +1 -1
  88. package/lib/esm/core-react/utils/Rectangle.d.ts.map +1 -1
  89. package/lib/esm/core-react/utils/Rectangle.js.map +1 -1
  90. package/lib/esm/core-react/utils/getCssVariable.js +1 -1
  91. package/lib/esm/core-react/utils/getCssVariable.js.map +1 -1
  92. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js +2 -1
  93. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  94. package/lib/esm/core-react/utils/hooks/useResizeObserver.js +14 -8
  95. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  96. package/package.json +2 -3
@@ -1 +1 @@
1
- {"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,gCAA8B;AAC9B,+BAA+B;AAC/B,2CAAoC;AACpC,0DAG+B;AAE/B,oEAAoD;AACpD,+DAA4D;AAqB5D;;GAEG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,UAAU,GACd,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ;QAClC,KAAK,CAAC,QAAQ,YAAY,uCAAsB;QAC9C,CAAC,CAAC,uCAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACjD,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,UAAU,EAAE;QACd,MAAM,kBAAkB,GACtB,kCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACtD,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,mBAAS,IAAI,WAAW,CAAC;YAE3C,MAAM,eA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AChB,CACL,CAAC;AACJ,CAAC;AApED,oBAoEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Icon\n */\n\nimport \"./IconComponent.scss\";\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport {\n ConditionalStringValue,\n IconSpecUtilities,\n} from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport { ConditionalIconItem } from \"./ConditionalIconItem\";\n\n/** Prototype for an IconSpec which can be a string, ReactNode or ConditionalStringValue.\n * @public\n */\nexport type IconSpec =\n | string\n | ConditionalStringValue\n | React.ReactNode\n | ConditionalIconItem;\n\n/** Properties for the [[Icon]] React component\n * @public\n */\nexport interface IconProps extends CommonProps {\n /** CSS class name or SvgPath for icon. This is optional because it is improperly\n * used to extend other interfaces and changing it would break existing API.\n */\n iconSpec?: IconSpec;\n}\n\n/** Icon Functional component displays an icon based on an [[IconSpec]].\n * @public\n */\nexport function Icon(props: IconProps) {\n if (!props.iconSpec) return null;\n\n const iconString =\n typeof props.iconSpec === \"string\" ||\n props.iconSpec instanceof ConditionalStringValue\n ? ConditionalStringValue.getValue(props.iconSpec)\n : undefined;\n\n if (iconString) {\n const webComponentString =\n IconSpecUtilities.getWebComponentSource(iconString);\n if (webComponentString) {\n const svgLoader = `<svg-loader src=\"${webComponentString}\"></svg-loader>`;\n const svgDiv = `<div>${svgLoader}</div>`;\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS;\n\n const sanitizerConfig = {\n ALLOWED_TAGS: [\"svg-loader\"],\n ADD_URI_SAFE_ATTR: webComponentString.startsWith(\"data:\")\n ? [\"src\"]\n : [],\n };\n\n const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);\n const webComponentNode = (\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n <div dangerouslySetInnerHTML={{ __html: sanitizedIconString }}></div>\n );\n return (\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)}>\n {webComponentNode}\n </i>\n );\n }\n return (\n <i\n className={classnames(\"icon\", iconString, props.className)}\n style={props.style}\n />\n );\n }\n\n if (ConditionalIconItem.isConditionalIconItem(props.iconSpec)) {\n return (\n <i\n className={classnames(\"icon\", \"core-svg-icon\", props.className)}\n style={props.style}\n >\n {ConditionalIconItem.getValue(props.iconSpec)}\n </i>\n );\n }\n\n return (\n <i\n className={classnames(\"icon\", \"core-svg-icon\", props.className)}\n style={props.style}\n >\n {props.iconSpec instanceof ConditionalStringValue\n ? undefined\n : props.iconSpec}\n </i>\n );\n}\n"]}
1
+ {"version":3,"file":"IconComponent.js","sourceRoot":"","sources":["../../../../src/core-react/icons/IconComponent.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,gCAA8B;AAC9B,+BAA+B;AAC/B,2CAAoC;AACpC,0DAG+B;AAE/B,oEAAoD;AACpD,+DAA4D;AAqB5D;;GAEG;AACH,SAAgB,IAAI,CAAC,KAAgB;IACnC,IAAI,CAAC,KAAK,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAC;IAEjC,MAAM,UAAU,GACd,OAAO,KAAK,CAAC,QAAQ,KAAK,QAAQ;QAClC,KAAK,CAAC,QAAQ,YAAY,uCAAsB;QAC9C,CAAC,CAAC,uCAAsB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC;QACjD,CAAC,CAAC,SAAS,CAAC;IAEhB,IAAI,UAAU,EAAE;QACd,MAAM,kBAAkB,GACtB,kCAAiB,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;QACtD,IAAI,kBAAkB,EAAE;YACtB,MAA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O,CACL,2BACE,SAAS,EAAE,IAAA,oBAAU,EAAC,MAAM,EAAE,eAAe,EAAE,KAAK,CAAC,SAAS,CAAC,EAC/D,KAAK,EAAE,KAAK,CAAC,KAAK,IAEjB,KAAK,CAAC,QAAQ,YAAY,uCAAsB;QAC/C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,KAAK,CAAC,QAAQ,CAChB,CACL,CAAC;AACJ,CAAC;AApED,oBAoEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Icon\n */\n\nimport \"./IconComponent.scss\";\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport {\n ConditionalStringValue,\n IconSpecUtilities,\n} from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport { ConditionalIconItem } from \"./ConditionalIconItem\";\n\n/** Prototype for an IconSpec which can be a string, ReactNode or ConditionalStringValue.\n * @public\n */\nexport type IconSpec =\n | string\n | ConditionalStringValue\n | React.ReactNode\n | ConditionalIconItem;\n\n/** Properties for the [[Icon]] React component\n * @public\n */\nexport interface IconProps extends CommonProps {\n /** CSS class name or SvgPath for icon. This is optional because it is improperly\n * used to extend other interfaces and changing it would break existing API.\n */\n iconSpec?: IconSpec;\n}\n\n/** Icon Functional component displays an icon based on an [[IconSpec]].\n * @public\n */\nexport function Icon(props: IconProps) {\n if (!props.iconSpec) return null;\n\n const iconString =\n typeof props.iconSpec === \"string\" ||\n props.iconSpec instanceof ConditionalStringValue\n ? ConditionalStringValue.getValue(props.iconSpec)\n : undefined;\n\n if (iconString) {\n const webComponentString =\n IconSpecUtilities.getWebComponentSource(iconString);\n if (webComponentString) {\n const svgLoader = `<svg-loader src=\"${webComponentString}\"></svg-loader>`;\n const svgDiv = `<div>${svgLoader}</div>`;\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS;\n\n const sanitizerConfig = {\n ALLOWED_TAGS: [\"svg-loader\"],\n ADD_URI_SAFE_ATTR: webComponentString.startsWith(\"data:\")\n ? [\"src\"]\n : [],\n };\n\n const sanitizedIconString = sanitizer.sanitize(svgDiv, sanitizerConfig);\n const webComponentNode = (\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n <div dangerouslySetInnerHTML={{ __html: sanitizedIconString }}></div>\n );\n return (\n <i className={classnames(\"icon\", \"core-svg-icon\", props.className)}>\n {webComponentNode}\n </i>\n );\n }\n return (\n <i\n className={classnames(\"icon\", iconString, props.className)}\n style={props.style}\n />\n );\n }\n\n if (ConditionalIconItem.isConditionalIconItem(props.iconSpec)) {\n return (\n <i\n className={classnames(\"icon\", \"core-svg-icon\", props.className)}\n style={props.style}\n >\n {ConditionalIconItem.getValue(props.iconSpec)}\n </i>\n );\n }\n\n return (\n <i\n className={classnames(\"icon\", \"core-svg-icon\", props.className)}\n style={props.style}\n >\n {props.iconSpec instanceof ConditionalStringValue\n ? undefined\n : props.iconSpec}\n </i>\n );\n}\n"]}
@@ -76,7 +76,7 @@ function Listbox(props) {
76
76
  const { ariaLabel, ariaLabelledBy, id, children, selectedValue, className, onListboxValueChange, onKeyDown, ...otherProps } = props;
77
77
  const listRef = React.useRef(null);
78
78
  const [listId] = React.useState(() => {
79
- return id ?? core_bentley_1.Guid.createValue();
79
+ return id !== null && id !== void 0 ? id : core_bentley_1.Guid.createValue();
80
80
  });
81
81
  const optionValues = React.useMemo(() => getOptionValueArray(children), [children]);
82
82
  const classes = React.useMemo(() => (0, classnames_1.default)("core-listbox", className), [className]);
@@ -206,9 +206,10 @@ function ListboxItem(props) {
206
206
  const itemRef = React.useRef(null);
207
207
  const isSelected = listboxValue === value;
208
208
  const handleClick = React.useCallback((event) => {
209
+ var _a, _b;
209
210
  event.preventDefault();
210
211
  // istanbul ignore next
211
- const selectedValue = event.currentTarget?.dataset?.value;
212
+ const selectedValue = (_b = (_a = event.currentTarget) === null || _a === void 0 ? void 0 : _a.dataset) === null || _b === void 0 ? void 0 : _b.value;
212
213
  // istanbul ignore else
213
214
  if (undefined !== selectedValue) {
214
215
  onListboxValueChange(selectedValue, event.ctrlKey);
@@ -1 +1 @@
1
- {"version":3,"file":"Listbox.js","sourceRoot":"","sources":["../../../../src/core-react/listbox/Listbox.tsx"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,+BAA+B;AAC/B,2CAAoC;AAEpC,0BAAwB;AACxB,sDAA2C;AAC3C,0DAAmD;AA2DnD;;;GAGG;AACH,uBAAuB;AACV,QAAA,cAAc,GAAG,KAAK,CAAC,aAAa,CAAsB;IACrE,oBAAoB,EAAE,CAAC,SAAmC,EAAE,EAAE,GAAE,CAAC;CAClE,CAAC,CAAC;AAEH,SAAS,MAAM,CAAC,GAAG,IAA+C;IAChE,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC;AAED,SAAS,mBAAmB,CAAC,UAA2B;IACtD,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,UAAU,CAAC;SACtC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;SAChE,GAAG,CACF,CAAC,UAAU,EAAE,EAAE,CACZ,UAAiC,CAAC,KAAyB,CAC/D,CAAC;AACN,CAAC;AAED,SAAS,yBAAyB,CAChC,YAAgC,EAChC,SAAiB,EACjB,GAAW;IAEX,IAAI,YAAY,GAAG,KAAK,CAAC;IACzB,IAAI,QAAQ,GAAG,SAAS,IA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KAAK,CAAC,MAAM,CAAgB,IAAI,CAAC,CAAC;IAClD,MAAM,UAAU,GAAG,YAAY,KAAK,KAAK,CAAC;IAE1C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACnC,CAAC,KAAkD,EAAE,EAAE;QACrD,KAAK,CAAC,cAAc,EAAE,CAAC;QACvB,uBAAuB;QACvB,MAAM,aAAa,GAAG,KAAK,CAAC,aAAa,EAAE,OAAO,EAAE,KAAK,CAAC;QAC1D,uBAAuB;QACvB,IAAI,SAAS,KAAK,aAAa,EAAE;YAC/B,oBAAoB,CAAC,aAAa,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;SACpD;IACH,CAAC,EACD,CAAC,oBAAoB,CAAC,CACvB,CAAC;IAEF,MAAM,SAAS,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE;QACvC,OAAO,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,OAAO;IACL,iEAAiE;IACjE,6CAIiB,UAAU,mBAIV,QAAQ,IAAI,SAAS;QACpC,uEAAuE;QACvE,sCAAsC;QACtC,wDAAwD;QACxD,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,KACd,UAAU,EACd,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,SAAS,EAAE,gBAEH,KAAK,EACjB,OAAO,EAAE,WAAW,IAEnB,QAAQ,CACN,CACN,CAAC;AACJ,CAAC;AA1DD,kCA0DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport classnames from \"classnames\";\n\nimport \"./Listbox.scss\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\n\n/** Ideas borrowed from https://reacttraining.com/reach-ui/listbox */\n\n/**\n * `Listbox` value.\n * @alpha\n */\nexport type ListboxValue = string;\n\n/**\n * `Listbox` Props.\n * @alpha\n */\nexport interface ListboxProps\n extends React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLUListElement>,\n HTMLUListElement\n > {\n id?: string;\n selectedValue?: ListboxValue;\n ariaLabel?: any;\n ariaLabelledBy?: any;\n onListboxValueChange?: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n}\n\n/**\n * `ListboxItem` Props.\n * @alpha\n */\nexport interface ListboxItemProps\n extends React.DetailedHTMLProps<\n React.LiHTMLAttributes<HTMLLIElement>,\n HTMLLIElement\n > {\n /** The unique item's value. */\n value: ListboxValue;\n /** set if item is disabled. */\n disabled?: boolean;\n}\n\n/**\n * `Listbox` Context.\n * @alpha\n */\nexport interface ListboxContextProps {\n listboxId?: string;\n listboxValue?: ListboxValue;\n focusValue?: ListboxValue;\n onListboxValueChange: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n listboxRef?: React.RefObject<HTMLUListElement>;\n}\n\n/**\n * Context set up by listbox for use by `ListboxItems` .\n * @alpha\n */\n// istanbul ignore next\nexport const ListboxContext = React.createContext<ListboxContextProps>({\n onListboxValueChange: (_newValue: ListboxValue | undefined) => {},\n});\n\nfunction makeId(...args: Array<string | number | null | undefined>) {\n return args.filter((val) => val != null).join(\"--\");\n}\n\nfunction getOptionValueArray(childNodes: React.ReactNode): ListboxItemProps[] {\n return React.Children.toArray(childNodes)\n .filter((node) => React.isValidElement(node) && node.props.value)\n .map(\n (optionNode) =>\n (optionNode as React.ReactElement).props as ListboxItemProps\n );\n}\n\nfunction processKeyboardNavigation(\n optionValues: ListboxItemProps[],\n itemIndex: number,\n key: string\n): [number, boolean] {\n let keyProcessed = false;\n let newIndex = itemIndex >= 0 ? itemIndex : 0;\n\n // Note: In aria example Page Up/Down just moves up or down by one item. See https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/js/listbox.js\n if (key === SpecialKey.ArrowDown || key === SpecialKey.PageDown) {\n for (let i = itemIndex + 1; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.ArrowUp || key === SpecialKey.PageUp) {\n for (let i = itemIndex - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.Home) {\n for (let i = 0; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.End) {\n for (let i = optionValues.length - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n }\n return [newIndex, keyProcessed];\n}\n\n/**\n * Single select `Listbox` component\n * @alpha\n */\nexport function Listbox(props: ListboxProps) {\n const {\n ariaLabel,\n ariaLabelledBy,\n id,\n children,\n selectedValue,\n className,\n onListboxValueChange,\n onKeyDown,\n ...otherProps\n } = props;\n const listRef = React.useRef<HTMLUListElement>(null);\n const [listId] = React.useState(() => {\n return id ?? Guid.createValue();\n });\n const optionValues = React.useMemo(\n () => getOptionValueArray(children),\n [children]\n );\n const classes = React.useMemo(\n () => classnames(\"core-listbox\", className),\n [className]\n );\n const [currentValue, setCurrentValue] = React.useState<\n ListboxValue | undefined\n >(selectedValue);\n const [focusValue, setFocusValue] = React.useState<ListboxValue | undefined>(\n currentValue\n );\n\n React.useEffect(() => {\n setCurrentValue(selectedValue);\n setFocusValue(selectedValue);\n }, [selectedValue]);\n\n const scrollTopRef = React.useRef(0);\n const handleValueChange = React.useCallback(\n (newValue: ListboxValue, isControlOrCommandPressed?: boolean) => {\n // istanbul ignore else\n if (newValue !== currentValue) {\n setCurrentValue(newValue);\n setFocusValue(newValue);\n if (onListboxValueChange)\n onListboxValueChange(newValue, isControlOrCommandPressed);\n }\n },\n [setCurrentValue, currentValue, onListboxValueChange]\n );\n\n const focusOption = React.useCallback(\n (itemIndex: number) => {\n // istanbul ignore else\n if (itemIndex >= 0 && itemIndex < optionValues.length) {\n const newSelection = optionValues[itemIndex];\n const listElement = listRef.current as HTMLUListElement;\n const optionToFocus = listElement.querySelector<HTMLLIElement>(\n `li[data-value=\"${newSelection.value}\"]`\n );\n // istanbul ignore else\n if (optionToFocus && listElement) {\n let newScrollTop = listElement.scrollTop;\n\n // istanbul ignore next\n if (listElement.scrollHeight > listElement.clientHeight) {\n const scrollBottom =\n listElement.clientHeight + listElement.scrollTop;\n const elementBottom =\n optionToFocus.offsetTop + optionToFocus.offsetHeight;\n if (elementBottom > scrollBottom) {\n newScrollTop = elementBottom - listElement.clientHeight;\n } else if (optionToFocus.offsetTop < listElement.scrollTop) {\n newScrollTop = optionToFocus.offsetTop;\n }\n scrollTopRef.current = newScrollTop;\n }\n setFocusValue(newSelection.value);\n }\n }\n },\n [optionValues]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (optionValues.length < 1) return;\n\n const itemIndex =\n undefined === focusValue\n ? -1\n : optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n\n if (event.key === SpecialKey.Space) {\n event.preventDefault();\n // istanbul ignore else\n if (focusValue)\n handleValueChange(\n focusValue,\n event.getModifierState(\"Control\") || event.getModifierState(\"Meta\")\n ); // Control or Command\n return;\n } else {\n const [newItemIndex, keyProcessed] = processKeyboardNavigation(\n optionValues,\n itemIndex,\n event.key\n );\n // istanbul ignore else\n if (keyProcessed) {\n event.preventDefault();\n focusOption(newItemIndex);\n return;\n }\n }\n\n // istanbul ignore else\n if (onKeyDown) onKeyDown(event);\n },\n [focusValue, optionValues, focusOption, onKeyDown, handleValueChange]\n );\n\n const isInitialMount = React.useRef(true);\n\n React.useEffect(() => {\n const list = listRef.current as HTMLUListElement;\n\n if (isInitialMount.current) {\n isInitialMount.current = false;\n\n if (undefined !== focusValue) {\n const itemIndex = optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n focusOption(itemIndex);\n }\n } else {\n list.scrollTop = scrollTopRef.current;\n }\n }, [focusValue, focusOption, optionValues]);\n\n // istanbul ignore next\n const handleOnScroll = React.useCallback(\n (_event: React.UIEvent<HTMLUListElement, UIEvent>) => {\n if (listRef.current) scrollTopRef.current = listRef.current.scrollTop;\n },\n []\n );\n\n // istanbul ignore next\n const handleOnFocus = React.useCallback(\n (_event: React.FocusEvent<HTMLUListElement>) => {\n if (!focusValue || 0 === focusValue.length) {\n if (currentValue) {\n setFocusValue(currentValue);\n } else {\n if (optionValues.length > 0) setFocusValue(optionValues[0].value);\n }\n }\n },\n [currentValue, focusValue, optionValues]\n );\n\n return (\n <ul\n className={classes}\n // If the listbox is not part of another widget, then it has a visible\n // label referenced by `aria-labelledby` on the element with role\n // `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n // If an `aria-label` is passed, we should skip `aria-labelledby` to\n // avoid confusion.\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy}\n aria-label={ariaLabel}\n // An element that contains or owns all the listbox options has role\n // listbox.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"listbox\"\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-collapsible.html\n tabIndex={0}\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-scrollable.html\n aria-activedescendant={makeId(currentValue, listId)}\n {...otherProps}\n ref={listRef}\n id={listId}\n onKeyDown={handleKeyDown}\n onScroll={handleOnScroll}\n data-value={currentValue}\n data-focusvalue={focusValue}\n onFocus={handleOnFocus}\n >\n <ListboxContext.Provider\n value={{\n listboxValue: currentValue,\n focusValue,\n listboxId: listId,\n onListboxValueChange: handleValueChange,\n listboxRef: listRef,\n }}\n >\n {children}\n </ListboxContext.Provider>\n </ul>\n );\n}\n\n/**\n * `ListboxItem` component.\n * @alpha\n */\nexport function ListboxItem(props: ListboxItemProps) {\n const { children, value, className, disabled, ...otherProps } = props;\n\n const { listboxValue, focusValue, listboxId, onListboxValueChange } =\n React.useContext(ListboxContext);\n\n const hasFocus = focusValue === value;\n\n const classes = React.useMemo(\n () => classnames(\"core-listbox-item\", hasFocus && \"focused\", className),\n [className, hasFocus]\n );\n const itemRef = React.useRef<HTMLLIElement>(null);\n const isSelected = listboxValue === value;\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLLIElement, MouseEvent>) => {\n event.preventDefault();\n // istanbul ignore next\n const selectedValue = event.currentTarget?.dataset?.value;\n // istanbul ignore else\n if (undefined !== selectedValue) {\n onListboxValueChange(selectedValue, event.ctrlKey);\n }\n },\n [onListboxValueChange]\n );\n\n const getItemId = React.useCallback(() => {\n return makeId(value, listboxId);\n }, [listboxId, value]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <li\n // In a single-select listbox, the selected option has `aria-selected`\n // set to `true`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n aria-selected={isSelected}\n // Applicable to all host language elements regardless of whether a\n // `role` is applied.\n // https://www.w3.org/WAI/PF/aria/states_and_properties#global_states_header\n aria-disabled={disabled || undefined}\n // Each option in the listbox has role `option` and is a DOM descendant\n // of the element with role `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"option\"\n className={classes}\n {...otherProps}\n ref={itemRef}\n id={getItemId()}\n // used for css styling\n data-value={value}\n onClick={handleClick}\n >\n {children}\n </li>\n );\n}\n"]}
1
+ {"version":3,"file":"Listbox.js","sourceRoot":"","sources":["../../../../src/core-react/listbox/Listbox.tsx"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG,+BAA+B;AAC/B,2CAAoC;AAEpC,0BAAwB;AACxB,sDAA2C;AAC3C,0DAAmD;AA2DnD;;;GAGG;AACH,uBAAuB;AACV,QAAA,cAAc,GAAG,KAAK,CAAC,aAAa,CAAsB;IACrE,oBAAoB,EAAE,CAAC,SAAmC,EAA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AC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC;IAEvB,OAAO;IACL,iEAAiE;IACjE,6CAIiB,UAAU,mBAIV,QAAQ,IAAI,SAAS;QACpC,uEAAuE;QACvE,sCAAsC;QACtC,wDAAwD;QACxD,IAAI,EAAC,QAAQ,EACb,SAAS,EAAE,OAAO,KACd,UAAU,EACd,GAAG,EAAE,OAAO,EACZ,EAAE,EAAE,SAAS,EAAE,gBAEH,KAAK,EACjB,OAAO,EAAE,WAAW,IAEnB,QAAQ,CACN,CACN,CAAC;AACJ,CAAC;AA1DD,kCA0DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\nimport * as React from \"react\";\nimport classnames from \"classnames\";\n\nimport \"./Listbox.scss\";\nimport { Guid } from \"@itwin/core-bentley\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\n\n/** Ideas borrowed from https://reacttraining.com/reach-ui/listbox */\n\n/**\n * `Listbox` value.\n * @alpha\n */\nexport type ListboxValue = string;\n\n/**\n * `Listbox` Props.\n * @alpha\n */\nexport interface ListboxProps\n extends React.DetailedHTMLProps<\n React.HTMLAttributes<HTMLUListElement>,\n HTMLUListElement\n > {\n id?: string;\n selectedValue?: ListboxValue;\n ariaLabel?: any;\n ariaLabelledBy?: any;\n onListboxValueChange?: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n}\n\n/**\n * `ListboxItem` Props.\n * @alpha\n */\nexport interface ListboxItemProps\n extends React.DetailedHTMLProps<\n React.LiHTMLAttributes<HTMLLIElement>,\n HTMLLIElement\n > {\n /** The unique item's value. */\n value: ListboxValue;\n /** set if item is disabled. */\n disabled?: boolean;\n}\n\n/**\n * `Listbox` Context.\n * @alpha\n */\nexport interface ListboxContextProps {\n listboxId?: string;\n listboxValue?: ListboxValue;\n focusValue?: ListboxValue;\n onListboxValueChange: (\n newValue: ListboxValue,\n isControlOrCommandPressed?: boolean\n ) => void;\n listboxRef?: React.RefObject<HTMLUListElement>;\n}\n\n/**\n * Context set up by listbox for use by `ListboxItems` .\n * @alpha\n */\n// istanbul ignore next\nexport const ListboxContext = React.createContext<ListboxContextProps>({\n onListboxValueChange: (_newValue: ListboxValue | undefined) => {},\n});\n\nfunction makeId(...args: Array<string | number | null | undefined>) {\n return args.filter((val) => val != null).join(\"--\");\n}\n\nfunction getOptionValueArray(childNodes: React.ReactNode): ListboxItemProps[] {\n return React.Children.toArray(childNodes)\n .filter((node) => React.isValidElement(node) && node.props.value)\n .map(\n (optionNode) =>\n (optionNode as React.ReactElement).props as ListboxItemProps\n );\n}\n\nfunction processKeyboardNavigation(\n optionValues: ListboxItemProps[],\n itemIndex: number,\n key: string\n): [number, boolean] {\n let keyProcessed = false;\n let newIndex = itemIndex >= 0 ? itemIndex : 0;\n\n // Note: In aria example Page Up/Down just moves up or down by one item. See https://www.w3.org/TR/wai-aria-practices-1.1/examples/listbox/js/listbox.js\n if (key === SpecialKey.ArrowDown || key === SpecialKey.PageDown) {\n for (let i = itemIndex + 1; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.ArrowUp || key === SpecialKey.PageUp) {\n for (let i = itemIndex - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.Home) {\n for (let i = 0; i < optionValues.length; i++) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n } else if (key === SpecialKey.End) {\n for (let i = optionValues.length - 1; i >= 0; i--) {\n if (!optionValues[i].disabled) {\n newIndex = i;\n break;\n }\n }\n keyProcessed = true;\n }\n return [newIndex, keyProcessed];\n}\n\n/**\n * Single select `Listbox` component\n * @alpha\n */\nexport function Listbox(props: ListboxProps) {\n const {\n ariaLabel,\n ariaLabelledBy,\n id,\n children,\n selectedValue,\n className,\n onListboxValueChange,\n onKeyDown,\n ...otherProps\n } = props;\n const listRef = React.useRef<HTMLUListElement>(null);\n const [listId] = React.useState(() => {\n return id ?? Guid.createValue();\n });\n const optionValues = React.useMemo(\n () => getOptionValueArray(children),\n [children]\n );\n const classes = React.useMemo(\n () => classnames(\"core-listbox\", className),\n [className]\n );\n const [currentValue, setCurrentValue] = React.useState<\n ListboxValue | undefined\n >(selectedValue);\n const [focusValue, setFocusValue] = React.useState<ListboxValue | undefined>(\n currentValue\n );\n\n React.useEffect(() => {\n setCurrentValue(selectedValue);\n setFocusValue(selectedValue);\n }, [selectedValue]);\n\n const scrollTopRef = React.useRef(0);\n const handleValueChange = React.useCallback(\n (newValue: ListboxValue, isControlOrCommandPressed?: boolean) => {\n // istanbul ignore else\n if (newValue !== currentValue) {\n setCurrentValue(newValue);\n setFocusValue(newValue);\n if (onListboxValueChange)\n onListboxValueChange(newValue, isControlOrCommandPressed);\n }\n },\n [setCurrentValue, currentValue, onListboxValueChange]\n );\n\n const focusOption = React.useCallback(\n (itemIndex: number) => {\n // istanbul ignore else\n if (itemIndex >= 0 && itemIndex < optionValues.length) {\n const newSelection = optionValues[itemIndex];\n const listElement = listRef.current as HTMLUListElement;\n const optionToFocus = listElement.querySelector<HTMLLIElement>(\n `li[data-value=\"${newSelection.value}\"]`\n );\n // istanbul ignore else\n if (optionToFocus && listElement) {\n let newScrollTop = listElement.scrollTop;\n\n // istanbul ignore next\n if (listElement.scrollHeight > listElement.clientHeight) {\n const scrollBottom =\n listElement.clientHeight + listElement.scrollTop;\n const elementBottom =\n optionToFocus.offsetTop + optionToFocus.offsetHeight;\n if (elementBottom > scrollBottom) {\n newScrollTop = elementBottom - listElement.clientHeight;\n } else if (optionToFocus.offsetTop < listElement.scrollTop) {\n newScrollTop = optionToFocus.offsetTop;\n }\n scrollTopRef.current = newScrollTop;\n }\n setFocusValue(newSelection.value);\n }\n }\n },\n [optionValues]\n );\n\n const handleKeyDown = React.useCallback(\n (event: React.KeyboardEvent<HTMLUListElement>) => {\n if (optionValues.length < 1) return;\n\n const itemIndex =\n undefined === focusValue\n ? -1\n : optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n\n if (event.key === SpecialKey.Space) {\n event.preventDefault();\n // istanbul ignore else\n if (focusValue)\n handleValueChange(\n focusValue,\n event.getModifierState(\"Control\") || event.getModifierState(\"Meta\")\n ); // Control or Command\n return;\n } else {\n const [newItemIndex, keyProcessed] = processKeyboardNavigation(\n optionValues,\n itemIndex,\n event.key\n );\n // istanbul ignore else\n if (keyProcessed) {\n event.preventDefault();\n focusOption(newItemIndex);\n return;\n }\n }\n\n // istanbul ignore else\n if (onKeyDown) onKeyDown(event);\n },\n [focusValue, optionValues, focusOption, onKeyDown, handleValueChange]\n );\n\n const isInitialMount = React.useRef(true);\n\n React.useEffect(() => {\n const list = listRef.current as HTMLUListElement;\n\n if (isInitialMount.current) {\n isInitialMount.current = false;\n\n if (undefined !== focusValue) {\n const itemIndex = optionValues.findIndex(\n (optionValue) => optionValue.value === focusValue\n );\n focusOption(itemIndex);\n }\n } else {\n list.scrollTop = scrollTopRef.current;\n }\n }, [focusValue, focusOption, optionValues]);\n\n // istanbul ignore next\n const handleOnScroll = React.useCallback(\n (_event: React.UIEvent<HTMLUListElement, UIEvent>) => {\n if (listRef.current) scrollTopRef.current = listRef.current.scrollTop;\n },\n []\n );\n\n // istanbul ignore next\n const handleOnFocus = React.useCallback(\n (_event: React.FocusEvent<HTMLUListElement>) => {\n if (!focusValue || 0 === focusValue.length) {\n if (currentValue) {\n setFocusValue(currentValue);\n } else {\n if (optionValues.length > 0) setFocusValue(optionValues[0].value);\n }\n }\n },\n [currentValue, focusValue, optionValues]\n );\n\n return (\n <ul\n className={classes}\n // If the listbox is not part of another widget, then it has a visible\n // label referenced by `aria-labelledby` on the element with role\n // `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n // If an `aria-label` is passed, we should skip `aria-labelledby` to\n // avoid confusion.\n aria-labelledby={ariaLabel ? undefined : ariaLabelledBy}\n aria-label={ariaLabel}\n // An element that contains or owns all the listbox options has role\n // listbox.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"listbox\"\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-collapsible.html\n tabIndex={0}\n // https://www.w3.org/TR/wai-aria-practices-1.2/examples/listbox/listbox-scrollable.html\n aria-activedescendant={makeId(currentValue, listId)}\n {...otherProps}\n ref={listRef}\n id={listId}\n onKeyDown={handleKeyDown}\n onScroll={handleOnScroll}\n data-value={currentValue}\n data-focusvalue={focusValue}\n onFocus={handleOnFocus}\n >\n <ListboxContext.Provider\n value={{\n listboxValue: currentValue,\n focusValue,\n listboxId: listId,\n onListboxValueChange: handleValueChange,\n listboxRef: listRef,\n }}\n >\n {children}\n </ListboxContext.Provider>\n </ul>\n );\n}\n\n/**\n * `ListboxItem` component.\n * @alpha\n */\nexport function ListboxItem(props: ListboxItemProps) {\n const { children, value, className, disabled, ...otherProps } = props;\n\n const { listboxValue, focusValue, listboxId, onListboxValueChange } =\n React.useContext(ListboxContext);\n\n const hasFocus = focusValue === value;\n\n const classes = React.useMemo(\n () => classnames(\"core-listbox-item\", hasFocus && \"focused\", className),\n [className, hasFocus]\n );\n const itemRef = React.useRef<HTMLLIElement>(null);\n const isSelected = listboxValue === value;\n\n const handleClick = React.useCallback(\n (event: React.MouseEvent<HTMLLIElement, MouseEvent>) => {\n event.preventDefault();\n // istanbul ignore next\n const selectedValue = event.currentTarget?.dataset?.value;\n // istanbul ignore else\n if (undefined !== selectedValue) {\n onListboxValueChange(selectedValue, event.ctrlKey);\n }\n },\n [onListboxValueChange]\n );\n\n const getItemId = React.useCallback(() => {\n return makeId(value, listboxId);\n }, [listboxId, value]);\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <li\n // In a single-select listbox, the selected option has `aria-selected`\n // set to `true`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n aria-selected={isSelected}\n // Applicable to all host language elements regardless of whether a\n // `role` is applied.\n // https://www.w3.org/WAI/PF/aria/states_and_properties#global_states_header\n aria-disabled={disabled || undefined}\n // Each option in the listbox has role `option` and is a DOM descendant\n // of the element with role `listbox`.\n // https://www.w3.org/TR/wai-aria-practices-1.2/#Listbox\n role=\"option\"\n className={classes}\n {...otherProps}\n ref={itemRef}\n id={getItemId()}\n // used for css styling\n data-value={value}\n onClick={handleClick}\n >\n {children}\n </li>\n );\n}\n"]}
@@ -65,12 +65,16 @@ export interface MessageContainerProps extends CommonProps {
65
65
  * @public
66
66
  */
67
67
  export declare class MessageContainer extends React.PureComponent<MessageContainerProps> {
68
+ /** Returns the class name corresponding to the MessageSeverity.
69
+ * @param severity MessageSeverity
70
+ */
71
+ static getIconClassName(severity: MessageSeverity): string;
68
72
  /** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.
69
73
  * @param severity MessageSeverity
70
- * @param _hollow @deprecated in 4.0. Ignored.
71
- * @deprecated in 4.0. Please use getIcon method
74
+ * @param hollow Should the icon be hollow
75
+ * @deprecated in 4.0. Hollow parameter ignored, WebFont is not returned, only the color.
72
76
  */
73
- static getIconClassName(severity: MessageSeverity, _hollow?: boolean): string;
77
+ static getIconClassName(severity: MessageSeverity, hollow?: boolean): string;
74
78
  /** Returns the React icon corresponding to the MessageSeverity.
75
79
  * @param severity MessageSeverity
76
80
  * @param hollow set to true to return the hollow form of the icon.
@@ -1 +1 @@
1
- {"version":3,"file":"MessageBox.d.ts","sourceRoot":"","sources":["../../../../src/core-react/messagebox/MessageBox.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,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ainer extends React.PureComponent {
38
- /** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.
39
- * @param severity MessageSeverity
40
- * @param _hollow @deprecated in 4.0. Ignored.
41
- * @deprecated in 4.0. Please use getIcon method
42
- */
43
38
  /* istanbul ignore next */
44
39
  static getIconClassName(severity, _hollow) {
45
40
  let iconClassName = "";
@@ -57,7 +52,7 @@ class MessageContainer extends React.PureComponent {
57
52
  iconClassName = "core-message-box-question";
58
53
  break;
59
54
  case appui_abstract_1.MessageSeverity.Warning:
60
- iconClassName = "core-message-box-warning"; // TODO - need icon-status-warning-hollow icon
55
+ iconClassName = "core-message-box-warning";
61
56
  break;
62
57
  case appui_abstract_1.MessageSeverity.Error:
63
58
  iconClassName = "core-message-box-error";
@@ -103,7 +98,7 @@ class MessageContainer extends React.PureComponent {
103
98
  return iconSpec;
104
99
  }
105
100
  render() {
106
- const iconClassName = (0, classnames_1.default)("icon", "core-message-box-icon");
101
+ const iconClassName = (0, classnames_1.default)("icon", "core-message-box-icon", MessageContainer.getIconClassName(this.props.severity));
107
102
  const iconSpec = MessageContainer.getIcon(this.props.severity);
108
103
  return (React.createElement("div", { className: "core-message-box-container" },
109
104
  React.createElement("div", { className: iconClassName },
@@ -1 +1 @@
1
- {"version":3,"file":"MessageBox.js","sourceRoot":"","sources":["../../../../src/core-react/messagebox/MessageBox.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,6BAA2B;AAC3B,2CAAoC;AACpC,+BAA+B;AAE/B,0DAAwD;AAExD,oEAYoC;AAEpC,0DAA8C;AAC9C,6CAA0C;AA0C1C;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK,CAAC,aAA8B;IAQlD,MAAM;QACpB,OAAO,CACL,oBAAC,eAAM,IACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MA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YACR,KAAK,gCAAe,CAAC,KAAK;gBACxB,QAAQ,GAAG,MAAM,CAAC,CAAC,CAAC,oBAAC,6CAAuB,OAAG,CAAC,CAAC,CAAC,oBAAC,uCAAiB,OAAG,CAAC;gBACxE,MAAM;SACT;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEe,MAAM;QACpB,MAAM,aAAa,GAAG,IAAA,oBAAU,EAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;QAElE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/D,OAAO,CACL,6BAAK,SAAS,EAAC,4BAA4B;YACzC,6BAAK,SAAS,EAAE,aAAa;gBAC3B,oBAAC,oBAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACxB;YACN,6BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,0BAA0B,EAC1B,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAEtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACF,CACP,CAAC;IACJ,CAAC;CACF;AAjGD,4CAiGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Dialog\n */\n\nimport \"./MessageBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { MessageSeverity } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport {\n SvgHelpCircular,\n SvgHelpCircularHollow,\n SvgInfoCircular,\n SvgInfoCircularHollow,\n SvgStatusError,\n SvgStatusErrorHollow,\n SvgStatusRejected,\n SvgStatusRejectedHollow,\n SvgStatusSuccess,\n SvgStatusSuccessHollow,\n SvgStatusWarning,\n} from \"@itwin/itwinui-icons-react\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Dialog } from \"../dialog/Dialog\";\n\n/** Properties for the [[MessageBox]] component\n * @public\n */\nexport interface MessageBoxProps extends CommonProps {\n /** Severity of MessageBox */\n severity: MessageSeverity;\n /** whether to show dialog or not */\n opened: boolean;\n /** List of [[DialogButtonDef]] objects specifying buttons and associated onClick events */\n buttonCluster: DialogButtonDef[];\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for <Esc> key */\n onEscape?: () => void;\n /** minimum width that the dialog may be resized to. Default: 400 */\n minWidth?: number;\n /** minimum height that the dialog may be resized to. Default: 400 */\n minHeight?: number;\n /** initial width of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"50%\"\n */\n width?: string | number;\n /** initial height of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"\"\n */\n height?: string | number;\n /** Whether to show background overlay. Default: true */\n modal?: boolean;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n /** Message content */\n children?: React.ReactNode;\n}\n\n/** Message Box React component.\n * @public\n */\nexport class MessageBox extends React.PureComponent<MessageBoxProps> {\n public static defaultProps: Partial<MessageBoxProps> = {\n minWidth: 400,\n minHeight: 400,\n width: \"512px\",\n modal: true,\n };\n\n public override render(): React.ReactElement {\n return (\n <Dialog\n title={this.props.title}\n buttonCluster={this.props.buttonCluster}\n opened={this.props.opened}\n onClose={this.props.onClose}\n onEscape={this.props.onEscape}\n modal={this.props.modal}\n className={this.props.className}\n style={this.props.style}\n width={this.props.width}\n >\n <MessageContainer\n severity={this.props.severity}\n className={this.props.contentClassName}\n style={this.props.contentStyle}\n >\n {this.props.children}\n </MessageContainer>\n </Dialog>\n );\n }\n}\n\n/** Properties for the [[MessageContainer]] component\n * @public\n */\nexport interface MessageContainerProps extends CommonProps {\n severity: MessageSeverity;\n /** Message Content */\n children?: React.ReactNode;\n}\n\n/** Message Container React component.\n * @public\n */\nexport class MessageContainer extends React.PureComponent<MessageContainerProps> {\n /** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param _hollow @deprecated in 4.0. Ignored.\n * @deprecated in 4.0. Please use getIcon method\n */\n /* istanbul ignore next */\n public static getIconClassName(\n severity: MessageSeverity,\n _hollow?: boolean\n ): string {\n let iconClassName = \"\";\n\n switch (severity) {\n case MessageSeverity.None:\n iconClassName = \"\";\n break;\n case MessageSeverity.Success:\n iconClassName = \"core-message-box-success\";\n break;\n case MessageSeverity.Information:\n iconClassName = \"core-message-box-information\";\n break;\n case MessageSeverity.Question:\n iconClassName = \"core-message-box-question\";\n break;\n case MessageSeverity.Warning:\n iconClassName = \"core-message-box-warning\"; // TODO - need icon-status-warning-hollow icon\n break;\n case MessageSeverity.Error:\n iconClassName = \"core-message-box-error\";\n break;\n case MessageSeverity.Fatal:\n iconClassName = \"core-message-box-fatal\";\n break;\n }\n\n return iconClassName;\n }\n\n /** Returns the React icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param hollow set to true to return the hollow form of the icon.\n * @returns IconSpec\n */\n /* ignore for unit tests and replace with visual testing */\n /* istanbul ignore next */\n public static getIcon(severity: MessageSeverity, hollow?: boolean): IconSpec {\n let iconSpec: IconSpec = \"\";\n switch (severity) {\n case MessageSeverity.None:\n iconSpec = \"\";\n break;\n case MessageSeverity.Success:\n iconSpec = hollow ? <SvgStatusSuccessHollow /> : <SvgStatusSuccess />;\n break;\n case MessageSeverity.Information:\n iconSpec = hollow ? <SvgInfoCircularHollow /> : <SvgInfoCircular />;\n break;\n case MessageSeverity.Question:\n iconSpec = hollow ? <SvgHelpCircularHollow /> : <SvgHelpCircular />;\n break;\n case MessageSeverity.Warning:\n iconSpec = <SvgStatusWarning />; // TODO - need icon-status-warning-hollow icon\n break;\n case MessageSeverity.Error:\n iconSpec = hollow ? <SvgStatusErrorHollow /> : <SvgStatusError />;\n break;\n case MessageSeverity.Fatal:\n iconSpec = hollow ? <SvgStatusRejectedHollow /> : <SvgStatusRejected />;\n break;\n }\n return iconSpec;\n }\n\n public override render(): React.ReactElement {\n const iconClassName = classnames(\"icon\", \"core-message-box-icon\");\n\n const iconSpec = MessageContainer.getIcon(this.props.severity);\n\n return (\n <div className=\"core-message-box-container\">\n <div className={iconClassName}>\n <Icon iconSpec={iconSpec} />\n </div>\n <div\n className={classnames(\n \"core-message-box-content\",\n this.props.className\n )}\n style={this.props.style}\n >\n {this.props.children}\n </div>\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"MessageBox.js","sourceRoot":"","sources":["../../../../src/core-react/messagebox/MessageBox.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,6BAA2B;AAC3B,2CAAoC;AACpC,+BAA+B;AAE/B,0DAAwD;AAExD,oEAYoC;AAEpC,0DAA8C;AAC9C,6CAA0C;AA0C1C;;GAEG;AACH,MAAa,UAAW,SAAQ,KAAK,CAAC,aAA8B;IAQlD,MAAM;QACpB,OAAO,CACL,oBAAC,eAAM,IACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YAEvB,oBAA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AAC,CACvD,CAAC;QAEF,MAAM,QAAQ,GAAG,gBAAgB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAE/D,OAAO,CACL,6BAAK,SAAS,EAAC,4BAA4B;YACzC,6BAAK,SAAS,EAAE,aAAa;gBAC3B,oBAAC,oBAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACxB;YACN,6BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,0BAA0B,EAC1B,IAAI,CAAC,KAAK,CAAC,SAAS,CACrB,EACD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,IAEtB,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACF,CACP,CAAC;IACJ,CAAC;CACF;AA9GD,4CA8GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Dialog\n */\n\nimport \"./MessageBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { DialogButtonDef } from \"@itwin/appui-abstract\";\nimport { MessageSeverity } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"../utils/Props\";\nimport {\n SvgHelpCircular,\n SvgHelpCircularHollow,\n SvgInfoCircular,\n SvgInfoCircularHollow,\n SvgStatusError,\n SvgStatusErrorHollow,\n SvgStatusRejected,\n SvgStatusRejectedHollow,\n SvgStatusSuccess,\n SvgStatusSuccessHollow,\n SvgStatusWarning,\n} from \"@itwin/itwinui-icons-react\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Dialog } from \"../dialog/Dialog\";\n\n/** Properties for the [[MessageBox]] component\n * @public\n */\nexport interface MessageBoxProps extends CommonProps {\n /** Severity of MessageBox */\n severity: MessageSeverity;\n /** whether to show dialog or not */\n opened: boolean;\n /** List of [[DialogButtonDef]] objects specifying buttons and associated onClick events */\n buttonCluster: DialogButtonDef[];\n /** Title to show in title bar of dialog */\n title?: string | React.ReactElement;\n /** onClick event for X button for dialog */\n onClose?: () => void;\n /** 'keyup' event for <Esc> key */\n onEscape?: () => void;\n /** minimum width that the dialog may be resized to. Default: 400 */\n minWidth?: number;\n /** minimum height that the dialog may be resized to. Default: 400 */\n minHeight?: number;\n /** initial width of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"50%\"\n */\n width?: string | number;\n /** initial height of dialog.\n * Displayed in px if value is a number, otherwise displayed in specified CSS unit.\n * Default: \"\"\n */\n height?: string | number;\n /** Whether to show background overlay. Default: true */\n modal?: boolean;\n /** Custom CSS class name for the content */\n contentClassName?: string;\n /** Custom CSS Style for the content */\n contentStyle?: React.CSSProperties;\n /** Message content */\n children?: React.ReactNode;\n}\n\n/** Message Box React component.\n * @public\n */\nexport class MessageBox extends React.PureComponent<MessageBoxProps> {\n public static defaultProps: Partial<MessageBoxProps> = {\n minWidth: 400,\n minHeight: 400,\n width: \"512px\",\n modal: true,\n };\n\n public override render(): React.ReactElement {\n return (\n <Dialog\n title={this.props.title}\n buttonCluster={this.props.buttonCluster}\n opened={this.props.opened}\n onClose={this.props.onClose}\n onEscape={this.props.onEscape}\n modal={this.props.modal}\n className={this.props.className}\n style={this.props.style}\n width={this.props.width}\n >\n <MessageContainer\n severity={this.props.severity}\n className={this.props.contentClassName}\n style={this.props.contentStyle}\n >\n {this.props.children}\n </MessageContainer>\n </Dialog>\n );\n }\n}\n\n/** Properties for the [[MessageContainer]] component\n * @public\n */\nexport interface MessageContainerProps extends CommonProps {\n severity: MessageSeverity;\n /** Message Content */\n children?: React.ReactNode;\n}\n\n/** Message Container React component.\n * @public\n */\nexport class MessageContainer extends React.PureComponent<MessageContainerProps> {\n /** Returns the class name corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n */\n public static getIconClassName(severity: MessageSeverity): string;\n /** Returns the class name associated with the WebFont icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param hollow Should the icon be hollow\n * @deprecated in 4.0. Hollow parameter ignored, WebFont is not returned, only the color.\n */\n public static getIconClassName(\n severity: MessageSeverity,\n // eslint-disable-next-line @typescript-eslint/unified-signatures\n hollow?: boolean\n ): string;\n /* istanbul ignore next */\n public static getIconClassName(\n severity: MessageSeverity,\n _hollow?: boolean\n ): string {\n let iconClassName = \"\";\n\n switch (severity) {\n case MessageSeverity.None:\n iconClassName = \"\";\n break;\n case MessageSeverity.Success:\n iconClassName = \"core-message-box-success\";\n break;\n case MessageSeverity.Information:\n iconClassName = \"core-message-box-information\";\n break;\n case MessageSeverity.Question:\n iconClassName = \"core-message-box-question\";\n break;\n case MessageSeverity.Warning:\n iconClassName = \"core-message-box-warning\";\n break;\n case MessageSeverity.Error:\n iconClassName = \"core-message-box-error\";\n break;\n case MessageSeverity.Fatal:\n iconClassName = \"core-message-box-fatal\";\n break;\n }\n\n return iconClassName;\n }\n\n /** Returns the React icon corresponding to the MessageSeverity.\n * @param severity MessageSeverity\n * @param hollow set to true to return the hollow form of the icon.\n * @returns IconSpec\n */\n /* ignore for unit tests and replace with visual testing */\n /* istanbul ignore next */\n public static getIcon(severity: MessageSeverity, hollow?: boolean): IconSpec {\n let iconSpec: IconSpec = \"\";\n switch (severity) {\n case MessageSeverity.None:\n iconSpec = \"\";\n break;\n case MessageSeverity.Success:\n iconSpec = hollow ? <SvgStatusSuccessHollow /> : <SvgStatusSuccess />;\n break;\n case MessageSeverity.Information:\n iconSpec = hollow ? <SvgInfoCircularHollow /> : <SvgInfoCircular />;\n break;\n case MessageSeverity.Question:\n iconSpec = hollow ? <SvgHelpCircularHollow /> : <SvgHelpCircular />;\n break;\n case MessageSeverity.Warning:\n iconSpec = <SvgStatusWarning />; // TODO - need icon-status-warning-hollow icon\n break;\n case MessageSeverity.Error:\n iconSpec = hollow ? <SvgStatusErrorHollow /> : <SvgStatusError />;\n break;\n case MessageSeverity.Fatal:\n iconSpec = hollow ? <SvgStatusRejectedHollow /> : <SvgStatusRejected />;\n break;\n }\n return iconSpec;\n }\n\n public override render(): React.ReactElement {\n const iconClassName = classnames(\n \"icon\",\n \"core-message-box-icon\",\n MessageContainer.getIconClassName(this.props.severity)\n );\n\n const iconSpec = MessageContainer.getIcon(this.props.severity);\n\n return (\n <div className=\"core-message-box-container\">\n <div className={iconClassName}>\n <Icon iconSpec={iconSpec} />\n </div>\n <div\n className={classnames(\n \"core-message-box-content\",\n this.props.className\n )}\n style={this.props.style}\n >\n {this.props.children}\n </div>\n </div>\n );\n }\n}\n"]}
@@ -24,7 +24,7 @@ function MessageRenderer(props) {
24
24
  // the esm build of dompurify has a default import but the cjs build does not
25
25
  // if there is a default export, use it (likely esm), otherwise use the namespace
26
26
  // istanbul ignore next
27
- const sanitizer = dompurify_1.default ?? DOMPurifyNS; // `sanitizer` is default function name for "jam3/no-sanitizer-with-danger" ESLint rule
27
+ const sanitizer = dompurify_1.default !== null && dompurify_1.default !== void 0 ? dompurify_1.default : DOMPurifyNS; // `sanitizer` is default function name for "jam3/no-sanitizer-with-danger" ESLint rule
28
28
  let validAnchors = false;
29
29
  let hasAnchors = false;
30
30
  // verify that the tag has proper relationships
@@ -1 +1 @@
1
- {"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,oEAAoD;AAEpD,+CAA8D;AAe9D;;GAEG;AACH,SAAgB,eAAe,CAAC,KAA2B;IACzD,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAElD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QACrC,WAAW,GAAG,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC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ACxD;YACA,UAAU,GAAG,IAAI,CAAC;YAClB,YAAY,GAAG,aAAa,CAAC,KAAK,CAAC,OAA4B,CAAC,CAAC;SAClE;aAAM;YACL,4EAA4E;YAC5E,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,EAAE;gBAC1B,iBAAiB,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;aAClC;SACF;QAED,IAAI,aAAa,CAAC;QAClB,IAAI,UAAU,IAAI,YAAY,EAAE;YAC9B,uDAAuD;YACvD,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE;gBAC1D,QAAQ,EAAE,CAAC,QAAQ,CAAC;aACrB,CAAC,CAAC;SACJ;aAAM;YACL,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SAC7D;QAED,WAAW,GAAG,CACZ,oBAAC,UAAU,IACT,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,iFAAiF;YACjF,yDAAyD;YACzD,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,GAClD,CACH,CAAC;KACH;SAAM;QACL,0BAA0B;QAC1B,IAAI,IAAA,4BAAc,EAAC,KAAK,CAAC,OAAO,CAAC;YAC/B,WAAW,GAAG,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IACnC,KAAK,CAAC,OAAO,CAAC,SAAS,CACb,CACd,CAAC;KACL;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAzFD,0CAyFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Notification\n */\n\nimport * as React from \"react\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport type { MessageType } from \"./MessageType\";\nimport { isHTMLElement, isReactMessage } from \"./MessageType\";\nimport type { ClassNameProps } from \"../utils/Props\";\n\n// cSpell:ignore dompurify\n\n/** Properties for the [[MessageRenderer]] component\n * @public\n */\nexport interface MessageRendererProps extends ClassNameProps {\n /** Message to render */\n message: MessageType;\n /** Indicates whether to use a `span` or `div` element for rendering */\n useSpan?: boolean;\n}\n\n/** React component renders a string, HTMLElement or React node in a `div` or `span`\n * @public\n */\nexport function MessageRenderer(props: MessageRendererProps) {\n let messageNode = null;\n const OutElement = props.useSpan ? \"span\" : \"div\";\n\n if (typeof props.message === \"string\") {\n messageNode = (\n <OutElement className={props.className}>{props.message}</OutElement>\n );\n } else if (isHTMLElement(props.message)) {\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS; // `sanitizer` is default function name for \"jam3/no-sanitizer-with-danger\" ESLint rule\n\n let validAnchors = false;\n let hasAnchors = false;\n\n // verify that the tag has proper relationships\n const isAnchorValid = (anchor: HTMLAnchorElement): boolean => {\n return (\n anchor.hasAttribute(\"rel\") &&\n (anchor.rel.includes(\"noopener\") || anchor.rel.includes(\"noreferrer\"))\n );\n };\n\n // recursively check child elements for valid anchor tags\n const checkChildAnchors = (parent: Element) => {\n const children = Array.from(parent.children);\n for (const child of children) {\n if (\n child.hasAttribute(\"target\") &&\n (child as HTMLAnchorElement).target === \"_blank\"\n ) {\n hasAnchors = true;\n validAnchors = isAnchorValid(child as HTMLAnchorElement);\n if (!validAnchors) {\n return;\n }\n }\n checkChildAnchors(child);\n }\n };\n\n // check for anchor tags in the message that have target _blank also have a relationship that avoids security holes\n // https://web.dev/external-anchors-use-rel-noopener/\n // first check the message element\n /* istanbul ignore else */\n if (\n props.message.hasAttribute(\"target\") &&\n (props.message as HTMLAnchorElement).target === \"_blank\"\n ) {\n hasAnchors = true;\n validAnchors = isAnchorValid(props.message as HTMLAnchorElement);\n } else {\n // if the message element is not an anchor, recursively verify it's children\n if (props.message.children) {\n checkChildAnchors(props.message);\n }\n }\n\n let sanitizedHtml;\n if (hasAnchors && validAnchors) {\n // all anchors are valid. do not remove the target attr\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, {\n ADD_ATTR: [\"target\"],\n });\n } else {\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);\n }\n\n messageNode = (\n <OutElement\n className={props.className}\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n dangerouslySetInnerHTML={{ __html: sanitizedHtml }}\n />\n );\n } else {\n /* istanbul ignore else */\n if (isReactMessage(props.message))\n messageNode = (\n <OutElement className={props.className}>\n {props.message.reactNode}\n </OutElement>\n );\n }\n\n return messageNode;\n}\n"]}
1
+ {"version":3,"file":"MessageRenderer.js","sourceRoot":"","sources":["../../../../src/core-react/notification/MessageRenderer.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,+BAA+B;AAC/B,oEAAoD;AAEpD,+CAA8D;AAe9D;;GAEG;AACH,SAAgB,eAAe,CAAC,KAA2B;IACzD,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;IAElD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ,EAAE;QACrC,WAAW,GAAG,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAG,KAAK,CAAC,OAAO,CAAc,CACrE,CAAC;KACH;SAAM,IAAI,IAAA,2BAAa,EAAC,KAAK,CAAC,OAAO,CAAC,EAAE;QACvC,6EAA6E;QAC7E,iFAAiF;QACjF,uBAAuB;QACvB,MAAM,SAAS,GAAG,mBAAS,aAAT,mBAAS,cAAT,mBAAS,GAAI,WAAW,CAAC,CAAC,uFAAuF;QAEnI,IAAI,YAAY,GAAG,K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,CAAC;QAClB,IAAI,UAAU,IAAI,YAAY,EAAE;YAC9B,uDAAuD;YACvD,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,EAAE;gBAC1D,QAAQ,EAAE,CAAC,QAAQ,CAAC;aACrB,CAAC,CAAC;SACJ;aAAM;YACL,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;SAC7D;QAED,WAAW,GAAG,CACZ,oBAAC,UAAU,IACT,SAAS,EAAE,KAAK,CAAC,SAAS;YAC1B,iFAAiF;YACjF,yDAAyD;YACzD,uBAAuB,EAAE,EAAE,MAAM,EAAE,aAAa,EAAE,GAClD,CACH,CAAC;KACH;SAAM;QACL,0BAA0B;QAC1B,IAAI,IAAA,4BAAc,EAAC,KAAK,CAAC,OAAO,CAAC;YAC/B,WAAW,GAAG,CACZ,oBAAC,UAAU,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,IACnC,KAAK,CAAC,OAAO,CAAC,SAAS,CACb,CACd,CAAC;KACL;IAED,OAAO,WAAW,CAAC;AACrB,CAAC;AAzFD,0CAyFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Notification\n */\n\nimport * as React from \"react\";\nimport DOMPurify, * as DOMPurifyNS from \"dompurify\";\nimport type { MessageType } from \"./MessageType\";\nimport { isHTMLElement, isReactMessage } from \"./MessageType\";\nimport type { ClassNameProps } from \"../utils/Props\";\n\n// cSpell:ignore dompurify\n\n/** Properties for the [[MessageRenderer]] component\n * @public\n */\nexport interface MessageRendererProps extends ClassNameProps {\n /** Message to render */\n message: MessageType;\n /** Indicates whether to use a `span` or `div` element for rendering */\n useSpan?: boolean;\n}\n\n/** React component renders a string, HTMLElement or React node in a `div` or `span`\n * @public\n */\nexport function MessageRenderer(props: MessageRendererProps) {\n let messageNode = null;\n const OutElement = props.useSpan ? \"span\" : \"div\";\n\n if (typeof props.message === \"string\") {\n messageNode = (\n <OutElement className={props.className}>{props.message}</OutElement>\n );\n } else if (isHTMLElement(props.message)) {\n // the esm build of dompurify has a default import but the cjs build does not\n // if there is a default export, use it (likely esm), otherwise use the namespace\n // istanbul ignore next\n const sanitizer = DOMPurify ?? DOMPurifyNS; // `sanitizer` is default function name for \"jam3/no-sanitizer-with-danger\" ESLint rule\n\n let validAnchors = false;\n let hasAnchors = false;\n\n // verify that the tag has proper relationships\n const isAnchorValid = (anchor: HTMLAnchorElement): boolean => {\n return (\n anchor.hasAttribute(\"rel\") &&\n (anchor.rel.includes(\"noopener\") || anchor.rel.includes(\"noreferrer\"))\n );\n };\n\n // recursively check child elements for valid anchor tags\n const checkChildAnchors = (parent: Element) => {\n const children = Array.from(parent.children);\n for (const child of children) {\n if (\n child.hasAttribute(\"target\") &&\n (child as HTMLAnchorElement).target === \"_blank\"\n ) {\n hasAnchors = true;\n validAnchors = isAnchorValid(child as HTMLAnchorElement);\n if (!validAnchors) {\n return;\n }\n }\n checkChildAnchors(child);\n }\n };\n\n // check for anchor tags in the message that have target _blank also have a relationship that avoids security holes\n // https://web.dev/external-anchors-use-rel-noopener/\n // first check the message element\n /* istanbul ignore else */\n if (\n props.message.hasAttribute(\"target\") &&\n (props.message as HTMLAnchorElement).target === \"_blank\"\n ) {\n hasAnchors = true;\n validAnchors = isAnchorValid(props.message as HTMLAnchorElement);\n } else {\n // if the message element is not an anchor, recursively verify it's children\n if (props.message.children) {\n checkChildAnchors(props.message);\n }\n }\n\n let sanitizedHtml;\n if (hasAnchors && validAnchors) {\n // all anchors are valid. do not remove the target attr\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML, {\n ADD_ATTR: [\"target\"],\n });\n } else {\n sanitizedHtml = sanitizer.sanitize(props.message.outerHTML);\n }\n\n messageNode = (\n <OutElement\n className={props.className}\n // we can safely disable jam3/no-sanitizer-with-danger as we are sanitizing above\n // eslint-disable-next-line jam3/no-sanitizer-with-danger\n dangerouslySetInnerHTML={{ __html: sanitizedHtml }}\n />\n );\n } else {\n /* istanbul ignore else */\n if (isReactMessage(props.message))\n messageNode = (\n <OutElement className={props.className}>\n {props.message.reactNode}\n </OutElement>\n );\n }\n\n return messageNode;\n}\n"]}
@@ -19,6 +19,7 @@ const FocusTrap_1 = require("../focustrap/FocusTrap");
19
19
  */
20
20
  class Popup extends React.Component {
21
21
  constructor(props) {
22
+ var _a, _b;
22
23
  super(props);
23
24
  this._popup = null;
24
25
  this._bindWindowEvents = () => {
@@ -200,7 +201,7 @@ class Popup extends React.Component {
200
201
  this.setState({ animationEnded: true });
201
202
  }
202
203
  };
203
- const parentDocument = this.props.target?.ownerDocument ?? document;
204
+ const parentDocument = (_b = (_a = this.props.target) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
204
205
  this.state = {
205
206
  animationEnded: false,
206
207
  isOpen: this.props.isOpen,
@@ -216,17 +217,19 @@ class Popup extends React.Component {
216
217
  }
217
218
  }
218
219
  getParentWindow() {
220
+ var _a;
219
221
  // istanbul ignore next
220
- return this.state.parentDocument.defaultView ?? window;
222
+ return (_a = this.state.parentDocument.defaultView) !== null && _a !== void 0 ? _a : window;
221
223
  }
222
224
  componentDidUpdate(previousProps, prevState) {
225
+ var _a, _b;
223
226
  if (this.state.position !== prevState.position) {
224
227
  this.setState({ animationEnded: false });
225
228
  }
226
229
  if (this.props.target !== previousProps.target) {
227
230
  // istanbul ignore next
228
231
  {
229
- const parentDocument = this.props.target?.ownerDocument ?? document;
232
+ const parentDocument = (_b = (_a = this.props.target) === null || _a === void 0 ? void 0 : _a.ownerDocument) !== null && _b !== void 0 ? _b : document;
230
233
  if (parentDocument !== this.state.parentDocument) {
231
234
  this._unBindWindowEvents();
232
235
  this.setState({ parentDocument });
@@ -401,6 +404,7 @@ class Popup extends React.Component {
401
404
  return newPosition;
402
405
  }
403
406
  render() {
407
+ var _a;
404
408
  const animate = this.props.animate !== undefined ? this.props.animate : true;
405
409
  const className = (0, classnames_1.default)("core-popup", this._getClassNameByPosition(this.state.position), this.props.showShadow && "core-popup-shadow", this.props.showArrow && "arrow", !animate && "core-popup-animation-none", this.props.className, this.state.animationEnded && "core-animation-ended", !this.props.isOpen &&
406
410
  this.props.keepContentsMounted &&
@@ -419,7 +423,7 @@ class Popup extends React.Component {
419
423
  }, style: style, role: role, "aria-modal": true, tabIndex: -1, "aria-label": this.props.ariaLabel, onAnimationEnd: this._handleAnimationEnd },
420
424
  React.createElement(FocusTrap_1.FocusTrap, { active: !!this.props.moveFocus, initialFocusElement: this.props.focusTarget, returnFocusOnDeactivate: true }, this.props.children)),
421
425
  // istanbul ignore next
422
- this.state.parentDocument.body.querySelector('[data-root-container="iui-root-id"]') ?? this.state.parentDocument.body);
426
+ (_a = this.state.parentDocument.body.querySelector('[data-root-container="iui-root-id"]')) !== null && _a !== void 0 ? _a : this.state.parentDocument.body);
423
427
  }
424
428
  }
425
429
  Popup.defaultProps = {
@@ -1 +1 @@
1
- {"version":3,"file":"Popup.js","sourceRoot":"","sources":["../../../../src/core-react/popup/Popup.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,wBAAsB;AACtB,2CAAoC;AACpC,+BAA+B;AAC/B,sCAAsC;AACtC,0DAAqE;AACrE,sDAAmD;AAuFnD;;GAEG;AACH,MAAa,KAAM,SAAQ,KAAK,CAAC,SAAiC;IAGhE,YAAY,KAAiB;QAC3B,KAAK,CAAC,KAAK,CAAC,CAAC;QAHP,WAAM,GAAuB,IAAI,CAAC;QAuFlC,sBAAiB,GAAG,GAAG,EAAE;YAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,CAAC;YAC5C,YAAY,CAAC,gBAAgB,CAAC,aAAa,EAAE,IAAI,CAAC,mBAAmB,CAAC,CAAC;YACvE,YAAY,CAAC,gBAA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,gBACE,IAAI,EAChB,QAAQ,EAAE,CAAC,CAAC,gBACA,IAAI,CAAC,KAAK,CAAC,SAAS,EAChC,cAAc,EAAE,IAAI,CAAC,mBAAmB;YAExC,oBAAC,qBAAS,IACR,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,EAC9B,mBAAmB,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EAC3C,uBAAuB,EAAE,IAAI,IAE5B,IAAI,CAAC,KAAK,CAAC,QAAQ,CACV,CACR;QACN,uBAAuB;QACvB,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAC1C,qCAAqC,CACtC,IAAI,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,IAAI,CACpC,CAAC;IACJ,CAAC;;AAlgBa,kBAAY,GAAwB;IAChD,QAAQ,EAAE,iCAAgB,CAAC,MAAM;IACjC,UAAU,EAAE,IAAI;IAChB,SAAS,EAAE,KAAK;IAChB,MAAM,EAAE,KAAK;IACb,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC,CAAC;IACP,IAAI,EAAE,CAAC,CAAC;CACT,AARyB,CAQxB;AAzBS,sBAAK;AAshBlB,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,MAAM,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Popup\n */\n\nimport \"./Popup.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport { FocusTrap } from \"../focustrap/FocusTrap\";\nimport type { CommonProps } from \"../utils/Props\";\n\n// cSpell:ignore focustrap focusable alertdialog\n\n/** @internal */\ninterface PopupPoint {\n x: number;\n y: number;\n}\n\n/** Properties for the [[Popup]] component\n * @public\n */\nexport interface PopupProps extends CommonProps {\n /** Show or hide the box shadow (defaults to true) */\n showShadow: boolean;\n /** Show or hide the arrow (defaults to false) */\n showArrow: boolean;\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position: RelativePosition;\n /** Top position (absolute positioning - defaults to 0) */\n top: number;\n /** Left position (absolute positioning - defaults to 0) */\n left: number;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Function called when the wheel is used */\n onWheel?: (e: WheelEvent) => void;\n /** Function called when the right mouse button is pressed */\n onContextMenu?: (e: MouseEvent) => void;\n /** Offset from the parent (defaults to 4) */\n offset: number;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Role - if not specified \"dialog\" is used */\n role?: \"dialog\" | \"alert\" | \"alertdialog\";\n /** accessibility label */\n ariaLabel?: string;\n /** set focus to popup - default to not set focus */\n moveFocus?: boolean;\n /** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */\n focusTarget?: React.RefObject<HTMLElement> | string;\n /** Indicates whether the popup is pinned. */\n isPinned?: boolean;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n /** Indicates whether to close the popup when Enter is pressed (defaults to true) */\n closeOnEnter?: boolean;\n /** Indicates whether to close the popup when the wheel is used (defaults to true) */\n closeOnWheel?: boolean;\n /** Indicates whether to close the popup when the right mouse button is pressed (defaults to true) */\n closeOnContextMenu?: boolean;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n /** If true the children are mounted once and unmounted when this component is unmounted. If false the\n * children are unmounted each time the popup is closed. */\n keepContentsMounted?: boolean;\n\n /**\n * If true the popup will remain open and will be repositioned when window resize events occur, default to false.\n * @beta\n * */\n repositionOnResize?: boolean;\n\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface PopupState {\n isOpen: boolean;\n top: number;\n left: number;\n position: RelativePosition;\n parentDocument: Document;\n animationEnded: boolean;\n}\n\n/** Popup React component displays a popup relative to an optional target element.\n * @public\n */\nexport class Popup extends React.Component<PopupProps, PopupState> {\n private _popup: HTMLElement | null = null;\n\n constructor(props: PopupProps) {\n super(props);\n const parentDocument = this.props.target?.ownerDocument ?? document;\n\n this.state = {\n animationEnded: false,\n isOpen: this.props.isOpen,\n top: 0,\n left: 0,\n position: this.props.position,\n parentDocument,\n };\n }\n\n public static defaultProps: Partial<PopupProps> = {\n position: RelativePosition.Bottom,\n showShadow: true,\n showArrow: false,\n isOpen: false,\n offset: 4,\n top: -1,\n left: -1,\n };\n\n public override componentDidMount() {\n if (this.props.isOpen) {\n this._onShow();\n }\n }\n\n private getParentWindow() {\n // istanbul ignore next\n return this.state.parentDocument.defaultView ?? window;\n }\n\n public override componentDidUpdate(\n previousProps: PopupProps,\n prevState: PopupState\n ) {\n if (this.state.position !== prevState.position) {\n this.setState({ animationEnded: false });\n }\n\n if (this.props.target !== previousProps.target) {\n // istanbul ignore next\n {\n const parentDocument = this.props.target?.ownerDocument ?? document;\n if (parentDocument !== this.state.parentDocument) {\n this._unBindWindowEvents();\n this.setState({ parentDocument });\n }\n }\n }\n\n if (this.props.isOpen === previousProps.isOpen) {\n if (this.props.isOpen) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n if (\n Math.abs(this.state.left - point.x) < 3 &&\n Math.abs(this.state.top - point.y) < 3 &&\n this.state.position === position\n )\n return;\n\n this.setState({\n left: point.x,\n top: point.y,\n position,\n });\n }\n return;\n }\n\n if (this.props.isOpen) {\n this._onShow();\n } else {\n this._onClose();\n }\n }\n\n public override componentWillUnmount() {\n this._unBindWindowEvents();\n }\n\n private _bindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.addEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.addEventListener(\"resize\", this._resize);\n activeWindow.addEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.addEventListener(\"scroll\", this._hide);\n activeWindow.addEventListener(\"wheel\", this._handleWheel);\n activeWindow.addEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _unBindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.removeEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.removeEventListener(\"resize\", this._resize);\n activeWindow.removeEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.removeEventListener(\"scroll\", this._hide);\n activeWindow.removeEventListener(\"wheel\", this._handleWheel);\n activeWindow.removeEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _handleWheel = (event: WheelEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onWheel) return this.props.onWheel(event);\n\n const closeOnWheel =\n this.props.closeOnWheel !== undefined ? this.props.closeOnWheel : true;\n if (closeOnWheel) this._hide();\n };\n\n private isInCorePopup(element: HTMLElement): boolean {\n if (element.nodeName === \"DIV\") {\n if (element.classList && element.classList.contains(\"core-popup\"))\n return true;\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n } else {\n // istanbul ignore else\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n }\n return false;\n }\n\n private _handleOutsideClick = (event: MouseEvent): void => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.isPinned) return;\n\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(event.target as HTMLElement)\n )\n return;\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(event);\n\n if (this.props.target && this.props.target.contains(event.target as Node))\n return;\n\n this._onClose();\n };\n\n private _handleContextMenu = (event: MouseEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onContextMenu) return this.props.onContextMenu(event);\n\n const closeOnContextMenu =\n this.props.closeOnContextMenu !== undefined\n ? this.props.closeOnContextMenu\n : true;\n if (closeOnContextMenu) this._hide();\n };\n\n private _handleKeyboard = (event: KeyboardEvent): void => {\n if (this.props.isPinned) return;\n\n if (event.key === SpecialKey.Escape || event.key === SpecialKey.Enter) {\n const closeOnEnter =\n this.props.closeOnEnter !== undefined ? this.props.closeOnEnter : true;\n if (event.key === SpecialKey.Enter) {\n if (closeOnEnter) this._onClose(true);\n else this.props.onEnter && this.props.onEnter();\n } else {\n this._onClose(false);\n }\n }\n };\n\n private _resize = () => {\n if (this.props.repositionOnResize) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n this.setState({ left: point.x, top: point.y, position });\n } else {\n this._hide(); // legacy behavior\n }\n };\n\n private _hide = () => {\n if (this.props.isPinned) return;\n\n this._onClose();\n };\n\n private _onShow() {\n this._bindWindowEvents();\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n\n this.setState(\n { left: point.x, top: point.y, isOpen: true, position },\n () => {\n if (this.props.onOpen) this.props.onOpen();\n }\n );\n }\n\n private _onClose(enterKey?: boolean) {\n if (!this.state.isOpen) return;\n\n this._unBindWindowEvents();\n\n this.setState({ isOpen: false }, () => {\n if (enterKey && this.props.onEnter) this.props.onEnter();\n if (this.props.onClose) this.props.onClose();\n });\n }\n\n private _isPositionAbsolute(): boolean {\n return this.props.top !== -1 && this.props.left !== -1;\n }\n\n private _getClassNameByPosition(position: RelativePosition): string {\n if (!this._isPositionAbsolute()) {\n switch (position) {\n case RelativePosition.TopLeft:\n return \"core-popup-top-left\";\n case RelativePosition.TopRight:\n return \"core-popup-top-right\";\n case RelativePosition.BottomLeft:\n return \"core-popup-bottom-left\";\n case RelativePosition.BottomRight:\n return \"core-popup-bottom-right\";\n case RelativePosition.Top:\n return \"core-popup-top\";\n case RelativePosition.Left:\n return \"core-popup-left\";\n case RelativePosition.Right:\n return \"core-popup-right\";\n case RelativePosition.Bottom:\n return \"core-popup-bottom\";\n case RelativePosition.LeftTop:\n return \"core-popup-left-top\";\n case RelativePosition.RightTop:\n return \"core-popup-right-top\";\n }\n }\n\n return \"\";\n }\n\n private _getPopupDimensions(): { popupWidth: number; popupHeight: number } {\n let popupWidth = 0;\n let popupHeight = 0;\n // istanbul ignore else\n if (this._popup) {\n const activeWindow = this.getParentWindow();\n const style = activeWindow.getComputedStyle(this._popup);\n const borderLeftWidth = parsePxString(style.borderLeftWidth);\n const borderRightWidth = parsePxString(style.borderRightWidth);\n const borderTopWidth = parsePxString(style.borderTopWidth);\n const borderBottomWidth = parsePxString(style.borderBottomWidth);\n popupWidth = this._popup.clientWidth + borderLeftWidth + borderRightWidth;\n popupHeight =\n this._popup.clientHeight + borderTopWidth + borderBottomWidth;\n }\n\n return { popupWidth, popupHeight };\n }\n\n private _getPosition = (position: RelativePosition) => {\n const activeWindow = this.getParentWindow();\n const { target, offset, top, left } = this.props;\n const offsetArrow = this.props.showArrow ? 6 : 0;\n\n // absolute position\n if (this._isPositionAbsolute()) return { x: left, y: top };\n\n // sanity check\n const point = { x: 0, y: 0 };\n if (!this._popup || !target) return point;\n\n // relative position\n const scrollY = activeWindow.scrollY;\n const scrollX = activeWindow.scrollX;\n\n const targetRect = target.getBoundingClientRect();\n\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n\n switch (position) {\n case RelativePosition.Top:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.TopLeft:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.TopRight:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Bottom:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.BottomLeft:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.BottomRight:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Left:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.LeftTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.Right:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n\n case RelativePosition.RightTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n }\n\n return point;\n };\n\n private _toggleRelativePosition(): RelativePosition {\n const { target, position, offset } = this.props;\n\n if (!this._popup || !target) return position;\n\n // istanbul ignore if\n if (this._isPositionAbsolute()) return position;\n\n let newPosition = position;\n\n interface Rect {\n left: number;\n top: number;\n right: number;\n bottom: number;\n }\n\n const activeWindow = this.getParentWindow();\n\n // Note: Cannot use DOMRect yet since it's experimental and not available in all browsers (Nov. 2018)\n const viewportRect: Rect = {\n left: activeWindow.scrollX,\n top: activeWindow.scrollY,\n right: activeWindow.scrollX + activeWindow.innerWidth,\n bottom: activeWindow.scrollY + activeWindow.innerHeight,\n };\n const targetRect = target.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const containerStyle = activeWindow.getComputedStyle(target);\n const offsetArrow = this.props.showArrow\n ? /* istanbul ignore next */ 10\n : 2;\n\n const bottomMargin = parseMargin(containerStyle.marginBottom);\n if (\n targetRect.bottom + popupHeight + bottomMargin + offsetArrow + offset >\n viewportRect.bottom\n ) {\n if (newPosition === RelativePosition.Bottom)\n newPosition = RelativePosition.Top;\n else if (newPosition === RelativePosition.BottomLeft)\n newPosition = RelativePosition.TopLeft;\n else if (newPosition === RelativePosition.BottomRight)\n newPosition = RelativePosition.TopRight;\n }\n\n const topMargin = parseMargin(containerStyle.marginTop);\n if (\n targetRect.top - popupHeight - topMargin - offsetArrow - offset <\n viewportRect.top\n ) {\n if (newPosition === RelativePosition.Top)\n newPosition = RelativePosition.Bottom;\n else if (newPosition === RelativePosition.TopLeft)\n newPosition = RelativePosition.BottomLeft;\n else if (newPosition === RelativePosition.TopRight)\n newPosition = RelativePosition.BottomRight;\n }\n\n const leftMargin = parseMargin(containerStyle.marginLeft);\n if (\n targetRect.left - popupWidth - leftMargin - offsetArrow - offset <\n viewportRect.left\n ) {\n if (newPosition === RelativePosition.Left)\n newPosition = RelativePosition.Right;\n else if (newPosition === RelativePosition.LeftTop)\n newPosition = RelativePosition.RightTop;\n }\n\n const rightMargin = parseMargin(containerStyle.marginRight);\n if (\n targetRect.right + popupWidth + rightMargin + offsetArrow + offset >\n viewportRect.right\n ) {\n if (newPosition === RelativePosition.Right)\n newPosition = RelativePosition.Left;\n else if (newPosition === RelativePosition.RightTop)\n newPosition = RelativePosition.LeftTop;\n }\n\n return newPosition;\n }\n\n // fit the popup within the extents of the view port\n private _fitPopup = (point: PopupPoint) => {\n const fittedPoint = point;\n\n // istanbul ignore if\n if (!this._popup) {\n return fittedPoint;\n }\n\n // const popupRect = this._popup.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const { innerWidth, innerHeight } = window;\n\n // istanbul ignore if\n if (fittedPoint.y + popupHeight > innerHeight) {\n fittedPoint.y = innerHeight - popupHeight;\n }\n\n // istanbul ignore if\n if (fittedPoint.x + popupWidth > innerWidth) {\n fittedPoint.x = innerWidth - popupWidth;\n }\n\n // istanbul ignore if\n if (fittedPoint.y < 0) {\n fittedPoint.y = 0;\n }\n\n if (fittedPoint.x < 0) {\n fittedPoint.x = 0;\n }\n\n return fittedPoint;\n };\n\n private _handleAnimationEnd = (\n event: React.AnimationEvent<HTMLDivElement>\n ) => {\n if (event.target === this._popup) {\n this.setState({ animationEnded: true });\n }\n };\n\n public override render() {\n const animate =\n this.props.animate !== undefined ? this.props.animate : true;\n const className = classnames(\n \"core-popup\",\n this._getClassNameByPosition(this.state.position),\n this.props.showShadow && \"core-popup-shadow\",\n this.props.showArrow && \"arrow\",\n !animate && \"core-popup-animation-none\",\n this.props.className,\n this.state.animationEnded && \"core-animation-ended\",\n !this.props.isOpen &&\n this.props.keepContentsMounted &&\n \"core-popup-hidden\"\n );\n\n const style: React.CSSProperties = {\n top: this.state.top,\n left: this.state.left,\n ...this.props.style,\n };\n\n const role = this.props.role ? this.props.role : \"dialog\"; // accessibility property\n\n if (!this.props.isOpen && !this.props.keepContentsMounted) {\n return null;\n }\n\n return ReactDOM.createPortal(\n <div\n className={className}\n data-testid=\"core-popup\"\n ref={(element) => {\n this._popup = element;\n }}\n style={style}\n role={role}\n aria-modal={true}\n tabIndex={-1}\n aria-label={this.props.ariaLabel}\n onAnimationEnd={this._handleAnimationEnd}\n >\n <FocusTrap\n active={!!this.props.moveFocus}\n initialFocusElement={this.props.focusTarget}\n returnFocusOnDeactivate={true}\n >\n {this.props.children}\n </FocusTrap>\n </div>,\n // istanbul ignore next\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"iui-root-id\"]'\n ) ?? this.state.parentDocument.body\n );\n }\n}\n\nfunction parsePxString(pxStr: string): number {\n const parsed = parseInt(pxStr, 10);\n return parsed || 0;\n}\n\nfunction parseMargin(value: string) {\n return value ? /* istanbul ignore next */ par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E,KAAK;IACb,MAAM,EAAE,CAAC;IACT,GAAG,EAAE,CAAC,CAAC;IACP,IAAI,EAAE,CAAC,CAAC;CACT,AARyB,CAQxB;AAzBS,sBAAK;AAshBlB,SAAS,aAAa,CAAC,KAAa;IAClC,MAAM,MAAM,GAAG,QAAQ,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACnC,OAAO,MAAM,IAAI,CAAC,CAAC;AACrB,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,CAAC,CAAC,0BAA0B,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Popup\n */\n\nimport \"./Popup.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport * as ReactDOM from \"react-dom\";\nimport { RelativePosition, SpecialKey } from \"@itwin/appui-abstract\";\nimport { FocusTrap } from \"../focustrap/FocusTrap\";\nimport type { CommonProps } from \"../utils/Props\";\n\n// cSpell:ignore focustrap focusable alertdialog\n\n/** @internal */\ninterface PopupPoint {\n x: number;\n y: number;\n}\n\n/** Properties for the [[Popup]] component\n * @public\n */\nexport interface PopupProps extends CommonProps {\n /** Show or hide the box shadow (defaults to true) */\n showShadow: boolean;\n /** Show or hide the arrow (defaults to false) */\n showArrow: boolean;\n /** Indicates whether the popup is shown or not (defaults to false) */\n isOpen: boolean;\n /** Direction (relative to the target) to which the popup is expanded (defaults to Bottom) */\n position: RelativePosition;\n /** Top position (absolute positioning - defaults to 0) */\n top: number;\n /** Left position (absolute positioning - defaults to 0) */\n left: number;\n /** Function called when the popup is opened */\n onOpen?: () => void;\n /** Function called when user clicks outside the popup */\n onOutsideClick?: (e: MouseEvent) => void;\n /** Function called when the popup is closed */\n onClose?: () => void;\n /** Function called when the popup is closed on Enter */\n onEnter?: () => void;\n /** Function called when the wheel is used */\n onWheel?: (e: WheelEvent) => void;\n /** Function called when the right mouse button is pressed */\n onContextMenu?: (e: MouseEvent) => void;\n /** Offset from the parent (defaults to 4) */\n offset: number;\n /** Target element to position popup */\n target?: HTMLElement | null;\n /** Role - if not specified \"dialog\" is used */\n role?: \"dialog\" | \"alert\" | \"alertdialog\";\n /** accessibility label */\n ariaLabel?: string;\n /** set focus to popup - default to not set focus */\n moveFocus?: boolean;\n /** Element to receive focus, specified by React.RefObject or CSS selector string. If undefined and moveFocus is true then focus is moved to first focusable element. */\n focusTarget?: React.RefObject<HTMLElement> | string;\n /** Indicates whether the popup is pinned. */\n isPinned?: boolean;\n /** Indicates whether to use animation for open/close (defaults to true) */\n animate?: boolean;\n /** Indicates whether to close the popup when Enter is pressed (defaults to true) */\n closeOnEnter?: boolean;\n /** Indicates whether to close the popup when the wheel is used (defaults to true) */\n closeOnWheel?: boolean;\n /** Indicates whether to close the popup when the right mouse button is pressed (defaults to true) */\n closeOnContextMenu?: boolean;\n /** If false outside click processing and closing are skipped if click occurs in another Popup component, default to false. */\n closeOnNestedPopupOutsideClick?: boolean;\n /** If true the children are mounted once and unmounted when this component is unmounted. If false the\n * children are unmounted each time the popup is closed. */\n keepContentsMounted?: boolean;\n\n /**\n * If true the popup will remain open and will be repositioned when window resize events occur, default to false.\n * @beta\n * */\n repositionOnResize?: boolean;\n\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface PopupState {\n isOpen: boolean;\n top: number;\n left: number;\n position: RelativePosition;\n parentDocument: Document;\n animationEnded: boolean;\n}\n\n/** Popup React component displays a popup relative to an optional target element.\n * @public\n */\nexport class Popup extends React.Component<PopupProps, PopupState> {\n private _popup: HTMLElement | null = null;\n\n constructor(props: PopupProps) {\n super(props);\n const parentDocument = this.props.target?.ownerDocument ?? document;\n\n this.state = {\n animationEnded: false,\n isOpen: this.props.isOpen,\n top: 0,\n left: 0,\n position: this.props.position,\n parentDocument,\n };\n }\n\n public static defaultProps: Partial<PopupProps> = {\n position: RelativePosition.Bottom,\n showShadow: true,\n showArrow: false,\n isOpen: false,\n offset: 4,\n top: -1,\n left: -1,\n };\n\n public override componentDidMount() {\n if (this.props.isOpen) {\n this._onShow();\n }\n }\n\n private getParentWindow() {\n // istanbul ignore next\n return this.state.parentDocument.defaultView ?? window;\n }\n\n public override componentDidUpdate(\n previousProps: PopupProps,\n prevState: PopupState\n ) {\n if (this.state.position !== prevState.position) {\n this.setState({ animationEnded: false });\n }\n\n if (this.props.target !== previousProps.target) {\n // istanbul ignore next\n {\n const parentDocument = this.props.target?.ownerDocument ?? document;\n if (parentDocument !== this.state.parentDocument) {\n this._unBindWindowEvents();\n this.setState({ parentDocument });\n }\n }\n }\n\n if (this.props.isOpen === previousProps.isOpen) {\n if (this.props.isOpen) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n if (\n Math.abs(this.state.left - point.x) < 3 &&\n Math.abs(this.state.top - point.y) < 3 &&\n this.state.position === position\n )\n return;\n\n this.setState({\n left: point.x,\n top: point.y,\n position,\n });\n }\n return;\n }\n\n if (this.props.isOpen) {\n this._onShow();\n } else {\n this._onClose();\n }\n }\n\n public override componentWillUnmount() {\n this._unBindWindowEvents();\n }\n\n private _bindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.addEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.addEventListener(\"resize\", this._resize);\n activeWindow.addEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.addEventListener(\"scroll\", this._hide);\n activeWindow.addEventListener(\"wheel\", this._handleWheel);\n activeWindow.addEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _unBindWindowEvents = () => {\n const activeWindow = this.getParentWindow();\n activeWindow.removeEventListener(\"pointerdown\", this._handleOutsideClick);\n activeWindow.removeEventListener(\"resize\", this._resize);\n activeWindow.removeEventListener(\"contextmenu\", this._handleContextMenu);\n activeWindow.removeEventListener(\"scroll\", this._hide);\n activeWindow.removeEventListener(\"wheel\", this._handleWheel);\n activeWindow.removeEventListener(\"keydown\", this._handleKeyboard);\n };\n\n private _handleWheel = (event: WheelEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onWheel) return this.props.onWheel(event);\n\n const closeOnWheel =\n this.props.closeOnWheel !== undefined ? this.props.closeOnWheel : true;\n if (closeOnWheel) this._hide();\n };\n\n private isInCorePopup(element: HTMLElement): boolean {\n if (element.nodeName === \"DIV\") {\n if (element.classList && element.classList.contains(\"core-popup\"))\n return true;\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n } else {\n // istanbul ignore else\n if (element.parentElement && this.isInCorePopup(element.parentElement))\n return true;\n }\n return false;\n }\n\n private _handleOutsideClick = (event: MouseEvent): void => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.isPinned) return;\n\n if (\n !this.props.closeOnNestedPopupOutsideClick &&\n this.isInCorePopup(event.target as HTMLElement)\n )\n return;\n\n if (this.props.onOutsideClick) return this.props.onOutsideClick(event);\n\n if (this.props.target && this.props.target.contains(event.target as Node))\n return;\n\n this._onClose();\n };\n\n private _handleContextMenu = (event: MouseEvent) => {\n if (this._popup && this._popup.contains(event.target as Node)) return;\n\n if (this.props.onContextMenu) return this.props.onContextMenu(event);\n\n const closeOnContextMenu =\n this.props.closeOnContextMenu !== undefined\n ? this.props.closeOnContextMenu\n : true;\n if (closeOnContextMenu) this._hide();\n };\n\n private _handleKeyboard = (event: KeyboardEvent): void => {\n if (this.props.isPinned) return;\n\n if (event.key === SpecialKey.Escape || event.key === SpecialKey.Enter) {\n const closeOnEnter =\n this.props.closeOnEnter !== undefined ? this.props.closeOnEnter : true;\n if (event.key === SpecialKey.Enter) {\n if (closeOnEnter) this._onClose(true);\n else this.props.onEnter && this.props.onEnter();\n } else {\n this._onClose(false);\n }\n }\n };\n\n private _resize = () => {\n if (this.props.repositionOnResize) {\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n this.setState({ left: point.x, top: point.y, position });\n } else {\n this._hide(); // legacy behavior\n }\n };\n\n private _hide = () => {\n if (this.props.isPinned) return;\n\n this._onClose();\n };\n\n private _onShow() {\n this._bindWindowEvents();\n const position = this._toggleRelativePosition();\n const point = this._fitPopup(this._getPosition(position));\n\n this.setState(\n { left: point.x, top: point.y, isOpen: true, position },\n () => {\n if (this.props.onOpen) this.props.onOpen();\n }\n );\n }\n\n private _onClose(enterKey?: boolean) {\n if (!this.state.isOpen) return;\n\n this._unBindWindowEvents();\n\n this.setState({ isOpen: false }, () => {\n if (enterKey && this.props.onEnter) this.props.onEnter();\n if (this.props.onClose) this.props.onClose();\n });\n }\n\n private _isPositionAbsolute(): boolean {\n return this.props.top !== -1 && this.props.left !== -1;\n }\n\n private _getClassNameByPosition(position: RelativePosition): string {\n if (!this._isPositionAbsolute()) {\n switch (position) {\n case RelativePosition.TopLeft:\n return \"core-popup-top-left\";\n case RelativePosition.TopRight:\n return \"core-popup-top-right\";\n case RelativePosition.BottomLeft:\n return \"core-popup-bottom-left\";\n case RelativePosition.BottomRight:\n return \"core-popup-bottom-right\";\n case RelativePosition.Top:\n return \"core-popup-top\";\n case RelativePosition.Left:\n return \"core-popup-left\";\n case RelativePosition.Right:\n return \"core-popup-right\";\n case RelativePosition.Bottom:\n return \"core-popup-bottom\";\n case RelativePosition.LeftTop:\n return \"core-popup-left-top\";\n case RelativePosition.RightTop:\n return \"core-popup-right-top\";\n }\n }\n\n return \"\";\n }\n\n private _getPopupDimensions(): { popupWidth: number; popupHeight: number } {\n let popupWidth = 0;\n let popupHeight = 0;\n // istanbul ignore else\n if (this._popup) {\n const activeWindow = this.getParentWindow();\n const style = activeWindow.getComputedStyle(this._popup);\n const borderLeftWidth = parsePxString(style.borderLeftWidth);\n const borderRightWidth = parsePxString(style.borderRightWidth);\n const borderTopWidth = parsePxString(style.borderTopWidth);\n const borderBottomWidth = parsePxString(style.borderBottomWidth);\n popupWidth = this._popup.clientWidth + borderLeftWidth + borderRightWidth;\n popupHeight =\n this._popup.clientHeight + borderTopWidth + borderBottomWidth;\n }\n\n return { popupWidth, popupHeight };\n }\n\n private _getPosition = (position: RelativePosition) => {\n const activeWindow = this.getParentWindow();\n const { target, offset, top, left } = this.props;\n const offsetArrow = this.props.showArrow ? 6 : 0;\n\n // absolute position\n if (this._isPositionAbsolute()) return { x: left, y: top };\n\n // sanity check\n const point = { x: 0, y: 0 };\n if (!this._popup || !target) return point;\n\n // relative position\n const scrollY = activeWindow.scrollY;\n const scrollX = activeWindow.scrollX;\n\n const targetRect = target.getBoundingClientRect();\n\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n\n switch (position) {\n case RelativePosition.Top:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.TopLeft:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.TopRight:\n point.y = scrollY + targetRect.top - popupHeight - offset - offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Bottom:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x =\n scrollX + targetRect.left + targetRect.width / 2 - popupWidth / 2;\n break;\n\n case RelativePosition.BottomLeft:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.left;\n break;\n\n case RelativePosition.BottomRight:\n point.y = scrollY + targetRect.bottom + offset + offsetArrow;\n point.x = scrollX + targetRect.right - popupWidth;\n break;\n\n case RelativePosition.Left:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.LeftTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.left - popupWidth - offset - offsetArrow;\n break;\n\n case RelativePosition.Right:\n point.y =\n scrollY + targetRect.top + targetRect.height / 2 - popupHeight / 2;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n\n case RelativePosition.RightTop:\n point.y = scrollY + targetRect.top;\n point.x = scrollX + targetRect.right + offset + offsetArrow;\n break;\n }\n\n return point;\n };\n\n private _toggleRelativePosition(): RelativePosition {\n const { target, position, offset } = this.props;\n\n if (!this._popup || !target) return position;\n\n // istanbul ignore if\n if (this._isPositionAbsolute()) return position;\n\n let newPosition = position;\n\n interface Rect {\n left: number;\n top: number;\n right: number;\n bottom: number;\n }\n\n const activeWindow = this.getParentWindow();\n\n // Note: Cannot use DOMRect yet since it's experimental and not available in all browsers (Nov. 2018)\n const viewportRect: Rect = {\n left: activeWindow.scrollX,\n top: activeWindow.scrollY,\n right: activeWindow.scrollX + activeWindow.innerWidth,\n bottom: activeWindow.scrollY + activeWindow.innerHeight,\n };\n const targetRect = target.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const containerStyle = activeWindow.getComputedStyle(target);\n const offsetArrow = this.props.showArrow\n ? /* istanbul ignore next */ 10\n : 2;\n\n const bottomMargin = parseMargin(containerStyle.marginBottom);\n if (\n targetRect.bottom + popupHeight + bottomMargin + offsetArrow + offset >\n viewportRect.bottom\n ) {\n if (newPosition === RelativePosition.Bottom)\n newPosition = RelativePosition.Top;\n else if (newPosition === RelativePosition.BottomLeft)\n newPosition = RelativePosition.TopLeft;\n else if (newPosition === RelativePosition.BottomRight)\n newPosition = RelativePosition.TopRight;\n }\n\n const topMargin = parseMargin(containerStyle.marginTop);\n if (\n targetRect.top - popupHeight - topMargin - offsetArrow - offset <\n viewportRect.top\n ) {\n if (newPosition === RelativePosition.Top)\n newPosition = RelativePosition.Bottom;\n else if (newPosition === RelativePosition.TopLeft)\n newPosition = RelativePosition.BottomLeft;\n else if (newPosition === RelativePosition.TopRight)\n newPosition = RelativePosition.BottomRight;\n }\n\n const leftMargin = parseMargin(containerStyle.marginLeft);\n if (\n targetRect.left - popupWidth - leftMargin - offsetArrow - offset <\n viewportRect.left\n ) {\n if (newPosition === RelativePosition.Left)\n newPosition = RelativePosition.Right;\n else if (newPosition === RelativePosition.LeftTop)\n newPosition = RelativePosition.RightTop;\n }\n\n const rightMargin = parseMargin(containerStyle.marginRight);\n if (\n targetRect.right + popupWidth + rightMargin + offsetArrow + offset >\n viewportRect.right\n ) {\n if (newPosition === RelativePosition.Right)\n newPosition = RelativePosition.Left;\n else if (newPosition === RelativePosition.RightTop)\n newPosition = RelativePosition.LeftTop;\n }\n\n return newPosition;\n }\n\n // fit the popup within the extents of the view port\n private _fitPopup = (point: PopupPoint) => {\n const fittedPoint = point;\n\n // istanbul ignore if\n if (!this._popup) {\n return fittedPoint;\n }\n\n // const popupRect = this._popup.getBoundingClientRect();\n const { popupWidth, popupHeight } = this._getPopupDimensions();\n const { innerWidth, innerHeight } = window;\n\n // istanbul ignore if\n if (fittedPoint.y + popupHeight > innerHeight) {\n fittedPoint.y = innerHeight - popupHeight;\n }\n\n // istanbul ignore if\n if (fittedPoint.x + popupWidth > innerWidth) {\n fittedPoint.x = innerWidth - popupWidth;\n }\n\n // istanbul ignore if\n if (fittedPoint.y < 0) {\n fittedPoint.y = 0;\n }\n\n if (fittedPoint.x < 0) {\n fittedPoint.x = 0;\n }\n\n return fittedPoint;\n };\n\n private _handleAnimationEnd = (\n event: React.AnimationEvent<HTMLDivElement>\n ) => {\n if (event.target === this._popup) {\n this.setState({ animationEnded: true });\n }\n };\n\n public override render() {\n const animate =\n this.props.animate !== undefined ? this.props.animate : true;\n const className = classnames(\n \"core-popup\",\n this._getClassNameByPosition(this.state.position),\n this.props.showShadow && \"core-popup-shadow\",\n this.props.showArrow && \"arrow\",\n !animate && \"core-popup-animation-none\",\n this.props.className,\n this.state.animationEnded && \"core-animation-ended\",\n !this.props.isOpen &&\n this.props.keepContentsMounted &&\n \"core-popup-hidden\"\n );\n\n const style: React.CSSProperties = {\n top: this.state.top,\n left: this.state.left,\n ...this.props.style,\n };\n\n const role = this.props.role ? this.props.role : \"dialog\"; // accessibility property\n\n if (!this.props.isOpen && !this.props.keepContentsMounted) {\n return null;\n }\n\n return ReactDOM.createPortal(\n <div\n className={className}\n data-testid=\"core-popup\"\n ref={(element) => {\n this._popup = element;\n }}\n style={style}\n role={role}\n aria-modal={true}\n tabIndex={-1}\n aria-label={this.props.ariaLabel}\n onAnimationEnd={this._handleAnimationEnd}\n >\n <FocusTrap\n active={!!this.props.moveFocus}\n initialFocusElement={this.props.focusTarget}\n returnFocusOnDeactivate={true}\n >\n {this.props.children}\n </FocusTrap>\n </div>,\n // istanbul ignore next\n this.state.parentDocument.body.querySelector(\n '[data-root-container=\"iui-root-id\"]'\n ) ?? this.state.parentDocument.body\n );\n }\n}\n\nfunction parsePxString(pxStr: string): number {\n const parsed = parseInt(pxStr, 10);\n return parsed || 0;\n}\n\nfunction parseMargin(value: string) {\n return value ? /* istanbul ignore next */ parseFloat(value) : 0;\n}\n"]}
@@ -40,8 +40,9 @@ class TreeNode extends React.Component {
40
40
  this.props.onClickExpansionToggle();
41
41
  };
42
42
  this._onClick = (e) => {
43
+ var _a, _b;
43
44
  e.stopPropagation();
44
- this.props.onClick?.(e);
45
+ (_b = (_a = this.props).onClick) === null || _b === void 0 ? void 0 : _b.call(_a, e);
45
46
  };
46
47
  }
47
48
  render() {