@itwin/imodel-components-react 5.28.1 → 5.30.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 CHANGED
@@ -1,5 +1,33 @@
1
1
  # Change Log - @itwin/imodel-components-react
2
2
 
3
+ ## 5.30.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b6ca75b: Deprecated legacy editor components in `@itwin/imodel-components-react`:
8
+
9
+ - `ColorEditor`, `ColorPropertyEditor`
10
+ - `WeightEditor`, `WeightPropertyEditor`
11
+
12
+ Use `EditorRenderer` from `@itwin/components-react` instead of using these editor components directly.
13
+
14
+ ### Patch Changes
15
+
16
+ - Updated dependencies [b6ca75b]
17
+ - @itwin/components-react@5.30.0
18
+ - @itwin/core-react@5.30.0
19
+
20
+ ## 5.29.0
21
+
22
+ ### Patch Changes
23
+
24
+ - 8202fee: New editor system now enforces numeric and string constraints. Numeric and quantity editors clamp rawValues to `minimumValue`/`maximumValue`. Text editors truncate to `maximumLength` and reject values shorter than `minimumLength`.
25
+ - Updated dependencies [8202fee]
26
+ - Updated dependencies [8202fee]
27
+ - Updated dependencies [cdd7f5b]
28
+ - @itwin/components-react@5.29.0
29
+ - @itwin/core-react@5.29.0
30
+
3
31
  ## 5.28.1
4
32
 
5
33
  ### Patch Changes
@@ -17,6 +17,7 @@ interface ColorEditorState {
17
17
  }
18
18
  /** ColorEditor React component that is a property editor with text input
19
19
  * @beta
20
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
20
21
  */
