@itwin/presentation-common 4.0.0-dev.80 → 4.0.0-dev.81
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/Ruleset.schema.json +4 -0
- package/lib/cjs/assets/locales/en/Presentation.json +4 -0
- package/lib/cjs/assets/locales/en-PSEUDO/Presentation.json +4 -0
- package/lib/cjs/presentation-common/{PropertyFormatter.d.ts → KoqPropertyValueFormatter.d.ts} +3 -14
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -0
- package/lib/cjs/presentation-common/{PropertyFormatter.js → KoqPropertyValueFormatter.js} +5 -48
- package/lib/cjs/presentation-common/KoqPropertyValueFormatter.js.map +1 -0
- package/lib/cjs/presentation-common/LocalizationHelper.d.ts.map +1 -1
- package/lib/cjs/presentation-common/LocalizationHelper.js +3 -0
- package/lib/cjs/presentation-common/LocalizationHelper.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationIpcInterface.d.ts +0 -13
- package/lib/cjs/presentation-common/PresentationIpcInterface.d.ts.map +1 -1
- package/lib/cjs/presentation-common/PresentationIpcInterface.js.map +1 -1
- package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts +6 -0
- package/lib/cjs/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
- package/lib/cjs/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/cjs/presentation-common/Update.d.ts +1 -64
- package/lib/cjs/presentation-common/Update.d.ts.map +1 -1
- package/lib/cjs/presentation-common/Update.js +1 -113
- package/lib/cjs/presentation-common/Update.js.map +1 -1
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts +29 -0
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -0
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.js +139 -0
- package/lib/cjs/presentation-common/content/PropertyValueFormatter.js.map +1 -0
- package/lib/cjs/presentation-common/content/Value.d.ts +18 -3
- package/lib/cjs/presentation-common/content/Value.d.ts.map +1 -1
- package/lib/cjs/presentation-common/content/Value.js +8 -0
- package/lib/cjs/presentation-common/content/Value.js.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.d.ts +7 -0
- package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.d.ts.map +1 -1
- package/lib/cjs/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
- package/lib/cjs/presentation-common.d.ts +2 -1
- package/lib/cjs/presentation-common.d.ts.map +1 -1
- package/lib/cjs/presentation-common.js +2 -1
- package/lib/cjs/presentation-common.js.map +1 -1
- package/lib/esm/presentation-common/{PropertyFormatter.d.ts → KoqPropertyValueFormatter.d.ts} +3 -14
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.d.ts.map +1 -0
- package/lib/esm/presentation-common/{PropertyFormatter.js → KoqPropertyValueFormatter.js} +3 -45
- package/lib/esm/presentation-common/KoqPropertyValueFormatter.js.map +1 -0
- package/lib/esm/presentation-common/LocalizationHelper.d.ts.map +1 -1
- package/lib/esm/presentation-common/LocalizationHelper.js +3 -0
- package/lib/esm/presentation-common/LocalizationHelper.js.map +1 -1
- package/lib/esm/presentation-common/PresentationIpcInterface.d.ts +0 -13
- package/lib/esm/presentation-common/PresentationIpcInterface.d.ts.map +1 -1
- package/lib/esm/presentation-common/PresentationIpcInterface.js.map +1 -1
- package/lib/esm/presentation-common/PresentationManagerOptions.d.ts +6 -0
- package/lib/esm/presentation-common/PresentationManagerOptions.d.ts.map +1 -1
- package/lib/esm/presentation-common/PresentationManagerOptions.js.map +1 -1
- package/lib/esm/presentation-common/Update.d.ts +1 -64
- package/lib/esm/presentation-common/Update.d.ts.map +1 -1
- package/lib/esm/presentation-common/Update.js +0 -112
- package/lib/esm/presentation-common/Update.js.map +1 -1
- package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts +29 -0
- package/lib/esm/presentation-common/content/PropertyValueFormatter.d.ts.map +1 -0
- package/lib/esm/presentation-common/content/PropertyValueFormatter.js +134 -0
- package/lib/esm/presentation-common/content/PropertyValueFormatter.js.map +1 -0
- package/lib/esm/presentation-common/content/Value.d.ts +18 -3
- package/lib/esm/presentation-common/content/Value.d.ts.map +1 -1
- package/lib/esm/presentation-common/content/Value.js +8 -0
- package/lib/esm/presentation-common/content/Value.js.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.d.ts +7 -0
- package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.d.ts.map +1 -1
- package/lib/esm/presentation-common/rules/content/modifiers/ContentModifier.js.map +1 -1
- package/lib/esm/presentation-common.d.ts +2 -1
- package/lib/esm/presentation-common.d.ts.map +1 -1
- package/lib/esm/presentation-common.js +2 -1
- package/lib/esm/presentation-common.js.map +1 -1
- package/lib/public/locales/en/Presentation.json +4 -0
- package/package.json +10 -10
- package/lib/cjs/presentation-common/PropertyFormatter.d.ts.map +0 -1
- package/lib/cjs/presentation-common/PropertyFormatter.js.map +0 -1
- package/lib/esm/presentation-common/PropertyFormatter.d.ts.map +0 -1
- package/lib/esm/presentation-common/PropertyFormatter.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"presentation-common.js","sourceRoot":"","sources":["../../src/presentation-common.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,kDAAkD,CAAC;AACjE,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,
|
|
1
|
+
{"version":3,"file":"presentation-common.js","sourceRoot":"","sources":["../../src/presentation-common.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;;;;GAKG;AACH,cAAc,kCAAkC,CAAC;AACjD,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uCAAuC,CAAC;AACtD,cAAc,kDAAkD,CAAC;AACjE,cAAc,yCAAyC,CAAC;AACxD,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,iDAAiD,CAAC;AAEhE;;;;;;GAMG;AACH,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,yCAAyC,CAAC;AAExD;;;;;GAKG;AACH,cAAc,gDAAgD,CAAC;AAE/D;;;;;GAKG;AACH,cAAc,wCAAwC,CAAC;AACvD,cAAc,uCAAuC,CAAC;AACtD,cAAc,0CAA0C,CAAC;AACzD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,sCAAsC,CAAC;AACrD,cAAc,sCAAsC,CAAC;AACrD,cAAc,oCAAoC,CAAC;AACnD,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC;AACvD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,qCAAqC,CAAC;AACpD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,sDAAsD,CAAC;AAErE;;;;;GAKG;AACH,cAAc,gDAAgD,CAAC;AAC/D,cAAc,qCAAqC,CAAC;AACpD,cAAc,sCAAsC,CAAC;AACrD,cAAc,iDAAiD,CAAC;AAEhE;;;;;GAKG;AACH,cAAc,qDAAqD,CAAC;AACpE,cAAc,8DAA8D,CAAC;AAC7E,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6EAA6E,CAAC;AAC5F,cAAc,mFAAmF,CAAC;AAClG,cAAc,sDAAsD,CAAC;AACrE,cAAc,yDAAyD,CAAC;AACxE,cAAc,yEAAyE,CAAC;AACxF,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AACnE,cAAc,wDAAwD,CAAC;AACvE,cAAc,6DAA6D,CAAC;AAC5E,cAAc,4DAA4D,CAAC;AAC3E,cAAc,wDAAwD,CAAC;AACvE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,iEAAiE,CAAC;AAChF,cAAc,yDAAyD,CAAC;AACxE,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,oFAAoF,CAAC;AACnG,cAAc,0EAA0E,CAAC;AACzF,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,wEAAwE,CAAC;AACvF,cAAc,qEAAqE,CAAC;AACpF,cAAc,iFAAiF,CAAC;AAChG,cAAc,+DAA+D,CAAC;AAC9E,cAAc,6EAA6E,CAAC;AAC5F,cAAc,4EAA4E,CAAC;AAC3F,cAAc,2EAA2E,CAAC;AAC1F,cAAc,8EAA8E,CAAC;AAC7F,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2DAA2D,CAAC;AAC1E,cAAc,kCAAkC,CAAC;AACjD,cAAc,qCAAqC,CAAC;AACpD,cAAc,kDAAkD,CAAC;AACjE,cAAc,uCAAuC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/**\r\n * @module Core\r\n *\r\n * @docs-group-description Core\r\n * Common types used all across Presentation packages.\r\n */\r\nexport * from \"./presentation-common/AsyncTasks\";\r\nexport * from \"./presentation-common/Diagnostics\";\r\nexport * from \"./presentation-common/EC\";\r\nexport * from \"./presentation-common/Error\";\r\nexport * from \"./presentation-common/KeySet\";\r\nexport * from \"./presentation-common/LabelDefinition\";\r\nexport * from \"./presentation-common/PresentationManagerOptions\";\r\nexport * from \"./presentation-common/RegisteredRuleset\";\r\nexport * from \"./presentation-common/RulesetVariables\";\r\nexport * from \"./presentation-common/RulesetsFactory\";\r\nexport * from \"./presentation-common/Update\";\r\nexport * from \"./presentation-common/Utils\";\r\nexport * from \"./presentation-common/PresentationIpcInterface\";\r\nexport * from \"./presentation-common/LocalizationHelper\";\r\nexport * from \"./presentation-common/InstanceFilterDefinition\";\r\nexport * from \"./presentation-common/KoqPropertyValueFormatter\";\r\n\r\n/**\r\n * @module RPC\r\n *\r\n * @docs-group-description RPC\r\n * Types used for RPC communication between frontend and backend. Generally should\r\n * only be used internally by presentation packages.\r\n */\r\nexport * from \"./presentation-common/PresentationRpcInterface\";\r\nexport * from \"./presentation-common/RpcRequestsHandler\";\r\nexport * from \"./presentation-common/ElementProperties\";\r\n\r\n/**\r\n * @module UnifiedSelection\r\n *\r\n * @docs-group-description UnifiedSelection\r\n * Types related to [unified selection]($docs/presentation/unified-selection/index.md).\r\n */\r\nexport * from \"./presentation-common/selection/SelectionScope\";\r\n\r\n/**\r\n * @module Content\r\n *\r\n * @docs-group-description Content\r\n * Types related to presentation [content]($docs/presentation/content/index.md).\r\n */\r\nexport * from \"./presentation-common/content/Category\";\r\nexport * from \"./presentation-common/content/Content\";\r\nexport * from \"./presentation-common/content/Descriptor\";\r\nexport * from \"./presentation-common/content/DisplayTypes\";\r\nexport * from \"./presentation-common/content/Editor\";\r\nexport * from \"./presentation-common/content/Fields\";\r\nexport * from \"./presentation-common/content/Item\";\r\nexport * from \"./presentation-common/content/Property\";\r\nexport * from \"./presentation-common/content/Renderer\";\r\nexport * from \"./presentation-common/content/TypeDescription\";\r\nexport * from \"./presentation-common/content/Value\";\r\nexport * from \"./presentation-common/content/ContentTraverser\";\r\nexport * from \"./presentation-common/content/PropertyValueFormatter\";\r\n\r\n/**\r\n * @module Hierarchies\r\n *\r\n * @docs-group-description Hierarchies\r\n * Types related to presentation [hierarchies]($docs/presentation/hierarchies/index.md).\r\n */\r\nexport * from \"./presentation-common/hierarchy/HierarchyLevel\";\r\nexport * from \"./presentation-common/hierarchy/Key\";\r\nexport * from \"./presentation-common/hierarchy/Node\";\r\nexport * from \"./presentation-common/hierarchy/NodePathElement\";\r\n\r\n/**\r\n * @module PresentationRules\r\n *\r\n * @docs-group-description PresentationRules\r\n * Types for defining the presentation ruleset.\r\n */\r\nexport * from \"./presentation-common/rules/hierarchy/ChildNodeRule\";\r\nexport * from \"./presentation-common/rules/hierarchy/ChildNodeSpecification\";\r\nexport * from \"./presentation-common/rules/hierarchy/CustomNodeSpecification\";\r\nexport * from \"./presentation-common/rules/hierarchy/CustomQueryInstanceNodesSpecification\";\r\nexport * from \"./presentation-common/rules/hierarchy/InstanceNodesOfSpecificClassesSpecification\";\r\nexport * from \"./presentation-common/rules/hierarchy/NavigationRule\";\r\nexport * from \"./presentation-common/rules/hierarchy/NodeArtifactsRule\";\r\nexport * from \"./presentation-common/rules/hierarchy/RelatedInstanceNodesSpecification\";\r\nexport * from \"./presentation-common/rules/hierarchy/RootNodeRule\";\r\nexport * from \"./presentation-common/rules/hierarchy/SubCondition\";\r\nexport * from \"./presentation-common/rules/customization/CheckBoxRule\";\r\nexport * from \"./presentation-common/rules/customization/CustomizationRule\";\r\nexport * from \"./presentation-common/rules/customization/ExtendedDataRule\";\r\nexport * from \"./presentation-common/rules/customization/GroupingRule\";\r\nexport * from \"./presentation-common/rules/customization/ImageIdOverride\";\r\nexport * from \"./presentation-common/rules/customization/InstanceLabelOverride\";\r\nexport * from \"./presentation-common/rules/customization/LabelOverride\";\r\nexport * from \"./presentation-common/rules/customization/SortingRule\";\r\nexport * from \"./presentation-common/rules/customization/StyleOverride\";\r\nexport * from \"./presentation-common/rules/content/ContentInstancesOfSpecificClassesSpecification\";\r\nexport * from \"./presentation-common/rules/content/ContentRelatedInstancesSpecification\";\r\nexport * from \"./presentation-common/rules/content/ContentRule\";\r\nexport * from \"./presentation-common/rules/content/ContentSpecification\";\r\nexport * from \"./presentation-common/rules/content/PropertySpecification\";\r\nexport * from \"./presentation-common/rules/content/SelectedNodeInstancesSpecification\";\r\nexport * from \"./presentation-common/rules/content/DefaultPropertyCategoryOverride\";\r\nexport * from \"./presentation-common/rules/content/modifiers/CalculatedPropertiesSpecification\";\r\nexport * from \"./presentation-common/rules/content/modifiers/ContentModifier\";\r\nexport * from \"./presentation-common/rules/content/modifiers/PropertyCategorySpecification\";\r\nexport * from \"./presentation-common/rules/content/modifiers/PropertyEditorsSpecification\";\r\nexport * from \"./presentation-common/rules/content/modifiers/CustomRendererSpecification\";\r\nexport * from \"./presentation-common/rules/content/modifiers/RelatedPropertiesSpecification\";\r\nexport * from \"./presentation-common/rules/ClassSpecifications\";\r\nexport * from \"./presentation-common/rules/RelatedInstanceSpecification\";\r\nexport * from \"./presentation-common/rules/RelationshipDirection\";\r\nexport * from \"./presentation-common/rules/RelationshipPathSpecification\";\r\nexport * from \"./presentation-common/rules/Rule\";\r\nexport * from \"./presentation-common/rules/Ruleset\";\r\nexport * from \"./presentation-common/rules/SchemasSpecification\";\r\nexport * from \"./presentation-common/rules/Variables\";\r\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-common",
|
|
3
|
-
"version": "4.0.0-dev.
|
|
3
|
+
"version": "4.0.0-dev.81",
|
|
4
4
|
"description": "Common pieces for iModel.js presentation packages",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -22,17 +22,17 @@
|
|
|
22
22
|
"module": "lib/esm/presentation-common.js",
|
|
23
23
|
"typings": "lib/cjs/presentation-common",
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@itwin/core-bentley": "^4.0.0-dev.
|
|
26
|
-
"@itwin/core-common": "^4.0.0-dev.
|
|
27
|
-
"@itwin/core-quantity": "^4.0.0-dev.
|
|
28
|
-
"@itwin/ecschema-metadata": "^4.0.0-dev.
|
|
25
|
+
"@itwin/core-bentley": "^4.0.0-dev.81",
|
|
26
|
+
"@itwin/core-common": "^4.0.0-dev.81",
|
|
27
|
+
"@itwin/core-quantity": "^4.0.0-dev.81",
|
|
28
|
+
"@itwin/ecschema-metadata": "^4.0.0-dev.81"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
|
-
"@itwin/build-tools": "4.0.0-dev.
|
|
32
|
-
"@itwin/core-bentley": "4.0.0-dev.
|
|
33
|
-
"@itwin/core-common": "4.0.0-dev.
|
|
34
|
-
"@itwin/core-quantity": "4.0.0-dev.
|
|
35
|
-
"@itwin/ecschema-metadata": "4.0.0-dev.
|
|
31
|
+
"@itwin/build-tools": "4.0.0-dev.81",
|
|
32
|
+
"@itwin/core-bentley": "4.0.0-dev.81",
|
|
33
|
+
"@itwin/core-common": "4.0.0-dev.81",
|
|
34
|
+
"@itwin/core-quantity": "4.0.0-dev.81",
|
|
35
|
+
"@itwin/ecschema-metadata": "4.0.0-dev.81",
|
|
36
36
|
"@itwin/eslint-plugin": "^4.0.0-dev.33",
|
|
37
37
|
"@types/chai": "4.3.1",
|
|
38
38
|
"@types/chai-as-promised": "^7",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyFormatter.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/PropertyFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAuB,aAAa,EAAE,UAAU,EAAiB,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACpH,OAAO,EAC6E,aAAa,EAEhG,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM5C,aAAa;AACb,MAAM,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6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,GAAG;QACjB,gBAAgB,EAAE,GAAG;QACrB,SAAS,EAAE;YACT,KAAK,EAAE,CAAC;oBACN,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B,CAAC;SACH;KACF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,UAAyB;IACxD,QAAQ,UAAU,EAAE;QAClB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;KAC/D;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Format, FormatProps, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\r\n Format as ECFormat, InvertedUnit, ISchemaLocater, KindOfQuantity, OverrideFormat, SchemaContext, SchemaKey, SchemaMatchType, SchemaUnitProvider,\r\n Unit,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { Content } from \"./content/Content\";\r\nimport { Field, PropertiesField } from \"./content/Fields\";\r\nimport { DisplayValue, NestedContentValue, Value } from \"./content/Value\";\r\nimport { KindOfQuantityInfo, PropertyInfo } from \"./EC\";\r\nimport { ValuesDictionary } from \"./Utils\";\r\n\r\n/** @alpha */\r\nexport interface FormatOptions {\r\n koqName: string;\r\n unitSystem: UnitSystemKey;\r\n}\r\n\r\n/** @alpha */\r\nexport class PropertyValueFormatter {\r\n private _unitsProvider: UnitsProvider;\r\n\r\n constructor(private _schemaContext: SchemaContext) {\r\n this._unitsProvider = new SchemaUnitProvider(_schemaContext);\r\n }\r\n\r\n public async format(value: number, options: FormatOptions) {\r\n const formatterSpec = await this.getFormatterSpec(options);\r\n if (!formatterSpec)\r\n return undefined;\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n\r\n public async getFormatterSpec(options: FormatOptions) {\r\n const formattingProps = await getFormattingProps(this._schemaContext, options);\r\n if (!formattingProps)\r\n return undefined;\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\r\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\r\n }\r\n\r\n public async getParserSpec(options: FormatOptions) {\r\n const formattingProps = await getFormattingProps(this._schemaContext, options);\r\n if (!formattingProps)\r\n return undefined;\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\r\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\r\n }\r\n}\r\n\r\n/** @alpha */\r\nexport class ContentPropertyValueFormatter {\r\n constructor(private _propertyValueFormatter: PropertyValueFormatter, private _unitSystem: UnitSystemKey) { }\r\n\r\n public async formatContent(content: Content) {\r\n const descriptor = content.descriptor;\r\n for (const item of content.contentSet) {\r\n await this.formatValues(item.values, item.displayValues, descriptor.fields, item.mergedFieldNames);\r\n }\r\n return content;\r\n }\r\n\r\n private async formatValues(values: ValuesDictionary<Value>, displayValues: ValuesDictionary<DisplayValue>, fields: Field[], mergedFields: string[]) {\r\n for (const field of fields) {\r\n const value = values[field.name];\r\n if (field.isNestedContentField() && !mergedFields.includes(field.name)) {\r\n assert(Value.isNestedContent(value));\r\n await this.formatNestedContentDisplayValues(value, field.nestedFields);\r\n continue;\r\n }\r\n\r\n if (!this.isFormattable(field) || typeof value !== \"number\")\r\n continue;\r\n\r\n const koq = field.properties[0].property.kindOfQuantity;\r\n const formattedValue = await this._propertyValueFormatter.format(value, { koqName: koq.name, unitSystem: this._unitSystem });\r\n if (!formattedValue)\r\n continue;\r\n\r\n displayValues[field.name] = formattedValue;\r\n }\r\n }\r\n\r\n private async formatNestedContentDisplayValues(nestedValues: NestedContentValue[], fields: Field[]) {\r\n for (const nestedValue of nestedValues) {\r\n await this.formatValues(nestedValue.values, nestedValue.displayValues, fields, nestedValue.mergedFieldNames);\r\n }\r\n }\r\n\r\n private isFormattable(field: Field): field is FormattableField {\r\n return field.isPropertiesField()\r\n && field.properties.length > 0\r\n && field.properties[0].property.kindOfQuantity !== undefined;\r\n }\r\n}\r\n\r\ntype FormattableField = PropertiesField & {\r\n properties: [{\r\n property: PropertyInfo & {\r\n kindOfQuantity: KindOfQuantityInfo;\r\n };\r\n }];\r\n};\r\n\r\ninterface FormattingProps {\r\n formatProps: FormatProps;\r\n persistenceUnitName: string;\r\n}\r\n\r\nasync function getFormattingProps(schemaLocater: ISchemaLocater, options: FormatOptions): Promise<FormattingProps | undefined> {\r\n const { koqName, unitSystem } = options;\r\n\r\n const koq = await getKoq(schemaLocater, koqName);\r\n if (!koq)\r\n return undefined;\r\n\r\n const persistenceUnit = await koq.persistenceUnit;\r\n // istanbul ignore if\r\n if (!persistenceUnit)\r\n return undefined;\r\n\r\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, unitSystem);\r\n if (!formatProps)\r\n return undefined;\r\n\r\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\r\n}\r\n\r\nasync function getKoq(schemaLocater: ISchemaLocater, fullName: string) {\r\n const [schemaName, propKoqName] = fullName.split(\":\");\r\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\r\n if (!schema)\r\n return undefined;\r\n\r\n return schema.getItem<KindOfQuantity>(propKoqName);\r\n}\r\n\r\nasync function getKoqFormatProps(koq: KindOfQuantity, persistenceUnit: Unit | InvertedUnit, unitSystem: UnitSystemKey) {\r\n const unitSystems = getUnitSystemGroupNames(unitSystem);\r\n // use one of KOQ presentation format that matches requested unit system\r\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystems);\r\n if (presentationFormat)\r\n return formatToFormatProps(presentationFormat);\r\n\r\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\r\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\r\n if (persistenceUnitSystem && unitSystems.includes(persistenceUnitSystem.name.toUpperCase()))\r\n return getPersistenceUnitFormatProps(persistenceUnit);\r\n\r\n // use default presentation format if persistence unit does not match requested unit system\r\n if (koq.defaultPresentationFormat)\r\n return formatToFormatProps(koq.defaultPresentationFormat);\r\n\r\n return undefined;\r\n}\r\n\r\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystems: string[]) {\r\n const presentationFormats = koq.presentationFormats;\r\n for (const system of unitSystems) {\r\n for (const format of presentationFormats) {\r\n const unit = format.units && format.units[0][0];\r\n // istanbul ignore if\r\n if (!unit)\r\n continue;\r\n\r\n const currentUnitSystem = await unit.unitSystem;\r\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system)\r\n return format;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction formatToFormatProps(format: ECFormat | OverrideFormat): FormatProps {\r\n // istanbul ignore if\r\n if (OverrideFormat.isOverrideFormat(format)) {\r\n const baseFormat = baseFormatToFormatProps(format.parent);\r\n return {\r\n ...baseFormat,\r\n composite: format.units\r\n ? {\r\n ...baseFormat.composite,\r\n units: format.units.map(([unit, _]) => ({ name: unit.fullName, label: unit.label })),\r\n spacer: format.spacer,\r\n includeZero: format.includeZero,\r\n }\r\n : baseFormat.composite,\r\n };\r\n }\r\n return baseFormatToFormatProps(format);\r\n}\r\n\r\nfunction baseFormatToFormatProps(format: ECFormat): FormatProps {\r\n const json = format.toJSON();\r\n return {\r\n ...json,\r\n composite: json.composite\r\n ? {\r\n ...json.composite,\r\n spacer: format.spacer,\r\n includeZero: format.includeZero,\r\n }\r\n : /* istanbul ignore next */ undefined,\r\n };\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n uomSeparator: \" \",\r\n decimalSeparator: \".\",\r\n composite: {\r\n units: [{\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n }],\r\n },\r\n };\r\n}\r\n\r\nfunction getUnitSystemGroupNames(unitSystem: UnitSystemKey) {\r\n switch (unitSystem) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"metric\":\r\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n }\r\n}\r\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"PropertyFormatter.d.ts","sourceRoot":"","sources":["../../../src/presentation-common/PropertyFormatter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAuB,aAAa,EAAE,UAAU,EAAiB,aAAa,EA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B;IAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC;IAC7B,OAAO;QACL,GAAG,IAAI;QACP,SAAS,EAAE,IAAI,CAAC,SAAS;YACvB,CAAC,CAAC;gBACA,GAAG,IAAI,CAAC,SAAS;gBACjB,MAAM,EAAE,MAAM,CAAC,MAAM;gBACrB,WAAW,EAAE,MAAM,CAAC,WAAW;aAChC;YACD,CAAC,CAAC,0BAA0B,CAAC,SAAS;KACzC,CAAC;AACJ,CAAC;AAED,SAAS,6BAA6B,CAAC,eAAoC;IACzE,oDAAoD;IACpD,OAAO;QACL,YAAY,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,CAAC;QACrE,SAAS,EAAE,CAAC;QACZ,IAAI,EAAE,SAAS;QACf,YAAY,EAAE,GAAG;QACjB,gBAAgB,EAAE,GAAG;QACrB,SAAS,EAAE;YACT,KAAK,EAAE,CAAC;oBACN,IAAI,EAAE,eAAe,CAAC,QAAQ;oBAC9B,KAAK,EAAE,eAAe,CAAC,KAAK;iBAC7B,CAAC;SACH;KACF,CAAC;AACJ,CAAC;AAED,SAAS,uBAAuB,CAAC,UAAyB;IACxD,QAAQ,UAAU,EAAE;QAClB,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAC9D,KAAK,QAAQ;YACX,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QACtD,KAAK,aAAa;YAChB,OAAO,CAAC,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;QAClD,KAAK,UAAU;YACb,OAAO,CAAC,UAAU,EAAE,UAAU,EAAE,eAAe,EAAE,SAAS,CAAC,CAAC;KAC/D;AACH,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Core\r\n */\r\n\r\nimport { assert } from \"@itwin/core-bentley\";\r\nimport { Format, FormatProps, FormatterSpec, ParserSpec, UnitsProvider, UnitSystemKey } from \"@itwin/core-quantity\";\r\nimport {\r\n Format as ECFormat, InvertedUnit, ISchemaLocater, KindOfQuantity, OverrideFormat, SchemaContext, SchemaKey, SchemaMatchType, SchemaUnitProvider,\r\n Unit,\r\n} from \"@itwin/ecschema-metadata\";\r\nimport { Content } from \"./content/Content\";\r\nimport { Field, PropertiesField } from \"./content/Fields\";\r\nimport { DisplayValue, NestedContentValue, Value } from \"./content/Value\";\r\nimport { KindOfQuantityInfo, PropertyInfo } from \"./EC\";\r\nimport { ValuesDictionary } from \"./Utils\";\r\n\r\n/** @alpha */\r\nexport interface FormatOptions {\r\n koqName: string;\r\n unitSystem: UnitSystemKey;\r\n}\r\n\r\n/** @alpha */\r\nexport class PropertyValueFormatter {\r\n private _unitsProvider: UnitsProvider;\r\n\r\n constructor(private _schemaContext: SchemaContext) {\r\n this._unitsProvider = new SchemaUnitProvider(_schemaContext);\r\n }\r\n\r\n public async format(value: number, options: FormatOptions) {\r\n const formatterSpec = await this.getFormatterSpec(options);\r\n if (!formatterSpec)\r\n return undefined;\r\n return formatterSpec.applyFormatting(value);\r\n }\r\n\r\n public async getFormatterSpec(options: FormatOptions) {\r\n const formattingProps = await getFormattingProps(this._schemaContext, options);\r\n if (!formattingProps)\r\n return undefined;\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\r\n return FormatterSpec.create(\"\", format, this._unitsProvider, persistenceUnit);\r\n }\r\n\r\n public async getParserSpec(options: FormatOptions) {\r\n const formattingProps = await getFormattingProps(this._schemaContext, options);\r\n if (!formattingProps)\r\n return undefined;\r\n const { formatProps, persistenceUnitName } = formattingProps;\r\n const persistenceUnit = await this._unitsProvider.findUnitByName(persistenceUnitName);\r\n const format = await Format.createFromJSON(\"\", this._unitsProvider, formatProps);\r\n return ParserSpec.create(format, this._unitsProvider, persistenceUnit);\r\n }\r\n}\r\n\r\n/** @alpha */\r\nexport class ContentPropertyValueFormatter {\r\n constructor(private _propertyValueFormatter: PropertyValueFormatter, private _unitSystem: UnitSystemKey) { }\r\n\r\n public async formatContent(content: Content) {\r\n const descriptor = content.descriptor;\r\n for (const item of content.contentSet) {\r\n await this.formatValues(item.values, item.displayValues, descriptor.fields, item.mergedFieldNames);\r\n }\r\n return content;\r\n }\r\n\r\n private async formatValues(values: ValuesDictionary<Value>, displayValues: ValuesDictionary<DisplayValue>, fields: Field[], mergedFields: string[]) {\r\n for (const field of fields) {\r\n const value = values[field.name];\r\n if (field.isNestedContentField() && !mergedFields.includes(field.name)) {\r\n assert(Value.isNestedContent(value));\r\n await this.formatNestedContentDisplayValues(value, field.nestedFields);\r\n continue;\r\n }\r\n\r\n if (!this.isFormattable(field) || typeof value !== \"number\")\r\n continue;\r\n\r\n const koq = field.properties[0].property.kindOfQuantity;\r\n const formattedValue = await this._propertyValueFormatter.format(value, { koqName: koq.name, unitSystem: this._unitSystem });\r\n if (!formattedValue)\r\n continue;\r\n\r\n displayValues[field.name] = formattedValue;\r\n }\r\n }\r\n\r\n private async formatNestedContentDisplayValues(nestedValues: NestedContentValue[], fields: Field[]) {\r\n for (const nestedValue of nestedValues) {\r\n await this.formatValues(nestedValue.values, nestedValue.displayValues, fields, nestedValue.mergedFieldNames);\r\n }\r\n }\r\n\r\n private isFormattable(field: Field): field is FormattableField {\r\n return field.isPropertiesField()\r\n && field.properties.length > 0\r\n && field.properties[0].property.kindOfQuantity !== undefined;\r\n }\r\n}\r\n\r\ntype FormattableField = PropertiesField & {\r\n properties: [{\r\n property: PropertyInfo & {\r\n kindOfQuantity: KindOfQuantityInfo;\r\n };\r\n }];\r\n};\r\n\r\ninterface FormattingProps {\r\n formatProps: FormatProps;\r\n persistenceUnitName: string;\r\n}\r\n\r\nasync function getFormattingProps(schemaLocater: ISchemaLocater, options: FormatOptions): Promise<FormattingProps | undefined> {\r\n const { koqName, unitSystem } = options;\r\n\r\n const koq = await getKoq(schemaLocater, koqName);\r\n if (!koq)\r\n return undefined;\r\n\r\n const persistenceUnit = await koq.persistenceUnit;\r\n // istanbul ignore if\r\n if (!persistenceUnit)\r\n return undefined;\r\n\r\n const formatProps = await getKoqFormatProps(koq, persistenceUnit, unitSystem);\r\n if (!formatProps)\r\n return undefined;\r\n\r\n return { formatProps, persistenceUnitName: persistenceUnit.fullName };\r\n}\r\n\r\nasync function getKoq(schemaLocater: ISchemaLocater, fullName: string) {\r\n const [schemaName, propKoqName] = fullName.split(\":\");\r\n const schema = await schemaLocater.getSchema(new SchemaKey(schemaName), SchemaMatchType.Latest);\r\n if (!schema)\r\n return undefined;\r\n\r\n return schema.getItem<KindOfQuantity>(propKoqName);\r\n}\r\n\r\nasync function getKoqFormatProps(koq: KindOfQuantity, persistenceUnit: Unit | InvertedUnit, unitSystem: UnitSystemKey) {\r\n const unitSystems = getUnitSystemGroupNames(unitSystem);\r\n // use one of KOQ presentation format that matches requested unit system\r\n const presentationFormat = await getKoqPresentationFormat(koq, unitSystems);\r\n if (presentationFormat)\r\n return formatToFormatProps(presentationFormat);\r\n\r\n // use persistence unit format if it matches requested unit system and matching presentation format was not found\r\n const persistenceUnitSystem = await persistenceUnit.unitSystem;\r\n if (persistenceUnitSystem && unitSystems.includes(persistenceUnitSystem.name.toUpperCase()))\r\n return getPersistenceUnitFormatProps(persistenceUnit);\r\n\r\n // use default presentation format if persistence unit does not match requested unit system\r\n if (koq.defaultPresentationFormat)\r\n return formatToFormatProps(koq.defaultPresentationFormat);\r\n\r\n return undefined;\r\n}\r\n\r\nasync function getKoqPresentationFormat(koq: KindOfQuantity, unitSystems: string[]) {\r\n const presentationFormats = koq.presentationFormats;\r\n for (const system of unitSystems) {\r\n for (const format of presentationFormats) {\r\n const unit = format.units && format.units[0][0];\r\n // istanbul ignore if\r\n if (!unit)\r\n continue;\r\n\r\n const currentUnitSystem = await unit.unitSystem;\r\n if (currentUnitSystem && currentUnitSystem.name.toUpperCase() === system)\r\n return format;\r\n }\r\n }\r\n return undefined;\r\n}\r\n\r\nfunction formatToFormatProps(format: ECFormat | OverrideFormat): FormatProps {\r\n // istanbul ignore if\r\n if (OverrideFormat.isOverrideFormat(format)) {\r\n const baseFormat = baseFormatToFormatProps(format.parent);\r\n return {\r\n ...baseFormat,\r\n composite: format.units\r\n ? {\r\n ...baseFormat.composite,\r\n units: format.units.map(([unit, _]) => ({ name: unit.fullName, label: unit.label })),\r\n spacer: format.spacer,\r\n includeZero: format.includeZero,\r\n }\r\n : baseFormat.composite,\r\n };\r\n }\r\n return baseFormatToFormatProps(format);\r\n}\r\n\r\nfunction baseFormatToFormatProps(format: ECFormat): FormatProps {\r\n const json = format.toJSON();\r\n return {\r\n ...json,\r\n composite: json.composite\r\n ? {\r\n ...json.composite,\r\n spacer: format.spacer,\r\n includeZero: format.includeZero,\r\n }\r\n : /* istanbul ignore next */ undefined,\r\n };\r\n}\r\n\r\nfunction getPersistenceUnitFormatProps(persistenceUnit: Unit | InvertedUnit): FormatProps {\r\n // Same as Format \"DefaultRealU\" in Formats ecschema\r\n return {\r\n formatTraits: [\"keepSingleZero\", \"keepDecimalPoint\", \"showUnitLabel\"],\r\n precision: 6,\r\n type: \"Decimal\",\r\n uomSeparator: \" \",\r\n decimalSeparator: \".\",\r\n composite: {\r\n units: [{\r\n name: persistenceUnit.fullName,\r\n label: persistenceUnit.label,\r\n }],\r\n },\r\n };\r\n}\r\n\r\nfunction getUnitSystemGroupNames(unitSystem: UnitSystemKey) {\r\n switch (unitSystem) {\r\n case \"imperial\":\r\n return [\"IMPERIAL\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"metric\":\r\n return [\"SI\", \"METRIC\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"usCustomary\":\r\n return [\"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n case \"usSurvey\":\r\n return [\"USSURVEY\", \"USCUSTOM\", \"INTERNATIONAL\", \"FINANCE\"];\r\n }\r\n}\r\n"]}
|