@itwin/core-react 4.13.1 → 4.13.3

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 (163) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/core-react/UiCore.js +1 -1
  3. package/lib/cjs/core-react/UiCore.js.map +1 -1
  4. package/lib/cjs/core-react/autosuggest/AutoSuggest.js.map +1 -1
  5. package/lib/cjs/core-react/button/UnderlinedButton.js.map +1 -1
  6. package/lib/cjs/core-react/contextmenu/ContextMenu.js +1 -1
  7. package/lib/cjs/core-react/contextmenu/ContextMenu.js.map +1 -1
  8. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js +1 -1
  9. package/lib/cjs/core-react/contextmenu/ContextMenuDirection.js.map +1 -1
  10. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js +1 -1
  11. package/lib/cjs/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  12. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js +1 -1
  13. package/lib/cjs/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  14. package/lib/cjs/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  15. package/lib/cjs/core-react/contextmenu/PopupContextMenu.js.map +1 -1
  16. package/lib/cjs/core-react/contextmenu/TildeFinder.js +1 -1
  17. package/lib/cjs/core-react/contextmenu/TildeFinder.js.map +1 -1
  18. package/lib/cjs/core-react/dialog/Dialog.js +2 -2
  19. package/lib/cjs/core-react/dialog/Dialog.js.map +1 -1
  20. package/lib/cjs/core-react/dialog/GlobalDialog.js.map +1 -1
  21. package/lib/cjs/core-react/elementseparator/ElementSeparator.js.map +1 -1
  22. package/lib/cjs/core-react/enums/Alignment.js +2 -2
  23. package/lib/cjs/core-react/enums/Alignment.js.map +1 -1
  24. package/lib/cjs/core-react/enums/CheckBoxState.js +1 -1
  25. package/lib/cjs/core-react/enums/CheckBoxState.js.map +1 -1
  26. package/lib/cjs/core-react/enums/Orientation.js +1 -1
  27. package/lib/cjs/core-react/enums/Orientation.js.map +1 -1
  28. package/lib/cjs/core-react/enums/SortDirection.js +1 -1
  29. package/lib/cjs/core-react/enums/SortDirection.js.map +1 -1
  30. package/lib/cjs/core-react/enums/TimeFormat.js +1 -1
  31. package/lib/cjs/core-react/enums/TimeFormat.js.map +1 -1
  32. package/lib/cjs/core-react/expandable/ExpandableList.js +1 -1
  33. package/lib/cjs/core-react/expandable/ExpandableList.js.map +1 -1
  34. package/lib/cjs/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  35. package/lib/cjs/core-react/focustrap/FocusTrap.js.map +1 -1
  36. package/lib/cjs/core-react/hocs/withOnOutsideClick.js.map +1 -1
  37. package/lib/cjs/core-react/icons/ConditionalIconItem.js.map +1 -1
  38. package/lib/cjs/core-react/icons/IconComponent.js.map +1 -1
  39. package/lib/cjs/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  40. package/lib/cjs/core-react/inputs/Input.js.map +1 -1
  41. package/lib/cjs/core-react/inputs/InputStatus.js +1 -1
  42. package/lib/cjs/core-react/inputs/InputStatus.js.map +1 -1
  43. package/lib/cjs/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  44. package/lib/cjs/core-react/l10n/usePackageTranslation.js.map +1 -1
  45. package/lib/cjs/core-react/l10n/useTranslation.js.map +1 -1
  46. package/lib/cjs/core-react/listbox/Listbox.js.map +1 -1
  47. package/lib/cjs/core-react/loading/LoadingBar.js +1 -1
  48. package/lib/cjs/core-react/loading/LoadingBar.js.map +1 -1
  49. package/lib/cjs/core-react/loading/LoadingPrompt.js +1 -1
  50. package/lib/cjs/core-react/loading/LoadingPrompt.js.map +1 -1
  51. package/lib/cjs/core-react/loading/LoadingSpinner.js +1 -1
  52. package/lib/cjs/core-react/loading/LoadingSpinner.js.map +1 -1
  53. package/lib/cjs/core-react/loading/LoadingStatus.js +1 -1
  54. package/lib/cjs/core-react/loading/LoadingStatus.js.map +1 -1
  55. package/lib/cjs/core-react/messagebox/MessageBox.js +1 -1
  56. package/lib/cjs/core-react/messagebox/MessageBox.js.map +1 -1
  57. package/lib/cjs/core-react/notification/MessageRenderer.js.map +1 -1
  58. package/lib/cjs/core-react/popup/Popup.js +1 -1
  59. package/lib/cjs/core-react/popup/Popup.js.map +1 -1
  60. package/lib/cjs/core-react/radialmenu/RadialMenu.js +2 -2
  61. package/lib/cjs/core-react/radialmenu/RadialMenu.js.map +1 -1
  62. package/lib/cjs/core-react/searchbox/SearchBox.js.map +1 -1
  63. package/lib/cjs/core-react/settings/SettingsContainer.js.map +1 -1
  64. package/lib/cjs/core-react/settings/SettingsManager.js.map +1 -1
  65. package/lib/cjs/core-react/tabs/Tabs.js.map +1 -1
  66. package/lib/cjs/core-react/text/FilteredText.js.map +1 -1
  67. package/lib/cjs/core-react/tree/Node.js.map +1 -1
  68. package/lib/cjs/core-react/tree/Tree.js.map +1 -1
  69. package/lib/cjs/core-react/uistate/UiStateEntry.js.map +1 -1
  70. package/lib/cjs/core-react/uistate/UiStateStorage.js +1 -1
  71. package/lib/cjs/core-react/uistate/UiStateStorage.js.map +1 -1
  72. package/lib/cjs/core-react/utils/IconHelper.js.map +1 -1
  73. package/lib/cjs/core-react/utils/IconWebComponent.js.map +1 -1
  74. package/lib/cjs/core-react/utils/Rectangle.js +1 -1
  75. package/lib/cjs/core-react/utils/Rectangle.js.map +1 -1
  76. package/lib/cjs/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  77. package/lib/cjs/core-react/utils/flattenChildren.js.map +1 -1
  78. package/lib/cjs/core-react/utils/getUserColor.js.map +1 -1
  79. package/lib/cjs/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  80. package/lib/cjs/core-react/utils/hooks/useDisposable.js.map +1 -1
  81. package/lib/cjs/core-react/utils/hooks/useEffectSkipFirst.js.map +1 -1
  82. package/lib/cjs/core-react/utils/hooks/useEventListener.js.map +1 -1
  83. package/lib/cjs/core-react/utils/hooks/useInterval.js.map +1 -1
  84. package/lib/cjs/core-react/utils/hooks/useLifecycleLogging.js.map +1 -1
  85. package/lib/cjs/core-react/utils/hooks/useOnOutsideClick.js.map +1 -1
  86. package/lib/cjs/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
  87. package/lib/cjs/core-react/utils/hooks/useRefs.js.map +1 -1
  88. package/lib/cjs/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  89. package/lib/cjs/core-react/utils/reuseOrCreatePromise.js.map +1 -1
  90. package/lib/cjs/core-react/utils/shallowDiffers.js.map +1 -1
  91. package/lib/esm/core-react/UiCore.js +1 -2
  92. package/lib/esm/core-react/UiCore.js.map +1 -1
  93. package/lib/esm/core-react/autosuggest/AutoSuggest.js.map +1 -1
  94. package/lib/esm/core-react/button/UnderlinedButton.js.map +1 -1
  95. package/lib/esm/core-react/contextmenu/ContextMenu.js +1 -2
  96. package/lib/esm/core-react/contextmenu/ContextMenu.js.map +1 -1
  97. package/lib/esm/core-react/contextmenu/ContextMenuItem.js +1 -2
  98. package/lib/esm/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  99. package/lib/esm/core-react/contextmenu/ContextSubMenu.js +1 -2
  100. package/lib/esm/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  101. package/lib/esm/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  102. package/lib/esm/core-react/contextmenu/PopupContextMenu.js.map +1 -1
  103. package/lib/esm/core-react/contextmenu/TildeFinder.js +1 -2
  104. package/lib/esm/core-react/contextmenu/TildeFinder.js.map +1 -1
  105. package/lib/esm/core-react/dialog/Dialog.js +1 -2
  106. package/lib/esm/core-react/dialog/Dialog.js.map +1 -1
  107. package/lib/esm/core-react/dialog/GlobalDialog.js.map +1 -1
  108. package/lib/esm/core-react/elementseparator/ElementSeparator.js.map +1 -1
  109. package/lib/esm/core-react/expandable/ExpandableList.js +1 -2
  110. package/lib/esm/core-react/expandable/ExpandableList.js.map +1 -1
  111. package/lib/esm/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  112. package/lib/esm/core-react/focustrap/FocusTrap.js.map +1 -1
  113. package/lib/esm/core-react/hocs/withOnOutsideClick.js.map +1 -1
  114. package/lib/esm/core-react/icons/ConditionalIconItem.js.map +1 -1
  115. package/lib/esm/core-react/icons/IconComponent.js.map +1 -1
  116. package/lib/esm/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  117. package/lib/esm/core-react/inputs/Input.js.map +1 -1
  118. package/lib/esm/core-react/inputs/numberinput/NumberInput.js.map +1 -1
  119. package/lib/esm/core-react/l10n/usePackageTranslation.js.map +1 -1
  120. package/lib/esm/core-react/l10n/useTranslation.js.map +1 -1
  121. package/lib/esm/core-react/listbox/Listbox.js.map +1 -1
  122. package/lib/esm/core-react/loading/LoadingBar.js +1 -2
  123. package/lib/esm/core-react/loading/LoadingBar.js.map +1 -1
  124. package/lib/esm/core-react/loading/LoadingPrompt.js +1 -2
  125. package/lib/esm/core-react/loading/LoadingPrompt.js.map +1 -1
  126. package/lib/esm/core-react/loading/LoadingSpinner.js +1 -2
  127. package/lib/esm/core-react/loading/LoadingSpinner.js.map +1 -1
  128. package/lib/esm/core-react/loading/LoadingStatus.js +1 -2
  129. package/lib/esm/core-react/loading/LoadingStatus.js.map +1 -1
  130. package/lib/esm/core-react/messagebox/MessageBox.js +1 -2
  131. package/lib/esm/core-react/messagebox/MessageBox.js.map +1 -1
  132. package/lib/esm/core-react/notification/MessageRenderer.js.map +1 -1
  133. package/lib/esm/core-react/popup/Popup.js +1 -2
  134. package/lib/esm/core-react/popup/Popup.js.map +1 -1
  135. package/lib/esm/core-react/radialmenu/RadialMenu.js +2 -3
  136. package/lib/esm/core-react/radialmenu/RadialMenu.js.map +1 -1
  137. package/lib/esm/core-react/searchbox/SearchBox.js.map +1 -1
  138. package/lib/esm/core-react/settings/SettingsContainer.js.map +1 -1
  139. package/lib/esm/core-react/settings/SettingsManager.js.map +1 -1
  140. package/lib/esm/core-react/tabs/Tabs.js.map +1 -1
  141. package/lib/esm/core-react/text/FilteredText.js.map +1 -1
  142. package/lib/esm/core-react/tree/Node.js.map +1 -1
  143. package/lib/esm/core-react/tree/Tree.js.map +1 -1
  144. package/lib/esm/core-react/uistate/UiStateEntry.js.map +1 -1
  145. package/lib/esm/core-react/utils/IconHelper.js.map +1 -1
  146. package/lib/esm/core-react/utils/IconWebComponent.js.map +1 -1
  147. package/lib/esm/core-react/utils/Rectangle.js.map +1 -1
  148. package/lib/esm/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  149. package/lib/esm/core-react/utils/flattenChildren.js.map +1 -1
  150. package/lib/esm/core-react/utils/getUserColor.js.map +1 -1
  151. package/lib/esm/core-react/utils/hooks/useCrossOriginPopup.js.map +1 -1
  152. package/lib/esm/core-react/utils/hooks/useDisposable.js.map +1 -1
  153. package/lib/esm/core-react/utils/hooks/useEffectSkipFirst.js.map +1 -1
  154. package/lib/esm/core-react/utils/hooks/useEventListener.js.map +1 -1
  155. package/lib/esm/core-react/utils/hooks/useInterval.js.map +1 -1
  156. package/lib/esm/core-react/utils/hooks/useLifecycleLogging.js.map +1 -1
  157. package/lib/esm/core-react/utils/hooks/useOnOutsideClick.js.map +1 -1
  158. package/lib/esm/core-react/utils/hooks/useProximityToMouse.js.map +1 -1
  159. package/lib/esm/core-react/utils/hooks/useRefs.js.map +1 -1
  160. package/lib/esm/core-react/utils/hooks/useResizeObserver.js.map +1 -1
  161. package/lib/esm/core-react/utils/reuseOrCreatePromise.js.map +1 -1
  162. package/lib/esm/core-react/utils/shallowDiffers.js.map +1 -1
  163. package/package.json +3 -3
@@ -16,7 +16,7 @@ import { AnnularSector, Annulus } from "./Annulus";
16
16
  * A context menu arranged in a radial layout.
17
17
  * @public
18
18
  */
