@itwin/imodel-components-react 5.17.0 → 5.19.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 +17 -0
- package/lib/imodel-components-react/inputs/new-editors/UseQuantityInfo.d.ts +1 -1
- package/lib/imodel-components-react/inputs/new-editors/UseQuantityInfo.d.ts.map +1 -1
- package/lib/imodel-components-react/inputs/new-editors/UseQuantityInfo.js +7 -1
- package/lib/imodel-components-react/inputs/new-editors/UseQuantityInfo.js.map +1 -1
- package/package.json +7 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Change Log - @itwin/imodel-components-react
|
|
2
2
|
|
|
3
|
+
## 5.19.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @itwin/components-react@5.19.0
|
|
8
|
+
- @itwin/core-react@5.19.0
|
|
9
|
+
|
|
10
|
+
## 5.18.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 4b5d07a: Fixed `QuantityEditor` overriding precision for fractional properties to invalid value.
|
|
15
|
+
- Updated dependencies [a756971]
|
|
16
|
+
- Updated dependencies [c7e347b]
|
|
17
|
+
- @itwin/components-react@5.18.0
|
|
18
|
+
- @itwin/core-react@5.18.0
|
|
19
|
+
|
|
3
20
|
## 5.17.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { QuantityTypeArg } from "@itwin/core-frontend";
|
|
2
|
-
import type
|
|
2
|
+
import { type FormatterSpec, type ParserSpec } from "@itwin/core-quantity";
|
|
3
3
|
interface UseQuantityInfoProps {
|
|
4
4
|
type: QuantityTypeArg | undefined;
|
|
5
5
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseQuantityInfo.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/UseQuantityInfo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"UseQuantityInfo.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/UseQuantityInfo.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EACL,KAAK,aAAa,EAGlB,KAAK,UAAU,EAChB,MAAM,sBAAsB,CAAC;AAO9B,UAAU,oBAAoB;IAC5B,IAAI,EAAE,eAAe,GAAG,SAAS,CAAC;CACnC;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,EAAE,IAAI,EAAE,EAAE,oBAAoB;;;EA8D7D"}
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
4
4
|
*--------------------------------------------------------------------------------------------*/
|
|
5
5
|
import { IModelApp } from "@itwin/core-frontend";
|
|
6
|
+
import { FormatType, parseFormatType, } from "@itwin/core-quantity";
|
|
6
7
|
import * as React from "react";
|
|
7
8
|
import { useIModelConnection } from "../../IModelConnectionContext.js";
|
|
8
9
|
/**
|
|
@@ -80,7 +81,12 @@ async function getFormatterParserSpec({ imodel, type, }) {
|
|
|
80
81
|
}
|
|
81
82
|
const persistenceUnitName = persistenceUnit.fullName;
|
|
82
83
|
const formatterSpec = await IModelApp.quantityFormatter.createFormatterSpec({
|
|
83
|
-
formatProps: {
|
|
84
|
+
formatProps: {
|
|
85
|
+
...formatProps,
|
|
86
|
+
precision: parseFormatType(formatProps.type, "") === FormatType.Decimal
|
|
87
|
+
? 12
|
|
88
|
+
: formatProps.precision,
|
|
89
|
+
},
|
|
84
90
|
persistenceUnitName,
|
|
85
91
|
});
|
|
86
92
|
const parserSpec = await IModelApp.quantityFormatter.createParserSpec({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UseQuantityInfo.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/UseQuantityInfo.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"UseQuantityInfo.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/inputs/new-editors/UseQuantityInfo.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAEL,UAAU,EACV,eAAe,GAEhB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AASvE;;;GAGG;AACH,MAAM,UAAU,eAAe,CAAC,EAAE,IAAI,EAAwB;IAC5D,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAGrD,GAAG,EAAE,CAAC,CAAC;QACR,SAAS,EAAE,SAAS;QACpB,MAAM,EAAE,SAAS;KAClB,CAAC,CAAC,CAAC;IAEJ,MAAM,MAAM,GAAG,mBAAmB,EAAE,CAAC;IAErC,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;YACvB,QAAQ,CAAC;gBACP,SAAS,EAAE,SAAS;gBACpB,MAAM,EAAE,SAAS;aAClB,CAAC,CAAC;YACH,OAAO;QACT,CAAC;QAED,IAAI,QAAQ,GAAG,KAAK,CAAC;QACrB,MAAM,mBAAmB,GAAG,KAAK,IAAI,EAAE;YACrC,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,GAAG,MAAM,sBAAsB,CAAC;gBACjE,MAAM;gBACN,IAAI;aACL,CAAC,CAAC;YACH,IAAI,CAAC,QAAQ,EAAE,CAA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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\nimport type { IModelConnection, QuantityTypeArg } from \"@itwin/core-frontend\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport {\n type FormatterSpec,\n FormatType,\n parseFormatType,\n type ParserSpec,\n} from \"@itwin/core-quantity\";\nimport * as React from \"react\";\nimport { useIModelConnection } from \"../../IModelConnectionContext.js\";\nimport type { KindOfQuantity } from \"@itwin/ecschema-metadata\";\n\n/* v8 ignore start */\n\ninterface UseQuantityInfoProps {\n type: QuantityTypeArg | undefined;\n}\n\n/**\n * Hook that finds the formatter and parser in `IModelApp.quantityFormatter` for a given quantity type.\n * @internal\n */\nexport function useQuantityInfo({ type }: UseQuantityInfoProps) {\n const [{ formatter, parser }, setState] = React.useState<{\n formatter: FormatterSpec | undefined;\n parser: ParserSpec | undefined;\n }>(() => ({\n formatter: undefined,\n parser: undefined,\n }));\n\n const imodel = useIModelConnection();\n\n React.useEffect(() => {\n if (type === undefined) {\n setState({\n formatter: undefined,\n parser: undefined,\n });\n return;\n }\n\n let disposed = false;\n const loadFormatterParser = async () => {\n const { formatterSpec, parserSpec } = await getFormatterParserSpec({\n imodel,\n type,\n });\n if (!disposed) {\n setState({ formatter: formatterSpec, parser: parserSpec });\n }\n };\n\n void loadFormatterParser();\n\n const removeListeners = [\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(\n loadFormatterParser\n ),\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(\n ({ quantityType }) => {\n if (quantityType === type) {\n void loadFormatterParser();\n }\n }\n ),\n ];\n if (IModelApp.formatsProvider) {\n removeListeners.push(\n IModelApp.formatsProvider.onFormatsChanged.addListener(async () =>\n loadFormatterParser()\n )\n );\n }\n\n return () => {\n disposed = true;\n removeListeners.forEach((remove) => {\n remove();\n });\n };\n }, [imodel, type]);\n\n return { formatter, parser };\n}\n\nasync function getFormatterParserSpec({\n imodel,\n type,\n}: {\n imodel?: IModelConnection;\n type: QuantityTypeArg;\n}) {\n // fallback to IModelApp.quantityFormatter:\n // - if `itwinjs-core` v4 is used\n // - don't have an iModelConnection to look up KOQ\n // - old quantity type enum is used instead of KOQ name\n if (!IModelApp.formatsProvider || !imodel || typeof type !== \"string\") {\n const quantityFormatterSpec =\n IModelApp.quantityFormatter.findFormatterSpecByQuantityType(type);\n const quantityParserSpec =\n IModelApp.quantityFormatter.findParserSpecByQuantityType(type);\n\n return {\n formatterSpec: quantityFormatterSpec,\n parserSpec: quantityParserSpec,\n };\n }\n\n const koq = await imodel.schemaContext.getSchemaItem(type);\n if (!koq) {\n return { formatter: undefined, parser: undefined };\n }\n\n // TODO: `KindOfQuantity` here is used only as a type because we don't have peerDep on `ecschema-metadata`\n // It should be added when dropping `itwinjs-core` v4 support\n const persistenceUnit = await (koq as KindOfQuantity).persistenceUnit;\n const formatProps = await IModelApp.formatsProvider.getFormat(type);\n if (!persistenceUnit || !formatProps) {\n return { formatter: undefined, parser: undefined };\n }\n\n const persistenceUnitName = persistenceUnit.fullName;\n const formatterSpec = await IModelApp.quantityFormatter.createFormatterSpec({\n formatProps: {\n ...formatProps,\n precision:\n parseFormatType(formatProps.type, \"\") === FormatType.Decimal\n ? 12\n : formatProps.precision,\n },\n persistenceUnitName,\n });\n const parserSpec = await IModelApp.quantityFormatter.createParserSpec({\n formatProps,\n persistenceUnitName,\n });\n return {\n formatterSpec,\n parserSpec,\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.
|
|
3
|
+
"version": "5.19.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.
|
|
48
|
-
"@itwin/core-react": "5.
|
|
47
|
+
"@itwin/components-react": "5.19.0",
|
|
48
|
+
"@itwin/core-react": "5.19.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@itwin/appui-abstract": "^5.1.0",
|
|
@@ -58,12 +58,11 @@
|
|
|
58
58
|
"@itwin/core-quantity": "^5.1.0",
|
|
59
59
|
"@itwin/ecschema-metadata": "^5.1.0",
|
|
60
60
|
"@itwin/eslint-plugin": "5.1.0",
|
|
61
|
-
"@itwin/itwinui-react": "^3.19.
|
|
61
|
+
"@itwin/itwinui-react": "^3.19.6",
|
|
62
62
|
"@itwin/webgl-compatibility": "^5.1.0",
|
|
63
63
|
"@testing-library/dom": "^10.4.1",
|
|
64
64
|
"@testing-library/react": "^16.3.0",
|
|
65
65
|
"@testing-library/user-event": "^14.6.1",
|
|
66
|
-
"@types/node": "20.17.8",
|
|
67
66
|
"@types/react": "^19.2.0",
|
|
68
67
|
"@types/react-dom": "^19.2.0",
|
|
69
68
|
"@vitest/coverage-v8": "^3.0.6",
|
|
@@ -84,9 +83,9 @@
|
|
|
84
83
|
"typemoq": "^2.1.0",
|
|
85
84
|
"typescript": "~5.6.2",
|
|
86
85
|
"upath": "^2.0.1",
|
|
87
|
-
"vitest": "^3.
|
|
88
|
-
"@itwin/components-react": "5.
|
|
89
|
-
"@itwin/core-react": "5.
|
|
86
|
+
"vitest": "^3.2.4",
|
|
87
|
+
"@itwin/components-react": "5.19.0",
|
|
88
|
+
"@itwin/core-react": "5.19.0"
|
|
90
89
|
},
|
|
91
90
|
"dependencies": {
|
|
92
91
|
"@itwin/itwinui-icons-react": "^2.8.0",
|