@itwin/core-react 5.19.0 → 5.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/lib/core-react/UiCore.js +2 -1
  3. package/lib/core-react/UiCore.js.map +1 -1
  4. package/lib/core-react/autosuggest/AutoSuggest.js +86 -86
  5. package/lib/core-react/autosuggest/AutoSuggest.js.map +1 -1
  6. package/lib/core-react/contextmenu/ContextMenu.js +272 -269
  7. package/lib/core-react/contextmenu/ContextMenu.js.map +1 -1
  8. package/lib/core-react/contextmenu/ContextMenuItem.js +57 -55
  9. package/lib/core-react/contextmenu/ContextMenuItem.js.map +1 -1
  10. package/lib/core-react/contextmenu/ContextSubMenu.js +70 -67
  11. package/lib/core-react/contextmenu/ContextSubMenu.js.map +1 -1
  12. package/lib/core-react/contextmenu/GlobalContextMenu.js +23 -22
  13. package/lib/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
  14. package/lib/core-react/contextmenu/TildeFinder.js +52 -52
  15. package/lib/core-react/contextmenu/TildeFinder.js.map +1 -1
  16. package/lib/core-react/dialog/Dialog.js +29 -29
  17. package/lib/core-react/dialog/Dialog.js.map +1 -1
  18. package/lib/core-react/dialog/GlobalDialog.js +24 -23
  19. package/lib/core-react/dialog/GlobalDialog.js.map +1 -1
  20. package/lib/core-react/expandable/ExpandableList.js +15 -15
  21. package/lib/core-react/expandable/ExpandableList.js.map +1 -1
  22. package/lib/core-react/focus/ItemKeyboardNavigator.js +7 -3
  23. package/lib/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
  24. package/lib/core-react/hocs/withIsPressed.js +14 -17
  25. package/lib/core-react/hocs/withIsPressed.js.map +1 -1
  26. package/lib/core-react/hocs/withOnOutsideClick.js +38 -41
  27. package/lib/core-react/hocs/withOnOutsideClick.js.map +1 -1
  28. package/lib/core-react/hocs/withTimeout.js +2 -5
  29. package/lib/core-react/hocs/withTimeout.js.map +1 -1
  30. package/lib/core-react/icons/ConditionalIconItem.js +3 -0
  31. package/lib/core-react/icons/ConditionalIconItem.js.map +1 -1
  32. package/lib/core-react/imagecheckbox/ImageCheckBox.js +15 -18
  33. package/lib/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
  34. package/lib/core-react/loading/LoadingBar.js +3 -3
  35. package/lib/core-react/loading/LoadingBar.js.map +1 -1
  36. package/lib/core-react/loading/LoadingPrompt.js +9 -9
  37. package/lib/core-react/loading/LoadingPrompt.js.map +1 -1
  38. package/lib/core-react/loading/LoadingSpinner.js +3 -3
  39. package/lib/core-react/loading/LoadingSpinner.js.map +1 -1
  40. package/lib/core-react/loading/LoadingStatus.js +4 -4
  41. package/lib/core-react/loading/LoadingStatus.js.map +1 -1
  42. package/lib/core-react/messagebox/MessageBox.js +6 -6
  43. package/lib/core-react/messagebox/MessageBox.js.map +1 -1
  44. package/lib/core-react/popup/Popup.js +209 -209
  45. package/lib/core-react/popup/Popup.js.map +1 -1
  46. package/lib/core-react/radialmenu/Annulus.js +19 -2
  47. package/lib/core-react/radialmenu/Annulus.js.map +1 -1
  48. package/lib/core-react/radialmenu/RadialMenu.js +56 -56
  49. package/lib/core-react/radialmenu/RadialMenu.js.map +1 -1
  50. package/lib/core-react/searchbox/SearchBox.js +60 -60
  51. package/lib/core-react/searchbox/SearchBox.js.map +1 -1
  52. package/lib/core-react/settings/SettingsManager.js +20 -22
  53. package/lib/core-react/settings/SettingsManager.js.map +1 -1
  54. package/lib/core-react/tabs/Tabs.js +14 -13
  55. package/lib/core-react/tabs/Tabs.js.map +1 -1
  56. package/lib/core-react/tree/Node.js +18 -18
  57. package/lib/core-react/tree/Node.js.map +1 -1
  58. package/lib/core-react/tree/Tree.js +1 -4
  59. package/lib/core-react/tree/Tree.js.map +1 -1
  60. package/lib/core-react/uistate/LocalStateStorage.js +1 -0
  61. package/lib/core-react/uistate/LocalStateStorage.js.map +1 -1
  62. package/lib/core-react/uistate/UiStateEntry.js +5 -0
  63. package/lib/core-react/uistate/UiStateEntry.js.map +1 -1
  64. package/lib/core-react/utils/Point.js +2 -0
  65. package/lib/core-react/utils/Point.js.map +1 -1
  66. package/lib/core-react/utils/Rectangle.js +4 -0
  67. package/lib/core-react/utils/Rectangle.js.map +1 -1
  68. package/lib/core-react/utils/ScrollPositionMaintainer.js +1 -0
  69. package/lib/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
  70. package/lib/core-react/utils/Timer.js +5 -2
  71. package/lib/core-react/utils/Timer.js.map +1 -1
  72. package/package.json +3 -3
