@itwin/imodel-components-react 5.33.2 → 5.34.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,24 @@
1
1
  # Change Log - @itwin/imodel-components-react
2
2
 
3
+ ## 5.34.0
4
+
5
+ ### Patch Changes
6
+
7
+ - af6103d: `KoqPropertyValueRenderer` now re-renders and re-formats its value when the active unit system, quantity formats, or formats provider formats change, so it no longer shows an outdated formatted value.
8
+ - Updated dependencies [6288f2e]
9
+ - Updated dependencies [fc74775]
10
+ - @itwin/components-react@5.34.0
11
+ - @itwin/core-react@5.34.0
12
+
13
+ ## 5.33.3
14
+
15
+ ### Patch Changes
16
+
17
+ - 68423de: Fixed issue where navigation cube would appear semi-transparent when theme bridge was enabled.
18
+ - Updated dependencies [b6f0279]
19
+ - @itwin/components-react@5.33.3
20
+ - @itwin/core-react@5.33.3
21
+
3
22
  ## 5.33.2
4
23
 
5
24
  ### Patch Changes
@@ -88,12 +88,12 @@ $arrow-margin: -3px;
88
88
  background: linear-gradient(#{$grad-start}, #{$grad-end});
89
89
  }
90
90
 
91
- .cube-top {
92
- background: $grad-start;
91
+ .cube-bottom {
92
+ background: linear-gradient(#{$grad-end}, #{$grad-end});
93
93
  }
94
94
 
95
- .cube-bottom {
96
- background: $grad-end;
95
+ .face {
96
+ background-color: $grad-start;
97
97
  }
98
98
 
99
99
  &.cube-dragging {
@@ -88,12 +88,12 @@ $arrow-margin: -3px;
88
88
  background: linear-gradient(#{$grad-start}, #{$grad-end});
89
89
  }
90
90
 
91
- .cube-top {
92
- background: $grad-start;
91
+ .cube-bottom {
92
+ background: linear-gradient(#{$grad-end}, #{$grad-end});
93
93
  }
94
94
 
95
- .cube-bottom {
96
- background: $grad-end;
95
+ .face {
96
+ background-color: $grad-start;
97
97
  }
98
98
 
99
99
  &.cube-dragging {
@@ -88,12 +88,12 @@ $arrow-margin: -3px;
88
88
  background: linear-gradient(#{$grad-start}, #{$grad-end});
89
89
  }
90
90
 
91
- .cube-top {
92
- background: $grad-start;
91
+ .cube-bottom {
92
+ background: linear-gradient(#{$grad-end}, #{$grad-end});
93
93
  }
94
94
 
95
- .cube-bottom {
96
- background: $grad-end;
95
+ .face {
96
+ background-color: $grad-start;
97
97
  }
98
98
 
99
99
  &.cube-dragging {
@@ -35,13 +35,48 @@ export class KoqPropertyValueRenderer {
35
35
  function KoqRenderer(props) {
36
36
  const { record, context } = props;
37
37
  const imodel = useIModelConnection();
38
+ const version = useFormattingChangeVersion(record.property.kindOfQuantityName);
38
39
  const stringValueCalculator = React.useCallback(async (recordToFormat) => {
39
40
  return imodel
40
41
  ? formatKoqValue(recordToFormat, imodel)
41
42
  : convertRecordToString(recordToFormat);
42
- }, [imodel]);
43
+ },
44
+ // eslint-disable-next-line react-hooks/exhaustive-deps -- version is intentionally included to force a reformat when the formatting changes
45
+ [imodel, version]);
43
46
  return (React.createElement(PrimitivePropertyValueRendererImpl, { record: record, context: context, stringValueCalculator: stringValueCalculator }));
44
47
  }
48
+ /**
49
+ * Returns a counter that increments whenever the active formatting unit system
50
+ * or the formats relevant to the given kind of quantity change. Used as part of
51
+ * the rendered component `key` to force a remount so the KOQ value is
52
+ * re-formatted and the rendered value stays up to date.
53
+ */
54
+ function useFormattingChangeVersion(koqName) {
55
+ const [version, setVersion] = React.useState(0);
56
+ React.useEffect(() => {
57
+ const bump = () => setVersion((prev) => prev + 1);
58
+ const removeListeners = [
59
+ IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(bump),
60
+ IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(({ quantityType }) => {
61
+ if (quantityType === koqName) {
62
+ bump();
63
+ }
64
+ }),
65
+ ];
66
+ if (IModelApp.formatsProvider) {
67
+ removeListeners.push(IModelApp.formatsProvider.onFormatsChanged.addListener(({ formatsChanged }) => {
68
+ if (formatsChanged === "all" ||
69
+ formatsChanged.some((formatName) => formatName === koqName)) {
70
+ bump();
71
+ }
72
+ }));
73
+ }
74
+ return () => {
75
+ removeListeners.forEach((remove) => remove());
76
+ };
77
+ }, [koqName]);
78
+ return version;
79
+ }
45
80
  async function formatKoqValue(record, imodel) {
46
81
  const value = record.value;
47
82
  const koqName = record.property.kindOfQuantityName;
@@ -1 +1 @@
1
- {"version":3,"file":"KoqPropertyRenderer.js","sourceRoot":"","sources":["../../../src/imodel-components-react/properties/KoqPropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,0BAA0B,CAAC;AAE5D;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IACnC,uDAAuD;IAChD,SAAS,CAAC,MAAsB;QACrC,OAAO,CACL,MAAM,CAAC,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS;YAC1D,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,CAAC,MAAM,CAAC,OAAO,EAAE;gBAC9D,MAAM,CAAC,QAAQ,CAAC,QAAQ,KAAK,iBAAiB,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACjE,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CACrC,CAAC;IACJ,CAAC;I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ACvC,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,GAAG,cAAc,CAAC,YAAY,IACnC,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAC/C,EAAE,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAC/C,KAAK,CAAC,KAAe,EACrB,aAAa,CACd,CAAC;AACJ,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\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { assert } from \"@itwin/core-bentley\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"@itwin/components-react\";\nimport { useIModelConnection } from \"../IModelConnectionContext.js\";\nimport { IModelApp, type IModelConnection } from \"@itwin/core-frontend\";\nimport {\n convertRecordToString,\n PrimitivePropertyValueRendererImpl,\n} from \"@itwin/components-react/internal\";\nimport { ValueUtilities } from \"@itwin/components-react\";\nimport { getFormatterParserSpec } from \"../KoqUtilities.js\";\n\n/**\n * Name of the renderer for properties with kind of quantity.\n * @public\n */\nexport const KOQ_RENDERER_NAME = \"KoqPropertyValueRenderer\";\n\n/**\n * Renderer for properties with kind of quantity.\n * @internal\n */\nexport class KoqPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n (record.property.typename === StandardTypeNames.Double.valueOf() ||\n record.property.typename === StandardTypeNames.Float.valueOf()) &&\n !!record.property.kindOfQuantityName\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return <KoqRenderer record={record} context={context} />;\n }\n}\n\nfunction KoqRenderer(props: {\n record: PropertyRecord;\n context?: PropertyValueRendererContext;\n}) {\n const { record, context } = props;\n const imodel = useIModelConnection();\n const stringValueCalculator = React.useCallback(\n async (recordToFormat: PropertyRecord) => {\n return imodel\n ? formatKoqValue(recordToFormat, imodel)\n : convertRecordToString(recordToFormat);\n },\n [imodel]\n );\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={stringValueCalculator}\n />\n );\n}\n\nasync function formatKoqValue(\n record: PropertyRecord,\n imodel: IModelConnection\n): Promise<string> {\n const value = record.value;\n const koqName = record.property.kindOfQuantityName;\n assert(\n value.valueFormat === PropertyValueFormat.Primitive,\n \"PropertyRecord value is not primitive\"\n );\n assert(koqName !== undefined, \"Kind of quantity name is undefined\");\n\n const { formatterSpec } = (await getFormatterParserSpec({\n imodel,\n type: koqName,\n })) ?? { formatterSpec: undefined };\n\n if (!formatterSpec) {\n return convertRecordToString(record);\n }\n\n if (record.isMerged) {\n return `${ValueUtilities.MERGED_VALUE} ${\n formatterSpec.unitConversions?.[0]?.label ?? \"\"\n }`;\n }\n\n return IModelApp.quantityFormatter.formatQuantity(\n value.value as number,\n formatterSpec\n );\n}\n"]}
1
+ {"version":3,"file":"KoqPropertyRenderer.js","sourceRoot":"","sources":["../../../src/imodel-components-react/properties/KoqPropertyRenderer.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAK7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAyB,MAAM,sBAAsB,CAAC;AACxE,OAAO,EACL,qBAAqB,EACrB,kCAAkC,GACnC,MAAM,kC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C;IACJ,CAAC,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC;IACd,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,KAAK,UAAU,cAAc,CAC3B,MAAsB,EACtB,MAAwB;IAExB,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;IAC3B,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAAC;IACnD,MAAM,CACJ,KAAK,CAAC,WAAW,KAAK,mBAAmB,CAAC,SAAS,EACnD,uCAAuC,CACxC,CAAC;IACF,MAAM,CAAC,OAAO,KAAK,SAAS,EAAE,oCAAoC,CAAC,CAAC;IAEpE,MAAM,EAAE,aAAa,EAAE,GAAG,CAAC,MAAM,sBAAsB,CAAC;QACtD,MAAM;QACN,IAAI,EAAE,OAAO;KACd,CAAC,CAAC,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC;IAEpC,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,OAAO,qBAAqB,CAAC,MAAM,CAAC,CAAC;IACvC,CAAC;IAED,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,OAAO,GAAG,cAAc,CAAC,YAAY,IACnC,aAAa,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAC/C,EAAE,CAAC;IACL,CAAC;IAED,OAAO,SAAS,CAAC,iBAAiB,CAAC,cAAc,CAC/C,KAAK,CAAC,KAAe,EACrB,aAAa,CACd,CAAC;AACJ,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\nimport * as React from \"react\";\nimport type { PropertyRecord } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat, StandardTypeNames } from \"@itwin/appui-abstract\";\nimport { assert } from \"@itwin/core-bentley\";\nimport type {\n IPropertyValueRenderer,\n PropertyValueRendererContext,\n} from \"@itwin/components-react\";\nimport { useIModelConnection } from \"../IModelConnectionContext.js\";\nimport { IModelApp, type IModelConnection } from \"@itwin/core-frontend\";\nimport {\n convertRecordToString,\n PrimitivePropertyValueRendererImpl,\n} from \"@itwin/components-react/internal\";\nimport { ValueUtilities } from \"@itwin/components-react\";\nimport { getFormatterParserSpec } from \"../KoqUtilities.js\";\n\n/**\n * Name of the renderer for properties with kind of quantity.\n * @public\n */\nexport const KOQ_RENDERER_NAME = \"KoqPropertyValueRenderer\";\n\n/**\n * Renderer for properties with kind of quantity.\n * @internal\n */\nexport class KoqPropertyValueRenderer implements IPropertyValueRenderer {\n /** Checks if the renderer can handle given property */\n public canRender(record: PropertyRecord) {\n return (\n record.value.valueFormat === PropertyValueFormat.Primitive &&\n (record.property.typename === StandardTypeNames.Double.valueOf() ||\n record.property.typename === StandardTypeNames.Float.valueOf()) &&\n !!record.property.kindOfQuantityName\n );\n }\n\n /** Method that returns a JSX representation of PropertyRecord */\n public render(\n record: PropertyRecord,\n context?: PropertyValueRendererContext\n ) {\n return <KoqRenderer record={record} context={context} />;\n }\n}\n\nfunction KoqRenderer(props: {\n record: PropertyRecord;\n context?: PropertyValueRendererContext;\n}) {\n const { record, context } = props;\n const imodel = useIModelConnection();\n const version = useFormattingChangeVersion(\n record.property.kindOfQuantityName\n );\n const stringValueCalculator = React.useCallback(\n async (recordToFormat: PropertyRecord) => {\n return imodel\n ? formatKoqValue(recordToFormat, imodel)\n : convertRecordToString(recordToFormat);\n },\n // eslint-disable-next-line react-hooks/exhaustive-deps -- version is intentionally included to force a reformat when the formatting changes\n [imodel, version]\n );\n return (\n <PrimitivePropertyValueRendererImpl\n record={record}\n context={context}\n stringValueCalculator={stringValueCalculator}\n />\n );\n}\n\n/**\n * Returns a counter that increments whenever the active formatting unit system\n * or the formats relevant to the given kind of quantity change. Used as part of\n * the rendered component `key` to force a remount so the KOQ value is\n * re-formatted and the rendered value stays up to date.\n */\nfunction useFormattingChangeVersion(koqName: string | undefined): number {\n const [version, setVersion] = React.useState(0);\n React.useEffect(() => {\n const bump = () => setVersion((prev) => prev + 1);\n\n const removeListeners = [\n IModelApp.quantityFormatter.onActiveFormattingUnitSystemChanged.addListener(\n bump\n ),\n IModelApp.quantityFormatter.onQuantityFormatsChanged.addListener(\n ({ quantityType }) => {\n if (quantityType === koqName) {\n bump();\n }\n }\n ),\n ];\n if (IModelApp.formatsProvider) {\n removeListeners.push(\n IModelApp.formatsProvider.onFormatsChanged.addListener(\n ({ formatsChanged }) => {\n if (\n formatsChanged === \"all\" ||\n formatsChanged.some((formatName) => formatName === koqName)\n ) {\n bump();\n }\n }\n )\n );\n }\n\n return () => {\n removeListeners.forEach((remove) => remove());\n };\n }, [koqName]);\n return version;\n}\n\nasync function formatKoqValue(\n record: PropertyRecord,\n imodel: IModelConnection\n): Promise<string> {\n const value = record.value;\n const koqName = record.property.kindOfQuantityName;\n assert(\n value.valueFormat === PropertyValueFormat.Primitive,\n \"PropertyRecord value is not primitive\"\n );\n assert(koqName !== undefined, \"Kind of quantity name is undefined\");\n\n const { formatterSpec } = (await getFormatterParserSpec({\n imodel,\n type: koqName,\n })) ?? { formatterSpec: undefined };\n\n if (!formatterSpec) {\n return convertRecordToString(record);\n }\n\n if (record.isMerged) {\n return `${ValueUtilities.MERGED_VALUE} ${\n formatterSpec.unitConversions?.[0]?.label ?? \"\"\n }`;\n }\n\n return IModelApp.quantityFormatter.formatQuantity(\n value.value as number,\n formatterSpec\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/imodel-components-react",
3
- "version": "5.33.2",
3
+ "version": "5.34.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.33.2",
48
- "@itwin/core-react": "5.33.2"
47
+ "@itwin/components-react": "5.34.0",
48
+ "@itwin/core-react": "5.34.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": "^4.1.10",
86
- "@itwin/components-react": "5.33.2",
87
- "@itwin/core-react": "5.33.2"
86
+ "@itwin/components-react": "5.34.0",
87
+ "@itwin/core-react": "5.34.0"
88
88
  },
89
89
  "dependencies": {
90
90
  "@itwin/itwinui-icons-react": "^2.11.0",