19
- class RadialMenu extends React.Component {
19
+ export class RadialMenu extends React.Component {
20
20
  constructor(props) {
21
21
  super(props);
22
22
  this._root = null;
@@ -121,7 +121,6 @@ RadialMenu.defaultProps = {
121
121
  labelRotate: false,
122
122
  selected: -1,
123
123
  };
124
- export { RadialMenu };
125
124
  /**
126
125
  * Button for use within a [[RadialMenu]]
127
126
  * @public
@@ -182,7 +181,7 @@ export class RadialButton extends React.Component {
182
181
  return (React.createElement("g", { onMouseOver: this._handleMouseOver, onMouseOut: this._handleMouseOut, onClick: this._handleClick },
183
182
  React.createElement("path", { className: classnames("core-radial-menu-sector", { selected: this.state.hover }, this.props.className), style: this.props.style, d: path }),
184
183
  React.createElement("foreignObject", { transform: t, x: p.x - size / 2, y: p.y - 16, width: size, height: size, className: "core-radial-menu-button-svg" },
185
- React.createElement("div", { ...{ xmlns: "http://www.w3.org/1999/xhtml" }, className: "core-radial-menu-button-container" },
184
+ React.createElement("div", { xmlns: "http://www.w3.org/1999/xhtml", className: "core-radial-menu-button-container" },
186
185
  React.createElement("div", { className: "core-radial-menu-button-icon" },
187
186
  React.createElement(Icon, { iconSpec: this.props.icon })),
188
187
  React.createElement("div", { className: "core-radial-menu-button-content" }, this.props.children)))));
@@ -1 +1 @@
1
- {"version":3,"file":"RadialMenu.js","sourceRoot":"","sources":["../../../../src/core-react/radialmenu/RadialMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkCnD;;;GAGG;AACH,MAAa,UAAW,SAAQ,KAAK,CAAC,SAGrC;IAaC,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;QAbP,UAAK,GAA0B,IAAI,CAAC;QACpC,oBAAe,GAAwB,IAAI,CAAC;QAMpD,gBAAgB;QACS,UAAK,GAA8B;YAC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AI,GACD;YACR,uCACE,SAAS,EAAE,CAAC,EACZ,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,GAAG,CAAC,EACjB,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,EAAE,EACX,KAAK,EAAE,IAAI,EACX,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,6BAA6B;gBAExC,gCACM,EAAE,KAAK,EAAE,8BAA8B,EAAE,EAC7C,SAAS,EAAE,mCAAmC;oBAE9C,6BAAK,SAAS,EAAC,8BAA8B;wBAC3C,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAI,CAC/B;oBACN,6BAAK,SAAS,EAAE,iCAAiC,IAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACF,CACQ,CACd,CACL,CAAC;IACJ,CAAC;CAoBF","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 RadialMenu\n */\n\nimport \"./RadialMenu.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Point } from \"../utils/Point\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { AnnularSector, Annulus } from \"./Annulus\";\n\n/** Properties for [[RadialMenu]]\n * @public\n */\nexport interface RadialMenuProps extends CommonProps {\n /** Whether to show RadialMenu */\n opened: boolean;\n /** Radius of inner portion of RadialMenu */\n innerRadius: number;\n /** Radius of outer portion of RadialMenu */\n outerRadius: number;\n /** Optional parameter to specify left position in viewport. */\n left?: number | string;\n /** Optional parameter to specify top position in viewport. */\n top?: number | string;\n /** Whether to rotate labels according to location on the RadialMenu, or to keep labels upright.\n * Default: false\n */\n labelRotate?: boolean;\n /** Which child RadialButton to highlight */\n selected?: number;\n /** triggered in case of onClick events anywhere other than radial menu */\n onBlur?: (event: any) => any;\n /** triggered onKeyUp for <Esc> key */\n onEsc?: (event: any) => any;\n /** Content */\n children?: React.ReactNode;\n}\n\ninterface RadialMenuState {\n sectors: AnnularSector[];\n}\n\n/**\n * A context menu arranged in a radial layout.\n * @public\n */\nexport class RadialMenu extends React.Component<\n RadialMenuProps,\n RadialMenuState\n> {\n private _root: HTMLDivElement | null = null;\n private _selectedButton: RadialButton | null = null;\n public static defaultProps: Partial<RadialMenuProps> = {\n labelRotate: false,\n selected: -1,\n };\n\n /** @internal */\n public override readonly state: Readonly<RadialMenuState> = {\n sectors: [],\n };\n\n constructor(props: RadialMenuProps) {\n super(props);\n }\n\n public override render(): React.ReactElement {\n const width = 2 * (this.props.outerRadius + 1);\n let x = this.props.left,\n y = this.props.top;\n\n if (\n this.props.left &&\n this.props.top &&\n typeof this.props.left === \"number\" &&\n typeof this.props.top === \"number\"\n ) {\n x = this.props.left;\n y = this.props.top;\n\n if (x < 0) x = 0;\n if (x > window.innerWidth - width) x = window.innerWidth - width;\n if (y < 0) y = 0;\n if (y > window.innerHeight - width) y = window.innerHeight - width;\n }\n\n const divStyle: React.CSSProperties = {\n left: x,\n top: y,\n ...this.props.style,\n };\n\n return (\n <div\n ref={(el) => {\n this._root = el;\n }}\n className={classnames(\n \"core-radial-menu\",\n { opened: this.props.opened },\n this.props.className\n )}\n style={divStyle}\n data-testid=\"core-radial-menu\"\n >\n <svg\n xmlns=\"http://w3.org/2000/svg\"\n version=\"1.1\"\n width={width}\n height={width}\n className={\"core-radial-menu-container\"}\n >\n {React.Children.map(this.props.children, (child, index) => {\n // istanbul ignore next\n if (!child || typeof child !== \"object\" || !(\"props\" in child))\n return child;\n\n const childElement = child as React.ReactElement<any>;\n return React.cloneElement(childElement, {\n key: index,\n ref: (el: any) => {\n if (this.props.selected === index) this._selectedButton = el;\n },\n selected: index === this.props.selected,\n labelRotate:\n childElement.props.labelRotate || this.props.labelRotate,\n annularSector: this.state.sectors[index],\n });\n })}\n </svg>\n </div>\n );\n }\n\n public override componentDidMount() {\n this._generateAnnularSectors();\n\n setTimeout(() => {\n window.addEventListener(\"keyup\", this._handleKeyUp);\n window.addEventListener(\"mouseup\", this._handleClick);\n });\n }\n\n public override componentWillUnmount() {\n window.removeEventListener(\"keyup\", this._handleKeyUp);\n window.removeEventListener(\"mouseup\", this._handleClick);\n }\n\n public override componentDidUpdate(prevProps: RadialMenuProps) {\n if (\n prevProps.innerRadius !== this.props.innerRadius ||\n prevProps.outerRadius !== this.props.outerRadius\n ) {\n this._generateAnnularSectors();\n }\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (event.key === Key.Escape.valueOf() && this.props.onEsc)\n this.props.onEsc(event);\n };\n\n private _handleClick = (event: MouseEvent) => {\n if (\n event.target instanceof HTMLElement &&\n this._root &&\n !event.target.contains(this._root) &&\n this.props.onBlur\n )\n this.props.onBlur(event);\n };\n\n /** Manually call onSelect of highlighted button. */\n public select = () => {\n // istanbul ignore else\n if (this._selectedButton) this._selectedButton.select();\n };\n\n private _generateAnnularSectors = () => {\n const n = React.Children.count(this.props.children);\n const angle = (2 * Math.PI) / n;\n const outer = this.props.outerRadius;\n const inner = this.props.innerRadius;\n\n const offset = -Math.PI / 8;\n const annulus = new Annulus(\n new Point(outer + 1, outer + 1),\n inner + 1,\n outer - 1\n );\n const sectors: AnnularSector[] = [];\n for (let i = 0; i < n; i++) {\n sectors.push(\n new AnnularSector(annulus, angle * i + offset, angle * (i + 1) + offset)\n );\n }\n this.setState({ sectors });\n };\n}\n\n/** Properties for [[RadialButton]] component\n * @public\n */\nexport interface RadialButtonProps extends CommonProps {\n /** Whether label is rotated to radial menu. Default: Inherit */\n labelRotate?: boolean;\n /** which icon to display in on the menu button */\n icon?: IconSpec;\n /** @internal */\n annularSector?: AnnularSector;\n /** listens to any onClick event, or any select event, which can be triggered by the select() method. */\n onSelect?: (e: any) => any;\n /** Whether item is highlighted */\n selected?: boolean;\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface RadialButtonState {\n hover: boolean;\n}\n\n/**\n * Button for use within a [[RadialMenu]]\n * @public\n */\nexport class RadialButton extends React.Component<\n RadialButtonProps,\n RadialButtonState\n> {\n /** @internal */\n public override readonly state: Readonly<RadialButtonState> = {\n hover: this.props.selected || false,\n };\n\n constructor(props: RadialButtonProps) {\n super(props);\n }\n\n public override render(): React.ReactElement {\n const sector = this.props.annularSector;\n let p = new Point();\n let size = 0;\n let t = \"\";\n let path = \"\";\n\n if (sector) {\n size = sector.start.p1.getDistanceTo(sector.end.p2) * 2;\n path = sector.path;\n\n const parent = sector.parent;\n const { x: cx, y: cy } = parent.center;\n const r = (parent.inner.radius + parent.outer.radius) / 2;\n const angle = (sector.startAngle + sector.endAngle) / 2;\n p = new Point(cx + r * Math.cos(angle), cy + r * Math.sin(angle));\n\n if (this.props.labelRotate) {\n let a = (angle * 180) / Math.PI + 90;\n while (a > 180) a -= 360;\n while (a < -180)\n /* istanbul ignore next */\n a += 360;\n if (a > 90) a -= 180;\n if (a < -90) a += 180;\n t = `rotate(${a} ${p.x}, ${p.y})`;\n }\n }\n\n return (\n <g\n onMouseOver={this._handleMouseOver}\n onMouseOut={this._handleMouseOut}\n onClick={this._handleClick}\n >\n <path\n className={classnames(\n \"core-radial-menu-sector\",\n { selected: this.state.hover },\n this.props.className\n )}\n style={this.props.style}\n d={path}\n ></path>\n <foreignObject\n transform={t}\n x={p.x - size / 2}\n y={p.y - 16}\n width={size}\n height={size}\n className={\"core-radial-menu-button-svg\"}\n >\n <div\n {...{ xmlns: \"http://www.w3.org/1999/xhtml\" }}\n className={\"core-radial-menu-button-container\"}\n >\n <div className=\"core-radial-menu-button-icon\">\n <Icon iconSpec={this.props.icon} />\n </div>\n <div className={\"core-radial-menu-button-content\"}>\n {this.props.children}\n </div>\n </div>\n </foreignObject>\n </g>\n );\n }\n\n /** Manually call this.props.onSelect */\n public select = () => {\n // istanbul ignore else\n if (this.props.onSelect) this.props.onSelect(undefined);\n };\n\n private _handleClick = (event: React.MouseEvent<SVGElement>) => {\n // istanbul ignore else\n if (this.props.onSelect) this.props.onSelect(event);\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<SVGElement>) => {\n this.setState({ hover: true });\n };\n\n private _handleMouseOut = (_event: React.MouseEvent<SVGElement>) => {\n this.setState({ hover: false });\n };\n}\n"]}
1
+ {"version":3,"file":"RadialMenu.js","sourceRoot":"","sources":["../../../../src/core-react/radialmenu/RadialMenu.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,mBAAmB,CAAC;AAC3B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAEvC,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAkCnD;;;GAGG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK,CAAC,SAGrC;IAaC,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;QAbP,UAAK,GAA0B,IAAI,CAAC;QACpC,oBAAe,GAAwB,IAAI,CAAC;QAMpD,gBAAgB;QACS,UAAK,GAA8B;YAC1D,OAAO,EAAE,EAAE;SACZ,CAAC;QAiGM,iBAAY,GAAG,CAAC,KAAoB,EAAE,EAAE;YAC9C,IAAI,KAAK,CAAC,GAAG,KAAK,GAAG,CAAC,MAAM,CAAC,OAAO,EAAE,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK;gBACxD,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,CAAC,CAAC;QAEM,iBAAY,GAAG,CAAC,KAAiB,EAAE,EA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SAAS,EAAE,mCAAmC;oBAE9C,6BAAK,SAAS,EAAC,8BAA8B;wBAC3C,oBAAC,IAAI,IAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,GAAI,CAC/B;oBACN,6BAAK,SAAS,EAAE,iCAAiC,IAC9C,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACF,CACQ,CACd,CACL,CAAC;IACJ,CAAC;CAoBF","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 RadialMenu\n */\n\nimport \"./RadialMenu.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { Point } from \"../utils/Point\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { AnnularSector, Annulus } from \"./Annulus\";\n\n/** Properties for [[RadialMenu]]\n * @public\n */\nexport interface RadialMenuProps extends CommonProps {\n /** Whether to show RadialMenu */\n opened: boolean;\n /** Radius of inner portion of RadialMenu */\n innerRadius: number;\n /** Radius of outer portion of RadialMenu */\n outerRadius: number;\n /** Optional parameter to specify left position in viewport. */\n left?: number | string;\n /** Optional parameter to specify top position in viewport. */\n top?: number | string;\n /** Whether to rotate labels according to location on the RadialMenu, or to keep labels upright.\n * Default: false\n */\n labelRotate?: boolean;\n /** Which child RadialButton to highlight */\n selected?: number;\n /** triggered in case of onClick events anywhere other than radial menu */\n onBlur?: (event: any) => any;\n /** triggered onKeyUp for <Esc> key */\n onEsc?: (event: any) => any;\n /** Content */\n children?: React.ReactNode;\n}\n\ninterface RadialMenuState {\n sectors: AnnularSector[];\n}\n\n/**\n * A context menu arranged in a radial layout.\n * @public\n */\nexport class RadialMenu extends React.Component<\n RadialMenuProps,\n RadialMenuState\n> {\n private _root: HTMLDivElement | null = null;\n private _selectedButton: RadialButton | null = null;\n public static defaultProps: Partial<RadialMenuProps> = {\n labelRotate: false,\n selected: -1,\n };\n\n /** @internal */\n public override readonly state: Readonly<RadialMenuState> = {\n sectors: [],\n };\n\n constructor(props: RadialMenuProps) {\n super(props);\n }\n\n public override render(): React.ReactElement {\n const width = 2 * (this.props.outerRadius + 1);\n let x = this.props.left,\n y = this.props.top;\n\n if (\n this.props.left &&\n this.props.top &&\n typeof this.props.left === \"number\" &&\n typeof this.props.top === \"number\"\n ) {\n x = this.props.left;\n y = this.props.top;\n\n if (x < 0) x = 0;\n if (x > window.innerWidth - width) x = window.innerWidth - width;\n if (y < 0) y = 0;\n if (y > window.innerHeight - width) y = window.innerHeight - width;\n }\n\n const divStyle: React.CSSProperties = {\n left: x,\n top: y,\n ...this.props.style,\n };\n\n return (\n <div\n ref={(el) => {\n this._root = el;\n }}\n className={classnames(\n \"core-radial-menu\",\n { opened: this.props.opened },\n this.props.className\n )}\n style={divStyle}\n data-testid=\"core-radial-menu\"\n >\n <svg\n xmlns=\"http://w3.org/2000/svg\"\n version=\"1.1\"\n width={width}\n height={width}\n className={\"core-radial-menu-container\"}\n >\n {React.Children.map(this.props.children, (child, index) => {\n // istanbul ignore next\n if (!child || typeof child !== \"object\" || !(\"props\" in child))\n return child;\n\n const childElement = child as React.ReactElement<any>;\n return React.cloneElement(childElement, {\n key: index,\n ref: (el: any) => {\n if (this.props.selected === index) this._selectedButton = el;\n },\n selected: index === this.props.selected,\n labelRotate:\n childElement.props.labelRotate || this.props.labelRotate,\n annularSector: this.state.sectors[index],\n });\n })}\n </svg>\n </div>\n );\n }\n\n public override componentDidMount() {\n this._generateAnnularSectors();\n\n setTimeout(() => {\n window.addEventListener(\"keyup\", this._handleKeyUp);\n window.addEventListener(\"mouseup\", this._handleClick);\n });\n }\n\n public override componentWillUnmount() {\n window.removeEventListener(\"keyup\", this._handleKeyUp);\n window.removeEventListener(\"mouseup\", this._handleClick);\n }\n\n public override componentDidUpdate(prevProps: RadialMenuProps) {\n if (\n prevProps.innerRadius !== this.props.innerRadius ||\n prevProps.outerRadius !== this.props.outerRadius\n ) {\n this._generateAnnularSectors();\n }\n }\n\n private _handleKeyUp = (event: KeyboardEvent) => {\n if (event.key === Key.Escape.valueOf() && this.props.onEsc)\n this.props.onEsc(event);\n };\n\n private _handleClick = (event: MouseEvent) => {\n if (\n event.target instanceof HTMLElement &&\n this._root &&\n !event.target.contains(this._root) &&\n this.props.onBlur\n )\n this.props.onBlur(event);\n };\n\n /** Manually call onSelect of highlighted button. */\n public select = () => {\n // istanbul ignore else\n if (this._selectedButton) this._selectedButton.select();\n };\n\n private _generateAnnularSectors = () => {\n const n = React.Children.count(this.props.children);\n const angle = (2 * Math.PI) / n;\n const outer = this.props.outerRadius;\n const inner = this.props.innerRadius;\n\n const offset = -Math.PI / 8;\n const annulus = new Annulus(\n new Point(outer + 1, outer + 1),\n inner + 1,\n outer - 1\n );\n const sectors: AnnularSector[] = [];\n for (let i = 0; i < n; i++) {\n sectors.push(\n new AnnularSector(annulus, angle * i + offset, angle * (i + 1) + offset)\n );\n }\n this.setState({ sectors });\n };\n}\n\n/** Properties for [[RadialButton]] component\n * @public\n */\nexport interface RadialButtonProps extends CommonProps {\n /** Whether label is rotated to radial menu. Default: Inherit */\n labelRotate?: boolean;\n /** which icon to display in on the menu button */\n icon?: IconSpec;\n /** @internal */\n annularSector?: AnnularSector;\n /** listens to any onClick event, or any select event, which can be triggered by the select() method. */\n onSelect?: (e: any) => any;\n /** Whether item is highlighted */\n selected?: boolean;\n /** Content */\n children?: React.ReactNode;\n}\n\n/** @internal */\ninterface RadialButtonState {\n hover: boolean;\n}\n\n/**\n * Button for use within a [[RadialMenu]]\n * @public\n */\nexport class RadialButton extends React.Component<\n RadialButtonProps,\n RadialButtonState\n> {\n /** @internal */\n public override readonly state: Readonly<RadialButtonState> = {\n hover: this.props.selected || false,\n };\n\n constructor(props: RadialButtonProps) {\n super(props);\n }\n\n public override render(): React.ReactElement {\n const sector = this.props.annularSector;\n let p = new Point();\n let size = 0;\n let t = \"\";\n let path = \"\";\n\n if (sector) {\n size = sector.start.p1.getDistanceTo(sector.end.p2) * 2;\n path = sector.path;\n\n const parent = sector.parent;\n const { x: cx, y: cy } = parent.center;\n const r = (parent.inner.radius + parent.outer.radius) / 2;\n const angle = (sector.startAngle + sector.endAngle) / 2;\n p = new Point(cx + r * Math.cos(angle), cy + r * Math.sin(angle));\n\n if (this.props.labelRotate) {\n let a = (angle * 180) / Math.PI + 90;\n while (a > 180) a -= 360;\n while (a < -180)\n /* istanbul ignore next */\n a += 360;\n if (a > 90) a -= 180;\n if (a < -90) a += 180;\n t = `rotate(${a} ${p.x}, ${p.y})`;\n }\n }\n\n return (\n <g\n onMouseOver={this._handleMouseOver}\n onMouseOut={this._handleMouseOut}\n onClick={this._handleClick}\n >\n <path\n className={classnames(\n \"core-radial-menu-sector\",\n { selected: this.state.hover },\n this.props.className\n )}\n style={this.props.style}\n d={path}\n ></path>\n <foreignObject\n transform={t}\n x={p.x - size / 2}\n y={p.y - 16}\n width={size}\n height={size}\n className={\"core-radial-menu-button-svg\"}\n >\n <div\n {...{ xmlns: \"http://www.w3.org/1999/xhtml\" }}\n className={\"core-radial-menu-button-container\"}\n >\n <div className=\"core-radial-menu-button-icon\">\n <Icon iconSpec={this.props.icon} />\n </div>\n <div className={\"core-radial-menu-button-content\"}>\n {this.props.children}\n </div>\n </div>\n </foreignObject>\n </g>\n );\n }\n\n /** Manually call this.props.onSelect */\n public select = () => {\n // istanbul ignore else\n if (this.props.onSelect) this.props.onSelect(undefined);\n };\n\n private _handleClick = (event: React.MouseEvent<SVGElement>) => {\n // istanbul ignore else\n if (this.props.onSelect) this.props.onSelect(event);\n };\n\n private _handleMouseOver = (_event: React.MouseEvent<SVGElement>) => {\n this.setState({ hover: true });\n };\n\n private _handleMouseOut = (_event: React.MouseEvent<SVGElement>) => {\n this.setState({ hover: false });\n };\n}\n"]}
@@ -1 +1 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AAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,IAAI,EAAC,WAAW,iBACJ,sBAAsB,GAClC;YACF,oBAAC,eAAe,IACd,SAAS,EAAC,uBAAuB,EACjC,OAAO,EAAE,IAAI,CAAC,gBAAgB,EAC9B,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,CAAC,EACZ,WAAW,EAAE,WAAW;gBAExB,8BAAM,SAAS,EAAE,aAAa;oBAC5B,oBAAC,IAAI,IAAC,QAAQ,EAAE,QAAQ,GAAI,CACvB,CACS,CACd,CACP,CAAC;IACJ,CAAC;IAmEe,oBAAoB;QAClC,IAAI,CAAC,aAAa,EAAE,CAAC;IACvB,CAAC;IAEM,KAAK;QACV,uBAAuB;QACvB,IAAI,IAAI,CAAC,aAAa;YAAE,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;IACrD,CAAC;CACF;AAED,MAAM,cAAc,GAAG,KAAK,CAAC,UAAU,CAGrC,SAAS,cAAc,CAAC,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IACtD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,OAAO,CACL,oBAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,IAAI,SAAS,CAAC,gBAAgB,CAAC,KACnD,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,EACvB,WAAW,EACX,GAAG,KAAK,EAC+C;IACvD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,SAAS,CAC3B,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,CACjD,CAAC;IACF,OAAO,6BAAK,KAAK,EAAE,WAAW,KAAM,KAAK,GAAI,CAAC;AAChD,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 SearchBox\n */\n\nimport \"./SearchBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgClose, SvgSearch } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Properties for [[SearchBox]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link SearchBox}.\n */\nexport interface SearchBoxProps extends CommonProps {\n /** Value to set SearchBox to initially */\n initialValue?: string;\n /** Placeholder value to show in gray before anything is entered in */\n placeholder?: string;\n /** Triggered when the content of SearchBox is changed */\n onValueChanged: (value: string) => void;\n /** Frequency to poll for changes in value, in milliseconds */\n valueChangedDelay?: number;\n /** Listens for <Enter> keypress */\n onEnterPressed?: () => void;\n /** Listens for <Esc> keypress */\n onEscPressed?: () => void;\n /** Listens for onClick event for Clear (x) icon */\n onClear?: () => void;\n}\n\ninterface SearchBoxState {\n value: string;\n}\n\n/** Input box for entering text to search for.\n * The SearchBox has an icon right-justified and bounded by the box and shows a Search or Clear icon.\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/searchbox iTwinUI SearchBox} instead.\n */\nexport class SearchBox extends React.Component<SearchBoxProps, SearchBoxState> {\n private _inputElement: HTMLInputElement | null = null;\n private _timeoutId: number = 0;\n\n /** @internal */\n public override readonly state: Readonly<SearchBoxState> = {\n value: this.props.initialValue || \"\",\n };\n\n constructor(props: SearchBoxProps) {\n super(props);\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const searchClassName = classnames(\"core-searchbox\", this.props.className);\n const emptyString = this.state.value === \"\";\n const iconClassName = classnames(\"core-searchbox-icon\", \"icon\");\n const iconSpec: IconSpec = emptyString ? <SvgSearch /> : <SvgClose />;\n return (\n <div\n className={searchClassName}\n style={this.props.style}\n data-testid=\"core-searchbox-instance\"\n >\n <SearchBoxInput\n defaultValue={this.props.initialValue}\n ref={(el) => {\n this._inputElement = el;\n }}\n onChange={this._trackChange}\n onKeyDown={this._handleKeyDown}\n onPaste={this._trackChange}\n onCut={this._trackChange}\n placeholder={this.props.placeholder}\n role=\"searchbox\"\n data-testid=\"core-searchbox-input\"\n />\n <SearchBoxButton\n className=\"core-searchbox-button\"\n onClick={this._handleIconClick}\n role=\"button\"\n tabIndex={-1}\n emptyString={emptyString}\n >\n <span className={iconClassName}>\n <Icon iconSpec={iconSpec} />\n </span>\n </SearchBoxButton>\n </div>\n );\n }\n\n /** Wrapper for onValueChanged to make sure we don't call search unless the new value is different from the previous value */\n private _onValueChanged = (value: string, previousValue: string) => {\n // istanbul ignore else\n if (value === previousValue) return;\n\n this.setState(\n (_prevState) => {\n return {\n value,\n };\n },\n () => {\n this.props.onValueChanged(this.state.value);\n }\n );\n };\n private _trackChange = (_event?: any): void => {\n let value = \"\";\n const previousValue = this.state.value;\n\n // istanbul ignore else\n if (this._inputElement) value = this._inputElement.value;\n\n if (this.props.valueChangedDelay) {\n this._unsetTimeout();\n this._timeoutId = window.setTimeout(() => {\n this._onValueChanged(value, previousValue);\n }, this.props.valueChangedDelay);\n } else {\n this._onValueChanged(value, previousValue);\n }\n };\n\n private _handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case Key.Escape.valueOf():\n // istanbul ignore else\n if (this.props.onEscPressed) this.props.onEscPressed();\n break;\n case Key.Enter.valueOf():\n // istanbul ignore else\n if (this.props.onEnterPressed) this.props.onEnterPressed();\n break;\n }\n };\n\n private _handleIconClick = (_event: React.MouseEvent<HTMLElement>): void => {\n // istanbul ignore else\n if (this._inputElement) {\n const clear = this.state.value !== \"\";\n this._inputElement.value = \"\";\n // istanbul ignore else\n if (clear && this.props.onClear) this.props.onClear();\n this._inputElement.focus();\n }\n this._trackChange();\n };\n\n private _unsetTimeout = (): void => {\n if (this._timeoutId) {\n window.clearTimeout(this._timeoutId);\n this._timeoutId = 0;\n }\n };\n\n public override componentWillUnmount() {\n this._unsetTimeout();\n }\n\n public focus() {\n // istanbul ignore else\n if (this._inputElement) this._inputElement.focus();\n }\n}\n\nconst SearchBoxInput = React.forwardRef<\n HTMLInputElement,\n React.ComponentProps<typeof Input>\n>(function SearchBoxInput({ placeholder, ...props }, ref) {\n const { translate } = useTranslation();\n return (\n <Input\n ref={ref}\n placeholder={placeholder || translate(\"general.search\")}\n {...props}\n />\n );\n});\n\nfunction SearchBoxButton({\n emptyString,\n ...props\n}: React.ComponentProps<\"div\"> & { emptyString: boolean }) {\n const { translate } = useTranslation();\n const buttonTitle = translate(\n emptyString ? \"general.search\" : \"general.clear\"\n );\n return <div title={buttonTitle} {...props} />;\n}\n"]}
1
+ {"version":3,"file":"SearchBox.js","sourceRoot":"","sources":["../../../../src/core-react/searchbox/SearchBox.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAC1B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAE7C,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AA6BxD;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK,CAAC,SAAyC;IAS5E,YAAY,KAAqB;QAC/B,KAAK,CAAC,KAAK,CAAC,CAAC;QATP,kBAAa,GAA4B,IAAI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CAAC,UAAU,CAGrC,SAAS,cAAc,CAAC,EAAE,WAAW,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG;IACtD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,OAAO,CACL,oBAAC,KAAK,IACJ,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,WAAW,IAAI,SAAS,CAAC,gBAAgB,CAAC,KACnD,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,SAAS,eAAe,CAAC,EACvB,WAAW,EACX,GAAG,KAAK,EAC+C;IACvD,MAAM,EAAE,SAAS,EAAE,GAAG,cAAc,EAAE,CAAC;IACvC,MAAM,WAAW,GAAG,SAAS,CAC3B,WAAW,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,eAAe,CACjD,CAAC;IACF,OAAO,6BAAK,KAAK,EAAE,WAAW,KAAM,KAAK,GAAI,CAAC;AAChD,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 SearchBox\n */\n\nimport \"./SearchBox.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { SvgClose, SvgSearch } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** Properties for [[SearchBox]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link SearchBox}.\n */\nexport interface SearchBoxProps extends CommonProps {\n /** Value to set SearchBox to initially */\n initialValue?: string;\n /** Placeholder value to show in gray before anything is entered in */\n placeholder?: string;\n /** Triggered when the content of SearchBox is changed */\n onValueChanged: (value: string) => void;\n /** Frequency to poll for changes in value, in milliseconds */\n valueChangedDelay?: number;\n /** Listens for <Enter> keypress */\n onEnterPressed?: () => void;\n /** Listens for <Esc> keypress */\n onEscPressed?: () => void;\n /** Listens for onClick event for Clear (x) icon */\n onClear?: () => void;\n}\n\ninterface SearchBoxState {\n value: string;\n}\n\n/** Input box for entering text to search for.\n * The SearchBox has an icon right-justified and bounded by the box and shows a Search or Clear icon.\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/searchbox iTwinUI SearchBox} instead.\n */\nexport class SearchBox extends React.Component<SearchBoxProps, SearchBoxState> {\n private _inputElement: HTMLInputElement | null = null;\n private _timeoutId: number = 0;\n\n /** @internal */\n public override readonly state: Readonly<SearchBoxState> = {\n value: this.props.initialValue || \"\",\n };\n\n constructor(props: SearchBoxProps) {\n super(props);\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const searchClassName = classnames(\"core-searchbox\", this.props.className);\n const emptyString = this.state.value === \"\";\n const iconClassName = classnames(\"core-searchbox-icon\", \"icon\");\n const iconSpec: IconSpec = emptyString ? <SvgSearch /> : <SvgClose />;\n return (\n <div\n className={searchClassName}\n style={this.props.style}\n data-testid=\"core-searchbox-instance\"\n >\n <SearchBoxInput\n defaultValue={this.props.initialValue}\n ref={(el) => {\n this._inputElement = el;\n }}\n onChange={this._trackChange}\n onKeyDown={this._handleKeyDown}\n onPaste={this._trackChange}\n onCut={this._trackChange}\n placeholder={this.props.placeholder}\n role=\"searchbox\"\n data-testid=\"core-searchbox-input\"\n />\n <SearchBoxButton\n className=\"core-searchbox-button\"\n onClick={this._handleIconClick}\n role=\"button\"\n tabIndex={-1}\n emptyString={emptyString}\n >\n <span className={iconClassName}>\n <Icon iconSpec={iconSpec} />\n </span>\n </SearchBoxButton>\n </div>\n );\n }\n\n /** Wrapper for onValueChanged to make sure we don't call search unless the new value is different from the previous value */\n private _onValueChanged = (value: string, previousValue: string) => {\n // istanbul ignore else\n if (value === previousValue) return;\n\n this.setState(\n (_prevState) => {\n return {\n value,\n };\n },\n () => {\n this.props.onValueChanged(this.state.value);\n }\n );\n };\n private _trackChange = (_event?: any): void => {\n let value = \"\";\n const previousValue = this.state.value;\n\n // istanbul ignore else\n if (this._inputElement) value = this._inputElement.value;\n\n if (this.props.valueChangedDelay) {\n this._unsetTimeout();\n this._timeoutId = window.setTimeout(() => {\n this._onValueChanged(value, previousValue);\n }, this.props.valueChangedDelay);\n } else {\n this._onValueChanged(value, previousValue);\n }\n };\n\n private _handleKeyDown = (e: React.KeyboardEvent) => {\n switch (e.key) {\n case Key.Escape.valueOf():\n // istanbul ignore else\n if (this.props.onEscPressed) this.props.onEscPressed();\n break;\n case Key.Enter.valueOf():\n // istanbul ignore else\n if (this.props.onEnterPressed) this.props.onEnterPressed();\n break;\n }\n };\n\n private _handleIconClick = (_event: React.MouseEvent<HTMLElement>): void => {\n // istanbul ignore else\n if (this._inputElement) {\n const clear = this.state.value !== \"\";\n this._inputElement.value = \"\";\n // istanbul ignore else\n if (clear && this.props.onClear) this.props.onClear();\n this._inputElement.focus();\n }\n this._trackChange();\n };\n\n private _unsetTimeout = (): void => {\n if (this._timeoutId) {\n window.clearTimeout(this._timeoutId);\n this._timeoutId = 0;\n }\n };\n\n public override componentWillUnmount() {\n this._unsetTimeout();\n }\n\n public focus() {\n // istanbul ignore else\n if (this._inputElement) this._inputElement.focus();\n }\n}\n\nconst SearchBoxInput = React.forwardRef<\n HTMLInputElement,\n React.ComponentProps<typeof Input>\n>(function SearchBoxInput({ placeholder, ...props }, ref) {\n const { translate } = useTranslation();\n return (\n <Input\n ref={ref}\n placeholder={placeholder || translate(\"general.search\")}\n {...props}\n />\n );\n});\n\nfunction SearchBoxButton({\n emptyString,\n ...props\n}: React.ComponentProps<\"div\"> & { emptyString: boolean }) {\n const { translate } = useTranslation();\n const buttonTitle = translate(\n emptyString ? \"general.search\" : \"general.clear\"\n );\n return <div title={buttonTitle} {...props} />;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsContainer.js","sourceRoot":"","sources":["../../../../src/core-react/settings/SettingsContainer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;;6GAW6G;AAE7G;;GAEG;AACH,MAAM,UAAU,qCAAqC,CACnD,eAAgC,EAChC,YAA2E;IAE3E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,mCAAmC,GAAG,CAC1C,EAAE,SAAS,EAAE,aAAa,EAA0C,CAAC,8CAA8C;UACnH,EAAE;YACF,YAAY,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;QACzC,CAAC,CAAC;QACF,OAAO,eAAe,CAAC,+BAA+B,CAAC,WAAW,CAChE,mCAAmC,CACpC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,qCAAqC,CACnD,eAAgC,EAChC,YAGS;IAET,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,kCAAkC,GAAG,CACzC,EACE,gBAAgB,EAChB,sBAAsB,GACgB,CAAC,8CAA8C;UACvF,EAAE;YACF,YAAY,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAAC;QACzD,CAAC,CAAC;QACF,OAAO,eAAe,CAAC,8BAA8B,CAAC,WAAW,CAC/D,kCAAkC,CACnC,CAAC;IACJ,CAAC,EAAE,CAAC,YAAY,EAAE,eAAe,CAAC,CAAC,CAAC;AACtC,CAAC;AAiBD;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,EAChC,IA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S,EAAC,+BAA+B;YAC3C,UAAU,IAAI,CACb,6BAAK,SAAS,EAAC,sCAAsC;gBACnD,8BAAM,SAAS,EAAC,qCAAqC,IAClD,OAAO,CAAC,KAAK,CACT;gBACN,OAAO,CAAC,QAAQ,IAAI,CACnB,8BAAM,SAAS,EAAC,yCAAyC,IACtD,OAAO,CAAC,QAAQ,CACZ,CACR,CACG,CACP;YACD,6BAAK,SAAS,EAAC,wCAAwC,IACpD,OAAO,CAAC,IAAI,CACT,CACF,CACF,CACP,CAAC;AACJ,CAAC,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 Settings\n */\n\nimport \"./SettingsContainer.scss\";\nimport * as React from \"react\";\nimport type {\n ActivateSettingsTabEventArgs,\n ProcessSettingsContainerCloseEventArgs,\n ProcessSettingsTabActivationEventArgs,\n SettingsManager,\n SettingsTabEntry,\n} from \"./SettingsManager\";\nimport { VerticalTabs } from \"../tabs/VerticalTabs\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\n\n/* ---------------------------------------------------------------------------------------------------\n// A typical implementation of a saveFunction callback\nconst saveChanges = React.useCallback((afterSaveFunction: (args: any) => void, args?: any) => {\n if (dataIsDirty) {\n // prompt user to save changes passing in function and arguments to call after saving changes.\n UiFramework.dialogs.modal.openDialog(<CustomSavePromptModalDialog customProps={customProps}\n onDialogCloseArgs={args} onDialogClose={afterSaveFunction} />);\n return;\n }\n afterSaveFunction(args);\n}, []);\n---------------------------------------------------------------------------------------------------------- */\n\n/** Hook to use within Settings Page component to allow saving the current page's data before the Setting Container is closed.\n * @public\n */\nexport function useSaveBeforeClosingSettingsContainer(\n settingsManager: SettingsManager,\n saveFunction: (closeFunc: (args: any) => void, closeFuncArgs?: any) => void\n) {\n React.useEffect(() => {\n const handleProcessSettingsContainerClose = (\n { closeFunc, closeFuncArgs }: ProcessSettingsContainerCloseEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n saveFunction(closeFunc, closeFuncArgs);\n };\n return settingsManager.onProcessSettingsContainerClose.addListener(\n handleProcessSettingsContainerClose\n );\n }, [saveFunction, settingsManager]);\n}\n\n/** Hook to use within Settings Page component to allow saving the current page's data before loading to the requested Setting Tab's page.\n * @public\n */\nexport function useSaveBeforeActivatingNewSettingsTab(\n settingsManager: SettingsManager,\n saveFunction: (\n tabSelectionFunc: (args: any) => void,\n requestedSettingsTabId?: string\n ) => void\n) {\n React.useEffect(() => {\n const handleProcessSettingsTabActivation = (\n {\n tabSelectionFunc,\n requestedSettingsTabId,\n }: ProcessSettingsTabActivationEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n saveFunction(tabSelectionFunc, requestedSettingsTabId);\n };\n return settingsManager.onProcessSettingsTabActivation.addListener(\n handleProcessSettingsTabActivation\n );\n }, [saveFunction, settingsManager]);\n}\n\n/**\n * @public\n */\nexport interface SettingsContainerProps {\n tabs: SettingsTabEntry[];\n // sets tab to set as active tab\n currentSettingsTab?: SettingsTabEntry;\n // If plugging into a SPA and you need to modify the route, you can pass in additional logic here\n onSettingsTabSelected?: (tab: SettingsTabEntry) => void;\n // The SettingsManager that can have event handlers registered against it so pages can save its settings before the page is closed.\n settingsManager: SettingsManager;\n // if true show tab label as header above page contents.\n showHeader?: boolean;\n}\n\n/**\n * SettingsContainer component that displays Setting Tabs on Left and the P\n * Note: that SettingsContainer is not rendered if tabs array is empty\n * @public\n */\nexport const SettingsContainer = ({\n tabs,\n onSettingsTabSelected,\n currentSettingsTab,\n settingsManager,\n showHeader,\n}: SettingsContainerProps) => {\n // sort the tabs based on itemPriority\n tabs = tabs.sort((a, b) => a.itemPriority - b.itemPriority);\n\n const [openTab, setOpenTab] = React.useState(() => {\n if (\n currentSettingsTab &&\n !ConditionalBooleanValue.getValue(currentSettingsTab.isDisabled)\n )\n return currentSettingsTab;\n else return tabs[0];\n });\n\n const processTabSelection = React.useCallback(\n (tab: SettingsTabEntry) => {\n if (ConditionalBooleanValue.getValue(tab.isDisabled)) return;\n onSettingsTabSelected && onSettingsTabSelected(tab);\n setOpenTab(tab);\n },\n [onSettingsTabSelected]\n );\n\n const processTabSelectionById = React.useCallback(\n (tabId: string) => {\n const tabToActivate = tabs.find((tab) => tab.tabId === tabId);\n tabToActivate && processTabSelection(tabToActivate);\n },\n [processTabSelection, tabs]\n );\n\n const onActivateTab = React.useCallback(\n (tabIndex: number) => {\n const selectedTab = tabs[tabIndex];\n if (openTab && openTab.pageWillHandleCloseRequest)\n settingsManager.onProcessSettingsTabActivation.emit({\n requestedSettingsTabId: selectedTab.tabId,\n tabSelectionFunc: processTabSelectionById,\n });\n else processTabSelection(selectedTab);\n },\n [\n openTab,\n processTabSelection,\n processTabSelectionById,\n settingsManager,\n tabs,\n ]\n );\n\n React.useEffect(() => {\n const handleActivateSettingsTab = (\n { settingsTabId }: ActivateSettingsTabEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const idToFind = settingsTabId.toLowerCase();\n let tabToActivate = tabs.find(\n (tab) => tab.tabId.toLowerCase() === idToFind\n );\n if (!tabToActivate)\n tabToActivate = tabs.find(\n (tab) => tab.label.toLowerCase() === idToFind\n );\n // istanbul ignore else\n if (tabToActivate) {\n if (openTab && openTab.pageWillHandleCloseRequest)\n settingsManager.onProcessSettingsTabActivation.emit({\n requestedSettingsTabId: tabToActivate.tabId,\n tabSelectionFunc: processTabSelectionById,\n });\n else processTabSelection(tabToActivate);\n }\n };\n\n return settingsManager.onActivateSettingsTab.addListener(\n handleActivateSettingsTab\n );\n }, [\n openTab,\n processTabSelection,\n processTabSelectionById,\n settingsManager,\n settingsManager.onActivateSettingsTab,\n tabs,\n ]);\n\n React.useEffect(() => {\n const handleSettingsContainerClose = (\n { closeFunc, closeFuncArgs }: ProcessSettingsContainerCloseEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n if (openTab && openTab.pageWillHandleCloseRequest)\n settingsManager.onProcessSettingsContainerClose.emit({\n closeFunc,\n closeFuncArgs,\n });\n else closeFunc(closeFuncArgs);\n };\n return settingsManager.onCloseSettingsContainer.addListener(\n handleSettingsContainerClose\n );\n }, [\n openTab,\n processTabSelection,\n settingsManager,\n settingsManager.onActivateSettingsTab,\n tabs,\n ]);\n\n const labels = tabs.map((tab) => {\n return {\n label: tab.label,\n subLabel: tab.subLabel,\n icon: tab.icon,\n tooltip: tab.tooltip,\n tabId: tab.tabId,\n disabled: ConditionalBooleanValue.getValue(tab.isDisabled),\n };\n });\n const activeIndex = tabs.findIndex((tab) => tab.tabId === openTab.tabId);\n return (\n <div className=\"core-settings-container\">\n <div className=\"core-settings-container-left\">\n {/* eslint-disable-next-line deprecation/deprecation */}\n <VerticalTabs\n labels={labels}\n activeIndex={activeIndex}\n onActivateTab={onActivateTab}\n />\n </div>\n <div className=\"core-settings-container-right\">\n {showHeader && (\n <div className=\"core-settings-container-right-header\">\n <span className=\"core-settings-container-main-header\">\n {openTab.label}\n </span>\n {openTab.subLabel && (\n <span className=\"core-settings-container-main-sub-header\">\n {openTab.subLabel}\n </span>\n )}\n </div>\n )}\n <div className=\"core-settings-container-right-contents\">\n {openTab.page}\n </div>\n </div>\n </div>\n );\n};\n"]}
1
+ {"version":3,"file":"SettingsContainer.js","sourceRoot":"","sources":["../../../../src/core-react/settings/SettingsContainer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAQ/B,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAC;AAEhE;;;;;;;;;;;6GAW6G;AAE7G;;GAEG;AACH,MAAM,UAAU,qCAAqC,CACnD,eAAgC,EAChC,YAA2E;IAE3E,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,mC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BAAmB;QACnB,eAAe;QACf,eAAe,CAAC,qBAAqB;QACrC,IAAI;KACL,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE;QAC9B,OAAO;YACL,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,GAAG,CAAC,OAAO;YACpB,KAAK,EAAE,GAAG,CAAC,KAAK;YAChB,QAAQ,EAAE,uBAAuB,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC;SAC3D,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,KAAK,OAAO,CAAC,KAAK,CAAC,CAAC;IACzE,OAAO,CACL,6BAAK,SAAS,EAAC,yBAAyB;QACtC,6BAAK,SAAS,EAAC,8BAA8B;YAE3C,oBAAC,YAAY,IACX,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,EAAE,aAAa,GAC5B,CACE;QACN,6BAAK,SAAS,EAAC,+BAA+B;YAC3C,UAAU,IAAI,CACb,6BAAK,SAAS,EAAC,sCAAsC;gBACnD,8BAAM,SAAS,EAAC,qCAAqC,IAClD,OAAO,CAAC,KAAK,CACT;gBACN,OAAO,CAAC,QAAQ,IAAI,CACnB,8BAAM,SAAS,EAAC,yCAAyC,IACtD,OAAO,CAAC,QAAQ,CACZ,CACR,CACG,CACP;YACD,6BAAK,SAAS,EAAC,wCAAwC,IACpD,OAAO,CAAC,IAAI,CACT,CACF,CACF,CACP,CAAC;AACJ,CAAC,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 Settings\n */\n\nimport \"./SettingsContainer.scss\";\nimport * as React from \"react\";\nimport type {\n ActivateSettingsTabEventArgs,\n ProcessSettingsContainerCloseEventArgs,\n ProcessSettingsTabActivationEventArgs,\n SettingsManager,\n SettingsTabEntry,\n} from \"./SettingsManager\";\nimport { VerticalTabs } from \"../tabs/VerticalTabs\";\nimport { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\n\n/* ---------------------------------------------------------------------------------------------------\n// A typical implementation of a saveFunction callback\nconst saveChanges = React.useCallback((afterSaveFunction: (args: any) => void, args?: any) => {\n if (dataIsDirty) {\n // prompt user to save changes passing in function and arguments to call after saving changes.\n UiFramework.dialogs.modal.openDialog(<CustomSavePromptModalDialog customProps={customProps}\n onDialogCloseArgs={args} onDialogClose={afterSaveFunction} />);\n return;\n }\n afterSaveFunction(args);\n}, []);\n---------------------------------------------------------------------------------------------------------- */\n\n/** Hook to use within Settings Page component to allow saving the current page's data before the Setting Container is closed.\n * @public\n */\nexport function useSaveBeforeClosingSettingsContainer(\n settingsManager: SettingsManager,\n saveFunction: (closeFunc: (args: any) => void, closeFuncArgs?: any) => void\n) {\n React.useEffect(() => {\n const handleProcessSettingsContainerClose = (\n { closeFunc, closeFuncArgs }: ProcessSettingsContainerCloseEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n saveFunction(closeFunc, closeFuncArgs);\n };\n return settingsManager.onProcessSettingsContainerClose.addListener(\n handleProcessSettingsContainerClose\n );\n }, [saveFunction, settingsManager]);\n}\n\n/** Hook to use within Settings Page component to allow saving the current page's data before loading to the requested Setting Tab's page.\n * @public\n */\nexport function useSaveBeforeActivatingNewSettingsTab(\n settingsManager: SettingsManager,\n saveFunction: (\n tabSelectionFunc: (args: any) => void,\n requestedSettingsTabId?: string\n ) => void\n) {\n React.useEffect(() => {\n const handleProcessSettingsTabActivation = (\n {\n tabSelectionFunc,\n requestedSettingsTabId,\n }: ProcessSettingsTabActivationEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n saveFunction(tabSelectionFunc, requestedSettingsTabId);\n };\n return settingsManager.onProcessSettingsTabActivation.addListener(\n handleProcessSettingsTabActivation\n );\n }, [saveFunction, settingsManager]);\n}\n\n/**\n * @public\n */\nexport interface SettingsContainerProps {\n tabs: SettingsTabEntry[];\n // sets tab to set as active tab\n currentSettingsTab?: SettingsTabEntry;\n // If plugging into a SPA and you need to modify the route, you can pass in additional logic here\n onSettingsTabSelected?: (tab: SettingsTabEntry) => void;\n // The SettingsManager that can have event handlers registered against it so pages can save its settings before the page is closed.\n settingsManager: SettingsManager;\n // if true show tab label as header above page contents.\n showHeader?: boolean;\n}\n\n/**\n * SettingsContainer component that displays Setting Tabs on Left and the P\n * Note: that SettingsContainer is not rendered if tabs array is empty\n * @public\n */\nexport const SettingsContainer = ({\n tabs,\n onSettingsTabSelected,\n currentSettingsTab,\n settingsManager,\n showHeader,\n}: SettingsContainerProps) => {\n // sort the tabs based on itemPriority\n tabs = tabs.sort((a, b) => a.itemPriority - b.itemPriority);\n\n const [openTab, setOpenTab] = React.useState(() => {\n if (\n currentSettingsTab &&\n !ConditionalBooleanValue.getValue(currentSettingsTab.isDisabled)\n )\n return currentSettingsTab;\n else return tabs[0];\n });\n\n const processTabSelection = React.useCallback(\n (tab: SettingsTabEntry) => {\n if (ConditionalBooleanValue.getValue(tab.isDisabled)) return;\n onSettingsTabSelected && onSettingsTabSelected(tab);\n setOpenTab(tab);\n },\n [onSettingsTabSelected]\n );\n\n const processTabSelectionById = React.useCallback(\n (tabId: string) => {\n const tabToActivate = tabs.find((tab) => tab.tabId === tabId);\n tabToActivate && processTabSelection(tabToActivate);\n },\n [processTabSelection, tabs]\n );\n\n const onActivateTab = React.useCallback(\n (tabIndex: number) => {\n const selectedTab = tabs[tabIndex];\n if (openTab && openTab.pageWillHandleCloseRequest)\n settingsManager.onProcessSettingsTabActivation.emit({\n requestedSettingsTabId: selectedTab.tabId,\n tabSelectionFunc: processTabSelectionById,\n });\n else processTabSelection(selectedTab);\n },\n [\n openTab,\n processTabSelection,\n processTabSelectionById,\n settingsManager,\n tabs,\n ]\n );\n\n React.useEffect(() => {\n const handleActivateSettingsTab = (\n { settingsTabId }: ActivateSettingsTabEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n const idToFind = settingsTabId.toLowerCase();\n let tabToActivate = tabs.find(\n (tab) => tab.tabId.toLowerCase() === idToFind\n );\n if (!tabToActivate)\n tabToActivate = tabs.find(\n (tab) => tab.label.toLowerCase() === idToFind\n );\n // istanbul ignore else\n if (tabToActivate) {\n if (openTab && openTab.pageWillHandleCloseRequest)\n settingsManager.onProcessSettingsTabActivation.emit({\n requestedSettingsTabId: tabToActivate.tabId,\n tabSelectionFunc: processTabSelectionById,\n });\n else processTabSelection(tabToActivate);\n }\n };\n\n return settingsManager.onActivateSettingsTab.addListener(\n handleActivateSettingsTab\n );\n }, [\n openTab,\n processTabSelection,\n processTabSelectionById,\n settingsManager,\n settingsManager.onActivateSettingsTab,\n tabs,\n ]);\n\n React.useEffect(() => {\n const handleSettingsContainerClose = (\n { closeFunc, closeFuncArgs }: ProcessSettingsContainerCloseEventArgs // eslint-disable-line deprecation/deprecation\n ) => {\n if (openTab && openTab.pageWillHandleCloseRequest)\n settingsManager.onProcessSettingsContainerClose.emit({\n closeFunc,\n closeFuncArgs,\n });\n else closeFunc(closeFuncArgs);\n };\n return settingsManager.onCloseSettingsContainer.addListener(\n handleSettingsContainerClose\n );\n }, [\n openTab,\n processTabSelection,\n settingsManager,\n settingsManager.onActivateSettingsTab,\n tabs,\n ]);\n\n const labels = tabs.map((tab) => {\n return {\n label: tab.label,\n subLabel: tab.subLabel,\n icon: tab.icon,\n tooltip: tab.tooltip,\n tabId: tab.tabId,\n disabled: ConditionalBooleanValue.getValue(tab.isDisabled),\n };\n });\n const activeIndex = tabs.findIndex((tab) => tab.tabId === openTab.tabId);\n return (\n <div className=\"core-settings-container\">\n <div className=\"core-settings-container-left\">\n {/* eslint-disable-next-line deprecation/deprecation */}\n <VerticalTabs\n labels={labels}\n activeIndex={activeIndex}\n onActivateTab={onActivateTab}\n />\n </div>\n <div className=\"core-settings-container-right\">\n {showHeader && (\n <div className=\"core-settings-container-right-header\">\n <span className=\"core-settings-container-main-header\">\n {openTab.label}\n </span>\n {openTab.subLabel && (\n <span className=\"core-settings-container-main-sub-header\">\n {openTab.subLabel}\n </span>\n )}\n </div>\n )}\n <div className=\"core-settings-container-right-contents\">\n {openTab.page}\n </div>\n </div>\n </div>\n );\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsManager.js","sourceRoot":"","sources":["../../../../src/core-react/settings/SettingsManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC;;;GAGG;AACH,mDAAmD;AACnD,MAAM,OAAO,6BAA8B,SAAQ,SAA4C;CAAG;AAUlG;;;;GAIG;AACH,mDAAmD;AACnD,MAAM,OAAO,iCAAkC,SAAQ,SAAgD;CAAG;AAW1G;;;;GAIG;AACH,mDAAmD;AACnD,MAAM,OAAO,kCAAmC,SAAQ,SAAiD;CAAG;AAW5G;;;GAGG;AACH,mDAAmD;AACnD,MAAM,OAAO,wBAAyB,SAAQ,SAAuC;CAAG;AAuBxF;;GAEG;AACH,MAAM,OAAO,eAAe;IAA5B;QACU,eAAU,GAAwC,EAAE,CAAC;QAE7D;WACG;QACa,+BAA0B,GACxC,IAAI,6BAA6B,EAAE,CAAC,CAAC,8CAA8C;QAErF;;WAEG;QACa,mCAA8B,GAC5C,IAAI,iCAAiC,EAAE,CAAC,CAAC,8CAA8C;QAEzF;;WAEG;QACa,oCAA+B,GAC7C,IAAI,kCAAkC,EAAE,CAAC,CAAC,8CAA8C;QAE1F;;WAEG;QACa,0BAAqB,GACnC,IAAI,SAAS,EAAgC,CAA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,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,UAAU,CAAC,CAAC;QAC5E,IAAI,gBAAgB,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;YACtD,IAAI,CAAC,SAAS,GAAG,gBAAgB,CAAC;YAClC,MAAM,GAAG,IAAI,CAAC;SACf;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,mFAAmF;IAC5E,iBAAiB,CACtB,OAAe,EACf,UAAkB;QAElB,MAAM,iBAAiB,GAAuB,EAAE,CAAC;QACjD,2CAA2C;QAC3C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,MAAM,OAAO,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACzD,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF","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 Settings\n */\n\nimport { BeUiEvent, Logger } from \"@itwin/core-bentley\";\nimport type { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport { UiCore } from \"../UiCore\";\n\n/** Interface used to populate a tab entry in the SettingContainer control\n * @public\n */\nexport interface SettingsTabEntry {\n /** unique id for entry */\n readonly tabId: string;\n /** localized display label */\n readonly label: string;\n /** Setting page content to display when tab item is selected. */\n readonly page: React.ReactElement;\n /** Setting to true if page will register to watch for stage closing event so it can save any dirty settings. Page component should register and handle the events:\n * `settingsManager.onProcessSettingsTabActivation` and `settingsManager.onProcessSettingsContainerClose` */\n readonly pageWillHandleCloseRequest?: boolean;\n /** used to determine position in tablist */\n readonly itemPriority: number;\n /** Optional Subtitle to show below label. */\n readonly subLabel?: string;\n /** Icon specification */\n readonly icon?: string | React.ReactElement;\n /** Tooltip. Allows JSX|Element to support react-tooltip component */\n readonly tooltip?: string | React.ReactElement;\n /** Allows Settings entry to be disabled */\n readonly isDisabled?: boolean | ConditionalBooleanValue;\n}\n\n/** Event class for [[this.onSettingsProvidersChanged]] which is emitted when a new SettingsTabsProvider is added or removed.\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class SettingsProvidersChangedEvent extends BeUiEvent<SettingsProvidersChangedEventArgs> {}\n\n/** Arguments of [[this.onSettingsProvidersChanged]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface SettingsProvidersChangedEventArgs {\n readonly providers: ReadonlyArray<SettingsTabsProvider>;\n}\n\n/** Event class for [[this.onProcessSettingsTabActivation]] which is emitted when a new Tab needs to be activated. This allows the current\n * settings page to save its settings before activating the new SettingTab.\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ProcessSettingsTabActivationEvent extends BeUiEvent<ProcessSettingsTabActivationEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsTabActivation]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ProcessSettingsTabActivationEventArgs {\n readonly tabSelectionFunc: (tabId: string) => void;\n readonly requestedSettingsTabId: string;\n}\n\n/** Event class for [[this.onProcessSettingsContainerClose]] which is emitted when the settings container will be closed. This allows the current\n * settings page to save its settings before calling the function to close the container.\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ProcessSettingsContainerCloseEvent extends BeUiEvent<ProcessSettingsContainerCloseEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsContainerClose]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ProcessSettingsContainerCloseEventArgs {\n readonly closeFunc: (args: any) => void;\n readonly closeFuncArgs?: any;\n}\n\n/** Event class for [[this.onActivateSettingsTab]] which is emitted when API call needs to set the active settings tab (ie via Tool key-in).\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ActivateSettingsTabEvent extends BeUiEvent<ActivateSettingsTabEventArgs> {}\n\n/** Arguments of [[this.onActivateSettingsTab]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ActivateSettingsTabEventArgs {\n readonly settingsTabId: string;\n}\n\n/** Setting Provider interface. Implemented by classes that want to supply settings pages for display in the SettingContainer. The\n * classes that implement this interface need to be registered with the [[SettingsManager]].\n * @public\n */\nexport interface SettingsTabsProvider {\n /** Id of provider, used to remove registration. */\n readonly id: string;\n getSettingEntries(\n stageId: string,\n stageUsage: string\n ): ReadonlyArray<SettingsTabEntry> | undefined;\n}\n\n/** Settings Manager class. Hold registration of settings providers and supplies events for the provided settings pages to listen.\n * @public\n */\nexport class SettingsManager {\n private _providers: ReadonlyArray<SettingsTabsProvider> = [];\n\n /** Event raised when SettingsProviders are changed.\n */\n public readonly onSettingsProvidersChanged =\n new SettingsProvidersChangedEvent(); // eslint-disable-line deprecation/deprecation\n\n /** Event raised solely for a settings page to monitor so it can save its settings before continuing tab activation.\n * See React hook function `useSaveBeforeActivatingNewSettingsTab`.\n */\n public readonly onProcessSettingsTabActivation =\n new ProcessSettingsTabActivationEvent(); // eslint-disable-line deprecation/deprecation\n\n /** Event raised when the settings container will be closed. Any setting page component that is 'modal' should register to\n * listen to this event so that it can save its state before closing. See React hook function `useSaveBeforeClosingSettingsContainer`.\n */\n public readonly onProcessSettingsContainerClose =\n new ProcessSettingsContainerCloseEvent(); // eslint-disable-line deprecation/deprecation\n\n /** Event raised to change the active settings tab shown in UI. Monitored by the SettingsContainer.\n * @internal\n */\n public readonly onActivateSettingsTab =\n new BeUiEvent<ActivateSettingsTabEventArgs>(); // eslint-disable-line deprecation/deprecation\n\n /** Event monitored by SettingsContainer to process request to close the settings container.\n * @internal\n */\n public readonly onCloseSettingsContainer =\n new BeUiEvent<ProcessSettingsContainerCloseEventArgs>(); // eslint-disable-line deprecation/deprecation\n\n /** @public */\n public get providers(): ReadonlyArray<SettingsTabsProvider> {\n return this._providers;\n }\n public set providers(p: ReadonlyArray<SettingsTabsProvider>) {\n this._providers = p;\n this.onSettingsProvidersChanged.emit({ providers: p });\n }\n\n /** Called by application when an tool, keyin, or other process want to change the active settings tab/page giving the current tab/page and opportunity\n * to save its state.\n */\n public activateSettingsTab(settingsTabId: string) {\n this.onActivateSettingsTab.emit({ settingsTabId });\n }\n\n /** Called by application when the Settings Container is to be closed. The function to invoke to actually close the Settings Container is\n * passed in and executed once the active settings tab/page has a chance to save its settings.\n */\n public closeSettingsContainer(\n closeFunc: (args: any) => void,\n closeFuncArgs?: any\n ) {\n this.onCloseSettingsContainer.emit({ closeFunc, closeFuncArgs });\n }\n\n public addSettingsProvider(settingsProvider: SettingsTabsProvider): void {\n const foundProvider = this._providers.find(\n (p) => p.id === settingsProvider.id\n );\n if (!foundProvider) {\n const updatedProviders = [...this.providers, settingsProvider];\n this.providers = updatedProviders;\n } else {\n Logger.logInfo(\n UiCore.loggerCategory(this),\n `Settings Provider with id of ${settingsProvider.id} has already been registered`\n );\n }\n }\n\n public removeSettingsProvider(providerId: string): boolean {\n let result = false;\n const updatedProviders = this._providers.filter((p) => p.id !== providerId);\n if (updatedProviders.length !== this._providers.length) {\n this.providers = updatedProviders;\n result = true;\n }\n\n return result;\n }\n\n /** Get an array of SettingsTabEntry objects to populate the settings container. */\n public getSettingEntries(\n stageId: string,\n stageUsage: string\n ): Array<SettingsTabEntry> {\n const allSettingEntries: SettingsTabEntry[] = [];\n // Consult the registered SettingsProviders\n this._providers.forEach((p) => {\n const entries = p.getSettingEntries(stageId, stageUsage);\n entries && allSettingEntries.push(...entries);\n });\n\n return allSettingEntries;\n }\n}\n"]}
1
+ {"version":3,"file":"SettingsManager.js","sourceRoot":"","sources":["../../../../src/core-react/settings/SettingsManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAExD,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AA2BnC;;;GAGG;AACH,mDAAmD;AACnD,MAAM,OAAO,6BAA8B,SAAQ,SAA4C;CAAG;AAUlG;;;;GAIG;AACH,mDAAmD;AACnD,MAAM,OAAO,iCAAkC,SAAQ,SAAgD;CAAG;AAW1G;;;;GAIG;AACH,mDAAmD;AACnD,MAAM,OAAO,kCAAmC,SAAQ,SAAiD;CAAG;AAW5G;;;GAGG;AACH,mDAAmD;AACnD,MAAM,OAAO,wBAAyB,SAAQ,SAAuC;CAAG;AAuBxF;;GAEG;AACH,MAAM,OAAO,eAAe;IAA5B;QACU,eAAU,GAAwC,EAAE,CAAC;QAE7D;WACG;QACa,+BAA0B,GACxC,IAAI,6BAA6B,EAAE,CAAC,CAAC,8CAA8C;QAErF;;WAEG;QACa,mCAA8B,GAC5C,IAAI,iCAAiC,EAAE,CAAC,CAAC,8CAA8C;QAEzF;;WAEG;QACa,oCAA+B,GAC7C,IAAI,kCAAkC,EAAE,CAAC,CAAC,8CAA8C;QAE1F;;WAEG;QACa,0BAAqB,GACnC,IAAI,SAAS,EAAgC,CAAC,CAAC,8CAA8C;QAE/F;;WAEG;QACa,6BAAwB,GACtC,IAAI,SAAS,EAA0C,CAAC,CAAC,8CAA8C;IAoE3G,CAAC;IAlEC,cAAc;IACd,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IACD,IAAW,SAAS,CAAC,CAAsC;QACzD,IA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,gBAAgB,CAAC;YAClC,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,mFAAmF;IAC5E,iBAAiB,CACtB,OAAe,EACf,UAAkB;QAElB,MAAM,iBAAiB,GAAuB,EAAE,CAAC;QACjD,2CAA2C;QAC3C,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,MAAM,OAAO,GAAG,CAAC,CAAC,iBAAiB,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;YACzD,OAAO,IAAI,iBAAiB,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,OAAO,iBAAiB,CAAC;IAC3B,CAAC;CACF","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 Settings\n */\n\nimport { BeUiEvent, Logger } from \"@itwin/core-bentley\";\nimport type { ConditionalBooleanValue } from \"@itwin/appui-abstract\";\nimport { UiCore } from \"../UiCore\";\n\n/** Interface used to populate a tab entry in the SettingContainer control\n * @public\n */\nexport interface SettingsTabEntry {\n /** unique id for entry */\n readonly tabId: string;\n /** localized display label */\n readonly label: string;\n /** Setting page content to display when tab item is selected. */\n readonly page: React.ReactElement;\n /** Setting to true if page will register to watch for stage closing event so it can save any dirty settings. Page component should register and handle the events:\n * `settingsManager.onProcessSettingsTabActivation` and `settingsManager.onProcessSettingsContainerClose` */\n readonly pageWillHandleCloseRequest?: boolean;\n /** used to determine position in tablist */\n readonly itemPriority: number;\n /** Optional Subtitle to show below label. */\n readonly subLabel?: string;\n /** Icon specification */\n readonly icon?: string | React.ReactElement;\n /** Tooltip. Allows JSX|Element to support react-tooltip component */\n readonly tooltip?: string | React.ReactElement;\n /** Allows Settings entry to be disabled */\n readonly isDisabled?: boolean | ConditionalBooleanValue;\n}\n\n/** Event class for [[this.onSettingsProvidersChanged]] which is emitted when a new SettingsTabsProvider is added or removed.\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class SettingsProvidersChangedEvent extends BeUiEvent<SettingsProvidersChangedEventArgs> {}\n\n/** Arguments of [[this.onSettingsProvidersChanged]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface SettingsProvidersChangedEventArgs {\n readonly providers: ReadonlyArray<SettingsTabsProvider>;\n}\n\n/** Event class for [[this.onProcessSettingsTabActivation]] which is emitted when a new Tab needs to be activated. This allows the current\n * settings page to save its settings before activating the new SettingTab.\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ProcessSettingsTabActivationEvent extends BeUiEvent<ProcessSettingsTabActivationEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsTabActivation]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ProcessSettingsTabActivationEventArgs {\n readonly tabSelectionFunc: (tabId: string) => void;\n readonly requestedSettingsTabId: string;\n}\n\n/** Event class for [[this.onProcessSettingsContainerClose]] which is emitted when the settings container will be closed. This allows the current\n * settings page to save its settings before calling the function to close the container.\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ProcessSettingsContainerCloseEvent extends BeUiEvent<ProcessSettingsContainerCloseEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsContainerClose]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ProcessSettingsContainerCloseEventArgs {\n readonly closeFunc: (args: any) => void;\n readonly closeFuncArgs?: any;\n}\n\n/** Event class for [[this.onActivateSettingsTab]] which is emitted when API call needs to set the active settings tab (ie via Tool key-in).\n * @public\n * @deprecated in 4.13.x. This class should not be used by applications to instantiate objects.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class ActivateSettingsTabEvent extends BeUiEvent<ActivateSettingsTabEventArgs> {}\n\n/** Arguments of [[this.onActivateSettingsTab]] event.\n * @public\n * @deprecated in 4.13.x. Event args are inferred from a listener. If explicit type is needed use a type helper.\n */\nexport interface ActivateSettingsTabEventArgs {\n readonly settingsTabId: string;\n}\n\n/** Setting Provider interface. Implemented by classes that want to supply settings pages for display in the SettingContainer. The\n * classes that implement this interface need to be registered with the [[SettingsManager]].\n * @public\n */\nexport interface SettingsTabsProvider {\n /** Id of provider, used to remove registration. */\n readonly id: string;\n getSettingEntries(\n stageId: string,\n stageUsage: string\n ): ReadonlyArray<SettingsTabEntry> | undefined;\n}\n\n/** Settings Manager class. Hold registration of settings providers and supplies events for the provided settings pages to listen.\n * @public\n */\nexport class SettingsManager {\n private _providers: ReadonlyArray<SettingsTabsProvider> = [];\n\n /** Event raised when SettingsProviders are changed.\n */\n public readonly onSettingsProvidersChanged =\n new SettingsProvidersChangedEvent(); // eslint-disable-line deprecation/deprecation\n\n /** Event raised solely for a settings page to monitor so it can save its settings before continuing tab activation.\n * See React hook function `useSaveBeforeActivatingNewSettingsTab`.\n */\n public readonly onProcessSettingsTabActivation =\n new ProcessSettingsTabActivationEvent(); // eslint-disable-line deprecation/deprecation\n\n /** Event raised when the settings container will be closed. Any setting page component that is 'modal' should register to\n * listen to this event so that it can save its state before closing. See React hook function `useSaveBeforeClosingSettingsContainer`.\n */\n public readonly onProcessSettingsContainerClose =\n new ProcessSettingsContainerCloseEvent(); // eslint-disable-line deprecation/deprecation\n\n /** Event raised to change the active settings tab shown in UI. Monitored by the SettingsContainer.\n * @internal\n */\n public readonly onActivateSettingsTab =\n new BeUiEvent<ActivateSettingsTabEventArgs>(); // eslint-disable-line deprecation/deprecation\n\n /** Event monitored by SettingsContainer to process request to close the settings container.\n * @internal\n */\n public readonly onCloseSettingsContainer =\n new BeUiEvent<ProcessSettingsContainerCloseEventArgs>(); // eslint-disable-line deprecation/deprecation\n\n /** @public */\n public get providers(): ReadonlyArray<SettingsTabsProvider> {\n return this._providers;\n }\n public set providers(p: ReadonlyArray<SettingsTabsProvider>) {\n this._providers = p;\n this.onSettingsProvidersChanged.emit({ providers: p });\n }\n\n /** Called by application when an tool, keyin, or other process want to change the active settings tab/page giving the current tab/page and opportunity\n * to save its state.\n */\n public activateSettingsTab(settingsTabId: string) {\n this.onActivateSettingsTab.emit({ settingsTabId });\n }\n\n /** Called by application when the Settings Container is to be closed. The function to invoke to actually close the Settings Container is\n * passed in and executed once the active settings tab/page has a chance to save its settings.\n */\n public closeSettingsContainer(\n closeFunc: (args: any) => void,\n closeFuncArgs?: any\n ) {\n this.onCloseSettingsContainer.emit({ closeFunc, closeFuncArgs });\n }\n\n public addSettingsProvider(settingsProvider: SettingsTabsProvider): void {\n const foundProvider = this._providers.find(\n (p) => p.id === settingsProvider.id\n );\n if (!foundProvider) {\n const updatedProviders = [...this.providers, settingsProvider];\n this.providers = updatedProviders;\n } else {\n Logger.logInfo(\n UiCore.loggerCategory(this),\n `Settings Provider with id of ${settingsProvider.id} has already been registered`\n );\n }\n }\n\n public removeSettingsProvider(providerId: string): boolean {\n let result = false;\n const updatedProviders = this._providers.filter((p) => p.id !== providerId);\n if (updatedProviders.length !== this._providers.length) {\n this.providers = updatedProviders;\n result = true;\n }\n\n return result;\n }\n\n /** Get an array of SettingsTabEntry objects to populate the settings container. */\n public getSettingEntries(\n stageId: string,\n stageUsage: string\n ): Array<SettingsTabEntry> {\n const allSettingEntries: SettingsTabEntry[] = [];\n // Consult the registered SettingsProviders\n this._providers.forEach((p) => {\n const entries = p.getSettingEntries(stageId, stageUsage);\n entries && allSettingEntries.push(...entries);\n });\n\n return allSettingEntries;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../../src/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AU,CACnB,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,IAAI,aAAa,EACjD,QAAQ,IAAI,wBAAwB,CACrC,EACD,IAAI,EAAC,KAAK,mBACK,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,cACrC,GAAG,KAAK,EAAE;gBAEnB,cAAc;gBAEf,2BACE,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,EAC5B,QAAQ,EAAE,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACnD,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAC1C,SAAS,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,mBAAmB,CAAC,KAAK,EAAE,KAAK,CAAC,EAC5D,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,iBAAiB,CAAC,KAAK,EAAE,KAAK,CAAC,iBAC3C,GAAG,KAAK,EAAE,EACvB,IAAI,EAAC,QAAQ;oBAEZ,GAAG;oBACJ,6BACE,SAAS,EAAE,UAAU,CACnB,0BAA0B,EAC1B,QAAQ,IAAI,wBAAwB,CACrC;wBAEA,eAAe,IAAI,CAClB,8BAAM,SAAS,EAAC,kBAAkB,IAAE,IAAI,CAAQ,CACjD;wBACD,6BAAK,SAAS,EAAC,sCAAsC;4BACnD,kCACG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAC3C;4BACN,QAAQ,IAAI,CACX,8BAAM,SAAS,EAAC,sBAAsB,IAAE,QAAQ,CAAQ,CACzD,CACG,CACF,CACJ,CACD,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,CAAC;IACJ,CAAC;CACF","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 Tabs\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Orientation } from \"../enums/Orientation\";\nimport { ItemKeyboardNavigator } from \"../focus/ItemKeyboardNavigator\";\nimport { IconHelper } from \"../utils/IconHelper\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** TabLabel provides ability to define label, icon, and tooltip for a tab entry. The tooltip can be defined as JSX|Element\n * to support react-tooltip component or a string that will be use to set the title property.\n * @public\n * @deprecated in 4.12.x. Interface used in a deprecated component {@link Tabs}.\n */\nexport interface TabLabel {\n label: string;\n subLabel?: string;\n icon?: string | React.ReactElement;\n tabId: string /* optional id added to tab so it can be used by react-tooltip */;\n /** tooltip allows React.ReactElement to support styled tooltips like react-tooltip. */\n tooltip?: string | React.ReactElement;\n disabled?: boolean;\n}\n\nfunction isTabLabelWithIcon(item: string | TabLabel): item is TabLabel {\n return typeof item !== \"string\" && !!item.icon;\n}\n\nfunction isTabLabel(item: string | TabLabel): item is TabLabel {\n return typeof item !== \"string\";\n}\n\n/** Properties for the [[VerticalTabs]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link Tabs}.\n */\nexport interface TabsProps\n extends React.AllHTMLAttributes<HTMLUListElement>,\n CommonProps {\n /** Text shown for each tab */\n labels: Array<string | TabLabel>;\n /** Handler for activating a tab */\n onActivateTab?: (index: number) => any;\n /** Index of the initial active tab */\n activeIndex?: number;\n /** Indicates whether the bar on the active tab is green instead of the default blue */\n green?: boolean;\n}\n\ninterface TabsState {\n activeIndex: number;\n}\n\n/** Properties for the base [[Tabs]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link Tabs}.\n */\nexport interface MainTabsProps extends TabsProps {\n /** Main CSS class name */\n mainClassName: string;\n /** Orientation of the Tabs list */\n orientation: Orientation;\n}\n\n/** Tabs meant to represent the current position in a page/section\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/tabs iTwinUI Tabs} instead.\n */\nexport class Tabs extends React.PureComponent<MainTabsProps, TabsState> {\n private _anchorRefs: Array<React.RefObject<HTMLAnchorElement>> = [];\n private _itemKeyboardNavigator: ItemKeyboardNavigator;\n\n constructor(props: MainTabsProps) {\n super(props);\n\n const activeIndex = this.validateActiveIndex(props.activeIndex);\n this.state = {\n activeIndex,\n };\n\n props.labels.forEach(() =>\n this._anchorRefs.push(React.createRef<HTMLAnchorElement>())\n );\n this._itemKeyboardNavigator = new ItemKeyboardNavigator(\n this._handleFocusItem,\n this._activateTab\n );\n }\n\n private validateActiveIndex(idx?: number): number {\n let activeIndex = 0;\n if (idx && idx >= 0 && idx < this.props.labels.length) activeIndex = idx;\n return activeIndex;\n }\n\n /** @internal */\n public override componentDidMount() {\n this._itemKeyboardNavigator.itemCount = this.props.labels.length;\n this._itemKeyboardNavigator.orientation = this.props.orientation;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: MainTabsProps) {\n if (prevProps.labels !== this.props.labels)\n this._itemKeyboardNavigator.itemCount = this.props.labels.length;\n\n if (prevProps.orientation !== this.props.orientation)\n this._itemKeyboardNavigator.orientation = this.props.orientation;\n\n if (prevProps.activeIndex !== this.props.activeIndex) {\n let hadFocus = false;\n const element = this._anchorRefs[this.state.activeIndex].current;\n // istanbul ignore else\n if (element && document.activeElement === element) hadFocus = true;\n const activeIndex = this.validateActiveIndex(this.props.activeIndex);\n\n this.setState(\n () => ({ activeIndex }),\n () => {\n // istanbul ignore else\n if (hadFocus) {\n const newElement = this._anchorRefs[activeIndex].current;\n // istanbul ignore else\n if (newElement) newElement.focus();\n }\n }\n );\n }\n }\n\n private _handleFocusItem = (index: number) => {\n const itemRef = this._anchorRefs[index];\n // istanbul ignore else\n if (itemRef && itemRef.current) itemRef.current.focus();\n };\n\n private _handleTabClick = (index: number) => {\n this._activateTab(index);\n };\n\n /** Handle keydown on tabs */\n private _handleKeyDownEvent(event: React.KeyboardEvent, index: number) {\n this._itemKeyboardNavigator.handleKeyDownEvent(event, index);\n }\n\n /** Handle keyup on tabs */\n private _handleKeyUpEvent(event: React.KeyboardEvent, index: number) {\n this._itemKeyboardNavigator.handleKeyUpEvent(event, index);\n }\n\n private _activateTab = (index: number) => {\n this.props.onActivateTab && this.props.onActivateTab(index);\n this.setState({ activeIndex: index });\n };\n\n /** @internal */\n public override render(): React.ReactElement {\n const ulClassNames = classnames(\n this.props.mainClassName,\n this.props.green && \"uicore-tabs-green\",\n this.props.className\n );\n\n const anyIconsPresent =\n this.props.labels.reduce(\n (a, b) => a + (isTabLabelWithIcon(b) ? 1 : 0),\n 0\n ) > 0;\n\n return (\n <ul\n className={ulClassNames}\n style={this.props.style}\n role=\"tablist\"\n aria-orientation={\n this.props.orientation === Orientation.Vertical\n ? \"vertical\"\n : \"horizontal\"\n }\n >\n {this.props.labels.map((label, index) => {\n let disabled;\n let tooltipElement: React.ReactElement | undefined;\n let title: string | undefined;\n let subLabel: string | undefined;\n let tabId = \"\";\n let icon;\n if (isTabLabel(label)) {\n icon = IconHelper.getIconReactNode(label.icon);\n subLabel = label.subLabel;\n disabled = label.disabled;\n tabId = label.tabId;\n if (React.isValidElement(label.tooltip))\n tooltipElement = label.tooltip;\n else if (typeof label.tooltip === \"string\") title = label.tooltip;\n }\n return (\n <li\n key={index}\n title={title}\n className={classnames(\n index === this.state.activeIndex && \"core-active\",\n disabled && \"core-tab-item-disabled\"\n )}\n role=\"tab\"\n aria-selected={index === this.state.activeIndex}\n data-for={`${tabId}`} /* to support react-tooltip */\n >\n {tooltipElement}\n {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}\n <a\n ref={this._anchorRefs[index]}\n tabIndex={index === this.state.activeIndex ? 0 : -1}\n onClick={() => this._handleTabClick(index)}\n onKeyDown={(event) => this._handleKeyDownEvent(event, index)}\n onKeyUp={(event) => this._handleKeyUpEvent(event, index)}\n data-testid={`${tabId}`}\n role=\"button\"\n >\n {\" \"}\n <div\n className={classnames(\n \"uicore-tabs-inline-label\",\n disabled && \"core-tab-item-disabled\"\n )}\n >\n {anyIconsPresent && (\n <span className=\"uicore-tabs-icon\">{icon}</span>\n )}\n <div className=\"uicore-tabs-label-subLabel-container\">\n <span>\n {typeof label === \"string\" ? label : label.label}\n </span>\n {subLabel && (\n <span className=\"uicore-tabs-subLabel\">{subLabel}</span>\n )}\n </div>\n </div>\n </a>\n </li>\n );\n })}\n </ul>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"Tabs.js","sourceRoot":"","sources":["../../../../src/core-react/tabs/Tabs.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AACvE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAmBjD,SAAS,kBAAkB,CAAC,IAAuB;IACjD,OAAO,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,SAAS,UAAU,CAAC,IAAuB;IACzC,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC;AAClC,CAAC;AAkCD;;;GAGG;AACH,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,aAAuC;IAIrE,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAJP,gBAAW,GAA8C,EAAE,CAAC;QA6D5D,qBAAgB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxC,uBAAuB;YACvB,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO;gBAAE,OAAO,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e,IAAI,CAClB,8BAAM,SAAS,EAAC,kBAAkB,IAAE,IAAI,CAAQ,CACjD;wBACD,6BAAK,SAAS,EAAC,sCAAsC;4BACnD,kCACG,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAC3C;4BACN,QAAQ,IAAI,CACX,8BAAM,SAAS,EAAC,sBAAsB,IAAE,QAAQ,CAAQ,CACzD,CACG,CACF,CACJ,CACD,CACN,CAAC;QACJ,CAAC,CAAC,CACC,CACN,CAAC;IACJ,CAAC;CACF","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 Tabs\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Orientation } from \"../enums/Orientation\";\nimport { ItemKeyboardNavigator } from \"../focus/ItemKeyboardNavigator\";\nimport { IconHelper } from \"../utils/IconHelper\";\n\n/* eslint-disable deprecation/deprecation */\n\n/** TabLabel provides ability to define label, icon, and tooltip for a tab entry. The tooltip can be defined as JSX|Element\n * to support react-tooltip component or a string that will be use to set the title property.\n * @public\n * @deprecated in 4.12.x. Interface used in a deprecated component {@link Tabs}.\n */\nexport interface TabLabel {\n label: string;\n subLabel?: string;\n icon?: string | React.ReactElement;\n tabId: string /* optional id added to tab so it can be used by react-tooltip */;\n /** tooltip allows React.ReactElement to support styled tooltips like react-tooltip. */\n tooltip?: string | React.ReactElement;\n disabled?: boolean;\n}\n\nfunction isTabLabelWithIcon(item: string | TabLabel): item is TabLabel {\n return typeof item !== \"string\" && !!item.icon;\n}\n\nfunction isTabLabel(item: string | TabLabel): item is TabLabel {\n return typeof item !== \"string\";\n}\n\n/** Properties for the [[VerticalTabs]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link Tabs}.\n */\nexport interface TabsProps\n extends React.AllHTMLAttributes<HTMLUListElement>,\n CommonProps {\n /** Text shown for each tab */\n labels: Array<string | TabLabel>;\n /** Handler for activating a tab */\n onActivateTab?: (index: number) => any;\n /** Index of the initial active tab */\n activeIndex?: number;\n /** Indicates whether the bar on the active tab is green instead of the default blue */\n green?: boolean;\n}\n\ninterface TabsState {\n activeIndex: number;\n}\n\n/** Properties for the base [[Tabs]] component\n * @public\n * @deprecated in 4.12.x. Props of deprecated component {@link Tabs}.\n */\nexport interface MainTabsProps extends TabsProps {\n /** Main CSS class name */\n mainClassName: string;\n /** Orientation of the Tabs list */\n orientation: Orientation;\n}\n\n/** Tabs meant to represent the current position in a page/section\n * @public\n * @deprecated in 4.12.x. Use {@link https://itwinui.bentley.com/docs/tabs iTwinUI Tabs} instead.\n */\nexport class Tabs extends React.PureComponent<MainTabsProps, TabsState> {\n private _anchorRefs: Array<React.RefObject<HTMLAnchorElement>> = [];\n private _itemKeyboardNavigator: ItemKeyboardNavigator;\n\n constructor(props: MainTabsProps) {\n super(props);\n\n const activeIndex = this.validateActiveIndex(props.activeIndex);\n this.state = {\n activeIndex,\n };\n\n props.labels.forEach(() =>\n this._anchorRefs.push(React.createRef<HTMLAnchorElement>())\n );\n this._itemKeyboardNavigator = new ItemKeyboardNavigator(\n this._handleFocusItem,\n this._activateTab\n );\n }\n\n private validateActiveIndex(idx?: number): number {\n let activeIndex = 0;\n if (idx && idx >= 0 && idx < this.props.labels.length) activeIndex = idx;\n return activeIndex;\n }\n\n /** @internal */\n public override componentDidMount() {\n this._itemKeyboardNavigator.itemCount = this.props.labels.length;\n this._itemKeyboardNavigator.orientation = this.props.orientation;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: MainTabsProps) {\n if (prevProps.labels !== this.props.labels)\n this._itemKeyboardNavigator.itemCount = this.props.labels.length;\n\n if (prevProps.orientation !== this.props.orientation)\n this._itemKeyboardNavigator.orientation = this.props.orientation;\n\n if (prevProps.activeIndex !== this.props.activeIndex) {\n let hadFocus = false;\n const element = this._anchorRefs[this.state.activeIndex].current;\n // istanbul ignore else\n if (element && document.activeElement === element) hadFocus = true;\n const activeIndex = this.validateActiveIndex(this.props.activeIndex);\n\n this.setState(\n () => ({ activeIndex }),\n () => {\n // istanbul ignore else\n if (hadFocus) {\n const newElement = this._anchorRefs[activeIndex].current;\n // istanbul ignore else\n if (newElement) newElement.focus();\n }\n }\n );\n }\n }\n\n private _handleFocusItem = (index: number) => {\n const itemRef = this._anchorRefs[index];\n // istanbul ignore else\n if (itemRef && itemRef.current) itemRef.current.focus();\n };\n\n private _handleTabClick = (index: number) => {\n this._activateTab(index);\n };\n\n /** Handle keydown on tabs */\n private _handleKeyDownEvent(event: React.KeyboardEvent, index: number) {\n this._itemKeyboardNavigator.handleKeyDownEvent(event, index);\n }\n\n /** Handle keyup on tabs */\n private _handleKeyUpEvent(event: React.KeyboardEvent, index: number) {\n this._itemKeyboardNavigator.handleKeyUpEvent(event, index);\n }\n\n private _activateTab = (index: number) => {\n this.props.onActivateTab && this.props.onActivateTab(index);\n this.setState({ activeIndex: index });\n };\n\n /** @internal */\n public override render(): React.ReactElement {\n const ulClassNames = classnames(\n this.props.mainClassName,\n this.props.green && \"uicore-tabs-green\",\n this.props.className\n );\n\n const anyIconsPresent =\n this.props.labels.reduce(\n (a, b) => a + (isTabLabelWithIcon(b) ? 1 : 0),\n 0\n ) > 0;\n\n return (\n <ul\n className={ulClassNames}\n style={this.props.style}\n role=\"tablist\"\n aria-orientation={\n this.props.orientation === Orientation.Vertical\n ? \"vertical\"\n : \"horizontal\"\n }\n >\n {this.props.labels.map((label, index) => {\n let disabled;\n let tooltipElement: React.ReactElement | undefined;\n let title: string | undefined;\n let subLabel: string | undefined;\n let tabId = \"\";\n let icon;\n if (isTabLabel(label)) {\n icon = IconHelper.getIconReactNode(label.icon);\n subLabel = label.subLabel;\n disabled = label.disabled;\n tabId = label.tabId;\n if (React.isValidElement(label.tooltip))\n tooltipElement = label.tooltip;\n else if (typeof label.tooltip === \"string\") title = label.tooltip;\n }\n return (\n <li\n key={index}\n title={title}\n className={classnames(\n index === this.state.activeIndex && \"core-active\",\n disabled && \"core-tab-item-disabled\"\n )}\n role=\"tab\"\n aria-selected={index === this.state.activeIndex}\n data-for={`${tabId}`} /* to support react-tooltip */\n >\n {tooltipElement}\n {/* eslint-disable-next-line jsx-a11y/anchor-is-valid */}\n <a\n ref={this._anchorRefs[index]}\n tabIndex={index === this.state.activeIndex ? 0 : -1}\n onClick={() => this._handleTabClick(index)}\n onKeyDown={(event) => this._handleKeyDownEvent(event, index)}\n onKeyUp={(event) => this._handleKeyUpEvent(event, index)}\n data-testid={`${tabId}`}\n role=\"button\"\n >\n {\" \"}\n <div\n className={classnames(\n \"uicore-tabs-inline-label\",\n disabled && \"core-tab-item-disabled\"\n )}\n >\n {anyIconsPresent && (\n <span className=\"uicore-tabs-icon\">{icon}</span>\n )}\n <div className=\"uicore-tabs-label-subLabel-container\">\n <span>\n {typeof label === \"string\" ? label : label.label}\n </span>\n {subLabel && (\n <span className=\"uicore-tabs-subLabel\">{subLabel}</span>\n )}\n </div>\n </div>\n </a>\n </li>\n );\n })}\n </ul>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FilteredText.js","sourceRoot":"","sources":["../../../../src/core-react/text/FilteredText.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,2BAA2B;AAE3B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,UAAU,MAAM,YAAY,CAAC;AAGpC,OAAO,qBAAqB,CAAC;AAgB7B;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,KAAwB;IACnD,MAAM,EACJ,KAAK,EACL,SAAS,EACT,OAAO,EACP,cAAc,EACd,UAAU,EACV,GAAG,UAAU,EACd,GAAG,KAAK,CAAC;IACV,uBAAuB;IACvB,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;QACjC,MAAM,KAAK,GAAsB,EAAE,CAAC;QAEpC,IAAI,QAAQ,GAAG,CAAC,CAAC;QACjB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE;YAC1B,uBAAuB;YACvB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ;gBACzB,KAAK,CAAC,IAAI,CACR,8BAAM,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,8BAA8B,IAC1D,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CACjC,CACR,CAAC;YACJ,KAAK,CAAC,IAAI,CACR,8BACE,GAAG,EAAE,IAAI,CAAC,KAAK,EACf,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,UAAU,CAAC,4BAA4B,EAAE,cAAc,CAAC,IAElE,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CACjC,CACR,CAAC;YACF,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC;SACrB;QACD,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;QAC5B,uBAAuB;QACvB,IAAI,QAAQ,GAAG,MAAM,EAAE;YACrB,KAAK,CAAC,IAAI,CACR,8BAAM,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAC,8BAA8B,IAC1D,KAAK,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAC7B,CACR,CAAC;SACH;QACD,OAAO,CACL,gCACM,UAAU,EACd,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EACxD,KAAK,EAAE,KAAK,IAEX,KAAK,CACF,CACP,CAAC;KACH;IAED,OAAO,CACL,iCACM,UAAU,EACd,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EACxD,KAAK,EAAE,KAAK,IAEX,KAAK,CACD,CACR,CAAC;AACJ,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 Text\n */\n\n// cSpell:ignore focusvalue\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { IMatch } from \"../utils/matches\";\nimport \"./FilteredText.scss\";\n\n/** Props supported by [FilteredText] component\n * @alpha\n */\nexport interface FilteredTextProps extends CommonProps {\n /** string that matched a filter string */\n value: string;\n /** define array of start and end positions of filter matches. */\n matches?: IMatch[];\n /** holds class name for matching span text. */\n matchClassName?: string;\n /** holds style for matching span text. */\n matchStyle?: React.CSSProperties;\n}\n\n/** Component used to highlight filter matches within a text string.\n * @alpha\n */\nexport function FilteredText(props: FilteredTextProps) {\n const {\n value,\n className,\n matches,\n matchClassName,\n matchStyle,\n ...otherProps\n } = props;\n // istanbul ignore else\n if (matches && matches.length > 0) {\n const spans: React.ReactNode[] = [];\n\n let startPos = 0;\n for (const span of matches) {\n // istanbul ignore else\n if (span.start !== startPos)\n spans.push(\n <span key={startPos} className=\"uicore-partial-filtered-text\">\n {value.substring(startPos, span.start)}\n </span>\n );\n spans.push(\n <span\n key={span.start}\n style={matchStyle}\n className={classnames(\"uicore-filtered-text-match\", matchClassName)}\n >\n {value.substring(span.start, span.end)}\n </span>\n );\n startPos = span.end;\n }\n const endPos = value.length;\n // istanbul ignore else\n if (startPos < endPos) {\n spans.push(\n <span key={startPos} className=\"uicore-partial-filtered-text\">\n {value.substring(startPos, endPos)}\n </span>\n );\n }\n return (\n <div\n {...otherProps}\n className={classnames(\"uicore-filtered-text\", className)}\n title={value}\n >\n {spans}\n </div>\n );\n }\n\n return (\n <span\n {...otherProps}\n className={classnames(\"uicore-filtered-text\", className)}\n title={value}\n >\n {value}\n </span>\n );\n}\n"]}
1
+ {"version":3,"file":"FilteredText.js","sourceRoot":"","sources":["../../../../src/core-react/text/FilteredText.tsx"],"names":[],"mappings":"AAAA;;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AC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAC7B,CACR,CAAC;QACJ,CAAC;QACD,OAAO,CACL,gCACM,UAAU,EACd,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EACxD,KAAK,EAAE,KAAK,IAEX,KAAK,CACF,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,iCACM,UAAU,EACd,SAAS,EAAE,UAAU,CAAC,sBAAsB,EAAE,SAAS,CAAC,EACxD,KAAK,EAAE,KAAK,IAEX,KAAK,CACD,CACR,CAAC;AACJ,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 Text\n */\n\n// cSpell:ignore focusvalue\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { IMatch } from \"../utils/matches\";\nimport \"./FilteredText.scss\";\n\n/** Props supported by [FilteredText] component\n * @alpha\n */\nexport interface FilteredTextProps extends CommonProps {\n /** string that matched a filter string */\n value: string;\n /** define array of start and end positions of filter matches. */\n matches?: IMatch[];\n /** holds class name for matching span text. */\n matchClassName?: string;\n /** holds style for matching span text. */\n matchStyle?: React.CSSProperties;\n}\n\n/** Component used to highlight filter matches within a text string.\n * @alpha\n */\nexport function FilteredText(props: FilteredTextProps) {\n const {\n value,\n className,\n matches,\n matchClassName,\n matchStyle,\n ...otherProps\n } = props;\n // istanbul ignore else\n if (matches && matches.length > 0) {\n const spans: React.ReactNode[] = [];\n\n let startPos = 0;\n for (const span of matches) {\n // istanbul ignore else\n if (span.start !== startPos)\n spans.push(\n <span key={startPos} className=\"uicore-partial-filtered-text\">\n {value.substring(startPos, span.start)}\n </span>\n );\n spans.push(\n <span\n key={span.start}\n style={matchStyle}\n className={classnames(\"uicore-filtered-text-match\", matchClassName)}\n >\n {value.substring(span.start, span.end)}\n </span>\n );\n startPos = span.end;\n }\n const endPos = value.length;\n // istanbul ignore else\n if (startPos < endPos) {\n spans.push(\n <span key={startPos} className=\"uicore-partial-filtered-text\">\n {value.substring(startPos, endPos)}\n </span>\n );\n }\n return (\n <div\n {...otherProps}\n className={classnames(\"uicore-filtered-text\", className)}\n title={value}\n >\n {spans}\n </div>\n );\n }\n\n return (\n <span\n {...otherProps}\n className={classnames(\"uicore-filtered-text\", className)}\n title={value}\n >\n {value}\n </span>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Node.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAsBpD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAgDlC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAC1D,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;QAqGP,sBAAiB,GAAG,CAAC,OAAgB,EAAE,EAAE;YAC/C,IACE,IAAI,CAAC,KAAK,CAAC,aAAa;gBACxB,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO;gBAChC,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,UAAU;gBAEpC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,CAC9B,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,EAA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IAAI,CAAC,KAAK,CAAC,UAAU,GACjC,CACH,CAAC;QAEF,OAAO;QACL,iEAAiE;QACjE,6BACE,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACV,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,EACtC,OAAO,EAAE,IAAI,CAAC,QAAQ,EACtB,aAAa,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,EACvC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,IAAI,EAAC,UAAU,mBACA,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,EAAE,CAAC,CAAC;YAEZ,6BACE,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,iBAChB,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC;gBAErD,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CACvB,oBAAC,cAAc,IACb,IAAI,EAAC,SAAS,EACd,aAAa,QACb,SAAS,EAAC,yBAAyB,GACnC,CACH;gBACA,MAAM;gBACN,QAAQ;gBACR,IAAI;gBACJ,IAAI,CAAC,KAAK,CAAC,KAAK,CACb;YACL,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,KAAa;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YAAE,OAAO,SAAS,CAAC;QACjD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;IACjD,CAAC;CA0BF","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 Tree\n */\n\nimport \"./Node.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Checkbox, ProgressRadial } from \"@itwin/itwinui-react\";\nimport { CheckBoxState } from \"../enums/CheckBoxState\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { ExpansionToggle } from \"./ExpansionToggle\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\n/** Props for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderProps = Omit<\n CheckboxProps,\n \"onChange\" | \"onClick\"\n> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/** Type for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderer = (\n props: NodeCheckboxRenderProps\n) => React.ReactNode;\n\n/** Number of pixels the node gets offset per each hierarchy level\n * @internal\n */\nexport const LEVEL_OFFSET = 20;\n\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/** Properties for Tree Node CheckBox\n * @public\n */\nexport interface NodeCheckboxProps {\n /** State of the checkbox */\n state?: CheckBoxState;\n /** Click event callback */\n onClick?: (newState: CheckBoxState) => void;\n /** Indicates whether checkbox is disabled */\n isDisabled?: boolean;\n /** Tooltip to be displayed when mouse is hovered over checkbox */\n tooltip?: string;\n}\n\n/** Properties for the [[TreeNode]] React component\n * @public\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactChild;\n /** Properties for the checkbox.\n * @public */\n checkboxProps?: NodeCheckboxProps;\n isLeaf?: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isFocused?: boolean;\n isSelected?: boolean;\n isHoverDisabled?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onContextMenu?: (e: React.MouseEvent) => void;\n onMouseMove?: (e: React.MouseEvent) => void;\n onMouseDown?: (e: React.MouseEvent) => void;\n onMouseUp?: (e: React.MouseEvent) => void;\n onClickExpansionToggle?: () => void;\n children?: React.ReactNode;\n\n /** Contains render overrides for different pieces of the node component. */\n renderOverrides?: {\n /** Callback to render a checkbox. Only called when checkbox is displayed. */\n renderCheckbox?: NodeCheckboxRenderer;\n };\n [\"data-testid\"]?: string;\n}\n\n/** Presentation React component for a Tree node\n * @public\n */\nexport class TreeNode extends React.Component<TreeNodeProps> {\n constructor(props: TreeNodeProps) {\n super(props);\n }\n\n public override render() {\n const className = classnames(\n \"core-tree-node\",\n this.props.isFocused && \"is-focused\",\n this.props.isSelected && \"is-selected\",\n this.props.isHoverDisabled && \"is-hover-disabled\",\n this.props.className\n );\n let offset = this.props.level * LEVEL_OFFSET;\n if (!this.props.isLoading && this.props.isLeaf)\n offset += EXPANSION_TOGGLE_WIDTH; // Add expansion toggle/loader width if they're not rendered\n\n let checkbox: React.ReactNode;\n if (this.props.checkboxProps) {\n const props: NodeCheckboxRenderProps = {\n label: \"\",\n checked: this.props.checkboxProps.state === CheckBoxState.On,\n indeterminate: this.props.checkboxProps.state === CheckBoxState.Partial,\n disabled: this.props.checkboxProps.isDisabled,\n title: this.props.checkboxProps.tooltip,\n onClick: this._onCheckboxClick,\n onChange: this._onCheckboxChange,\n };\n if (\n this.props.renderOverrides &&\n this.props.renderOverrides.renderCheckbox\n ) {\n checkbox = this.props.renderOverrides.renderCheckbox(props);\n } else {\n checkbox = (\n <Checkbox\n {...props}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n this._onCheckboxChange(e.target.checked)\n }\n data-testid={this.createSubComponentTestId(\"checkbox\")}\n />\n );\n }\n }\n\n const icon = this.props.icon ? (\n <div className=\"core-tree-node-icon\">{this.props.icon}</div>\n ) : undefined;\n\n const toggle = this.props.isLoading ? undefined : this.props.isLeaf ? (\n <div />\n ) : (\n <ExpansionToggle\n className=\"expansion-toggle\"\n data-testid={this.createSubComponentTestId(\"expansion-toggle\")}\n onClick={this._onClickExpansionToggle}\n isExpanded={this.props.isExpanded}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n className={className}\n style={this.props.style}\n data-testid={this.props[\"data-testid\"]}\n onClick={this._onClick}\n onContextMenu={this.props.onContextMenu}\n onMouseDown={this.props.onMouseDown}\n onMouseUp={this.props.onMouseUp}\n onMouseMove={this.props.onMouseMove}\n role=\"treeitem\"\n aria-selected={this.props.isSelected ? \"true\" : \"false\"}\n tabIndex={-1}\n >\n <div\n className=\"contents\"\n style={{ marginLeft: offset }}\n data-testid={this.createSubComponentTestId(\"contents\")}\n >\n {this.props.isLoading && (\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n className=\"core-progress-indicator\"\n />\n )}\n {toggle}\n {checkbox}\n {icon}\n {this.props.label}\n </div>\n {this.props.children}\n </div>\n );\n }\n\n private createSubComponentTestId(subId: string): string | undefined {\n if (!this.props[\"data-testid\"]) return undefined;\n return `${this.props[\"data-testid\"]}-${subId}`;\n }\n\n private _onCheckboxChange = (checked: boolean) => {\n if (\n this.props.checkboxProps &&\n this.props.checkboxProps.onClick &&\n !this.props.checkboxProps.isDisabled\n )\n this.props.checkboxProps.onClick(\n checked ? CheckBoxState.On : CheckBoxState.Off\n );\n };\n\n private _onCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _onClickExpansionToggle = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (this.props.onClickExpansionToggle) this.props.onClickExpansionToggle();\n };\n\n private _onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n this.props.onClick?.(e);\n };\n}\n"]}
1
+ {"version":3,"file":"Node.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Node.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MA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CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,EACvD,QAAQ,EAAE,CAAC,CAAC;YAEZ,6BACE,SAAS,EAAC,UAAU,EACpB,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,EAAE,iBAChB,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC;gBAErD,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,CACvB,oBAAC,cAAc,IACb,IAAI,EAAC,SAAS,EACd,aAAa,QACb,SAAS,EAAC,yBAAyB,GACnC,CACH;gBACA,MAAM;gBACN,QAAQ;gBACR,IAAI;gBACJ,IAAI,CAAC,KAAK,CAAC,KAAK,CACb;YACL,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;IAEO,wBAAwB,CAAC,KAAa;QAC5C,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC;YAAE,OAAO,SAAS,CAAC;QACjD,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC;IACjD,CAAC;CA0BF","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 Tree\n */\n\nimport \"./Node.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Checkbox, ProgressRadial } from \"@itwin/itwinui-react\";\nimport { CheckBoxState } from \"../enums/CheckBoxState\";\nimport type { CommonProps } from \"../utils/Props\";\nimport type { Omit } from \"../utils/typeUtils\";\nimport { ExpansionToggle } from \"./ExpansionToggle\";\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\n/** Props for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderProps = Omit<\n CheckboxProps,\n \"onChange\" | \"onClick\"\n> & {\n onChange: (checked: boolean) => void;\n onClick: (e: React.MouseEvent) => void;\n};\n\n/** Type for node Checkbox renderer\n * @public\n */\nexport type NodeCheckboxRenderer = (\n props: NodeCheckboxRenderProps\n) => React.ReactNode;\n\n/** Number of pixels the node gets offset per each hierarchy level\n * @internal\n */\nexport const LEVEL_OFFSET = 20;\n\nconst EXPANSION_TOGGLE_WIDTH = 24;\n\n/** Properties for Tree Node CheckBox\n * @public\n */\nexport interface NodeCheckboxProps {\n /** State of the checkbox */\n state?: CheckBoxState;\n /** Click event callback */\n onClick?: (newState: CheckBoxState) => void;\n /** Indicates whether checkbox is disabled */\n isDisabled?: boolean;\n /** Tooltip to be displayed when mouse is hovered over checkbox */\n tooltip?: string;\n}\n\n/** Properties for the [[TreeNode]] React component\n * @public\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactChild;\n /** Properties for the checkbox.\n * @public */\n checkboxProps?: NodeCheckboxProps;\n isLeaf?: boolean;\n isLoading?: boolean;\n isExpanded?: boolean;\n isFocused?: boolean;\n isSelected?: boolean;\n isHoverDisabled?: boolean;\n onClick?: (e: React.MouseEvent) => void;\n onContextMenu?: (e: React.MouseEvent) => void;\n onMouseMove?: (e: React.MouseEvent) => void;\n onMouseDown?: (e: React.MouseEvent) => void;\n onMouseUp?: (e: React.MouseEvent) => void;\n onClickExpansionToggle?: () => void;\n children?: React.ReactNode;\n\n /** Contains render overrides for different pieces of the node component. */\n renderOverrides?: {\n /** Callback to render a checkbox. Only called when checkbox is displayed. */\n renderCheckbox?: NodeCheckboxRenderer;\n };\n [\"data-testid\"]?: string;\n}\n\n/** Presentation React component for a Tree node\n * @public\n */\nexport class TreeNode extends React.Component<TreeNodeProps> {\n constructor(props: TreeNodeProps) {\n super(props);\n }\n\n public override render() {\n const className = classnames(\n \"core-tree-node\",\n this.props.isFocused && \"is-focused\",\n this.props.isSelected && \"is-selected\",\n this.props.isHoverDisabled && \"is-hover-disabled\",\n this.props.className\n );\n let offset = this.props.level * LEVEL_OFFSET;\n if (!this.props.isLoading && this.props.isLeaf)\n offset += EXPANSION_TOGGLE_WIDTH; // Add expansion toggle/loader width if they're not rendered\n\n let checkbox: React.ReactNode;\n if (this.props.checkboxProps) {\n const props: NodeCheckboxRenderProps = {\n label: \"\",\n checked: this.props.checkboxProps.state === CheckBoxState.On,\n indeterminate: this.props.checkboxProps.state === CheckBoxState.Partial,\n disabled: this.props.checkboxProps.isDisabled,\n title: this.props.checkboxProps.tooltip,\n onClick: this._onCheckboxClick,\n onChange: this._onCheckboxChange,\n };\n if (\n this.props.renderOverrides &&\n this.props.renderOverrides.renderCheckbox\n ) {\n checkbox = this.props.renderOverrides.renderCheckbox(props);\n } else {\n checkbox = (\n <Checkbox\n {...props}\n onChange={(e: React.ChangeEvent<HTMLInputElement>) =>\n this._onCheckboxChange(e.target.checked)\n }\n data-testid={this.createSubComponentTestId(\"checkbox\")}\n />\n );\n }\n }\n\n const icon = this.props.icon ? (\n <div className=\"core-tree-node-icon\">{this.props.icon}</div>\n ) : undefined;\n\n const toggle = this.props.isLoading ? undefined : this.props.isLeaf ? (\n <div />\n ) : (\n <ExpansionToggle\n className=\"expansion-toggle\"\n data-testid={this.createSubComponentTestId(\"expansion-toggle\")}\n onClick={this._onClickExpansionToggle}\n isExpanded={this.props.isExpanded}\n />\n );\n\n return (\n // eslint-disable-next-line jsx-a11y/click-events-have-key-events\n <div\n className={className}\n style={this.props.style}\n data-testid={this.props[\"data-testid\"]}\n onClick={this._onClick}\n onContextMenu={this.props.onContextMenu}\n onMouseDown={this.props.onMouseDown}\n onMouseUp={this.props.onMouseUp}\n onMouseMove={this.props.onMouseMove}\n role=\"treeitem\"\n aria-selected={this.props.isSelected ? \"true\" : \"false\"}\n tabIndex={-1}\n >\n <div\n className=\"contents\"\n style={{ marginLeft: offset }}\n data-testid={this.createSubComponentTestId(\"contents\")}\n >\n {this.props.isLoading && (\n <ProgressRadial\n size=\"x-small\"\n indeterminate\n className=\"core-progress-indicator\"\n />\n )}\n {toggle}\n {checkbox}\n {icon}\n {this.props.label}\n </div>\n {this.props.children}\n </div>\n );\n }\n\n private createSubComponentTestId(subId: string): string | undefined {\n if (!this.props[\"data-testid\"]) return undefined;\n return `${this.props[\"data-testid\"]}-${subId}`;\n }\n\n private _onCheckboxChange = (checked: boolean) => {\n if (\n this.props.checkboxProps &&\n this.props.checkboxProps.onClick &&\n !this.props.checkboxProps.isDisabled\n )\n this.props.checkboxProps.onClick(\n checked ? CheckBoxState.On : CheckBoxState.Off\n );\n };\n\n private _onCheckboxClick = (e: React.MouseEvent) => {\n e.stopPropagation();\n };\n\n private _onClickExpansionToggle = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n if (this.props.onClickExpansionToggle) this.props.onClickExpansionToggle();\n };\n\n private _onClick = (e: React.MouseEvent<HTMLDivElement>) => {\n e.stopPropagation();\n this.props.onClick?.(e);\n };\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Tree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAc/C;;GAEG;AACH,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,aAAwB;IAAxD;;QACU,iBAAY,GAAoC,KAAK,CAAC,SAAS,EAAE,CAAC;IAgI5E,CAAC;IA9HC,IAAY,oBAAoB;QAC9B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO;YAAE,OAAO,SAAS,CAAC;QAEjD,MAAM,YAAY,GAAG,CAAC,OAAgB,EAAE,EAAE;YACxC,MAAM,KAAK,GAAG,MAAM,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC/C,OAAO,CACL,KAAK,CAAC,QAAQ,KAAK,MAAM;gBACzB,KAAK,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,CAAC,CAAC;QAC5E,OAAO,KAAK,CAAC;IACf,CAAC;IACD,uBAAuB;IAChB,mBAAmB,CAAC,QAAgB;QACzC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CACrD,QAAQ,CACM,CAAC;YACjB,uBAAuB;YACvB,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE;gBAC5B,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,GAAG,IAAI,CAAC;aACf;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAEe,MAAM;QACpB,MAAM,SAAS,GAAG,UAAU,CAAC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QAEhE,OAAO,CACL,6BACE,GAAG,EAAE,IAAI,CAAC,YAAY,EACtB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,WAAW,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,CAAC,IAEX,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;CACF","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 Tree\n */\n\nimport \"./Tree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Rectangle } from \"../utils/Rectangle\";\n\n/** Properties for the [[Tree]] presentational React component\n * @public\n */\nexport interface TreeProps extends CommonProps {\n children?: React.ReactNode;\n onMouseDown?: React.MouseEventHandler<HTMLDivElement>;\n onMouseMove?: React.MouseEventHandler<HTMLDivElement>;\n onMouseUp?: React.MouseEventHandler<HTMLDivElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;\n}\n\n/** Presentation React component for a Tree\n * @public\n */\nexport class Tree extends React.PureComponent<TreeProps> {\n private _treeElement: React.RefObject<HTMLDivElement> = React.createRef();\n\n private get _scrollableContainer(): Element | undefined {\n if (!this._treeElement.current) return undefined;\n\n const isScrollable = (element: Element) => {\n const style = window.getComputedStyle(element);\n return (\n style.overflow === \"auto\" ||\n style.overflow === \"scroll\" ||\n style.overflowY === \"auto\" ||\n style.overflowY === \"scroll\" ||\n style.overflowX === \"auto\" ||\n style.overflowX === \"scroll\"\n );\n };\n let scrollableContainer: Element | undefined = this._treeElement.current;\n while (scrollableContainer && !isScrollable(scrollableContainer))\n scrollableContainer =\n scrollableContainer.children.length > 0\n ? scrollableContainer.children[0]\n : undefined;\n\n return scrollableContainer;\n }\n\n public scrollToElement(element: Element) {\n const container = this._scrollableContainer;\n if (!container) return;\n\n // istanbul ignore next\n if (!Element.prototype.scrollTo) {\n // workaround for Edge scrollTo issue https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15534521/\n element.scrollIntoView();\n return;\n }\n\n const elementBox = element.getBoundingClientRect();\n const elementRange = Rectangle.createXYXY(\n elementBox.left,\n elementBox.top,\n elementBox.right,\n elementBox.bottom\n );\n const containerBox = container.getBoundingClientRect();\n const containerRange = Rectangle.createXYXY(\n containerBox.left - container.scrollLeft,\n containerBox.top - container.scrollTop,\n containerBox.right - container.scrollLeft,\n containerBox.bottom - container.scrollTop\n );\n\n let left: number;\n if (\n container.scrollLeft > 0 &&\n elementRange.right <= containerRange.right\n ) {\n // always attempt to keep horizontal scroll at 0\n left = 0;\n } else if (\n containerRange.left <= elementRange.left &&\n containerRange.right >= elementRange.right\n ) {\n // already visible - no need to scroll to\n left = container.scrollLeft;\n } else {\n left = elementRange.left - containerRange.left;\n }\n\n let top: number;\n if (\n containerRange.top <= elementRange.top &&\n containerRange.bottom >= elementRange.bottom\n ) {\n // already visible - no need to scroll to\n top = container.scrollTop;\n } else {\n top = elementRange.top - containerRange.top;\n }\n\n container.scrollTo({ left, top });\n }\n\n public getElementsByClassName(className: string): Element[] {\n if (!this._treeElement.current) return [];\n\n const elems = new Array<Element>();\n const collection =\n this._treeElement.current.getElementsByClassName(className);\n for (let i = 0; i < collection.length; ++i) elems.push(collection.item(i)!);\n return elems;\n }\n // istanbul ignore next\n public setFocusByClassName(selector: string): boolean {\n let status = false;\n if (this._treeElement.current) {\n const element = this._treeElement.current.querySelector(\n selector\n ) as HTMLElement;\n // istanbul ignore else\n if (element && element.focus) {\n element.focus();\n status = true;\n }\n }\n return status;\n }\n\n public override render() {\n const className = classnames(\"core-tree\", this.props.className);\n\n return (\n <div\n ref={this._treeElement}\n className={className}\n style={this.props.style}\n onMouseDown={this.props.onMouseDown}\n onMouseMove={this.props.onMouseMove}\n onMouseUp={this.props.onMouseUp}\n onKeyDown={this.props.onKeyDown}\n onKeyUp={this.props.onKeyUp}\n role=\"tree\"\n tabIndex={-1}\n >\n {this.props.children}\n </div>\n );\n }\n}\n"]}
1
+ {"version":3,"file":"Tree.js","sourceRoot":"","sources":["../../../../src/core-react/tree/Tree.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,aAAa,CAAC;AACrB,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAc/C;;GAEG;AACH,MAAM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C,KAAK,CAAC,WAAW,EACnC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAC/B,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EAC3B,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,CAAC,IAEX,IAAI,CAAC,KAAK,CAAC,QAAQ,CAChB,CACP,CAAC;IACJ,CAAC;CACF","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 Tree\n */\n\nimport \"./Tree.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"../utils/Props\";\nimport { Rectangle } from \"../utils/Rectangle\";\n\n/** Properties for the [[Tree]] presentational React component\n * @public\n */\nexport interface TreeProps extends CommonProps {\n children?: React.ReactNode;\n onMouseDown?: React.MouseEventHandler<HTMLDivElement>;\n onMouseMove?: React.MouseEventHandler<HTMLDivElement>;\n onMouseUp?: React.MouseEventHandler<HTMLDivElement>;\n onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;\n onKeyUp?: React.KeyboardEventHandler<HTMLDivElement>;\n}\n\n/** Presentation React component for a Tree\n * @public\n */\nexport class Tree extends React.PureComponent<TreeProps> {\n private _treeElement: React.RefObject<HTMLDivElement> = React.createRef();\n\n private get _scrollableContainer(): Element | undefined {\n if (!this._treeElement.current) return undefined;\n\n const isScrollable = (element: Element) => {\n const style = window.getComputedStyle(element);\n return (\n style.overflow === \"auto\" ||\n style.overflow === \"scroll\" ||\n style.overflowY === \"auto\" ||\n style.overflowY === \"scroll\" ||\n style.overflowX === \"auto\" ||\n style.overflowX === \"scroll\"\n );\n };\n let scrollableContainer: Element | undefined = this._treeElement.current;\n while (scrollableContainer && !isScrollable(scrollableContainer))\n scrollableContainer =\n scrollableContainer.children.length > 0\n ? scrollableContainer.children[0]\n : undefined;\n\n return scrollableContainer;\n }\n\n public scrollToElement(element: Element) {\n const container = this._scrollableContainer;\n if (!container) return;\n\n // istanbul ignore next\n if (!Element.prototype.scrollTo) {\n // workaround for Edge scrollTo issue https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/15534521/\n element.scrollIntoView();\n return;\n }\n\n const elementBox = element.getBoundingClientRect();\n const elementRange = Rectangle.createXYXY(\n elementBox.left,\n elementBox.top,\n elementBox.right,\n elementBox.bottom\n );\n const containerBox = container.getBoundingClientRect();\n const containerRange = Rectangle.createXYXY(\n containerBox.left - container.scrollLeft,\n containerBox.top - container.scrollTop,\n containerBox.right - container.scrollLeft,\n containerBox.bottom - container.scrollTop\n );\n\n let left: number;\n if (\n container.scrollLeft > 0 &&\n elementRange.right <= containerRange.right\n ) {\n // always attempt to keep horizontal scroll at 0\n left = 0;\n } else if (\n containerRange.left <= elementRange.left &&\n containerRange.right >= elementRange.right\n ) {\n // already visible - no need to scroll to\n left = container.scrollLeft;\n } else {\n left = elementRange.left - containerRange.left;\n }\n\n let top: number;\n if (\n containerRange.top <= elementRange.top &&\n containerRange.bottom >= elementRange.bottom\n ) {\n // already visible - no need to scroll to\n top = container.scrollTop;\n } else {\n top = elementRange.top - containerRange.top;\n }\n\n container.scrollTo({ left, top });\n }\n\n public getElementsByClassName(className: string): Element[] {\n if (!this._treeElement.current) return [];\n\n const elems = new Array<Element>();\n const collection =\n this._treeElement.current.getElementsByClassName(className);\n for (let i = 0; i < collection.length; ++i) elems.push(collection.item(i)!);\n return elems;\n }\n // istanbul ignore next\n public setFocusByClassName(selector: string): boolean {\n let status = false;\n if (this._treeElement.current) {\n const element = this._treeElement.current.querySelector(\n selector\n ) as HTMLElement;\n // istanbul ignore else\n if (element && element.focus) {\n element.focus();\n status = true;\n }\n }\n return status;\n }\n\n public override render() {\n const className = classnames(\"core-tree\", this.props.className);\n\n return (\n <div\n ref={this._treeElement}\n className={className}\n style={this.props.style}\n onMouseDown={this.props.onMouseDown}\n onMouseMove={this.props.onMouseMove}\n onMouseUp={this.props.onMouseUp}\n onKeyDown={this.props.onKeyDown}\n onKeyUp={this.props.onKeyUp}\n role=\"tree\"\n tabIndex={-1}\n >\n {this.props.children}\n </div>\n );\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"UiStateEntry.js","sourceRoot":"","sources":["../../../../src/core-react/uistate/UiStateEntry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;;;OAMG;IACH,YACS,gBAAwB,EACxB,WAAmB,EACnB,QAAiB,EACjB,UAA2B,EAC3B,YAAgB;QAJhB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAS;QACjB,eAAU,GAAV,UAAU,CAAiB;QAC3B,iBAAY,GAAZ,YAAY,CAAI;IACtB,CAAC;IAEJ,+CAA+C;IACxC,KAAK,CAAC,UAAU,CACrB,OAAuB;QAEvB,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACrE,CAAC;IAED,6EAA6E;IACtE,KAAK,CAAC,WAAW,CACtB,OAAuB;QAEvB,OAAO,OAAO,CAAC,WAAW,CACxB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,EAAE,CAChB,CAAC;IACJ,CAAC;IAED,8CAA8C;IACvC,KAAK,CAAC,aAAa,CACxB,OAAuB;QAEvB,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACxE,CAAC;IAED,iGAAiG;IAC1F,KAAK,CAAC,uBAAuB,CAClC,OAAuB;QAEvB,IAAI,IAAI,CAAC,UAAU,EAAE;YACnB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,oBAAoB,CAAC,OAAO,EAAE;gBAClD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;aACjC;iBAAM,IAAI,SAAS,KAAK,IAAI,CAAC,YAAY,EAAE;gBAC1C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBACnC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;gBACnC,MAAM,CAAC,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC;aAC9C;YACD,OAAO,MAAM,CAAC;SACf;QACD,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,aAAa,EAAE,CAAC;IACxD,CAAC;CACF","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 UiStateStorage\n */\n\nimport type { UiStateStorage, UiStateStorageResult } from \"./UiStateStorage\";\nimport { UiStateStorageStatus } from \"./UiStateStorage\";\n\n/** A single UI State entry that is identified by namespace and setting name.\n * @public\n */\nexport class UiStateEntry<T> {\n /** Constructor\n * @param settingNamespace Namespace for the setting, passed to UiStateStorage.\n * @param settingName Name for the setting, passed to UiStateStorage.\n * @param getValue Function for getting the value from the application.\n * @param applyValue Function for applying the setting value to the application.\n * @param defaultValue Optional default value if not already stored.\n */\n public constructor(\n public settingNamespace: string,\n public settingName: string,\n public getValue: () => T,\n public applyValue?: (v: T) => void,\n public defaultValue?: T\n ) {}\n\n /** Gets the setting from [[UiStateStorage]] */\n public async getSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.getSetting(this.settingNamespace, this.settingName);\n }\n\n /** Saves the setting value from the `getValue` function to UiStateStorage */\n public async saveSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.saveSetting(\n this.settingNamespace,\n this.settingName,\n this.getValue()\n );\n }\n\n /** Deletes the setting from UiStateStorage */\n public async deleteSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.deleteSetting(this.settingNamespace, this.settingName);\n }\n\n /** Gets the setting from UiStateStorage and applies the value using the `applyValue` function */\n public async getSettingAndApplyValue(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n if (this.applyValue) {\n const result = await this.getSetting(storage);\n if (result.status === UiStateStorageStatus.Success) {\n this.applyValue(result.setting);\n } else if (undefined !== this.defaultValue) {\n this.applyValue(this.defaultValue);\n result.setting = this.defaultValue;\n result.status = UiStateStorageStatus.Success;\n }\n return result;\n }\n return { status: UiStateStorageStatus.Uninitialized };\n }\n}\n"]}
1
+ {"version":3,"file":"UiStateEntry.js","sourceRoot":"","sources":["../../../../src/core-react/uistate/UiStateEntry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD;;GAEG;AACH,MAAM,OAAO,YAAY;IACvB;;;;;;OAMG;IACH,YACS,gBAAwB,EACxB,WAAmB,EACnB,QAAiB,EACjB,UAA2B,EAC3B,YAAgB;QAJhB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAS;QACjB,eAAU,GAAV,UAAU,CAAiB;QAC3B,iBAAY,GAAZ,YAAY,CAAI;IACtB,CAAC;IAEJ,+CAA+C;IACxC,KAAK,CAAC,UAAU,CACrB,OAAuB;QAEvB,OAAO,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACrE,CAAC;IAED,6EAA6E;IACtE,KAAK,CAAC,WAAW,CACtB,OAAuB;QAEvB,OAAO,OAAO,CAAC,WAAW,CACxB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,QAAQ,EAAE,CAChB,CAAC;IACJ,CAAC;IAED,8CAA8C;IACvC,KAAK,CAAC,aAAa,CACxB,OAAuB;QAEvB,OAAO,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,gBAAgB,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACxE,CAAC;IAED,iGAAiG;IAC1F,KAAK,CAAC,uBAAuB,CAClC,OAAuB;QAEvB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YAC9C,IAAI,MAAM,CAAC,MAAM,KAAK,oBAAoB,CAAC,OAAO,EAAE,CAAC;gBACnD,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;iBAAM,IAAI,SAAS,KAAK,IAAI,CAAC,YAAY,EAAE,CAAC;gBAC3C,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;gBACnC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC;gBACnC,MAAM,CAAC,MAAM,GAAG,oBAAoB,CAAC,OAAO,CAAC;YAC/C,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,aAAa,EAAE,CAAC;IACxD,CAAC;CACF","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 UiStateStorage\n */\n\nimport type { UiStateStorage, UiStateStorageResult } from \"./UiStateStorage\";\nimport { UiStateStorageStatus } from \"./UiStateStorage\";\n\n/** A single UI State entry that is identified by namespace and setting name.\n * @public\n */\nexport class UiStateEntry<T> {\n /** Constructor\n * @param settingNamespace Namespace for the setting, passed to UiStateStorage.\n * @param settingName Name for the setting, passed to UiStateStorage.\n * @param getValue Function for getting the value from the application.\n * @param applyValue Function for applying the setting value to the application.\n * @param defaultValue Optional default value if not already stored.\n */\n public constructor(\n public settingNamespace: string,\n public settingName: string,\n public getValue: () => T,\n public applyValue?: (v: T) => void,\n public defaultValue?: T\n ) {}\n\n /** Gets the setting from [[UiStateStorage]] */\n public async getSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.getSetting(this.settingNamespace, this.settingName);\n }\n\n /** Saves the setting value from the `getValue` function to UiStateStorage */\n public async saveSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.saveSetting(\n this.settingNamespace,\n this.settingName,\n this.getValue()\n );\n }\n\n /** Deletes the setting from UiStateStorage */\n public async deleteSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.deleteSetting(this.settingNamespace, this.settingName);\n }\n\n /** Gets the setting from UiStateStorage and applies the value using the `applyValue` function */\n public async getSettingAndApplyValue(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n if (this.applyValue) {\n const result = await this.getSetting(storage);\n if (result.status === UiStateStorageStatus.Success) {\n this.applyValue(result.setting);\n } else if (undefined !== this.defaultValue) {\n this.applyValue(this.defaultValue);\n result.setting = this.defaultValue;\n result.status = UiStateStorageStatus.Success;\n }\n return result;\n }\n return { status: UiStateStorageStatus.Uninitialized };\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"IconHelper.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,C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,uBAAuB;YACvB,IAAI,YAAY,EAAE;gBAChB,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAC/B,UAAU,CAAC,sBAAsB,CACX,CAAC;gBACzB,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAE,mBAAmB,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAI,CAAC;aACnE;YACD,OAAO,IAAI,CAAC;SACb;QACD,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAE,UAAU,GAAI,CAAC;IACxC,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,WAAW,CACvB,QAAkB,EAClB,YAA+B;QAE/B,IAAI,IAAI,CAAC;QACT,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,QAAQ,CAAC,EAAE;YACvD,IAAI,GAAG,UAAU,CAAC,sBAAsB,CAAC;YACzC,uBAAuB;YACvB,IAAI,YAAY;gBACd,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;YAChE,OAAO,IAAI,CAAC;SACb;aAAM;YACL,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;gBACnC,CAAC,CAAC,UAAU,CAAC,YAAY;gBACzB,CAAC,CAAC,QAAQ,CAAC;SACd;QAED,IACE,YAAY;YACZ,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,UAAU,CAAC,YAAY,EAChC;YACA,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;SACrD;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,YAAY,sBAAsB;YACpE,OAAO,IAAI,CAAC;QAEd,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\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 Utilities\n */\n\nimport * as React from \"react\";\nimport { ConditionalStringValue } from \"@itwin/appui-abstract\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { ConditionalIconItem } from \"../icons/ConditionalIconItem\";\n\n/** Icon Helper Class used to store the data needed to generate an <Icon> for use in any control that shows an icon.\n * @public\n */\nexport class IconHelper {\n public static get reactIconKey(): string {\n return \"#-react-iconspec-node-#\";\n }\n public static get conditionalIconItemKey(): string {\n return \"#-conditional-icon-item-node-#\";\n }\n /** Returns an <Icon> ReactNode from the many ways an icon can be specified.\n * @param icon abstract icon specification.\n * @param internalData a map that may hold a React.ReactNode stored in an abstract item definition.\n */\n public static getIconReactNode(\n icon:\n | string\n | ConditionalStringValue\n | React.ReactNode\n | ConditionalIconItem,\n internalData?: Map<string, any>\n ): React.ReactNode {\n // istanbul ignore else\n if (!icon) return null;\n\n // istanbul ignore else\n if (ConditionalIconItem.isConditionalIconItem(icon))\n return <Icon iconSpec={ConditionalIconItem.getValue(icon)} />;\n // istanbul ignore else\n if (React.isValidElement(icon)) return <Icon iconSpec={icon} />;\n\n // istanbul ignore if\n if (!(icon instanceof ConditionalStringValue) && typeof icon !== \"string\")\n return null;\n\n const iconString = ConditionalStringValue.getValue(icon);\n if (!iconString) return null;\n\n // istanbul ignore else\n if (iconString === IconHelper.reactIconKey) {\n // istanbul ignore else\n if (internalData)\n return (\n <Icon\n iconSpec={\n internalData.get(IconHelper.reactIconKey) as React.ReactNode\n }\n />\n );\n return null;\n } else if (iconString === IconHelper.conditionalIconItemKey) {\n // istanbul ignore else\n if (internalData) {\n const iconItem = internalData.get(\n IconHelper.conditionalIconItemKey\n ) as ConditionalIconItem;\n return <Icon iconSpec={ConditionalIconItem.getValue(iconItem)} />;\n }\n return null;\n }\n return <Icon iconSpec={iconString} />;\n }\n\n /** Returns an icon definition that can be stored in an abstract item definition. If the iconSpec specifies a ReactNode\n * then the react data is stored in the internalData map and the key to the react data is returned.\n * @param iconSpec any supported variations of how an icon can be defined in an abstract item or IconProps.\n * @param internalData a map supplied by the caller to store away react element if React.ReactNode\n */\n public static getIconData(\n iconSpec: IconSpec,\n internalData?: Map<string, any>\n ): string | ConditionalStringValue {\n let icon;\n if (ConditionalIconItem.isConditionalIconItem(iconSpec)) {\n icon = IconHelper.conditionalIconItemKey;\n // istanbul ignore else\n if (internalData)\n internalData.set(IconHelper.conditionalIconItemKey, iconSpec);\n return icon;\n } else {\n icon = React.isValidElement(iconSpec)\n ? IconHelper.reactIconKey\n : iconSpec;\n }\n\n if (\n internalData &&\n typeof icon === \"string\" &&\n icon === IconHelper.reactIconKey\n ) {\n internalData.set(IconHelper.reactIconKey, iconSpec);\n }\n\n if (typeof icon === \"string\" || icon instanceof ConditionalStringValue)\n return icon;\n\n return \"\";\n }\n}\n"]}
1
+ {"version":3,"file":"IconHelper.js","sourceRoot":"","sources":["../../../../src/core-react/utils/IconHelper.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAE/D,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE;;GAEG;AACH,MAAM,OAAO,UAAU;IACd,MAAM,KAAK,YAAY;QAC5B,OAAO,yBAAyB,CAAC;IACnC,CAAC;IACM,MAAM,KAAK,sBAAsB;QACtC,OAAO,gCAAgC,CAAC;IAC1C,CAAC;IACD;;;OAGG;IACI,MAAM,CAAC,gBAAgB,CAC5B,IAIuB,EACvB,YAA+B;QAE/B,uBAAuB;QACvB,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QAEvB,uBAAuB;QACvB,IAAI,mBAAmB,CAAC,qBAAqB,CAAC,IAAI,CAAC;YACjD,OAAO,oBAAC,IAAI,IAAC,QAAQ,EAAE,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IAAI,GAAG,UAAU,CAAC,sBAAsB,CAAC;YACzC,uBAAuB;YACvB,IAAI,YAAY;gBACd,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,sBAAsB,EAAE,QAAQ,CAAC,CAAC;YAChE,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC;gBACnC,CAAC,CAAC,UAAU,CAAC,YAAY;gBACzB,CAAC,CAAC,QAAQ,CAAC;QACf,CAAC;QAED,IACE,YAAY;YACZ,OAAO,IAAI,KAAK,QAAQ;YACxB,IAAI,KAAK,UAAU,CAAC,YAAY,EAChC,CAAC;YACD,YAAY,CAAC,GAAG,CAAC,UAAU,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,YAAY,sBAAsB;YACpE,OAAO,IAAI,CAAC;QAEd,OAAO,EAAE,CAAC;IACZ,CAAC;CACF","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 Utilities\n */\n\nimport * as React from \"react\";\nimport { ConditionalStringValue } from \"@itwin/appui-abstract\";\nimport type { IconSpec } from \"../icons/IconComponent\";\nimport { Icon } from \"../icons/IconComponent\";\nimport { ConditionalIconItem } from \"../icons/ConditionalIconItem\";\n\n/** Icon Helper Class used to store the data needed to generate an <Icon> for use in any control that shows an icon.\n * @public\n */\nexport class IconHelper {\n public static get reactIconKey(): string {\n return \"#-react-iconspec-node-#\";\n }\n public static get conditionalIconItemKey(): string {\n return \"#-conditional-icon-item-node-#\";\n }\n /** Returns an <Icon> ReactNode from the many ways an icon can be specified.\n * @param icon abstract icon specification.\n * @param internalData a map that may hold a React.ReactNode stored in an abstract item definition.\n */\n public static getIconReactNode(\n icon:\n | string\n | ConditionalStringValue\n | React.ReactNode\n | ConditionalIconItem,\n internalData?: Map<string, any>\n ): React.ReactNode {\n // istanbul ignore else\n if (!icon) return null;\n\n // istanbul ignore else\n if (ConditionalIconItem.isConditionalIconItem(icon))\n return <Icon iconSpec={ConditionalIconItem.getValue(icon)} />;\n // istanbul ignore else\n if (React.isValidElement(icon)) return <Icon iconSpec={icon} />;\n\n // istanbul ignore if\n if (!(icon instanceof ConditionalStringValue) && typeof icon !== \"string\")\n return null;\n\n const iconString = ConditionalStringValue.getValue(icon);\n if (!iconString) return null;\n\n // istanbul ignore else\n if (iconString === IconHelper.reactIconKey) {\n // istanbul ignore else\n if (internalData)\n return (\n <Icon\n iconSpec={\n internalData.get(IconHelper.reactIconKey) as React.ReactNode\n }\n />\n );\n return null;\n } else if (iconString === IconHelper.conditionalIconItemKey) {\n // istanbul ignore else\n if (internalData) {\n const iconItem = internalData.get(\n IconHelper.conditionalIconItemKey\n ) as ConditionalIconItem;\n return <Icon iconSpec={ConditionalIconItem.getValue(iconItem)} />;\n }\n return null;\n }\n return <Icon iconSpec={iconString} />;\n }\n\n /** Returns an icon definition that can be stored in an abstract item definition. If the iconSpec specifies a ReactNode\n * then the react data is stored in the internalData map and the key to the react data is returned.\n * @param iconSpec any supported variations of how an icon can be defined in an abstract item or IconProps.\n * @param internalData a map supplied by the caller to store away react element if React.ReactNode\n */\n public static getIconData(\n iconSpec: IconSpec,\n internalData?: Map<string, any>\n ): string | ConditionalStringValue {\n let icon;\n if (ConditionalIconItem.isConditionalIconItem(iconSpec)) {\n icon = IconHelper.conditionalIconItemKey;\n // istanbul ignore else\n if (internalData)\n internalData.set(IconHelper.conditionalIconItemKey, iconSpec);\n return icon;\n } else {\n icon = React.isValidElement(iconSpec)\n ? IconHelper.reactIconKey\n : iconSpec;\n }\n\n if (\n internalData &&\n typeof icon === \"string\" &&\n icon === IconHelper.reactIconKey\n ) {\n internalData.set(IconHelper.reactIconKey, iconSpec);\n }\n\n if (typeof icon === \"string\" || icon instanceof ConditionalStringValue)\n return icon;\n\n return \"\";\n }\n}\n"]}