@@ -19,68 +19,13 @@ import { useTranslation } from "../l10n/useTranslation.js";
19
19
  * @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/searchbox iTwinUI SearchBox} instead.
20
20
  */
21
21
  export class SearchBox extends React.Component {
22
+ _inputElement = null;
23
+ _timeoutId = 0;
24
+ state = {
25
+ value: this.props.initialValue || "",
26
+ };
22
27
  constructor(props) {
23
28
  super(props);
24
- this._inputElement = null;
25
- this._timeoutId = 0;
26
- this.state = {
27
- value: this.props.initialValue || "",
28
- };
29
- /** Wrapper for onValueChanged to make sure we don't call search unless the new value is different from the previous value */
30
- this._onValueChanged = (value, previousValue) => {
31
- if (value === previousValue)
32
- return;
33
- this.setState((_prevState) => {
34
- return {
35
- value,
36
- };
37
- }, () => {
38
- this.props.onValueChanged(this.state.value);
39
- });
40
- };
41
- this._trackChange = (_event) => {
42
- let value = "";
43
- const previousValue = this.state.value;
44
- if (this._inputElement)
45
- value = this._inputElement.value;
46
- if (this.props.valueChangedDelay) {
47
- this._unsetTimeout();
48
- this._timeoutId = window.setTimeout(() => {
49
- this._onValueChanged(value, previousValue);
50
- }, this.props.valueChangedDelay);
51
- }
52
- else {
53
- this._onValueChanged(value, previousValue);
54
- }
55
- };
56
- this._handleKeyDown = (e) => {
57
- switch (e.key) {
58
- case Key.Escape.valueOf():
59
- if (this.props.onEscPressed)
60
- this.props.onEscPressed();
61
- break;
62
- case Key.Enter.valueOf():
63
- if (this.props.onEnterPressed)
64
- this.props.onEnterPressed();
65
- break;
66
- }
67
- };
68
- this._handleIconClick = (_event) => {
69
- if (this._inputElement) {
70
- const clear = this.state.value !== "";
71
- this._inputElement.value = "";
72
- if (clear && this.props.onClear)
73
- this.props.onClear();
74
- this._inputElement.focus();
75
- }
76
- this._trackChange();
77
- };
78
- this._unsetTimeout = () => {
79
- if (this._timeoutId) {
80
- window.clearTimeout(this._timeoutId);
81
- this._timeoutId = 0;
82
- }
83
- };
84
29
  }
85
30
  render() {
86
31
  const searchClassName = classnames("core-searchbox", this.props.className);
@@ -95,6 +40,61 @@ export class SearchBox extends React.Component {
95
40
  React.createElement("span", { className: iconClassName },
96
41
  React.createElement(Icon, { iconSpec: iconSpec })))));
97
42
  }
43
+ /** Wrapper for onValueChanged to make sure we don't call search unless the new value is different from the previous value */
44
+ _onValueChanged = (value, previousValue) => {
45
+ if (value === previousValue)
46
+ return;
47
+ this.setState((_prevState) => {
48
+ return {
49
+ value,
50
+ };
51
+ }, () => {
52
+ this.props.onValueChanged(this.state.value);
53
+ });
54
+ };
55
+ _trackChange = (_event) => {
56
+ let value = "";
57
+ const previousValue = this.state.value;
58
+ if (this._inputElement)
59
+ value = this._inputElement.value;
60
+ if (this.props.valueChangedDelay) {
61
+ this._unsetTimeout();
62
+ this._timeoutId = window.setTimeout(() => {
63
+ this._onValueChanged(value, previousValue);
64
+ }, this.props.valueChangedDelay);
65
+ }
66
+ else {
67
+ this._onValueChanged(value, previousValue);
68
+ }
69
+ };
70
+ _handleKeyDown = (e) => {
71
+ switch (e.key) {
72
+ case Key.Escape.valueOf():
73
+ if (this.props.onEscPressed)
74
+ this.props.onEscPressed();
75
+ break;
76
+ case Key.Enter.valueOf():
77
+ if (this.props.onEnterPressed)
78
+ this.props.onEnterPressed();
79
+ break;
80
+ }
81
+ };
82
+ _handleIconClick = (_event) => {
83
+ if (this._inputElement) {
84
+ const clear = this.state.value !== "";
85
+ this._inputElement.value = "";
86
+ if (clear && this.props.onClear)
87
+ this.props.onClear();
88
+ this._inputElement.focus();
89
+ }
90
+ this._trackChange();
91
+ };
92
+ _unsetTimeout = () => {
93
+ if (this._timeoutId) {
94
+ window.clearTimeout(this._timeoutId);
95
+ this._timeoutId = 0;
96
+ }
97
+ };
98
98
  componentWillUnmount() {
99
99
  this._unsetTimeout();
100
100
  }
