@itwin/core-react 5.19.0 → 5.21.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.
- package/CHANGELOG.md +4 -0
- package/lib/core-react/UiCore.js +2 -1
- package/lib/core-react/UiCore.js.map +1 -1
- package/lib/core-react/autosuggest/AutoSuggest.js +86 -86
- package/lib/core-react/autosuggest/AutoSuggest.js.map +1 -1
- package/lib/core-react/contextmenu/ContextMenu.js +272 -269
- package/lib/core-react/contextmenu/ContextMenu.js.map +1 -1
- package/lib/core-react/contextmenu/ContextMenuItem.js +57 -55
- package/lib/core-react/contextmenu/ContextMenuItem.js.map +1 -1
- package/lib/core-react/contextmenu/ContextSubMenu.js +70 -67
- package/lib/core-react/contextmenu/ContextSubMenu.js.map +1 -1
- package/lib/core-react/contextmenu/GlobalContextMenu.js +23 -22
- package/lib/core-react/contextmenu/GlobalContextMenu.js.map +1 -1
- package/lib/core-react/contextmenu/TildeFinder.js +52 -52
- package/lib/core-react/contextmenu/TildeFinder.js.map +1 -1
- package/lib/core-react/dialog/Dialog.js +29 -29
- package/lib/core-react/dialog/Dialog.js.map +1 -1
- package/lib/core-react/dialog/GlobalDialog.js +24 -23
- package/lib/core-react/dialog/GlobalDialog.js.map +1 -1
- package/lib/core-react/expandable/ExpandableList.js +15 -15
- package/lib/core-react/expandable/ExpandableList.js.map +1 -1
- package/lib/core-react/focus/ItemKeyboardNavigator.js +7 -3
- package/lib/core-react/focus/ItemKeyboardNavigator.js.map +1 -1
- package/lib/core-react/hocs/withIsPressed.js +14 -17
- package/lib/core-react/hocs/withIsPressed.js.map +1 -1
- package/lib/core-react/hocs/withOnOutsideClick.js +38 -41
- package/lib/core-react/hocs/withOnOutsideClick.js.map +1 -1
- package/lib/core-react/hocs/withTimeout.js +2 -5
- package/lib/core-react/hocs/withTimeout.js.map +1 -1
- package/lib/core-react/icons/ConditionalIconItem.js +3 -0
- package/lib/core-react/icons/ConditionalIconItem.js.map +1 -1
- package/lib/core-react/imagecheckbox/ImageCheckBox.js +15 -18
- package/lib/core-react/imagecheckbox/ImageCheckBox.js.map +1 -1
- package/lib/core-react/loading/LoadingBar.js +3 -3
- package/lib/core-react/loading/LoadingBar.js.map +1 -1
- package/lib/core-react/loading/LoadingPrompt.js +9 -9
- package/lib/core-react/loading/LoadingPrompt.js.map +1 -1
- package/lib/core-react/loading/LoadingSpinner.js +3 -3
- package/lib/core-react/loading/LoadingSpinner.js.map +1 -1
- package/lib/core-react/loading/LoadingStatus.js +4 -4
- package/lib/core-react/loading/LoadingStatus.js.map +1 -1
- package/lib/core-react/messagebox/MessageBox.js +6 -6
- package/lib/core-react/messagebox/MessageBox.js.map +1 -1
- package/lib/core-react/popup/Popup.js +209 -209
- package/lib/core-react/popup/Popup.js.map +1 -1
- package/lib/core-react/radialmenu/Annulus.js +19 -2
- package/lib/core-react/radialmenu/Annulus.js.map +1 -1
- package/lib/core-react/radialmenu/RadialMenu.js +56 -56
- package/lib/core-react/radialmenu/RadialMenu.js.map +1 -1
- package/lib/core-react/searchbox/SearchBox.js +60 -60
- package/lib/core-react/searchbox/SearchBox.js.map +1 -1
- package/lib/core-react/settings/SettingsManager.js +20 -22
- package/lib/core-react/settings/SettingsManager.js.map +1 -1
- package/lib/core-react/tabs/Tabs.js +14 -13
- package/lib/core-react/tabs/Tabs.js.map +1 -1
- package/lib/core-react/tree/Node.js +18 -18
- package/lib/core-react/tree/Node.js.map +1 -1
- package/lib/core-react/tree/Tree.js +1 -4
- package/lib/core-react/tree/Tree.js.map +1 -1
- package/lib/core-react/uistate/LocalStateStorage.js +1 -0
- package/lib/core-react/uistate/LocalStateStorage.js.map +1 -1
- package/lib/core-react/uistate/UiStateEntry.js +5 -0
- package/lib/core-react/uistate/UiStateEntry.js.map +1 -1
- package/lib/core-react/utils/Point.js +2 -0
- package/lib/core-react/utils/Point.js.map +1 -1
- package/lib/core-react/utils/Rectangle.js +4 -0
- package/lib/core-react/utils/Rectangle.js.map +1 -1
- package/lib/core-react/utils/ScrollPositionMaintainer.js +1 -0
- package/lib/core-react/utils/ScrollPositionMaintainer.js.map +1 -1
- package/lib/core-react/utils/Timer.js +5 -2
- package/lib/core-react/utils/Timer.js.map +1 -1
- package/package.json +3 -3
|
@@ -12,6 +12,11 @@ import { UiStateStorageStatus } from "./UiStateStorage.js";
|
|
|
12
12
|
* @deprecated in 4.16.0. Use {@link UiStateStorage} APIs instead.
|
|
13
13
|
*/
|
|
14
14
|
export class UiStateEntry {
|
|
15
|
+
settingNamespace;
|
|
16
|
+
settingName;
|
|
17
|
+
getValue;
|
|
18
|
+
applyValue;
|
|
19
|
+
defaultValue;
|
|
15
20
|
/** Constructor
|
|
16
21
|
* @param settingNamespace Namespace for the setting, passed to UiStateStorage.
|
|
17
22
|
* @param settingName Name for the setting, passed to UiStateStorage.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiStateEntry.js","sourceRoot":"","sources":["../../../src/core-react/uistate/UiStateEntry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,qDAAqD;AAErD;;;GAGG;AACH,MAAM,OAAO,YAAY;
|
|
1
|
+
{"version":3,"file":"UiStateEntry.js","sourceRoot":"","sources":["../../../src/core-react/uistate/UiStateEntry.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAE3D,qDAAqD;AAErD;;;GAGG;AACH,MAAM,OAAO,YAAY;IASd;IACA;IACA;IACA;IACA;IAZT;;;;;;OAMG;IACH,YACS,gBAAwB,EACxB,WAAmB,EACnB,QAAiB,EACjB,UAA2B,EAC3B,YAAgB;QAJhB,qBAAgB,GAAhB,gBAAgB,CAAQ;QACxB,gBAAW,GAAX,WAAW,CAAQ;QACnB,aAAQ,GAAR,QAAQ,CAAS;QACjB,eAAU,GAAV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","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/** A single UI State entry that is identified by namespace and setting name.\n * @public\n * @deprecated in 4.16.0. Use {@link UiStateStorage} APIs instead.\n */\nexport class UiStateEntry<T> {\n /** Constructor\n * @param settingNamespace Namespace for the setting, passed to UiStateStorage.\n * @param settingName Name for the setting, passed to UiStateStorage.\n * @param getValue Function for getting the value from the application.\n * @param applyValue Function for applying the setting value to the application.\n * @param defaultValue Optional default value if not already stored.\n */\n public constructor(\n public settingNamespace: string,\n public settingName: string,\n public getValue: () => T,\n public applyValue?: (v: T) => void,\n public defaultValue?: T\n ) {}\n\n /** Gets the setting from [[UiStateStorage]] */\n public async getSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.getSetting(this.settingNamespace, this.settingName);\n }\n\n /** Saves the setting value from the `getValue` function to UiStateStorage */\n public async saveSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.saveSetting(\n this.settingNamespace,\n this.settingName,\n this.getValue()\n );\n }\n\n /** Deletes the setting from UiStateStorage */\n public async deleteSetting(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n return storage.deleteSetting(this.settingNamespace, this.settingName);\n }\n\n /** Gets the setting from UiStateStorage and applies the value using the `applyValue` function */\n public async getSettingAndApplyValue(\n storage: UiStateStorage\n ): Promise<UiStateStorageResult> {\n if (this.applyValue) {\n const result = await this.getSetting(storage);\n if (result.status === UiStateStorageStatus.Success) {\n this.applyValue(result.setting);\n } else if (undefined !== this.defaultValue) {\n this.applyValue(this.defaultValue);\n result.setting = this.defaultValue;\n result.status = UiStateStorageStatus.Success;\n }\n return result;\n }\n return { status: UiStateStorageStatus.Uninitialized };\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Point.js","sourceRoot":"","sources":["../../../src/core-react/utils/Point.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH;;GAEG;AACH,MAAM,OAAO,KAAK;
|
|
1
|
+
{"version":3,"file":"Point.js","sourceRoot":"","sources":["../../../src/core-react/utils/Point.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAIH;;GAEG;AACH,MAAM,OAAO,KAAK;IAOmB;IAAuB;IAN1D,oCAAoC;IAC7B,MAAM,CAAC,MAAM,CAAC,UAAsB;QACzC,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IAC/C,CAAC;IAED,2BAA2B;IAC3B,YAAmC,IAAI,CAAC,EAAkB,IAAI,CAAC;QAA5B,MAAC,GAAD,CAAC,CAAI;QAAkB,MAAC,GAAD,CAAC,CAAI;IAAG,CAAC;IAEnE,oDAAoD;IAC7C,aAAa,CAAC,KAAiB;QACpC,MAAM,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QACvC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAClE,CAAC;IAED,kCAAkC;IAC3B,WAAW,CAAC,KAAiB;QAClC,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;IACvD,CAAC;IAED,oEAAoE;IAC7D,MAAM,CAAC,MAAkB;QAC9B,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;IACzD,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,MAAc;QAC3B,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;IAED,8DAA8D;IACvD,OAAO,CAAC,MAAc;QAC3B,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IAC5C,CAAC;IAED,oEAAoE;IAC7D,MAAM,CAAC,KAAiB;QAC7B,OAAO,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC;IAClD,CAAC;IAED,oDAAoD;IAC7C,IAAI,CAAC,CAAS;QACnB,OAAO,IAAI,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,oDAAoD;IAC7C,IAAI,CAAC,CAAS;QACnB,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9B,CAAC;IAED,8EAA8E;IACvE,QAAQ,CAAC,MAAc;QAC5B,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;IACrD,CAAC;IAED,iDAAiD;IAC1C,OAAO;QACZ,OAAO;YACL,CAAC,EAAE,IAAI,CAAC,CAAC;YACT,CAAC,EAAE,IAAI,CAAC,CAAC;SACV,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 Utilities\n */\n\nimport type { PointProps } from \"./PointProps.js\";\n\n/** Describes and provides methods to work with 2d points.\n * @internal\n */\nexport class Point implements PointProps {\n /** Creates point from PointProps */\n public static create(pointProps: PointProps) {\n return new Point(pointProps.x, pointProps.y);\n }\n\n /** Creates a new point. */\n public constructor(public readonly x = 0, public readonly y = 0) {}\n\n /** Calculates Euclidean distance to other point. */\n public getDistanceTo(other: PointProps): number {\n const offset = this.getOffsetTo(other);\n return Math.sqrt(Math.pow(offset.x, 2) + Math.pow(offset.y, 2));\n }\n\n /** Gets offset to other point. */\n public getOffsetTo(other: PointProps) {\n return new Point(other.x - this.x, other.y - this.y);\n }\n\n /** @returns New [[Point]] that is offset along the X and Y axes. */\n public offset(offset: PointProps) {\n return new Point(this.x + offset.x, this.y + offset.y);\n }\n\n /** @returns New [[Point]] that is offset along the X axis. */\n public offsetX(offset: number) {\n return new Point(this.x + offset, this.y);\n }\n\n /** @returns New [[Point]] that is offset along the Y axis. */\n public offsetY(offset: number) {\n return new Point(this.x, this.y + offset);\n }\n\n /** @returns True if position of this and other points are equal. */\n public equals(other: PointProps) {\n return other.x === this.x && other.y === this.y;\n }\n\n /** @returns New [[Point]] with modified x value. */\n public setX(x: number) {\n return new Point(x, this.y);\n }\n\n /** @returns New [[Point]] with modified y value. */\n public setY(y: number) {\n return new Point(this.x, y);\n }\n\n /** @returns New [[Point]] with coordinates multiplied by specified factor. */\n public multiply(factor: number) {\n return new Point(this.x * factor, this.y * factor);\n }\n\n /** @returns PointProps object for this point. */\n public toProps(): PointProps {\n return {\n x: this.x,\n y: this.y,\n };\n }\n}\n"]}
|
|
@@ -20,6 +20,10 @@ export var Corner;
|
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
22
|
export class Rectangle {
|
|
23
|
+
left;
|
|
24
|
+
top;
|
|
25
|
+
right;
|
|
26
|
+
bottom;
|
|
23
27
|
/** Creates rectangle from [[RectangleProps]]. */
|
|
24
28
|
static create(props) {
|
|
25
29
|
return new Rectangle(props.left, props.top, props.right, props.bottom);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rectangle.js","sourceRoot":"","sources":["../../../src/core-react/utils/Rectangle.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBnC;;GAEG;AACH,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,yCAAO,CAAA;IACP,2CAAQ,CAAA;IACR,iDAAW,CAAA;IACX,+CAAU,CAAA;AACZ,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AAED;;GAEG;AACH,MAAM,OAAO,SAAS;IACpB,iDAAiD;IAC1C,MAAM,CAAC,MAAM,CAAC,KAAqB;QACxC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzE,CAAC;IAED,4CAA4C;IACrC,MAAM,CAAC,cAAc,CAAC,IAAe;QAC1C,OAAO,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,sHAAsH;IAC/G,MAAM,CAAC,UAAU,CACtB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU;QAEV,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAChB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAChB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,EAChB,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CACjB,CAAC;IACJ,CAAC;IAED,+CAA+C;IAC/C,YACkB,OAAO,CAAC,E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IAAI,CAAC,KAAK,EAAE,CAAC;YACjC,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG;gBAAE,gBAAgB,GAAG,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;iBACzD,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM;gBAAE,gBAAgB,GAAG,CAAC,CAAC;;gBACjD,gBAAgB,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;QAChD,CAAC;aAAM,CAAC;YACN,IAAI,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG;gBACpB,gBAAgB,GAAG,YAAY,CAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,EACpB,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CACnB,CAAC;iBACC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,MAAM;gBAAE,gBAAgB,GAAG,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;;gBAEvE,gBAAgB,GAAG,YAAY,CAC7B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,CAAC,EACpB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,CACtB,CAAC;QACN,CAAC;QAED,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,6DAA6D;IACtD,OAAO;QACZ,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;IACJ,CAAC;CACF;AAED,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,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 Utilities\n */\n\nimport { Point } from \"./Point.js\";\nimport type { PointProps } from \"./PointProps.js\";\nimport type { SizeProps } from \"./Size.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Describes 2d bounds.\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/appui-react#RectangleProps} instead.\n */\nexport interface RectangleProps {\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\n/** Available corners of [[Rectangle]].\n * @internal\n */\nexport enum Corner {\n TopLeft,\n TopRight,\n BottomRight,\n BottomLeft,\n}\n\n/** Describes and provides methods to work with 2d bounds.\n * @internal\n */\nexport class Rectangle implements RectangleProps {\n /** Creates rectangle from [[RectangleProps]]. */\n public static create(props: RectangleProps): Rectangle {\n return new Rectangle(props.left, props.top, props.right, props.bottom);\n }\n\n /** Creates rectangle from [[SizeProps]]. */\n public static createFromSize(size: SizeProps): Rectangle {\n return new Rectangle(0, 0, size.width, size.height);\n }\n\n /** Create a rectangle with 2 pairs of xy candidates. Theses are compared and shuffled as needed for the rectangle. */\n public static createXYXY(\n xA: number,\n yA: number,\n xB: number,\n yB: number\n ): Rectangle {\n return new Rectangle(\n Math.min(xA, xB),\n Math.min(yA, yB),\n Math.max(xA, xB),\n Math.max(yA, yB)\n );\n }\n\n /** Creates rectangle with specified bounds. */\n public constructor(\n public readonly left = 0,\n public readonly top = 0,\n public readonly right = 0,\n public readonly bottom = 0\n ) {}\n\n /** @returns Size of this rectangle. */\n public getSize(): SizeProps {\n const width = this.getWidth();\n const height = this.getHeight();\n return { width, height };\n }\n\n /** @returns Width of this rectangle. */\n public getWidth(): number {\n return this.right - this.left;\n }\n\n /** @returns Height of this rectangle. */\n public getHeight(): number {\n return this.bottom - this.top;\n }\n\n /** @returns Position of specified corner. */\n public getCorner(corner: Corner): Point {\n switch (corner) {\n case Corner.TopLeft: {\n return this.topLeft();\n }\n case Corner.TopRight: {\n return new Point(this.right, this.top);\n }\n case Corner.BottomLeft: {\n return new Point(this.left, this.bottom);\n }\n case Corner.BottomRight: {\n return new Point(this.right, this.bottom);\n }\n }\n }\n\n /**\n * Inset the bounds of this rectangle.\n * @note Negative arguments will increase the size of rectangle.\n * @returns New [[Rectangle]] with modified bounds.\n */\n public inset(\n left: number,\n top: number,\n right: number,\n bottom: number\n ): Rectangle {\n return new Rectangle(\n this.left + left,\n this.top + top,\n this.right - right,\n this.bottom - bottom\n );\n }\n\n /**\n * Offsets the rectangle along the X and Y axes.\n * @returns New [[Rectangle]] with modified position.\n */\n public offset(offset: PointProps): Rectangle {\n return new Rectangle(\n this.left + offset.x,\n this.top + offset.y,\n this.right + offset.x,\n this.bottom + offset.y\n );\n }\n\n /**\n * Offsets the rectangle along the X axis.\n * @returns New [[Rectangle]] with modified position along X axis.\n */\n public offsetX(offset: number): Rectangle {\n return new Rectangle(\n this.left + offset,\n this.top,\n this.right + offset,\n this.bottom\n );\n }\n\n /**\n * Offsets the rectangle along the Y axis.\n * @returns New [[Rectangle]] with modified position along Y axis.\n */\n public offsetY(offset: number): Rectangle {\n return new Rectangle(\n this.left,\n this.top + offset,\n this.right,\n this.bottom + offset\n );\n }\n\n /**\n * Moves the top left corner of rectangle to specified point.\n * @returns New [[Rectangle]] with modified position.\n */\n public setPosition(position: PointProps): Rectangle {\n return new Rectangle(\n position.x,\n position.y,\n position.x + this.getWidth(),\n position.y + this.getHeight()\n );\n }\n\n /**\n * Sets the height of the rectangle.\n * @note Only [[Edge.Bottom]] is subject to change.\n * @returns New [[Rectangle]] with modified height.\n */\n public setHeight(height: number): Rectangle {\n return new Rectangle(this.left, this.top, this.right, this.top + height);\n }\n\n /**\n * Sets the width of the rectangle.\n * @note Only [[Edge.Right]] is subject to change.\n * @returns New [[Rectangle]] with modified width.\n */\n public setWidth(width: number): Rectangle {\n return new Rectangle(this.left, this.top, this.left + width, this.bottom);\n }\n\n /**\n * Sets the height and width of the rectangle.\n * @note Only [[Edge.Bottom]] and [[Edge.Right]] are subjects to change.\n * @returns New [[Rectangle]] with modified height.\n */\n public setSize(size: SizeProps): Rectangle {\n return new Rectangle(\n this.left,\n this.top,\n this.left + size.width,\n this.top + size.height\n );\n }\n\n /** Checks if bounds of two rectangles match. */\n public equals(other: RectangleProps): boolean {\n if (\n this.left === other.left &&\n this.top === other.top &&\n this.right === other.right &&\n this.bottom === other.bottom\n )\n return true;\n\n return false;\n }\n\n /**\n * Checks if point is within bounds of the rectangle.\n * @note Inclusive.\n */\n public containsPoint(point: PointProps): boolean {\n return (\n point.x >= this.left &&\n point.x <= this.right &&\n point.y >= this.top &&\n point.y <= this.bottom\n );\n }\n\n /**\n * Checks if a point given as x,y is within the rectangle.\n * @note Inclusive.\n */\n public containsXY(x: number, y: number): boolean {\n return this.containsPoint({ x, y });\n }\n\n /**\n * @returns true if this rectangle contains other rectangle.\n * @note Inclusive.\n */\n public contains(other: RectangleProps): boolean {\n return (\n other.left >= this.left &&\n other.right <= this.right &&\n other.top >= this.top &&\n other.bottom <= this.bottom\n );\n }\n\n /** @returns New [[Rectangle]] which is contained in other rectangle. */\n public containIn(other: RectangleProps): Rectangle {\n let contained: Rectangle = this.containVerticallyIn(other);\n contained = contained.containHorizontallyIn(other);\n return contained;\n }\n\n /** @returns New [[Rectangle]] which is vertically contained in other rectangle. */\n public containVerticallyIn(other: RectangleProps): Rectangle {\n const contained = this.offsetY(Math.min(other.bottom - this.bottom, 0));\n return contained.offsetY(Math.max(other.top - contained.top, 0));\n }\n\n /** @returns New [[Rectangle]] which is horizontally contained in other rectangle. */\n public containHorizontallyIn(other: RectangleProps): Rectangle {\n const contained = this.offsetX(Math.min(other.right - this.right, 0));\n return contained.offsetX(Math.max(other.left - contained.left, 0));\n }\n\n /** @returns [[Corner.TopLeft]] position of this rectangle. */\n public topLeft(): Point {\n return new Point(this.left, this.top);\n }\n\n /** @returns Center point position of this rectangle. */\n public center(): Point {\n const x = this.left + (this.right - this.left) / 2;\n const y = this.top + (this.bottom - this.top) / 2;\n return new Point(x, y);\n }\n\n /** @returns true if this rectangle intersects other rectangle. */\n public intersects(other: RectangleProps): boolean {\n return (\n this.left < other.right &&\n this.right > other.left &&\n this.top < other.bottom &&\n this.bottom > other.top\n );\n }\n\n /**\n * Merges outer edges of this and other rectangles.\n * @returns New [[Rectangle]] with merged bounds.\n */\n public outerMergeWith(other: RectangleProps): Rectangle {\n const left = Math.min(this.left, other.left);\n const top = Math.min(this.top, other.top);\n const right = Math.max(this.right, other.right);\n const bottom = Math.max(this.bottom, other.bottom);\n return new Rectangle(left, top, right, bottom);\n }\n\n /**\n * Vertically divides this rectangle into specified number of equal height segments.\n * @returns Vertical rectangle segment.\n */\n public getVerticalSegmentBounds(\n segmentId: number,\n numberOfSegments: number\n ): Rectangle {\n const segmentHeight = this.getHeight() / numberOfSegments;\n\n const top = segmentId * segmentHeight;\n return this.inset(0, top, 0, 0).setHeight(segmentHeight);\n }\n\n /**\n * Horizontally divides this rectangle into specified number of equal width segments.\n * @returns Horizontal rectangle segment.\n */\n public getHorizontalSegmentBounds(\n segmentId: number,\n numberOfSegments: number\n ): Rectangle {\n const segmentWidth = this.getWidth() / numberOfSegments;\n\n const left = segmentId * segmentWidth;\n return this.inset(left, 0, 0, 0).setWidth(segmentWidth);\n }\n\n /**\n * Calculates the shortest distance between this rectangle and a given point.\n * @returns The shortest distance to a point.\n */\n public getShortestDistanceToPoint(point: PointProps): number {\n let shortestDistance = 0;\n\n if (point.x < this.left) {\n if (point.y < this.top)\n shortestDistance = hypotenuseXY(\n this.left - point.x,\n this.top - point.y\n );\n else if (point.y <= this.bottom) shortestDistance = this.left - point.x;\n else\n shortestDistance = hypotenuseXY(\n this.left - point.x,\n this.bottom - point.y\n );\n } else if (point.x <= this.right) {\n if (point.y < this.top) shortestDistance = this.top - point.y;\n else if (point.y <= this.bottom) shortestDistance = 0;\n else shortestDistance = point.y - this.bottom;\n } else {\n if (point.y < this.top)\n shortestDistance = hypotenuseXY(\n this.right - point.x,\n this.top - point.y\n );\n else if (point.y <= this.bottom) shortestDistance = point.x - this.right;\n else\n shortestDistance = hypotenuseXY(\n this.right - point.x,\n this.bottom - point.y\n );\n }\n\n return shortestDistance;\n }\n\n /** @returns [[RectangleProps]] object for this rectangle. */\n public toProps(): RectangleProps {\n return {\n bottom: this.bottom,\n left: this.left,\n right: this.right,\n top: this.top,\n };\n }\n}\n\nfunction hypotenuseXY(x: number, y: number): number {\n return Math.sqrt(x * x + y * y);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Rectangle.js","sourceRoot":"","sources":["../../../src/core-react/utils/Rectangle.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAiBnC;;GAEG;AACH,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,yCAAO,CAAA;IACP,2CAAQ,CAAA;IACR,iDAAW,CAAA;IACX,+CAAU,CAAA;AACZ,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB;AAED;;GAEG;AACH,MAAM,OAAO,SAAS;IA4BF;IACA;IACA;IACA;IA9BlB,iDAAiD;IAC1C,MAAM,CAAC,MAAM,CAAC,KAAqB;QACxC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACzE,CAAC;IAED,4CAA4C;IACrC,MAAM,CAAC,cAAc,CAAC,IAAe;QAC1C,OAAO,IAAI,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED,sHAAsH;IAC/G,MAAM,CAAC,UAAU,CACtB,EAAU,EACV,EAAU,EACV,EAAU,EACV,EAAU;QAEV,OAAO,IA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,IAAI;YACf,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC;IACJ,CAAC;CACF;AAED,SAAS,YAAY,CAAC,CAAS,EAAE,CAAS;IACxC,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;AAClC,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 Utilities\n */\n\nimport { Point } from \"./Point.js\";\nimport type { PointProps } from \"./PointProps.js\";\nimport type { SizeProps } from \"./Size.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** Describes 2d bounds.\n * @public\n * @deprecated in 4.16.0. Use {@link @itwin/appui-react#RectangleProps} instead.\n */\nexport interface RectangleProps {\n readonly left: number;\n readonly top: number;\n readonly right: number;\n readonly bottom: number;\n}\n\n/** Available corners of [[Rectangle]].\n * @internal\n */\nexport enum Corner {\n TopLeft,\n TopRight,\n BottomRight,\n BottomLeft,\n}\n\n/** Describes and provides methods to work with 2d bounds.\n * @internal\n */\nexport class Rectangle implements RectangleProps {\n /** Creates rectangle from [[RectangleProps]]. */\n public static create(props: RectangleProps): Rectangle {\n return new Rectangle(props.left, props.top, props.right, props.bottom);\n }\n\n /** Creates rectangle from [[SizeProps]]. */\n public static createFromSize(size: SizeProps): Rectangle {\n return new Rectangle(0, 0, size.width, size.height);\n }\n\n /** Create a rectangle with 2 pairs of xy candidates. Theses are compared and shuffled as needed for the rectangle. */\n public static createXYXY(\n xA: number,\n yA: number,\n xB: number,\n yB: number\n ): Rectangle {\n return new Rectangle(\n Math.min(xA, xB),\n Math.min(yA, yB),\n Math.max(xA, xB),\n Math.max(yA, yB)\n );\n }\n\n /** Creates rectangle with specified bounds. */\n public constructor(\n public readonly left = 0,\n public readonly top = 0,\n public readonly right = 0,\n public readonly bottom = 0\n ) {}\n\n /** @returns Size of this rectangle. */\n public getSize(): SizeProps {\n const width = this.getWidth();\n const height = this.getHeight();\n return { width, height };\n }\n\n /** @returns Width of this rectangle. */\n public getWidth(): number {\n return this.right - this.left;\n }\n\n /** @returns Height of this rectangle. */\n public getHeight(): number {\n return this.bottom - this.top;\n }\n\n /** @returns Position of specified corner. */\n public getCorner(corner: Corner): Point {\n switch (corner) {\n case Corner.TopLeft: {\n return this.topLeft();\n }\n case Corner.TopRight: {\n return new Point(this.right, this.top);\n }\n case Corner.BottomLeft: {\n return new Point(this.left, this.bottom);\n }\n case Corner.BottomRight: {\n return new Point(this.right, this.bottom);\n }\n }\n }\n\n /**\n * Inset the bounds of this rectangle.\n * @note Negative arguments will increase the size of rectangle.\n * @returns New [[Rectangle]] with modified bounds.\n */\n public inset(\n left: number,\n top: number,\n right: number,\n bottom: number\n ): Rectangle {\n return new Rectangle(\n this.left + left,\n this.top + top,\n this.right - right,\n this.bottom - bottom\n );\n }\n\n /**\n * Offsets the rectangle along the X and Y axes.\n * @returns New [[Rectangle]] with modified position.\n */\n public offset(offset: PointProps): Rectangle {\n return new Rectangle(\n this.left + offset.x,\n this.top + offset.y,\n this.right + offset.x,\n this.bottom + offset.y\n );\n }\n\n /**\n * Offsets the rectangle along the X axis.\n * @returns New [[Rectangle]] with modified position along X axis.\n */\n public offsetX(offset: number): Rectangle {\n return new Rectangle(\n this.left + offset,\n this.top,\n this.right + offset,\n this.bottom\n );\n }\n\n /**\n * Offsets the rectangle along the Y axis.\n * @returns New [[Rectangle]] with modified position along Y axis.\n */\n public offsetY(offset: number): Rectangle {\n return new Rectangle(\n this.left,\n this.top + offset,\n this.right,\n this.bottom + offset\n );\n }\n\n /**\n * Moves the top left corner of rectangle to specified point.\n * @returns New [[Rectangle]] with modified position.\n */\n public setPosition(position: PointProps): Rectangle {\n return new Rectangle(\n position.x,\n position.y,\n position.x + this.getWidth(),\n position.y + this.getHeight()\n );\n }\n\n /**\n * Sets the height of the rectangle.\n * @note Only [[Edge.Bottom]] is subject to change.\n * @returns New [[Rectangle]] with modified height.\n */\n public setHeight(height: number): Rectangle {\n return new Rectangle(this.left, this.top, this.right, this.top + height);\n }\n\n /**\n * Sets the width of the rectangle.\n * @note Only [[Edge.Right]] is subject to change.\n * @returns New [[Rectangle]] with modified width.\n */\n public setWidth(width: number): Rectangle {\n return new Rectangle(this.left, this.top, this.left + width, this.bottom);\n }\n\n /**\n * Sets the height and width of the rectangle.\n * @note Only [[Edge.Bottom]] and [[Edge.Right]] are subjects to change.\n * @returns New [[Rectangle]] with modified height.\n */\n public setSize(size: SizeProps): Rectangle {\n return new Rectangle(\n this.left,\n this.top,\n this.left + size.width,\n this.top + size.height\n );\n }\n\n /** Checks if bounds of two rectangles match. */\n public equals(other: RectangleProps): boolean {\n if (\n this.left === other.left &&\n this.top === other.top &&\n this.right === other.right &&\n this.bottom === other.bottom\n )\n return true;\n\n return false;\n }\n\n /**\n * Checks if point is within bounds of the rectangle.\n * @note Inclusive.\n */\n public containsPoint(point: PointProps): boolean {\n return (\n point.x >= this.left &&\n point.x <= this.right &&\n point.y >= this.top &&\n point.y <= this.bottom\n );\n }\n\n /**\n * Checks if a point given as x,y is within the rectangle.\n * @note Inclusive.\n */\n public containsXY(x: number, y: number): boolean {\n return this.containsPoint({ x, y });\n }\n\n /**\n * @returns true if this rectangle contains other rectangle.\n * @note Inclusive.\n */\n public contains(other: RectangleProps): boolean {\n return (\n other.left >= this.left &&\n other.right <= this.right &&\n other.top >= this.top &&\n other.bottom <= this.bottom\n );\n }\n\n /** @returns New [[Rectangle]] which is contained in other rectangle. */\n public containIn(other: RectangleProps): Rectangle {\n let contained: Rectangle = this.containVerticallyIn(other);\n contained = contained.containHorizontallyIn(other);\n return contained;\n }\n\n /** @returns New [[Rectangle]] which is vertically contained in other rectangle. */\n public containVerticallyIn(other: RectangleProps): Rectangle {\n const contained = this.offsetY(Math.min(other.bottom - this.bottom, 0));\n return contained.offsetY(Math.max(other.top - contained.top, 0));\n }\n\n /** @returns New [[Rectangle]] which is horizontally contained in other rectangle. */\n public containHorizontallyIn(other: RectangleProps): Rectangle {\n const contained = this.offsetX(Math.min(other.right - this.right, 0));\n return contained.offsetX(Math.max(other.left - contained.left, 0));\n }\n\n /** @returns [[Corner.TopLeft]] position of this rectangle. */\n public topLeft(): Point {\n return new Point(this.left, this.top);\n }\n\n /** @returns Center point position of this rectangle. */\n public center(): Point {\n const x = this.left + (this.right - this.left) / 2;\n const y = this.top + (this.bottom - this.top) / 2;\n return new Point(x, y);\n }\n\n /** @returns true if this rectangle intersects other rectangle. */\n public intersects(other: RectangleProps): boolean {\n return (\n this.left < other.right &&\n this.right > other.left &&\n this.top < other.bottom &&\n this.bottom > other.top\n );\n }\n\n /**\n * Merges outer edges of this and other rectangles.\n * @returns New [[Rectangle]] with merged bounds.\n */\n public outerMergeWith(other: RectangleProps): Rectangle {\n const left = Math.min(this.left, other.left);\n const top = Math.min(this.top, other.top);\n const right = Math.max(this.right, other.right);\n const bottom = Math.max(this.bottom, other.bottom);\n return new Rectangle(left, top, right, bottom);\n }\n\n /**\n * Vertically divides this rectangle into specified number of equal height segments.\n * @returns Vertical rectangle segment.\n */\n public getVerticalSegmentBounds(\n segmentId: number,\n numberOfSegments: number\n ): Rectangle {\n const segmentHeight = this.getHeight() / numberOfSegments;\n\n const top = segmentId * segmentHeight;\n return this.inset(0, top, 0, 0).setHeight(segmentHeight);\n }\n\n /**\n * Horizontally divides this rectangle into specified number of equal width segments.\n * @returns Horizontal rectangle segment.\n */\n public getHorizontalSegmentBounds(\n segmentId: number,\n numberOfSegments: number\n ): Rectangle {\n const segmentWidth = this.getWidth() / numberOfSegments;\n\n const left = segmentId * segmentWidth;\n return this.inset(left, 0, 0, 0).setWidth(segmentWidth);\n }\n\n /**\n * Calculates the shortest distance between this rectangle and a given point.\n * @returns The shortest distance to a point.\n */\n public getShortestDistanceToPoint(point: PointProps): number {\n let shortestDistance = 0;\n\n if (point.x < this.left) {\n if (point.y < this.top)\n shortestDistance = hypotenuseXY(\n this.left - point.x,\n this.top - point.y\n );\n else if (point.y <= this.bottom) shortestDistance = this.left - point.x;\n else\n shortestDistance = hypotenuseXY(\n this.left - point.x,\n this.bottom - point.y\n );\n } else if (point.x <= this.right) {\n if (point.y < this.top) shortestDistance = this.top - point.y;\n else if (point.y <= this.bottom) shortestDistance = 0;\n else shortestDistance = point.y - this.bottom;\n } else {\n if (point.y < this.top)\n shortestDistance = hypotenuseXY(\n this.right - point.x,\n this.top - point.y\n );\n else if (point.y <= this.bottom) shortestDistance = point.x - this.right;\n else\n shortestDistance = hypotenuseXY(\n this.right - point.x,\n this.bottom - point.y\n );\n }\n\n return shortestDistance;\n }\n\n /** @returns [[RectangleProps]] object for this rectangle. */\n public toProps(): RectangleProps {\n return {\n bottom: this.bottom,\n left: this.left,\n right: this.right,\n top: this.top,\n };\n }\n}\n\nfunction hypotenuseXY(x: number, y: number): number {\n return Math.sqrt(x * x + y * y);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ScrollPositionMaintainer.js","sourceRoot":"","sources":["../../../src/core-react/utils/ScrollPositionMaintainer.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,4DAA4D;AAC5D,MAAM,OAAO,wBAAwB;
|
|
1
|
+
{"version":3,"file":"ScrollPositionMaintainer.js","sourceRoot":"","sources":["../../../src/core-react/utils/ScrollPositionMaintainer.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;GAYG;AACH,4DAA4D;AAC5D,MAAM,OAAO,wBAAwB;IAC3B,QAAQ,CAAuB;IACvC,YAAmB,EAAW;QAC5B,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAE,CAAC;QAC1B,4DAA4D;QAC5D,wBAAwB,CAAC,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpE,CAAC;IACM,OAAO;QACZ,4DAA4D;QAC5D,wBAAwB,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjE,CAAC;IACO,MAAM,CAAC,mBAAmB,CAChC,QAAoC,EACpC,OAA6B;QAE7B,KAAK,MAAM,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC1B,IAAI,EAAE,CAAC,SAAS;gBAAE,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,CAAC,CAAC;YAChD,IAAI,EAAE,CAAC,QAAQ;gBAAE,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IACO,MAAM,CAAC,sBAAsB,CAAC,OAA6B;QACjE,OAAO,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC,CAAC;IACjE,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\nimport type { IDisposable } from \"@itwin/core-bentley\";\n\n/**\n * A helper class to recursively save and restore scroll positions.\n * Usage:\n * ```ts\n * // scroll positions are saved when `ScrollPositionMaintainer` object is created\n * const maintainer = new ScrollPositionMaintainer(element);\n * // can do something with `element` here\n * // disposing the `maintainer` object restores scroll positions\n * maintainer.dispose();\n * ```\n * @public\n * @deprecated in 4.15.0. Not use by AppUI.\n */\n// eslint-disable-next-line @typescript-eslint/no-deprecated\nexport class ScrollPositionMaintainer implements IDisposable {\n private _storage: Map<Element, number>;\n public constructor(el: Element) {\n this._storage = new Map();\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ScrollPositionMaintainer.saveScrollPositions([el], this._storage);\n }\n public dispose() {\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n ScrollPositionMaintainer.restoreScrollPositions(this._storage);\n }\n private static saveScrollPositions(\n elements: Element[] | HTMLCollection,\n storage: Map<Element, number>\n ) {\n for (const el of elements) {\n if (el.scrollTop) storage.set(el, el.scrollTop);\n if (el.children) this.saveScrollPositions(el.children, storage);\n }\n }\n private static restoreScrollPositions(storage: Map<Element, number>) {\n storage.forEach((scrollTop, el) => (el.scrollTop = scrollTop));\n }\n}\n"]}
|
|
@@ -10,13 +10,16 @@
|
|
|
10
10
|
* @deprecated in 4.15.0. Used internally.
|
|
11
11
|
*/
|
|
12
12
|
export class Timer {
|
|
13
|
+
_delay;
|
|
14
|
+
_isRunning = false;
|
|
15
|
+
_timerId = 0;
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
17
|
+
_onExecute;
|
|
13
18
|
/**
|
|
14
19
|
* Creates a new Timer.
|
|
15
20
|
* @param msDelay Time interval in milliseconds after which handler will be notified.
|
|
16
21
|
*/
|
|
17
22
|
constructor(msDelay) {
|
|
18
|
-
this._isRunning = false;
|
|
19
|
-
this._timerId = 0;
|
|
20
23
|
this._delay = msDelay;
|
|
21
24
|
}
|
|
22
25
|
/** Indicates whether the timer is running */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Timer.js","sourceRoot":"","sources":["../../../src/core-react/utils/Timer.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAQH;;;GAGG;AACH,MAAM,OAAO,KAAK;
|
|
1
|
+
{"version":3,"file":"Timer.js","sourceRoot":"","sources":["../../../src/core-react/utils/Timer.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAQH;;;GAGG;AACH,MAAM,OAAO,KAAK;IACR,MAAM,CAAS;IACf,UAAU,GAAG,KAAK,CAAC;IACnB,QAAQ,GAAG,CAAC,CAAC;IACrB,4DAA4D;IACpD,UAAU,CAA6B;IAE/C;;;OAGG;IACH,YAAmB,OAAe;QAChC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,6CAA6C;IAC7C,IAAW,SAAS;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,0EAA0E;IAC1E,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,IAAW,KAAK,CAAC,EAAU;QACzB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IAED,uDAAuD;IACvD,4DAA4D;IACrD,YAAY,CAAC,SAAqC;QACvD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,yBAAyB;IAClB,KAAK;QACV,IAAI,IAAI,CAAC,UAAU;YAAE,IAAI,CAAC,YAAY,EAAE,CAAC;QAEzC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACvB,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAED,wBAAwB;IACjB,IAAI;QACT,IAAI,CAAC,IAAI,CAAC,UAAU;YAAE,OAAO;QAE7B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,YAAY,EAAE,CAAC;IACtB,CAAC;IAEO,OAAO;QACb,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QACrC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAEO,UAAU;QAChB,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACvE,CAAC;IAEO,YAAY;QAClB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Utilities\n */\n\n/** Signature for [[Timer]] execute callback.\n * @public\n * @deprecated in 4.15.0. Used internally.\n */\nexport type ExecuteHandler = (this: void) => void;\n\n/** Notifies handler after a set interval.\n * @public\n * @deprecated in 4.15.0. Used internally.\n */\nexport class Timer {\n private _delay: number;\n private _isRunning = false;\n private _timerId = 0;\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n private _onExecute: ExecuteHandler | undefined;\n\n /**\n * Creates a new Timer.\n * @param msDelay Time interval in milliseconds after which handler will be notified.\n */\n public constructor(msDelay: number) {\n this._delay = msDelay;\n }\n\n /** Indicates whether the timer is running */\n public get isRunning(): boolean {\n return this._isRunning;\n }\n\n /** Time interval in milliseconds after which handler will be notified. */\n public get delay() {\n return this._delay;\n }\n public set delay(ms: number) {\n this._delay = ms;\n }\n\n /** Set handler that is called after a set interval. */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n public setOnExecute(onExecute: ExecuteHandler | undefined) {\n this._onExecute = onExecute;\n }\n\n /** Starts this Timer. */\n public start() {\n if (this._isRunning) this.clearTimeout();\n\n this._isRunning = true;\n this.setTimeout();\n }\n\n /** Stops this Timer. */\n public stop() {\n if (!this._isRunning) return;\n\n this._isRunning = false;\n this.clearTimeout();\n }\n\n private execute() {\n this._onExecute && this._onExecute();\n this._isRunning = false;\n }\n\n private setTimeout() {\n this._timerId = window.setTimeout(() => this.execute(), this._delay);\n }\n\n private clearTimeout() {\n window.clearTimeout(this._timerId);\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/core-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.21.0",
|
|
4
4
|
"description": "A react component library of iTwin.js UI general purpose components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/core-react.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@itwin/appui-abstract": "^5.1.0",
|
|
48
|
-
"@itwin/build-tools": "
|
|
48
|
+
"@itwin/build-tools": "^5.3.2",
|
|
49
49
|
"@itwin/core-bentley": "^5.1.0",
|
|
50
50
|
"@itwin/core-common": "^5.1.0",
|
|
51
51
|
"@itwin/core-geometry": "^5.1.0",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"raf": "^3.4.0",
|
|
71
71
|
"react": "^19.2.0",
|
|
72
72
|
"react-dom": "^19.2.0",
|
|
73
|
-
"rimraf": "^6.0
|
|
73
|
+
"rimraf": "^6.1.0",
|
|
74
74
|
"ts-node": "^10.8.2",
|
|
75
75
|
"typemoq": "^2.1.0",
|
|
76
76
|
"typescript": "~5.6.2",
|