@itwin/components-react 5.16.0 → 5.18.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 +18 -0
- package/lib/components-react/editors/ToggleEditor.d.ts +2 -1
- package/lib/components-react/editors/ToggleEditor.d.ts.map +1 -1
- package/lib/components-react/editors/ToggleEditor.js +6 -0
- package/lib/components-react/editors/ToggleEditor.js.map +1 -1
- package/lib/components-react/new-editors/interop/EditorInterop.d.ts.map +1 -1
- package/lib/components-react/new-editors/interop/EditorInterop.js +2 -0
- package/lib/components-react/new-editors/interop/EditorInterop.js.map +1 -1
- package/package.json +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# Change Log - @itwin/components-react
|
|
2
2
|
|
|
3
|
+
## 5.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a756971: Render `ToggleEditor` component after loading to reduce flicker in the property grid.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- c7e347b: Fix `roundingError` not being preserved when converting between new & legacy property editor value formats.
|
|
12
|
+
- @itwin/core-react@5.18.0
|
|
13
|
+
|
|
14
|
+
## 5.17.0
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [2e99cd6]
|
|
19
|
+
- @itwin/core-react@5.17.0
|
|
20
|
+
|
|
3
21
|
## 5.16.0
|
|
4
22
|
|
|
5
23
|
### Minor Changes
|
|
@@ -9,6 +9,7 @@ import { PropertyEditorBase } from "./PropertyEditorManager.js";
|
|
|
9
9
|
/** @internal */
|
|
10
10
|
interface ToggleEditorState {
|
|
11
11
|
toggleValue: boolean;
|
|
12
|
+
isLoaded: boolean;
|
|
12
13
|
}
|
|
13
14
|
/** ToggleEditor React component that is a property editor with checkbox input
|
|
14
15
|
* @public
|
|
@@ -26,7 +27,7 @@ export declare class ToggleEditor extends React.PureComponent<PropertyEditorProp
|
|
|
26
27
|
/** @internal */
|
|
27
28
|
componentDidUpdate(prevProps: PropertyEditorProps): void;
|
|
28
29
|
private setStateFromProps;
|
|
29
|
-
render(): React.JSX.Element;
|
|
30
|
+
render(): React.JSX.Element | null;
|
|
30
31
|
}
|
|
31
32
|
/** Toggle Property Editor registered for the "bool" and "boolean" type names and "toggle" editor name.
|
|
32
33
|
* It uses the [[ToggleEditor]] React component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,gBAAgB;AAChB,UAAU,iBAAiB;IACzB,WAAW,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"ToggleEditor.d.ts","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAE7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,gBAAgB;AAChB,UAAU,iBAAiB;IACzB,WAAW,EAAE,OAAO,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,qBAAa,YACX,SAAQ,KAAK,CAAC,aAAa,CAAC,mBAAmB,EAAE,iBAAiB,CAClE,YAAW,UAAU;IAErB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,aAAa,CAAuC;IAE5D,SAAyB,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,CAGzD;IAEW,gBAAgB,IAAI,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC;IAcnE,IAAW,WAAW,IAAI,WAAW,GAAG,IAAI,CAE3C;IAED,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,OAAO,CAAC,kBAAkB,CAyBxB;IAEc,iBAAiB;IAKjB,oBAAoB;IAIpC,gBAAgB;IACA,kBAAkB,CAAC,SAAS,EAAE,mBAAmB;YAMnD,iBAAiB;IAmBf,MAAM;CA4BvB;AAED;;;GAGG;AACH,qBAAa,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAoB,oBAAoB,IAAI,OAAO,CAElD;IAED,IAAW,SAAS,IAAI,KAAK,CAAC,SAAS,CAEtC;CACF"}
|
|
@@ -21,6 +21,7 @@ export class ToggleEditor extends React.PureComponent {
|
|
|
21
21
|
this._inputElement = React.createRef();
|
|
22
22
|
this.state = {
|
|
23
23
|
toggleValue: false,
|
|
24
|
+
isLoaded: false,
|
|
24
25
|
};
|
|
25
26
|
this._updateToggleValue = (e) => {
|
|
26
27
|
if (this._isMounted) {
|
|
@@ -85,9 +86,14 @@ export class ToggleEditor extends React.PureComponent {
|
|
|
85
86
|
if (this._isMounted)
|
|
86
87
|
this.setState({
|
|
87
88
|
toggleValue,
|
|
89
|
+
isLoaded: true,
|
|
88
90
|
});
|
|
89
91
|
}
|
|
90
92
|
render() {
|
|
93
|
+
// Don't render until the value is loaded to avoid showing false briefly
|
|
94
|
+
if (!this.state.isLoaded) {
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
91
97
|
const className = classnames("components-cell-editor", "components-toggle-editor", this.props.className);
|
|
92
98
|
const isChecked = this.state.toggleValue;
|
|
93
99
|
return (React.createElement(ToggleSwitch, { ref: this._inputElement, onBlur: this.props.onBlur, className: className, style: this.props.style, checked: isChecked, readOnly: this.props.propertyRecord?.isReadonly, disabled: this.props.propertyRecord?.isDisabled, onChange: this._updateToggleValue, "data-testid": "components-toggle-editor", autoFocus: this.props.setFocus }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ToggleEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.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,4BAA4B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ToggleEditor.js","sourceRoot":"","sources":["../../../src/components-react/editors/ToggleEditor.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,4BAA4B,CAAC;AAChE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAQpD;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IADrE;;QAIU,eAAU,GAAG,KAAK,CAAC;QACnB,kBAAa,GAAG,KAAK,CAAC,SAAS,EAAoB,CAAC;QAEnC,UAAK,GAAgC;YAC5D,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,KAAK;SAChB,CAA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AI,CAAC,aAAa,EACvB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EACzB,SAAS,EAAE,SAAS,EACpB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,OAAO,EAAE,SAAS,EAClB,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE,UAAU,EAC/C,QAAQ,EAAE,IAAI,CAAC,kBAAkB,iBACrB,0BAA0B,EACtC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,GAC9B,CACH,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAoB,oBAAoB;QACtC,OAAO,KAAK,CAAC;IACf,CAAC;IAED,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 \"./ToggleEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"./EditorContainer.js\";\nimport { PropertyEditorBase } from \"./PropertyEditorManager.js\";\nimport { ToggleSwitch } from \"@itwin/itwinui-react\";\n\n/** @internal */\ninterface ToggleEditorState {\n toggleValue: boolean;\n isLoaded: boolean;\n}\n\n/** ToggleEditor React component that is a property editor with checkbox input\n * @public\n */\nexport class ToggleEditor\n extends React.PureComponent<PropertyEditorProps, ToggleEditorState>\n implements TypeEditor\n{\n private _isMounted = false;\n private _inputElement = React.createRef<HTMLInputElement>();\n\n public override readonly state: Readonly<ToggleEditorState> = {\n toggleValue: false,\n isLoaded: false,\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.toggleValue,\n displayValue: \"\",\n };\n }\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._inputElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._inputElement.current;\n }\n\n private _updateToggleValue = (\n e: React.ChangeEvent<HTMLInputElement>\n ): any => {\n if (this._isMounted) {\n if (this._isMounted) {\n const toggleValue = !!e.target.checked;\n\n this.setState(\n {\n toggleValue,\n },\n async () => {\n if (this.props.propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({\n propertyRecord: this.props.propertyRecord,\n newValue: propertyValue,\n });\n }\n }\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 { propertyRecord } = this.props;\n let toggleValue = false;\n\n if (\n propertyRecord &&\n propertyRecord.value.valueFormat === PropertyValueFormat.Primitive\n ) {\n const primitiveValue = propertyRecord.value.value;\n toggleValue = primitiveValue as boolean;\n }\n\n if (this._isMounted)\n this.setState({\n toggleValue,\n isLoaded: true,\n });\n }\n\n public override render() {\n // Don't render until the value is loaded to avoid showing false briefly\n if (!this.state.isLoaded) {\n return null;\n }\n\n const className = classnames(\n \"components-cell-editor\",\n \"components-toggle-editor\",\n this.props.className\n );\n const isChecked = this.state.toggleValue;\n\n return (\n <ToggleSwitch\n ref={this._inputElement}\n onBlur={this.props.onBlur}\n className={className}\n style={this.props.style}\n checked={isChecked}\n readOnly={this.props.propertyRecord?.isReadonly}\n disabled={this.props.propertyRecord?.isDisabled}\n onChange={this._updateToggleValue}\n data-testid=\"components-toggle-editor\"\n autoFocus={this.props.setFocus} // eslint-disable-line jsx-a11y/no-autofocus\n />\n );\n }\n}\n\n/** Toggle Property Editor registered for the \"bool\" and \"boolean\" type names and \"toggle\" editor name.\n * It uses the [[ToggleEditor]] React component.\n * @public\n */\nexport class TogglePropertyEditor extends PropertyEditorBase {\n public override get containerHandlesBlur(): boolean {\n return false;\n }\n\n public get reactNode(): React.ReactNode {\n return <ToggleEditor />;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASvD;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,GAAG;QACnE,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;QACxC,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,
|
|
1
|
+
{"version":3,"file":"EditorInterop.d.ts","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAEV,cAAc,EACd,cAAc,EACf,MAAM,uBAAuB,CAAC;AAU/B,OAAO,KAAK,EAAE,KAAK,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AASvD;;;GAGG;AACH,yBAAiB,aAAa,CAAC;IAC7B,6EAA6E;IAC7E,SAAgB,mBAAmB,CAAC,cAAc,EAAE,cAAc,GAAG;QACnE,QAAQ,EAAE,iBAAiB,GAAG,SAAS,CAAC;QACxC,KAAK,EAAE,cAAc,GAAG,SAAS,CAAC;KACnC,CAgGA;IAED,oEAAoE;IACpE,SAAgB,uBAAuB,CACrC,QAAQ,EAAE,cAAc,GACvB,cAAc,CAuChB;CACF"}
|
|
@@ -75,6 +75,7 @@ export var EditorInterop;
|
|
|
75
75
|
: primitiveValue.value !== undefined
|
|
76
76
|
? `${primitiveValue.value}`
|
|
77
77
|
: "",
|
|
78
|
+
roundingError: primitiveValue.roundingError,
|
|
78
79
|
},
|
|
79
80
|
};
|
|
80
81
|
case "enum":
|
|
@@ -119,6 +120,7 @@ export var EditorInterop;
|
|
|
119
120
|
valueFormat: PropertyValueFormat.Primitive,
|
|
120
121
|
value: newValue.rawValue,
|
|
121
122
|
displayValue: newValue.displayValue,
|
|
123
|
+
roundingError: newValue.roundingError,
|
|
122
124
|
};
|
|
123
125
|
}
|
|
124
126
|
if (isBoolean(newValue)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAOhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAW5D,OAAO,EACL,SAAS,EACT,MAAM,EACN,MAAM,EACN,SAAS,EACT,MAAM,GACP,MAAM,6BAA6B,CAAC;AAErC;;;GAGG;AACH,MAAM,KAAW,aAAa,
|
|
1
|
+
{"version":3,"file":"EditorInterop.js","sourceRoot":"","sources":["../../../../src/components-react/new-editors/interop/EditorInterop.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAOhG,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;A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------------------------------------------------------------------------\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\nimport type {\n Primitives,\n PrimitiveValue,\n PropertyRecord,\n} from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type {\n BooleanValue,\n DateValue,\n EnumValue,\n InstanceKeyValue,\n NumericValue,\n TextValue,\n} from \"../values/Values.js\";\nimport type { Value as NewEditorValue } from \"../values/Values.js\";\nimport type { OldEditorMetadata } from \"./Metadata.js\";\nimport {\n isBoolean,\n isDate,\n isEnum,\n isNumeric,\n isText,\n} from \"../values/ValueUtilities.js\";\n\n/**\n * Interop utilities for converting between old and new editor values.\n * @internal\n */\nexport namespace EditorInterop {\n /** Attempts to convert `PropertyRecord` into `ValueMetadata` and `Value`. */\n export function getMetadataAndValue(propertyRecord: PropertyRecord): {\n metadata: OldEditorMetadata | undefined;\n value: NewEditorValue | undefined;\n } {\n const baseMetadata: Omit<OldEditorMetadata, \"type\"> = {\n preferredEditor: propertyRecord.property.editor?.name,\n params: propertyRecord.property.editor?.params,\n extendedData: propertyRecord.extendedData,\n enum: propertyRecord.property.enum,\n typename: propertyRecord.property.typename,\n // eslint-disable-next-line @typescript-eslint/no-deprecated\n quantityType: propertyRecord.property.quantityType,\n };\n\n const primitiveValue = propertyRecord.value as PrimitiveValue;\n switch (propertyRecord.property.typename) {\n case \"text\":\n case \"string\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"string\",\n },\n value: {\n value: (primitiveValue.value as string) ?? \"\",\n } satisfies TextValue,\n };\n case \"dateTime\":\n case \"shortdate\":\n return {\n metadata: {\n ...baseMetadata,\n type:\n propertyRecord.property.typename === \"shortdate\"\n ? \"date\"\n : \"dateTime\",\n },\n value: {\n value: (primitiveValue.value as Date) ?? new Date(),\n } satisfies DateValue,\n };\n case \"boolean\":\n case \"bool\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"bool\",\n },\n value: {\n value: (primitiveValue.value as boolean) ?? false,\n } satisfies BooleanValue,\n };\n case \"float\":\n case \"double\":\n case \"int\":\n case \"integer\":\n case \"number\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"number\",\n },\n value: {\n rawValue: primitiveValue.value as number,\n displayValue: primitiveValue.displayValue\n ? primitiveValue.displayValue\n : primitiveValue.value !== undefined\n ? `${primitiveValue.value as number}`\n : \"\",\n roundingError: primitiveValue.roundingError,\n } satisfies NumericValue,\n };\n case \"enum\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"enum\",\n },\n value: {\n choice: primitiveValue.value as number | string,\n } satisfies EnumValue,\n };\n case \"navigation\":\n return {\n metadata: {\n ...baseMetadata,\n type: \"instanceKey\",\n },\n value: {\n key: primitiveValue.value as Primitives.InstanceKey,\n label: primitiveValue.displayValue ?? \"\",\n } satisfies InstanceKeyValue,\n };\n }\n\n return {\n metadata: undefined,\n value: undefined,\n };\n }\n\n /** Converts new editors system `Value` into old `PrimitiveValue` */\n export function convertToPrimitiveValue(\n newValue: NewEditorValue\n ): PrimitiveValue {\n if (isText(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value,\n };\n }\n if (isNumeric(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.rawValue,\n displayValue: newValue.displayValue,\n roundingError: newValue.roundingError,\n };\n }\n if (isBoolean(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n if (isDate(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.value,\n displayValue: newValue.value.toString(),\n };\n }\n\n if (isEnum(newValue)) {\n return {\n valueFormat: PropertyValueFormat.Primitive,\n value: newValue.choice,\n };\n }\n\n throw new Error(\"Unsupported value type\");\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/components-react",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.18.0",
|
|
4
4
|
"description": "A react component library of iTwin.js UI data-oriented components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./lib/components-react.d.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"@itwin/itwinui-react": "^3.15.0",
|
|
41
41
|
"react": "^18.0.0 || ^19.0.0",
|
|
42
42
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
43
|
-
"@itwin/core-react": "5.
|
|
43
|
+
"@itwin/core-react": "5.18.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@itwin/appui-abstract": "^5.1.0",
|
|
@@ -75,8 +75,8 @@
|
|
|
75
75
|
"typemoq": "^2.1.0",
|
|
76
76
|
"typescript": "~5.6.2",
|
|
77
77
|
"upath": "^2.0.1",
|
|
78
|
-
"vitest": "^3.
|
|
79
|
-
"@itwin/core-react": "5.
|
|
78
|
+
"vitest": "^3.2.4",
|
|
79
|
+
"@itwin/core-react": "5.18.0"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@itwin/itwinui-icons-react": "^2.8.0",
|