Skip to content

Commit

Permalink
Remove @itwin/core-geometry from @itwin/components-react (backport
Browse files Browse the repository at this point in the history
…#1147) (#1149)

* Remove `@itwin/core-geometry` from `@itwin/components-react` (#1147)

* Add missing peer deps

* change

* Remove  from  only types from it are used.

* Inline clamp

* change

(cherry picked from commit 687abfc)

# Conflicts:
#	common/config/rush/pnpm-lock.yaml

* rush update

---------

Co-authored-by: Saulius Skliutas <[email protected]>
Co-authored-by: GerardasB <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2024
1 parent cb78850 commit 330b528
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/components-react",
"comment": "Remove `@itwin/core-geometry` usage from `@itwin/components-react`",
"type": "none"
}
],
"packageName": "@itwin/components-react"
}
3 changes: 0 additions & 3 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion ui/components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"@itwin/build-tools": "4.10.0-dev.31",
"@itwin/core-bentley": "^4.0.0",
"@itwin/core-common": "^4.0.0",
"@itwin/core-geometry": "^4.0.0",
"@itwin/core-i18n": "^4.0.0",
"@itwin/core-react": "workspace:*",
"@itwin/eslint-plugin": "^4.1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* See LICENSE.md in the project root for license terms and full copyright notice.
*--------------------------------------------------------------------------------------------*/
import * as React from "react";
import { Geometry } from "@itwin/core-geometry";
import type { PropertyListProps } from "./PropertyList.js";
import { Orientation } from "../../common/Orientation.js";

Expand Down Expand Up @@ -79,7 +78,7 @@ export class ColumnResizingPropertyListPropsSupplier extends React.Component<
};

private _onColumnRatioChanged = (ratio: number) => {
ratio = Geometry.clamp(ratio, this._minRatio, this._maxRatio);
ratio = clamp(ratio, this._minRatio, this._maxRatio);
if (this.state.columnRatio === ratio) return { ratio };

this.setState({ columnRatio: ratio });
Expand Down Expand Up @@ -140,11 +139,7 @@ export class ColumnResizingPropertyListPropsSupplier extends React.Component<
}

private getValidColumnRatio(): number {
return Geometry.clamp(
this.state.columnRatio,
this._minRatio,
this._maxRatio
);
return clamp(this.state.columnRatio, this._minRatio, this._maxRatio);
}

public override render() {
Expand All @@ -167,3 +162,7 @@ export class ColumnResizingPropertyListPropsSupplier extends React.Component<
return this.props.children(listProps);
}
}

function clamp(value: number, min: number, max: number) {
return Math.max(min, Math.min(max, value));
}

0 comments on commit 330b528

Please sign in to comment.