@@ -1 +1 @@
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,2BAA2B,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA6B3D;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK,CAAC,SAAyC;IAQ5E,YAAY,KAAqB;QAC/B,KAAK,CAAC,KAAK,CAAC,CAAC;QARP,kBAAa,GAA4B,IAAI,CAAC;QAC9C,eAAU,GAAW,CAAC,CAAC;QAEN,UAAK,GAA6B;YACzD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE;SACrC,CAAC;QA6CF,6HAA6H;QACrH,oBAAe,GAAG,CAAC,KAAa,EAAE,aAAqB,EAAE,EAAE;YACjE,IAAI,KAAK,KAAK,aAAa;gBAAE,OAAO;YAEpC,IAAI,CAAC,QAAQ,CACX,CAAC,UAAU,EAAE,EAAE;gBACb,OAAO;oBACL,KAAK;iBACN,CAAC;YACJ,CAAC,EACD,GAAG,EAAE;gBACH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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.js\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { IconSpec } from \"../icons/IconComponent.js\";\nimport { Icon } from \"../icons/IconComponent.js\";\nimport { SvgClose, SvgSearch } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Properties for [[SearchBox]] component\n * @public\n * @deprecated in 4.12.0. 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.0. 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 public override readonly state: Readonly<SearchBoxState> = {\n value: this.props.initialValue || \"\",\n };\n\n constructor(props: SearchBoxProps) {\n super(props);\n }\n\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 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 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 if (this.props.onEscPressed) this.props.onEscPressed();\n break;\n case Key.Enter.valueOf():\n if (this.props.onEnterPressed) this.props.onEnterPressed();\n break;\n }\n };\n\n private _handleIconClick = (_event: React.MouseEvent<HTMLElement>): void => {\n if (this._inputElement) {\n const clear = this.state.value !== \"\";\n this._inputElement.value = \"\";\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 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,2BAA2B,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA6B3D;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,KAAK,CAAC,SAAyC;IACpE,aAAa,GAA4B,IAAI,CAAC;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,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.js\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport type { IconSpec } from \"../icons/IconComponent.js\";\nimport { Icon } from \"../icons/IconComponent.js\";\nimport { SvgClose, SvgSearch } from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../l10n/useTranslation.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Properties for [[SearchBox]] component\n * @public\n * @deprecated in 4.12.0. 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.0. 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 public override readonly state: Readonly<SearchBoxState> = {\n value: this.props.initialValue || \"\",\n };\n\n constructor(props: SearchBoxProps) {\n super(props);\n }\n\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 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 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 if (this.props.onEscPressed) this.props.onEscPressed();\n break;\n case Key.Enter.valueOf():\n if (this.props.onEnterPressed) this.props.onEnterPressed();\n break;\n }\n };\n\n private _handleIconClick = (_event: React.MouseEvent<HTMLElement>): void => {\n if (this._inputElement) {\n const clear = this.state.value !== \"\";\n this._inputElement.value = \"\";\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 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"]}
@@ -38,28 +38,26 @@ export class ActivateSettingsTabEvent extends BeUiEvent {
38
38
  * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsManager} instead.
39
39
  */