21
22
  export declare class ColorEditor extends React.PureComponent<PropertyEditorProps, ColorEditorState> implements TypeEditor {
22
23
  private _buttonElement;
@@ -35,6 +36,7 @@ export declare class ColorEditor extends React.PureComponent<PropertyEditorProps
35
36
  /** Color Property Editor registered for the "number" type name and "color-picker" editor name.
36
37
  * It uses the [[ColorEditor]] React component.
37
38
  * @beta
39
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
38
40
  */
39
41
  export declare class ColorPropertyEditor extends PropertyEditorBase {
40
42
  get reactNode(): React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"ColorEditor.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/ColorEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAIV,aAAa,EACd,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,gBAAgB;AAChB,UAAU,gBAAgB;IACxB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,QAAQ,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,WACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,gBAAgB,CACjE,YAAW,UAAU;IAErB,OAAO,CAAC,cAAc,CACF;IAEpB,SAAyB,KAAK,EAAE,QAAQ,CAAC,gBAAgB,CAAC,CAKxD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAenE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,QAAQ;IAUhB,OAAO,CAAC,YAAY,CAgBlB;IAEc,iBAAiB;IAIjC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAk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AAM;CAwBvB;AAED;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,kBAAkB;IACzD,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
@@ -14,6 +14,7 @@ import { PropertyEditorBase } from "@itwin/components-react";
14
14
  import { ColorPickerButton } from "../color/ColorPickerButton.js";
15
15
  /** ColorEditor React component that is a property editor with text input
16
16
  * @beta
17
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
17
18
  */
18
19
  export class ColorEditor extends React.PureComponent {
19
20
  _buttonElement = React.createRef();
@@ -98,8 +99,7 @@ export class ColorEditor extends React.PureComponent {
98
99
  render() {
99
100
  const colorDef = ColorDef.create(this.state.colorValue);
100
101
  return (React.createElement("div", { className: classnames("components-color-editor", this.props.className), style: this.props.style },
101
- React.createElement(ColorPickerButton // eslint-disable-line @typescript-eslint/no-deprecated
102
- , { ref: this._buttonElement, initialColor: colorDef, colorDefs: this.state.availableColors.length > 0
102
+ React.createElement(ColorPickerButton, { ref: this._buttonElement, initialColor: colorDef, colorDefs: this.state.availableColors.length > 0
103
103
  ? this.state.availableColors
104
104
  : [colorDef], numColumns: this.state.numColumns, disabled: this.state.isDisabled ? true : false, readonly: this.state.readonly, onColorPick: this._onColorPick, "data-testid": "components-color-editor" })));
105
105
  }
@@ -107,6 +107,7 @@ export class ColorEditor extends React.PureComponent {
107
107
  /** Color Property Editor registered for the "number" type name and "color-picker" editor name.
108
108
  * It uses the [[ColorEditor]] React component.
109
109
  * @beta
110
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
110
111
  */
111
112
  export class ColorPropertyEditor extends PropertyEditorBase {
112
113
  get reactNode() {
@@ -1 +1 @@
1
- {"version":3,"file":"ColorEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/ColorEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,O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AO,CACL,6BACE,SAAS,EAAE,UAAU,CAAC,yBAAyB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EACtE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YAEvB,oBAAC,iBAAiB,CAAC,uDAAuD;gBACxE,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,YAAY,EAAE,QAAQ,EACtB,SAAS,EACP,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBACnC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe;oBAC5B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAEhB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,WAAW,EAAE,IAAI,CAAC,YAAY,iBAClB,yBAAyB,GACrC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IACzD,IAAW,SAAS;QAClB,OAAO,oBAAC,WAAW,OAAG,CAAC;IACzB,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 PropertyEditors\n */\n\nimport \"./ColorEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorDef } from \"@itwin/core-common\";\nimport type {\n ColorEditorParams,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { ColorPickerButton } from \"../color/ColorPickerButton.js\";\n\n/** @internal */\ninterface ColorEditorState {\n colorValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n numColumns: number;\n availableColors: ColorDef[];\n}\n\n/** ColorEditor React component that is a property editor with text input\n * @beta\n */\nexport class ColorEditor\n extends React.PureComponent<PropertyEditorProps, ColorEditorState>\n implements TypeEditor\n{\n private _buttonElement: React.RefObject<HTMLButtonElement | null> =\n React.createRef();\n\n public override readonly state: Readonly<ColorEditorState> = {\n colorValue: 0,\n readonly: false,\n numColumns: 4,\n availableColors: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.colorValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._buttonElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._buttonElement.current;\n }\n\n private setFocus(): void {\n if (\n this._buttonElement &&\n this._buttonElement.current &&\n !this.state.isDisabled\n ) {\n this._buttonElement.current.focus();\n }\n }\n\n private _onColorPick = (color: ColorDef) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n colorValue: color.tbgr,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n };\n\n public override componentDidMount() {\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const colorValue = record.value.value as number;\n let numColumns = 4;\n const availableColors = new Array<ColorDef>();\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (record.property.editor && record.property.editor.params) {\n const colorParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ColorData.valueOf()\n ) as ColorEditorParams;\n if (colorParams) {\n colorParams.colorValues.forEach((colorNumber: number) => {\n availableColors.push(ColorDef.create(colorNumber));\n });\n if (colorParams.numColumns) numColumns = colorParams.numColumns;\n }\n }\n this.setState(\n { colorValue, readonly, isDisabled, numColumns, availableColors },\n () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n }\n );\n }\n }\n\n public override render() {\n const colorDef = ColorDef.create(this.state.colorValue);\n return (\n <div\n className={classnames(\"components-color-editor\", this.props.className)}\n style={this.props.style}\n >\n <ColorPickerButton // eslint-disable-line @typescript-eslint/no-deprecated\n ref={this._buttonElement}\n initialColor={colorDef}\n colorDefs={\n this.state.availableColors.length > 0\n ? this.state.availableColors\n : [colorDef]\n }\n numColumns={this.state.numColumns}\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onColorPick={this._onColorPick}\n data-testid=\"components-color-editor\"\n />\n </div>\n );\n }\n}\n\n/** Color Property Editor registered for the \"number\" type name and \"color-picker\" editor name.\n * It uses the [[ColorEditor]] React component.\n * @beta\n */\nexport class ColorPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <ColorEditor />;\n }\n}\n"]}
1
+ {"version":3,"file":"ColorEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/ColorEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO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I,CAAC,KAAK,CAAC,KAAK;YAEvB,oBAAC,iBAAiB,IAChB,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,YAAY,EAAE,QAAQ,EACtB,SAAS,EACP,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBACnC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe;oBAC5B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAEhB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,WAAW,EAAE,IAAI,CAAC,YAAY,iBAClB,yBAAyB,GACrC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IACzD,IAAW,SAAS;QAClB,OAAO,oBAAC,WAAW,OAAG,CAAC;IACzB,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 PropertyEditors\n */\n\nimport \"./ColorEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorDef } from \"@itwin/core-common\";\nimport type {\n ColorEditorParams,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { ColorPickerButton } from \"../color/ColorPickerButton.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\ninterface ColorEditorState {\n colorValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n numColumns: number;\n availableColors: ColorDef[];\n}\n\n/** ColorEditor React component that is a property editor with text input\n * @beta\n * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.\n */\nexport class ColorEditor\n extends React.PureComponent<PropertyEditorProps, ColorEditorState>\n implements TypeEditor\n{\n private _buttonElement: React.RefObject<HTMLButtonElement | null> =\n React.createRef();\n\n public override readonly state: Readonly<ColorEditorState> = {\n colorValue: 0,\n readonly: false,\n numColumns: 4,\n availableColors: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.colorValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._buttonElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._buttonElement.current;\n }\n\n private setFocus(): void {\n if (\n this._buttonElement &&\n this._buttonElement.current &&\n !this.state.isDisabled\n ) {\n this._buttonElement.current.focus();\n }\n }\n\n private _onColorPick = (color: ColorDef) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n colorValue: color.tbgr,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n };\n\n public override componentDidMount() {\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const colorValue = record.value.value as number;\n let numColumns = 4;\n const availableColors = new Array<ColorDef>();\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (record.property.editor && record.property.editor.params) {\n const colorParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ColorData.valueOf()\n ) as ColorEditorParams;\n if (colorParams) {\n colorParams.colorValues.forEach((colorNumber: number) => {\n availableColors.push(ColorDef.create(colorNumber));\n });\n if (colorParams.numColumns) numColumns = colorParams.numColumns;\n }\n }\n this.setState(\n { colorValue, readonly, isDisabled, numColumns, availableColors },\n () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n }\n );\n }\n }\n\n public override render() {\n const colorDef = ColorDef.create(this.state.colorValue);\n return (\n <div\n className={classnames(\"components-color-editor\", this.props.className)}\n style={this.props.style}\n >\n <ColorPickerButton\n ref={this._buttonElement}\n initialColor={colorDef}\n colorDefs={\n this.state.availableColors.length > 0\n ? this.state.availableColors\n : [colorDef]\n }\n numColumns={this.state.numColumns}\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onColorPick={this._onColorPick}\n data-testid=\"components-color-editor\"\n />\n </div>\n );\n }\n}\n\n/** Color Property Editor registered for the \"number\" type name and \"color-picker\" editor name.\n * It uses the [[ColorEditor]] React component.\n * @beta\n * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.\n */\nexport class ColorPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <ColorEditor />;\n }\n}\n"]}
@@ -14,6 +14,7 @@ interface WeightEditorState {
14
14
  }
15
15
  /** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component
16
16
  * @public
17
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
17
18
  */
18
19
  export declare class WeightEditor extends React.PureComponent<PropertyEditorProps, WeightEditorState> implements TypeEditor {
19
20
  private _control;
@@ -37,6 +38,7 @@ export declare class WeightEditor extends React.PureComponent<PropertyEditorProp
37
38
  /** Weight Property Editor registered for the "number" type name and "weight-picker" editor name.
38
39
  * It uses the [[WeightEditor]] React component.
39
40
  * @public
41
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
40
42
  */
41
43
  export declare class WeightPropertyEditor extends PropertyEditorBase {
42
44
  get reactNode(): React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"WeightEditor.d.ts","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAkB,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAG7D,gBAAgB;AAChB,UAAU,iBAAiB;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,qBAAa,YACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,iBAAiB,CAClE,YAAW,UAAU;IAErB,OAAO,CAAC,QAAQ,CAAa;IAC7B,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,iBAAiB,CAAgB;IACzC,OAAO,CAAC,WAAW,CAAqC;IAExD,SAAyB,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAGzD;gBAEU,KAAK,EAAE,mBAAmB;IAezB,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAenE,IAAW,WAAW,IAAI,W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E,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAK7B;IAED,OAAO,CAAC,QAAQ;IAMhB,OAAO,CAAC,iBAAiB,CAgBvB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAoBf,MAAM;CAyBvB;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
@@ -13,6 +13,7 @@ import { PropertyEditorBase } from "@itwin/components-react";
13
13
  import { WeightPickerButton } from "../lineweight/WeightPickerButton.js";
14
14
  /** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component
15
15
  * @public
16
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
16
17
  */
17
18
  export class WeightEditor extends React.PureComponent {
18
19
  _control = null;
@@ -115,6 +116,7 @@ export class WeightEditor extends React.PureComponent {
115
116
  /** Weight Property Editor registered for the "number" type name and "weight-picker" editor name.
116
117
  * It uses the [[WeightEditor]] React component.
117
118
  * @public
119
+ * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.
118
120
  */
119
121
  export class WeightPropertyEditor extends PropertyEditorBase {
120
122
  get reactNode() {
@@ -1 +1 @@
1
- {"version":3,"file":"WeightEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAA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,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,iBAC5B,0BAA0B,GACtC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,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 PropertyEditors\n */\n\nimport \"./WeightEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { WeightPickerButton } from \"../lineweight/WeightPickerButton.js\";\n\n/** @internal */\ninterface WeightEditorState {\n weightValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n}\n\n/** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component\n * @public\n */\nexport class WeightEditor\n extends React.PureComponent<PropertyEditorProps, WeightEditorState>\n implements TypeEditor\n{\n private _control: any = null;\n private _isMounted = false;\n private _availableWeights: number[] = [];\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<WeightEditorState> = {\n weightValue: 0,\n readonly: false,\n };\n\n constructor(props: PropertyEditorProps) {\n super(props);\n\n // TODO: add support for following if we need to specify set of weights to display\n // const record = this.props.propertyRecord;\n // if (record && record.property && record.property.editor && record.property.editor.params) {\n // const weightParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ColorData) as WeightEditorParams;\n // // if (weightParams) {\n // weightParams.weightValues.forEach((weight: number) => {\n // this._availableWeights.push(weight);\n // });\n // }\n // }\n }\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.weightValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private setFocus(): void {\n if (this._control && !this.state.isDisabled) {\n this._control.setFocus();\n }\n }\n\n private _onLineWeightPick = (weight: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n weightValue: weight,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (this._isMounted)\n this.setState({ weightValue: initialValue, readonly, isDisabled }, () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n });\n }\n\n public override render() {\n return (\n <div\n className={classnames(\"components-weight-editor\", this.props.className)}\n style={this.props.style}\n ref={this._divElement}\n >\n <WeightPickerButton\n ref={(control) => {\n this._control = control;\n }}\n activeWeight={this.state.weightValue}\n weights={\n this._availableWeights.length > 0\n ? this._availableWeights\n : undefined\n }\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onLineWeightPick={this._onLineWeightPick}\n data-testid=\"components-weight-editor\"\n />\n </div>\n );\n }\n}\n\n/** Weight Property Editor registered for the \"number\" type name and \"weight-picker\" editor name.\n * It uses the [[WeightEditor]] React component.\n * @public\n */\nexport class WeightPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <WeightEditor />;\n }\n}\n"]}
1
+ {"version":3,"file":"WeightEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAWzE;;;GAGG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IAG3D,QAAQ,GAAQ,IAAI,CAAC;IACrB,UAAU,GAAG,KAAK,CAAC;IACnB,iBAAiB,GAAa,EAAE,CAAC;IACjC,WAAW,GAAG,KAAK,CAAC,SAAS,EAAkB,CAAC;IAE/B,KAAK,GAAgC;QAC5D,WAAW,EAAE,CAAC;QACd,QAAQ,EAAE,KAAK;KAChB,CAAC;IAEF,YAAY,KAA0B;QACpC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,kFAAkF;QAClF,6CAA6C;QAC7C,+FAA+F;QAC/F,wKAAwK;QACxK,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AY,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,GAAG,EAAE;gBACtE,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC;YACH,CAAC,CAAC,CAAC;IACP,CAAC;IAEe,MAAM;QACpB,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CAAC,0BAA0B,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EACvE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,GAAG,EAAE,IAAI,CAAC,WAAW;YAErB,oBAAC,kBAAkB,IACjB,GAAG,EAAE,CAAC,OAAO,EAAE,EAAE;oBACf,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;gBAC1B,CAAC,EACD,YAAY,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,EACpC,OAAO,EACL,IAAI,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC;oBAC/B,CAAC,CAAC,IAAI,CAAC,iBAAiB;oBACxB,CAAC,CAAC,SAAS,EAEf,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,iBAC5B,0BAA0B,GACtC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,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 PropertyEditors\n */\n\nimport \"./WeightEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { WeightPickerButton } from \"../lineweight/WeightPickerButton.js\";\n\n/* eslint-disable @typescript-eslint/no-deprecated */\n\n/** @internal */\ninterface WeightEditorState {\n weightValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n}\n\n/** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component\n * @public\n * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.\n */\nexport class WeightEditor\n extends React.PureComponent<PropertyEditorProps, WeightEditorState>\n implements TypeEditor\n{\n private _control: any = null;\n private _isMounted = false;\n private _availableWeights: number[] = [];\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<WeightEditorState> = {\n weightValue: 0,\n readonly: false,\n };\n\n constructor(props: PropertyEditorProps) {\n super(props);\n\n // TODO: add support for following if we need to specify set of weights to display\n // const record = this.props.propertyRecord;\n // if (record && record.property && record.property.editor && record.property.editor.params) {\n // const weightParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ColorData) as WeightEditorParams;\n // // if (weightParams) {\n // weightParams.weightValues.forEach((weight: number) => {\n // this._availableWeights.push(weight);\n // });\n // }\n // }\n }\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.weightValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private setFocus(): void {\n if (this._control && !this.state.isDisabled) {\n this._control.setFocus();\n }\n }\n\n private _onLineWeightPick = (weight: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n weightValue: weight,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (this._isMounted)\n this.setState({ weightValue: initialValue, readonly, isDisabled }, () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n });\n }\n\n public override render() {\n return (\n <div\n className={classnames(\"components-weight-editor\", this.props.className)}\n style={this.props.style}\n ref={this._divElement}\n >\n <WeightPickerButton\n ref={(control) => {\n this._control = control;\n }}\n activeWeight={this.state.weightValue}\n weights={\n this._availableWeights.length > 0\n ? this._availableWeights\n : undefined\n }\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onLineWeightPick={this._onLineWeightPick}\n data-testid=\"components-weight-editor\"\n />\n </div>\n );\n }\n}\n\n/** Weight Property Editor registered for the \"number\" type name and \"weight-picker\" editor name.\n * It uses the [[WeightEditor]] React component.\n * @public\n * @deprecated in 5.30. This is part of the old editor system and should not be used directly. Use `EditorRenderer` from `@itwin/components-react` instead.\n */\nexport class WeightPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <WeightEditor />;\n }\n}\n"]}
@@ -1,10 +1,17 @@
1
1
  /** @packageDocumentation
2
2
  * @module PropertyEditors
3
3
  */
4
+ import * as React from "react";
4
5
  import { type QuantityTypeArg } from "@itwin/core-frontend";
5
- import { type EditorSpec, type ValueMetadata } from "@itwin/components-react";
6
+ import { type EditorProps, type EditorSpec, type NumericValue, type NumericValueMetadata } from "@itwin/components-react";
6
7
  /**
7
8
  * Editor specification for quantity values based on `IModelApp.quantityFormatter`.
9
+ *
10
+ * **Note:** value provided to `onChange` might have mismatching `displayValue` and `rawValue`.
11
+ * This can happen when input is invalid, some examples:
12
+ * - input is not numeric. input `abc` -> { `displayValue`: "abc", `rawValue`: undefined }
13
+ * - input is smaller than property constraints. input: `2 in`, minimumValue is `1 m` -> { `displayValue`: `2 in`, `rawValue`: 1 }
14
+ * - input is larger than property constraints. input: `6 m`, maximumValue is `5 m` -> { `displayValue`: `6 m`, `rawValue`: 5 }
8
15
  * @beta
9
16
  */
10
17
  export declare const QuantityEditorSpec: EditorSpec;
@@ -12,8 +19,9 @@ export declare const QuantityEditorSpec: EditorSpec;
12
19
  * Metadata for quantity values.
13
20
  * @beta
14
21
  */
15
- export interface QuantityValueMetadata extends ValueMetadata {
16
- type: "number";
22
+ export interface QuantityValueMetadata extends NumericValueMetadata {
17
23
  quantityType: QuantityTypeArg;
18
24
  }
25
+ /** @internal */
26
+ export declare function QuantityEditor({ metadata, value, onChange, size, }: EditorProps<QuantityValueMetadata, NumericValue>): React.JSX.Element;
19
27
  //# sourceMappingURL=QuantityEditor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityEditor.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/QuantityEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAGL,KAAK,UAAU,EAEf,KAAK,aAAa,EAEnB,MAAM,yBAAyB,CAAC;AAKjC;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAO/B,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,IAAI,EAAE,QAAQ,CAAC;IACf,YAAY,EAAE,eAAe,CAAC;CAC/B"}
1
+ {"version":3,"file":"QuantityEditor.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/QuantityEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAEL,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,YAAY,EACjB,KAAK,oBAAoB,EAE1B,MAAM,yBAAyB,CAAC;AAMjC;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,EAAE,UAO/B,CAAC;AAEH;;;GAGG;AACH,MAAM,WAAW,qBAAsB,SAAQ,oBAAoB;IACjE,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,gBAAgB;AAChB,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,GACL,EAAE,WAAW,CAAC,qBAAqB,EAAE,YAAY,CAAC,qBAwClD"}
@@ -8,10 +8,17 @@
8
8
  import * as React from "react";
9
9
  import { useQuantityInfo } from "./UseQuantityInfo.js";
10
10
  import { createEditorSpec, ValueUtilities, } from "@itwin/components-react";
11
+ import { applyNumericConstraints } from "@itwin/components-react/internal";
11
12
  import { QuantityInput } from "./QuantityInput.js";
12
13
  /* v8 ignore start */
13
14
  /**
14
15
  * Editor specification for quantity values based on `IModelApp.quantityFormatter`.
16
+ *
17
+ * **Note:** value provided to `onChange` might have mismatching `displayValue` and `rawValue`.
18
+ * This can happen when input is invalid, some examples:
19
+ * - input is not numeric. input `abc` -> { `displayValue`: "abc", `rawValue`: undefined }
20
+ * - input is smaller than property constraints. input: `2 in`, minimumValue is `1 m` -> { `displayValue`: `2 in`, `rawValue`: 1 }
21
+ * - input is larger than property constraints. input: `6 m`, maximumValue is `5 m` -> { `displayValue`: `6 m`, `rawValue`: 5 }
15
22
  * @beta
16
23
  */
17
24
  export const QuantityEditorSpec = createEditorSpec({
@@ -21,7 +28,8 @@ export const QuantityEditorSpec = createEditorSpec({
21
28
  isValueSupported: ValueUtilities.isNumeric,
22
29
  Editor: QuantityEditor,
23
30
  });
24
- function QuantityEditor({ metadata, value, onChange, size, }) {
31
+ /** @internal */
32
+ export function QuantityEditor({ metadata, value, onChange, size, }) {
25
33
  const { defaultFormatter, highPrecisionFormatter, parser } = useQuantityInfo({
26
34
  type: metadata.quantityType,
27
35
  });
@@ -29,7 +37,26 @@ function QuantityEditor({ metadata, value, onChange, size, }) {
29
37
  const currentValue = value
30
38
  ? value
31
39
  : { rawValue: undefined, displayValue: "" };
32
- return (React.createElement(QuantityInput, { value: currentValue, onChange: onChange, size: size, formatter: isEditing ? highPrecisionFormatter : defaultFormatter, parser: parser, onBlur: () => setEditing(false), onFocus: () => setEditing(true) }));
40
+ const { minimumValue, maximumValue } = metadata.constraints ?? {
41
+ minimumValue: undefined,
42
+ maximumValue: undefined,
43
+ };
44
+ const handleChange = (newValue) => {
45
+ if (!newValue?.rawValue) {
46
+ onChange(newValue);
47
+ return;
48
+ }
49
+ onChange({
50
+ ...newValue,
51
+ rawValue: applyNumericConstraints({
52
+ value: newValue.rawValue,
53
+ min: minimumValue,
54
+ max: maximumValue,
55
+ }),
56
+ });
57
+ return;
58
+ };
59
+ return (React.createElement(QuantityInput, { value: currentValue, onChange: handleChange, size: size, formatter: isEditing ? highPrecisionFormatter : defaultFormatter, parser: parser, onBlur: () => setEditing(false), onFocus: () => setEditing(true) }));
33
60
  }
34
61
  /* v8 ignore stop */
35
62
  //# sourceMappingURL=QuantityEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityEditor.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/QuantityEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,gBAAgB,EAKhB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qBAAqB;AAErB;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe,gBAAgB,CAAC;IAC7D,mBAAmB,EAAE,CAAC,QAAQ,EAAqC,EAAE,CACnE,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,cAAc,IAAI,QAAQ;QAC1B,QAAQ,CAAC,YAAY,KAAK,SAAS;IACrC,gBAAgB,EAAE,cAAc,CAAC,SAAS;IAC1C,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC;AAWH,SAAS,cAAc,CAAC,EACtB,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,GAC6C;IACjD,MAAM,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;QAC3E,IAAI,EAAE,QAAQ,CAAC,YAAY;KAC5B,CAAC,CAAC;IACH,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,KAAK;QACxB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAE9C,OAAO,CACL,oBAAC,aAAa,IACZ,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,EAChE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAC/B,CACH,CAAC;AACJ,CAAC;AAED,oBAAoB","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 PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { type QuantityTypeArg } from \"@itwin/core-frontend\";\nimport { useQuantityInfo } from \"./UseQuantityInfo.js\";\nimport {\n createEditorSpec,\n type EditorProps,\n type EditorSpec,\n type NumericValue,\n type ValueMetadata,\n ValueUtilities,\n} from \"@itwin/components-react\";\nimport { QuantityInput } from \"./QuantityInput.js\";\n\n/* v8 ignore start */\n\n/**\n * Editor specification for quantity values based on `IModelApp.quantityFormatter`.\n * @beta\n */\nexport const QuantityEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is QuantityValueMetadata =>\n metadata.type === \"number\" &&\n \"quantityType\" in metadata &&\n metadata.quantityType !== undefined,\n isValueSupported: ValueUtilities.isNumeric,\n Editor: QuantityEditor,\n});\n\n/**\n * Metadata for quantity values.\n * @beta\n */\nexport interface QuantityValueMetadata extends ValueMetadata {\n type: \"number\";\n quantityType: QuantityTypeArg;\n}\n\nfunction QuantityEditor({\n metadata,\n value,\n onChange,\n size,\n}: EditorProps<QuantityValueMetadata, NumericValue>) {\n const { defaultFormatter, highPrecisionFormatter, parser } = useQuantityInfo({\n type: metadata.quantityType,\n });\n const [isEditing, setEditing] = React.useState(false);\n const currentValue = value\n ? value\n : { rawValue: undefined, displayValue: \"\" };\n\n return (\n <QuantityInput\n value={currentValue}\n onChange={onChange}\n size={size}\n formatter={isEditing ? highPrecisionFormatter : defaultFormatter}\n parser={parser}\n onBlur={() => setEditing(false)}\n onFocus={() => setEditing(true)}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
1
+ {"version":3,"file":"QuantityEditor.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/QuantityEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EACL,gBAAgB,EAKhB,cAAc,GACf,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,qBAAqB;AAErB;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAe,gBAAgB,CAAC;IAC7D,mBAAmB,EAAE,CAAC,QAAQ,EAAqC,EAAE,CACnE,QAAQ,CAAC,IAAI,KAAK,QAAQ;QAC1B,cAAc,IAAI,QAAQ;QAC1B,QAAQ,CAAC,YAAY,KAAK,SAAS;IACrC,gBAAgB,EAAE,cAAc,CAAC,SAAS;IAC1C,MAAM,EAAE,cAAc;CACvB,CAAC,CAAC;AAUH,gBAAgB;AAChB,MAAM,UAAU,cAAc,CAAC,EAC7B,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,IAAI,GAC6C;IACjD,MAAM,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,EAAE,GAAG,eAAe,CAAC;QAC3E,IAAI,EAAE,QAAQ,CAAC,YAAY;KAC5B,CAAC,CAAC;IACH,MAAM,CAAC,SAAS,EAAE,UAAU,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,YAAY,GAAG,KAAK;QACxB,CAAC,CAAC,KAAK;QACP,CAAC,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC;IAE9C,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,WAAW,IAAI;QAC7D,YAAY,EAAE,SAAS;QACvB,YAAY,EAAE,SAAS;KACxB,CAAC;IACF,MAAM,YAAY,GAAG,CAAC,QAAsB,EAAE,EAAE;QAC9C,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC;YACxB,QAAQ,CAAC,QAAQ,CAAC,CAAC;YACnB,OAAO;QACT,CAAC;QACD,QAAQ,CAAC;YACP,GAAG,QAAQ;YACX,QAAQ,EAAE,uBAAuB,CAAC;gBAChC,KAAK,EAAE,QAAQ,CAAC,QAAQ;gBACxB,GAAG,EAAE,YAAY;gBACjB,GAAG,EAAE,YAAY;aAClB,CAAC;SACH,CAAC,CAAC;QACH,OAAO;IACT,CAAC,CAAC;IAEF,OAAO,CACL,oBAAC,aAAa,IACZ,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,YAAY,EACtB,IAAI,EAAE,IAAI,EACV,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,gBAAgB,EAChE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAC/B,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,GAC/B,CACH,CAAC;AACJ,CAAC;AAED,oBAAoB","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 PropertyEditors\n */\n\nimport * as React from \"react\";\nimport { type QuantityTypeArg } from \"@itwin/core-frontend\";\nimport { useQuantityInfo } from \"./UseQuantityInfo.js\";\nimport {\n createEditorSpec,\n type EditorProps,\n type EditorSpec,\n type NumericValue,\n type NumericValueMetadata,\n ValueUtilities,\n} from \"@itwin/components-react\";\nimport { applyNumericConstraints } from \"@itwin/components-react/internal\";\nimport { QuantityInput } from \"./QuantityInput.js\";\n\n/* v8 ignore start */\n\n/**\n * Editor specification for quantity values based on `IModelApp.quantityFormatter`.\n *\n * **Note:** value provided to `onChange` might have mismatching `displayValue` and `rawValue`.\n * This can happen when input is invalid, some examples:\n * - input is not numeric. input `abc` -> { `displayValue`: \"abc\", `rawValue`: undefined }\n * - input is smaller than property constraints. input: `2 in`, minimumValue is `1 m` -> { `displayValue`: `2 in`, `rawValue`: 1 }\n * - input is larger than property constraints. input: `6 m`, maximumValue is `5 m` -> { `displayValue`: `6 m`, `rawValue`: 5 }\n * @beta\n */\nexport const QuantityEditorSpec: EditorSpec = createEditorSpec({\n isMetadataSupported: (metadata): metadata is QuantityValueMetadata =>\n metadata.type === \"number\" &&\n \"quantityType\" in metadata &&\n metadata.quantityType !== undefined,\n isValueSupported: ValueUtilities.isNumeric,\n Editor: QuantityEditor,\n});\n\n/**\n * Metadata for quantity values.\n * @beta\n */\nexport interface QuantityValueMetadata extends NumericValueMetadata {\n quantityType: QuantityTypeArg;\n}\n\n/** @internal */\nexport function QuantityEditor({\n metadata,\n value,\n onChange,\n size,\n}: EditorProps<QuantityValueMetadata, NumericValue>) {\n const { defaultFormatter, highPrecisionFormatter, parser } = useQuantityInfo({\n type: metadata.quantityType,\n });\n const [isEditing, setEditing] = React.useState(false);\n const currentValue = value\n ? value\n : { rawValue: undefined, displayValue: \"\" };\n\n const { minimumValue, maximumValue } = metadata.constraints ?? {\n minimumValue: undefined,\n maximumValue: undefined,\n };\n const handleChange = (newValue: NumericValue) => {\n if (!newValue?.rawValue) {\n onChange(newValue);\n return;\n }\n onChange({\n ...newValue,\n rawValue: applyNumericConstraints({\n value: newValue.rawValue,\n min: minimumValue,\n max: maximumValue,\n }),\n });\n return;\n };\n\n return (\n <QuantityInput\n value={currentValue}\n onChange={handleChange}\n size={size}\n formatter={isEditing ? highPrecisionFormatter : defaultFormatter}\n parser={parser}\n onBlur={() => setEditing(false)}\n onFocus={() => setEditing(true)}\n />\n );\n}\n\n/* v8 ignore stop */\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/imodel-components-react",
3
- "version": "5.28.1",
3
+ "version": "5.30.0",
4
4
  "description": "A react component library of iTwin.js UI iModel components",
5
5
  "type": "module",
6
6
  "types": "./lib/imodel-components-react.d.ts",
@@ -44,8 +44,8 @@
44
44
  "@itwin/itwinui-react": "^3.15.0",
45
45
  "react": "^18.0.0 || ^19.0.0",
46
46
  "react-dom": "^18.0.0 || ^19.0.0",
47
- "@itwin/components-react": "5.28.1",
48
- "@itwin/core-react": "5.28.1"
47
+ "@itwin/components-react": "5.30.0",
48
+ "@itwin/core-react": "5.30.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@itwin/appui-abstract": "^5.8.1",
@@ -83,8 +83,8 @@
83
83
  "typescript": "~5.6.3",
84
84
  "upath": "^2.0.1",
85
85
  "vitest": "^3.2.4",
86
- "@itwin/components-react": "5.28.1",
87
- "@itwin/core-react": "5.28.1"
86
+ "@itwin/components-react": "5.30.0",
87
+ "@itwin/core-react": "5.30.0"
88
88
  },
89
89
  "dependencies": {
90
90
  "@itwin/itwinui-icons-react": "^2.11.0",