40
40
  export class SettingsManager {
41
- constructor() {
42
- this._providers = [];
43
- /** Event raised when SettingsProviders are changed.
44
- */
45
- this.onSettingsProvidersChanged = new SettingsProvidersChangedEvent();
46
- /** Event raised solely for a settings page to monitor so it can save its settings before continuing tab activation.
47
- * See React hook function `useSaveBeforeActivatingNewSettingsTab`.
48
- */
49
- this.onProcessSettingsTabActivation = new ProcessSettingsTabActivationEvent();
50
- /** Event raised when the settings container will be closed. Any setting page component that is 'modal' should register to
51
- * listen to this event so that it can save its state before closing. See React hook function `useSaveBeforeClosingSettingsContainer`.
52
- */
53
- this.onProcessSettingsContainerClose = new ProcessSettingsContainerCloseEvent();
54
- /** Event raised to change the active settings tab shown in UI. Monitored by the SettingsContainer.
55
- * @internal
56
- */
57
- this.onActivateSettingsTab = new BeUiEvent();
58
- /** Event monitored by SettingsContainer to process request to close the settings container.
59
- * @internal
60
- */
61
- this.onCloseSettingsContainer = new BeUiEvent();
62
- }
41
+ _providers = [];
42
+ /** Event raised when SettingsProviders are changed.
43
+ */
44
+ onSettingsProvidersChanged = new SettingsProvidersChangedEvent();
45
+ /** Event raised solely for a settings page to monitor so it can save its settings before continuing tab activation.
46
+ * See React hook function `useSaveBeforeActivatingNewSettingsTab`.
47
+ */
48
+ onProcessSettingsTabActivation = new ProcessSettingsTabActivationEvent();
49
+ /** Event raised when the settings container will be closed. Any setting page component that is 'modal' should register to
50
+ * listen to this event so that it can save its state before closing. See React hook function `useSaveBeforeClosingSettingsContainer`.
51
+ */
52
+ onProcessSettingsContainerClose = new ProcessSettingsContainerCloseEvent();
53
+ /** Event raised to change the active settings tab shown in UI. Monitored by the SettingsContainer.
54
+ * @internal
55
+ */
56
+ onActivateSettingsTab = new BeUiEvent();
57
+ /** Event monitored by SettingsContainer to process request to close the settings container.
58
+ * @internal
59
+ */
60
+ onCloseSettingsContainer = new BeUiEvent();
63
61
  get providers() {
64
62
  return this._providers;
65
63
  }
@@ -1 +1 @@
1
- {"version":3,"file":"SettingsManager.js","sourceRoot":"","sources":["../../../src/core-react/settings/SettingsManager.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;A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AAC,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.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Interface used to populate a tab entry in the SettingContainer control\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsTabEntry} instead.\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.0. This class should not be used by applications to instantiate objects.\n */\nexport class SettingsProvidersChangedEvent extends BeUiEvent<SettingsProvidersChangedEventArgs> {}\n\n/** Arguments of [[this.onSettingsProvidersChanged]] event.\n * @public\n * @deprecated in 4.13.0. 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.0. This class should not be used by applications to instantiate objects.\n */\nexport class ProcessSettingsTabActivationEvent extends BeUiEvent<ProcessSettingsTabActivationEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsTabActivation]] event.\n * @public\n * @deprecated in 4.13.0. 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.0. This class should not be used by applications to instantiate objects.\n */\nexport class ProcessSettingsContainerCloseEvent extends BeUiEvent<ProcessSettingsContainerCloseEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsContainerClose]] event.\n * @public\n * @deprecated in 4.13.0. 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.0. This class should not be used by applications to instantiate objects.\n */\nexport class ActivateSettingsTabEvent extends BeUiEvent<ActivateSettingsTabEventArgs> {}\n\n/** Arguments of [[this.onActivateSettingsTab]] event.\n * @public\n * @deprecated in 4.13.0. 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 * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsTabsProvider} instead.\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 * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsManager} instead.\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();\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();\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();\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>();\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>();\n\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(\"SettingsManager\"),\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,cAAc,CAAC;AA8BtC;;;GAGG;AACH,MAAM,OAAO,6BAA8B,SAAQ,SAA4C;CAAG;AAUlG;;;;GAIG;AACH,MAAM,OAAO,iCAAkC,SAAQ,SAAgD;CAAG;AAW1G;;;;GAIG;AACH,MAAM,OAAO,kCAAmC,SAAQ,SAAiD;CAAG;AAW5G;;;GAGG;AACH,MAAM,OAAO,wBAAyB,SAAQ,S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B,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,OAAO,CACZ,MAAM,CAAC,cAAc,CAAC,iBAAiB,CAAC,EACxC,gCAAgC,gBAAgB,CAAC,EAAE,8BAA8B,CAClF,CAAC;QACJ,CAAC;IACH,CAAC;IAEM,sBAAsB,CAAC,UAAkB;QAC9C,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,CAAC,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,CAAC;YACvD,IAAI,CAAC,SAAS,GAAG,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.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Interface used to populate a tab entry in the SettingContainer control\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsTabEntry} instead.\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.0. This class should not be used by applications to instantiate objects.\n */\nexport class SettingsProvidersChangedEvent extends BeUiEvent<SettingsProvidersChangedEventArgs> {}\n\n/** Arguments of [[this.onSettingsProvidersChanged]] event.\n * @public\n * @deprecated in 4.13.0. 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.0. This class should not be used by applications to instantiate objects.\n */\nexport class ProcessSettingsTabActivationEvent extends BeUiEvent<ProcessSettingsTabActivationEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsTabActivation]] event.\n * @public\n * @deprecated in 4.13.0. 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.0. This class should not be used by applications to instantiate objects.\n */\nexport class ProcessSettingsContainerCloseEvent extends BeUiEvent<ProcessSettingsContainerCloseEventArgs> {}\n\n/** Arguments of [[this.onProcessSettingsContainerClose]] event.\n * @public\n * @deprecated in 4.13.0. 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.0. This class should not be used by applications to instantiate objects.\n */\nexport class ActivateSettingsTabEvent extends BeUiEvent<ActivateSettingsTabEventArgs> {}\n\n/** Arguments of [[this.onActivateSettingsTab]] event.\n * @public\n * @deprecated in 4.13.0. 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 * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsTabsProvider} instead.\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 * @deprecated in 4.16.0. Use {@link @itwin/appui-react#SettingsManager} instead.\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();\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();\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();\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>();\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>();\n\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(\"SettingsManager\"),\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"]}
@@ -21,21 +21,10 @@ function isTabLabel(item) {
21
21
  * @deprecated in 4.12.0. Use {@link https://itwinui.bentley.com/docs/tabs iTwinUI Tabs} instead.
22
22
  */
23
23
  export class Tabs extends React.PureComponent {
24
+ _anchorRefs = [];
25
+ _itemKeyboardNavigator;
24
26
  constructor(props) {
25
27
  super(props);
26
- this._anchorRefs = [];
27
- this._handleFocusItem = (index) => {
28
- const itemRef = this._anchorRefs[index];
29
- if (itemRef && itemRef.current)
30
- itemRef.current.focus();
31
- };
32
- this._handleTabClick = (index) => {
33
- this._activateTab(index);
34
- };
35
- this._activateTab = (index) => {
36
- this.props.onActivateTab && this.props.onActivateTab(index);
37
- this.setState({ activeIndex: index });
38
- };
39
28
  const activeIndex = this.validateActiveIndex(props.activeIndex);
40
29
  this.state = {
41
30
  activeIndex,
@@ -74,6 +63,14 @@ export class Tabs extends React.PureComponent {
74
63
  });
75
64
  }
76
65
  }
66
+ _handleFocusItem = (index) => {
67
+ const itemRef = this._anchorRefs[index];
68
+ if (itemRef && itemRef.current)
69
+ itemRef.current.focus();
70
+ };
71
+ _handleTabClick = (index) => {
72
+ this._activateTab(index);
73
+ };
77
74
  /** Handle keydown on tabs */
78
75
  _handleKeyDownEvent(event, index) {
79
76
  this._itemKeyboardNavigator.handleKeyDownEvent(event, index);
@@ -82,6 +79,10 @@ export class Tabs extends React.PureComponent {
82
79
  _handleKeyUpEvent(event, index) {
83
80
  this._itemKeyboardNavigator.handleKeyUpEvent(event, index);
84
81
  }
82
+ _activateTab = (index) => {
83
+ this.props.onActivateTab && this.props.onActivateTab(index);
84
+ this.setState({ activeIndex: index });
85
+ };
85
86
  render() {
86
87
  const ulClassNames = classnames(this.props.mainClassName, this.props.green && "uicore-tabs-green", this.props.className);
87
88
  const anyIconsPresent = this.props.labels.reduce((a, b) => a + (isTabLabelWithIcon(b) ? 1 : 0), 0) > 0;
@@ -1 +1 @@
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,yBAAyB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAmBpD,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,GAAqD,EAAE,CAAC;QAyDnE,qBAAgB,GAAG,CAAC,KAAa,EAAE,EAAE;YAC3C,MAAM,OAAO,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;YACxC,IAAI,OAAO,IAAI,OAAO,CAAC,OAAO;gBAAE,OAAO,CAAC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C,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.js\";\nimport { Orientation } from \"../enums/Orientation.js\";\nimport { ItemKeyboardNavigator } from \"../focus/ItemKeyboardNavigator.js\";\nimport { IconHelper } from \"../utils/IconHelper.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\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.0. 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.0. 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.0. 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.0. 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 | null>> = [];\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 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 if (element && document.activeElement === element) hadFocus = true;\n const activeIndex = this.validateActiveIndex(this.props.activeIndex);\n\n this.setState(\n () => ({ activeIndex }),\n () => {\n if (hadFocus) {\n const newElement = this._anchorRefs[activeIndex].current;\n if (newElement) newElement.focus();\n }\n }\n );\n }\n }\n\n private _handleFocusItem = (index: number) => {\n const itemRef = this._anchorRefs[index];\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 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 <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,yBAAyB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAmBpD,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;IAC7D,WA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AAiB,CAAC,KAAK,EAAE,KAAK,CAAC,iBAC3C,GAAG,KAAK,EAAE,EACvB,IAAI,EAAC,QAAQ;oBAEb,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.js\";\nimport { Orientation } from \"../enums/Orientation.js\";\nimport { ItemKeyboardNavigator } from \"../focus/ItemKeyboardNavigator.js\";\nimport { IconHelper } from \"../utils/IconHelper.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\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.0. 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.0. 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.0. 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.0. 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 | null>> = [];\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 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 if (element && document.activeElement === element) hadFocus = true;\n const activeIndex = this.validateActiveIndex(this.props.activeIndex);\n\n this.setState(\n () => ({ activeIndex }),\n () => {\n if (hadFocus) {\n const newElement = this._anchorRefs[activeIndex].current;\n if (newElement) newElement.focus();\n }\n }\n );\n }\n }\n\n private _handleFocusItem = (index: number) => {\n const itemRef = this._anchorRefs[index];\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 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 <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"]}
@@ -23,24 +23,6 @@ const EXPANSION_TOGGLE_WIDTH = 24;
23
23
  export class TreeNode extends React.Component {
24
24
  constructor(props) {
25
25
  super(props);
26
- this._onCheckboxChange = (checked) => {
27
- if (this.props.checkboxProps &&
28
- this.props.checkboxProps.onClick &&
29
- !this.props.checkboxProps.isDisabled)
30
- this.props.checkboxProps.onClick(checked ? CheckBoxState.On : CheckBoxState.Off);
31
- };
32
- this._onCheckboxClick = (e) => {
33
- e.stopPropagation();
34
- };
35
- this._onClickExpansionToggle = (e) => {
36
- e.stopPropagation();
37
- if (this.props.onClickExpansionToggle)
38
- this.props.onClickExpansionToggle();
39
- };
40
- this._onClick = (e) => {
41
- e.stopPropagation();
42
- this.props.onClick?.(e);
43
- };
44
26
  }
45
27
  render() {
46
28
  const className = classnames("core-tree-node", this.props.isFocused && "is-focused", this.props.isSelected && "is-selected", this.props.isHoverDisabled && "is-hover-disabled", this.props.className);
@@ -84,5 +66,23 @@ export class TreeNode extends React.Component {
84
66
  return undefined;
85
67
  return `${this.props["data-testid"]}-${subId}`;
86
68
  }
69
+ _onCheckboxChange = (checked) => {
70
+ if (this.props.checkboxProps &&
71
+ this.props.checkboxProps.onClick &&
72
+ !this.props.checkboxProps.isDisabled)
73
+ this.props.checkboxProps.onClick(checked ? CheckBoxState.On : CheckBoxState.Off);
74
+ };
75
+ _onCheckboxClick = (e) => {
76
+ e.stopPropagation();
77
+ };
78
+ _onClickExpansionToggle = (e) => {
79
+ e.stopPropagation();
80
+ if (this.props.onClickExpansionToggle)
81
+ this.props.onClickExpansionToggle();
82
+ };
83
+ _onClick = (e) => {
84
+ e.stopPropagation();
85
+ this.props.onClick?.(e);
86
+ };
87
87
  }
88
88
  //# sourceMappingURL=Node.js.map
@@ -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,2BAA2B,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0BvD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAgDlC;;;GAGG;AACH,MAAM,OAA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ACnC,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.js\";\nimport type { CommonProps } from \"../utils/Props.js\";\nimport { ExpansionToggle } from \"./ExpansionToggle.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\n/** Props for node Checkbox renderer\n * @public\n * @deprecated in 4.16.0. Type is inlined in component props. Use `React.ComponentProps` type helper instead.\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 * @deprecated in 4.16.0. Type is inlined in component props. Use `React.ComponentProps` type helper instead.\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 * @deprecated in 4.15.0. Used in deprecated {@link TreeNodeProps} props.\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 * @deprecated in 4.15.0. Props of deprecated {@link TreeNode} component.\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactElement | string | number;\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 * @deprecated in 4.15.0. Use {@link https://itwinui.bentley.com/docs/tree iTwinUI Tree} instead.\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,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AA0BvD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAgDlC;;;GAGG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK,CAAC,SAAwB;IAC1D,YAAY,KAAoB;QAC9B,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEe,MAAM;QACpB,MAAM,SAAS,GAAG,UAAU,CAC1B,gBAAgB,EAChB,IAAI,CAAC,KAAK,CAAC,SAAS,IAAI,YAAY,EACpC,IAAI,CAAC,KAAK,CAAC,UAAU,IAA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,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC,CAAC;CACH","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.js\";\nimport type { CommonProps } from \"../utils/Props.js\";\nimport { ExpansionToggle } from \"./ExpansionToggle.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\ntype CheckboxProps = React.ComponentPropsWithoutRef<typeof Checkbox>;\n\n/** Props for node Checkbox renderer\n * @public\n * @deprecated in 4.16.0. Type is inlined in component props. Use `React.ComponentProps` type helper instead.\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 * @deprecated in 4.16.0. Type is inlined in component props. Use `React.ComponentProps` type helper instead.\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 * @deprecated in 4.15.0. Used in deprecated {@link TreeNodeProps} props.\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 * @deprecated in 4.15.0. Props of deprecated {@link TreeNode} component.\n */\nexport interface TreeNodeProps extends CommonProps {\n label: React.ReactNode;\n level: number;\n icon?: React.ReactElement | string | number;\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 * @deprecated in 4.15.0. Use {@link https://itwinui.bentley.com/docs/tree iTwinUI Tree} instead.\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"]}
@@ -15,10 +15,7 @@ import { Rectangle } from "../utils/Rectangle.js";
15
15
  */
16
16
  // eslint-disable-next-line @typescript-eslint/no-deprecated
17
17
  export class Tree extends React.PureComponent {
18
- constructor() {
19
- super(...arguments);
20
- this._treeElement = React.createRef();
21
- }
18
+ _treeElement = React.createRef();
22
19
  get _scrollableContainer() {
23
20
  if (!this._treeElement.current)
24
21
  return undefined;
@@ -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,uBAAuB,CAAC;AAgBlD;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,OAAO,IAAK,SAAQ,KAAK,CAAC,aAAwB;IAAxD;;QACU,iBAAY,GAClB,KAAK,CAAC,SAAS,EAAE,CAAC;IA8HtB,CAAC;IA5HC,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,CAAC,QAAQ,KAAK,QAAQ;gBAC3B,KAAK,CAAC,SAAS,KAAK,MAAM;gB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AAC;QACrC,OAAO,QAAQ,CAAC;IAClB,CAAC;IACM,mBAAmB,CAAC,QAAgB;QACzC,IAAI,MAAM,GAAG,KAAK,CAAC;QACnB,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;YAC9B,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,aAAa,CACrD,QAAQ,CACM,CAAC;YACjB,IAAI,OAAO,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAC7B,OAAO,CAAC,KAAK,EAAE,CAAC;gBAChB,MAAM,GAAG,IAAI,CAAC;YAChB,CAAC;QACH,CAAC;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.js\";\nimport { Rectangle } from \"../utils/Rectangle.js\";\n\n/** Properties for the [[Tree]] presentational React component\n * @public\n * @deprecated in 4.15.0. Props of deprecated {@link Tree} component.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\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 * @deprecated in 4.15.0. Use {@link https://itwinui.bentley.com/docs/tree iTwinUI Tree} instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class Tree extends React.PureComponent<TreeProps> {\n private _treeElement: React.RefObject<HTMLDivElement | null> =\n 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 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 elements = new Array<Element>();\n const collection =\n this._treeElement.current.getElementsByClassName(className);\n for (let i = 0; i < collection.length; ++i)\n elements.push(collection.item(i)!);\n return elements;\n }\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 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,Y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C,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.js\";\nimport { Rectangle } from \"../utils/Rectangle.js\";\n\n/** Properties for the [[Tree]] presentational React component\n * @public\n * @deprecated in 4.15.0. Props of deprecated {@link Tree} component.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\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 * @deprecated in 4.15.0. Use {@link https://itwinui.bentley.com/docs/tree iTwinUI Tree} instead.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class Tree extends React.PureComponent<TreeProps> {\n private _treeElement: React.RefObject<HTMLDivElement | null> =\n 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 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 elements = new Array<Element>();\n const collection =\n this._treeElement.current.getElementsByClassName(className);\n for (let i = 0; i < collection.length; ++i)\n elements.push(collection.item(i)!);\n return elements;\n }\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 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"]}
@@ -12,6 +12,7 @@ import { UiStateStorageStatus } from "./UiStateStorage.js";
12
12
  * @deprecated in 4.16.0. Use {@link @itwin/appui-react#LocalStateStorage} instead.
13
13
  */
14
14
  export class LocalStateStorage {
15
+ w;
15
16
  constructor(w = window) {
16
17
  this.w = w;
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"LocalStateStorage.js","sourceRoot":"","sources":["../../../src/core-react/uistate/LocalStateStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,qDAAqD;AAErD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IAC5B,YAAmB,IAAY,MAAM;QAAlB,MAAC,GAAD,CAAC,CAAiB;IAAG,CAAC;IAElC,KAAK,CAAC,UAAU,CACrB,gBAAwB,EACxB,WAAmB;QAEnB,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CACzC,GAAG,gBAAgB,IAAI,WAAW,EAAE,CACrC,CAAC;QACF,IAAI,OAAO,KAAK,IAAI;YAClB,OAAO;gBACL,MAAM,EAAE,oBAAoB,CAAC,OAAO;gBACpC,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;aAC7B,CAAC;;YACC,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC;IACxD,CAAC;IAEM,KAAK,CAAC,WAAW,CACtB,gBAAwB,EACxB,WAAmB,EACnB,OAAY;QAEZ,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CACzB,GAAG,gBAAgB,IAAI,WAAW,EAAE,EACpC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CACxB,CAAC;QACF,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,UAAU,CACrB,gBAAwB,EACxB,WAAmB;QAEnB,MAAM,IAAI,GAAG,GAAG,gBAAgB,IAAI,WAAW,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,KAAK,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,KAAK,CAAC,aAAa,CACxB,gBAAwB,EACxB,WAAmB;QAEnB,MAAM,IAAI,GAAG,GAAG,gBAAgB,IAAI,WAAW,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC;QACvE,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC;IAClD,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.js\";\nimport { UiStateStorageStatus } from \"./UiStateStorage.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Implementation of [[UiStateStorage]] using Window.localStorage.\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/appui-react#LocalStateStorage} instead.\n */\nexport class LocalStateStorage implements UiStateStorage {\n constructor(public w: Window = window) {}\n\n public async getSetting(\n settingNamespace: string,\n settingName: string\n ): Promise<UiStateStorageResult> {\n const setting = this.w.localStorage.getItem(\n `${settingNamespace}.${settingName}`\n );\n if (setting !== null)\n return {\n status: UiStateStorageStatus.Success,\n setting: JSON.parse(setting),\n };\n else return { status: UiStateStorageStatus.NotFound };\n }\n\n public async saveSetting(\n settingNamespace: string,\n settingName: string,\n setting: any\n ): Promise<UiStateStorageResult> {\n this.w.localStorage.setItem(\n `${settingNamespace}.${settingName}`,\n JSON.stringify(setting)\n );\n return { status: UiStateStorageStatus.Success };\n }\n\n public async hasSetting(\n settingNamespace: string,\n settingName: string\n ): Promise<boolean> {\n const name = `${settingNamespace}.${settingName}`;\n const setting = this.w.localStorage.getItem(name);\n if (setting === null) return false;\n return true;\n }\n\n public async deleteSetting(\n settingNamespace: string,\n settingName: string\n ): Promise<UiStateStorageResult> {\n const name = `${settingNamespace}.${settingName}`;\n const setting = this.w.localStorage.getItem(name);\n if (setting === null) return { status: UiStateStorageStatus.NotFound };\n this.w.localStorage.removeItem(name);\n return { status: UiStateStorageStatus.Success };\n }\n}\n"]}
1
+ {"version":3,"file":"LocalStateStorage.js","sourceRoot":"","sources":["../../../src/core-react/uistate/LocalStateStorage.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,qDAAqD;AAErD;;;GAGG;AACH,MAAM,OAAO,iBAAiB;IACT;IAAnB,YAA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;QAClD,IAAI,OAAO,KAAK,IAAI;YAAE,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,QAAQ,EAAE,CAAC;QACvE,IAAI,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QACrC,OAAO,EAAE,MAAM,EAAE,oBAAoB,CAAC,OAAO,EAAE,CAAC;IAClD,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.js\";\nimport { UiStateStorageStatus } from \"./UiStateStorage.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Implementation of [[UiStateStorage]] using Window.localStorage.\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/appui-react#LocalStateStorage} instead.\n */\nexport class LocalStateStorage implements UiStateStorage {\n constructor(public w: Window = window) {}\n\n public async getSetting(\n settingNamespace: string,\n settingName: string\n ): Promise<UiStateStorageResult> {\n const setting = this.w.localStorage.getItem(\n `${settingNamespace}.${settingName}`\n );\n if (setting !== null)\n return {\n status: UiStateStorageStatus.Success,\n setting: JSON.parse(setting),\n };\n else return { status: UiStateStorageStatus.NotFound };\n }\n\n public async saveSetting(\n settingNamespace: string,\n settingName: string,\n setting: any\n ): Promise<UiStateStorageResult> {\n this.w.localStorage.setItem(\n `${settingNamespace}.${settingName}`,\n JSON.stringify(setting)\n );\n return { status: UiStateStorageStatus.Success };\n }\n\n public async hasSetting(\n settingNamespace: string,\n settingName: string\n ): Promise<boolean> {\n const name = `${settingNamespace}.${settingName}`;\n const setting = this.w.localStorage.getItem(name);\n if (setting === null) return false;\n return true;\n }\n\n public async deleteSetting(\n settingNamespace: string,\n settingName: string\n ): Promise<UiStateStorageResult> {\n const name = `${settingNamespace}.${settingName}`;\n const setting = this.w.localStorage.getItem(name);\n if (setting === null) return { status: UiStateStorageStatus.NotFound };\n this.w.localStorage.removeItem(name);\n return { status: UiStateStorageStatus.Success };\n }\n}\n"]}