@itwin/core-quantity 3.1.0-dev.8 → 3.2.0-dev.3
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 -1
- package/lib/cjs/Exception.d.ts.map +1 -1
- package/lib/cjs/Exception.js +1 -0
- package/lib/cjs/Exception.js.map +1 -1
- package/lib/cjs/Formatter/Format.d.ts +37 -41
- package/lib/cjs/Formatter/Format.d.ts.map +1 -1
- package/lib/cjs/Formatter/Format.js +117 -341
- package/lib/cjs/Formatter/Format.js.map +1 -1
- package/lib/cjs/Formatter/FormatEnums.d.ts +46 -1
- package/lib/cjs/Formatter/FormatEnums.d.ts.map +1 -1
- package/lib/cjs/Formatter/FormatEnums.js +219 -2
- package/lib/cjs/Formatter/FormatEnums.js.map +1 -1
- package/lib/cjs/Formatter/FormatterSpec.js +1 -1
- package/lib/cjs/Formatter/FormatterSpec.js.map +1 -1
- package/lib/cjs/Interfaces.d.ts +9 -1
- package/lib/cjs/Interfaces.d.ts.map +1 -1
- package/lib/cjs/Interfaces.js.map +1 -1
- package/lib/esm/Exception.d.ts.map +1 -1
- package/lib/esm/Exception.js +2 -1
- package/lib/esm/Exception.js.map +1 -1
- package/lib/esm/Formatter/Format.d.ts +37 -41
- package/lib/esm/Formatter/Format.d.ts.map +1 -1
- package/lib/esm/Formatter/Format.js +116 -341
- package/lib/esm/Formatter/Format.js.map +1 -1
- package/lib/esm/Formatter/FormatEnums.d.ts +46 -1
- package/lib/esm/Formatter/FormatEnums.d.ts.map +1 -1
- package/lib/esm/Formatter/FormatEnums.js +205 -1
- package/lib/esm/Formatter/FormatEnums.js.map +1 -1
- package/lib/esm/Formatter/FormatterSpec.js +1 -1
- package/lib/esm/Formatter/FormatterSpec.js.map +1 -1
- package/lib/esm/Interfaces.d.ts +9 -1
- package/lib/esm/Interfaces.d.ts.map +1 -1
- package/lib/esm/Interfaces.js.map +1 -1
- package/package.json +5 -5
|
@@ -1 +1 @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AAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC;YAClE,YAAY,EAAE,MAAM,CAAC,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC;YAC3D,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;YACpG,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS;SACV,CAAC;IACJ,CAAC;CACF","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 Quantity\r\n */\r\n\r\nimport { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport { DecimalPrecision, FormatTraits, FormatType, FractionalPrecision, ScientificType, ShowSignOption } from \"./FormatEnums\";\r\nimport { CloneOptions, CustomFormatProps, FormatProps, isCustomFormatProps } from \"./Interfaces\";\r\n\r\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\r\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\r\n\r\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n protected _formatTraits: FormatTraits = 0x0;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public get type(): FormatType { return this._type; }\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public get spacer(): string { return this._spacer; }\r\n public get includeZero(): boolean { return this._includeZero; }\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n // parse and toString methods\r\n public static scientificTypeToString(scientificType: ScientificType): string {\r\n if (scientificType === ScientificType.Normalized)\r\n return \"Normalized\";\r\n else\r\n return \"ZeroNormalized\";\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ScientificType. Throws exception if not valid. */\r\n public static parseScientificType(scientificType: string, formatName: string): ScientificType {\r\n switch (scientificType.toLowerCase()) {\r\n case \"normalized\":\r\n return ScientificType.Normalized;\r\n case \"zeronormalized\":\r\n return ScientificType.ZeroNormalized;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'SCIENTIFIC_TYPE' attribute.`);\r\n }\r\n }\r\n\r\n /** Method used when generating a JSON object that represents this Format. */\r\n public static showSignOptionToString(showSign: ShowSignOption): string {\r\n switch (showSign) {\r\n case ShowSignOption.NegativeParentheses:\r\n return \"NegativeParentheses\";\r\n case ShowSignOption.NoSign:\r\n return \"NoSign\";\r\n case ShowSignOption.OnlyNegative:\r\n return \"OnlyNegative\";\r\n case ShowSignOption.SignAlways:\r\n return \"SignAlways\";\r\n }\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid ShowSignOption. Throws exception if not valid. */\r\n public static parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\r\n switch (showSignOption.toLowerCase()) {\r\n case \"nosign\":\r\n return ShowSignOption.NoSign;\r\n case \"onlynegative\":\r\n return ShowSignOption.OnlyNegative;\r\n case \"signalways\":\r\n return ShowSignOption.SignAlways;\r\n case \"negativeparentheses\":\r\n return ShowSignOption.NegativeParentheses;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\r\n }\r\n }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = Format.getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n /** Get string used in FormatProps */\r\n public static getTraitString(trait: FormatTraits) {\r\n switch (trait) {\r\n case FormatTraits.TrailZeroes:\r\n return \"trailZeroes\";\r\n case FormatTraits.KeepSingleZero:\r\n return \"keepSingleZero\";\r\n case FormatTraits.ZeroEmpty:\r\n return \"zeroEmpty\";\r\n case FormatTraits.KeepDecimalPoint:\r\n return \"keepDecimalPoint\";\r\n case FormatTraits.ApplyRounding:\r\n return \"applyRounding\";\r\n case FormatTraits.FractionDash:\r\n return \"fractionDash\";\r\n case FormatTraits.ShowUnitLabel:\r\n return \"showUnitLabel\";\r\n case FormatTraits.PrependUnitLabel:\r\n return \"prependUnitLabel\";\r\n case FormatTraits.Use1000Separator:\r\n return \"use1000Separator\";\r\n case FormatTraits.ExponentOnlyNegative:\r\n default:\r\n return \"exponentOnlyNegative\";\r\n }\r\n }\r\n\r\n /** Method used when generating a JSON object that represents this Format. */\r\n public static formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\r\n const formatTraitsArr = Array<string>();\r\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes) formatTraitsArr.push(Format.getTraitString(FormatTraits.TrailZeroes));\r\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero) formatTraitsArr.push(Format.getTraitString(FormatTraits.KeepSingleZero));\r\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty) formatTraitsArr.push(Format.getTraitString(FormatTraits.ZeroEmpty));\r\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint) formatTraitsArr.push(Format.getTraitString(FormatTraits.KeepDecimalPoint));\r\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding) formatTraitsArr.push(Format.getTraitString(FormatTraits.ApplyRounding));\r\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash) formatTraitsArr.push(Format.getTraitString(FormatTraits.FractionDash));\r\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel) formatTraitsArr.push(Format.getTraitString(FormatTraits.ShowUnitLabel));\r\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel) formatTraitsArr.push(Format.getTraitString(FormatTraits.PrependUnitLabel));\r\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator) formatTraitsArr.push(Format.getTraitString(FormatTraits.Use1000Separator));\r\n // NOTE: the formatter does not current use trait ExponentOnlyNegative\r\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative) formatTraitsArr.push(Format.getTraitString(FormatTraits.ExponentOnlyNegative));\r\n\r\n return formatTraitsArr;\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatTrait. Throws exception if not valid. */\r\n public static parseFormatTrait(stringToCheck: string, currentFormatTrait: number): FormatTraits {\r\n switch (stringToCheck.toLowerCase()) {\r\n case \"trailzeroes\":\r\n return currentFormatTrait | FormatTraits.TrailZeroes;\r\n case \"keepsinglezero\":\r\n return currentFormatTrait | FormatTraits.KeepSingleZero; // keep single when format type is Decimal\r\n case \"zeroempty\":\r\n return currentFormatTrait | FormatTraits.ZeroEmpty;\r\n case \"keepdecimalpoint\":\r\n return currentFormatTrait | FormatTraits.KeepDecimalPoint; // add decimal point when no fractional part and format type is Decimal\r\n case \"applyrounding\":\r\n return currentFormatTrait | FormatTraits.ApplyRounding;\r\n case \"fractiondash\":\r\n return currentFormatTrait | FormatTraits.FractionDash;\r\n case \"showunitlabel\":\r\n return currentFormatTrait | FormatTraits.ShowUnitLabel;\r\n case \"prependunitlabel\":\r\n return currentFormatTrait | FormatTraits.PrependUnitLabel;\r\n case \"use1000separator\":\r\n return currentFormatTrait | FormatTraits.Use1000Separator;\r\n case \"exponentonlynegative\":\r\n return currentFormatTrait | FormatTraits.ExponentOnlyNegative;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Format has an invalid 'formatTraits' option.`);\r\n }\r\n }\r\n\r\n /** Get FormatTrait from entry in FormatProps */\r\n public static parseFormatTraits(formatTraitsFromJson: string | string[] | undefined) {\r\n if (!formatTraitsFromJson)\r\n return undefined;\r\n\r\n const formatTraits = Array.isArray(formatTraitsFromJson) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n let traits = 0;\r\n for (const traitStr of formatTraits) {\r\n traits = Format.parseFormatTrait(traitStr, traits);\r\n }\r\n if (0 === traits)\r\n return undefined;\r\n\r\n return traits as FormatTraits;\r\n }\r\n\r\n /** Method used when generating a JSON object that represents this Format. */\r\n public static formatTypeToString(type: FormatType): string {\r\n switch (type) {\r\n case FormatType.Decimal:\r\n return \"Decimal\";\r\n case FormatType.Scientific:\r\n return \"Scientific\";\r\n case FormatType.Station:\r\n return \"Station\";\r\n case FormatType.Fractional:\r\n return \"Fractional\";\r\n }\r\n }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\r\n public static parseFormatType(jsonObjType: string, formatName: string): FormatType {\r\n switch (jsonObjType.toLowerCase()) {\r\n case \"decimal\":\r\n return FormatType.Decimal;\r\n case \"scientific\":\r\n return FormatType.Scientific;\r\n case \"station\":\r\n return FormatType.Station;\r\n case \"fractional\":\r\n return FormatType.Fractional;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\r\n }\r\n }\r\n\r\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision. Throws exception if not valid. */\r\n public static parseDecimalPrecision(jsonObjPrecision: number): DecimalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 0:\r\n return DecimalPrecision.Zero;\r\n case 1:\r\n return DecimalPrecision.One;\r\n case 2:\r\n return DecimalPrecision.Two;\r\n case 3:\r\n return DecimalPrecision.Three;\r\n case 4:\r\n return DecimalPrecision.Four;\r\n case 5:\r\n return DecimalPrecision.Five;\r\n case 6:\r\n return DecimalPrecision.Six;\r\n case 7:\r\n return DecimalPrecision.Seven;\r\n case 8:\r\n return DecimalPrecision.Eight;\r\n case 9:\r\n return DecimalPrecision.Nine;\r\n case 10:\r\n return DecimalPrecision.Ten;\r\n case 11:\r\n return DecimalPrecision.Eleven;\r\n case 12:\r\n return DecimalPrecision.Twelve;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The 'precision' attribute must be an integer in the range 0-12.`);\r\n }\r\n }\r\n\r\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision. Throws exception if not valid. */\r\n public static parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 1:\r\n return FractionalPrecision.One;\r\n case 2:\r\n return FractionalPrecision.Two;\r\n case 4:\r\n return FractionalPrecision.Four;\r\n case 8:\r\n return FractionalPrecision.Eight;\r\n case 16:\r\n return FractionalPrecision.Sixteen;\r\n case 32:\r\n return FractionalPrecision.ThirtyTwo;\r\n case 64:\r\n return FractionalPrecision.SixtyFour;\r\n case 128:\r\n return FractionalPrecision.OneHundredTwentyEight;\r\n case 256:\r\n return FractionalPrecision.TwoHundredFiftySix;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n }\r\n\r\n /** This method validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. Throws exception if not valid. */\r\n public static parsePrecision(precision: number, formatName: string, type: FormatType): DecimalPrecision | FractionalPrecision {\r\n switch (type) { // type must be decimal, fractional, scientific, or station\r\n case FormatType.Decimal:\r\n case FormatType.Scientific:\r\n case FormatType.Station:\r\n return Format.parseDecimalPrecision(precision);\r\n case FormatType.Fractional:\r\n return Format.parseFractionalPrecision(precision, formatName);\r\n }\r\n }\r\n\r\n private verifyFormatTraitsOptions(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n this._formatTraits = Format.parseFormatTrait(formatTraitsString, this.formatTraits);\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n private async createUnit(unitsProvider: UnitsProvider, name: string, label?: string): Promise<void> {\r\n if (name === undefined || typeof (name) !== \"string\" || (label !== undefined && typeof (label) !== \"string\")) // throws if name is undefined or name isn't a string or if label is defined and isn't a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n for (const unit of this.units!) {\r\n const unitObj = unit[0].name;\r\n if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\r\n }\r\n const newUnit: UnitProps = await unitsProvider.findUnitByName(name);\r\n if (!newUnit || !newUnit.isValid)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n this.units!.push([newUnit, label]);\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = Format.parsePrecision(options?.precision, \"clone\", newFormat._type);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n private loadFormatProperties(jsonObj: FormatProps) {\r\n if (isCustomFormatProps(jsonObj))\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined === jsonObj.type) // type is required\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} does not have the required 'type' attribute.`);\r\n if (typeof (jsonObj.type) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'type' attribute. It should be of type 'string'.`);\r\n this._type = Format.parseFormatType(jsonObj.type, this.name);\r\n\r\n if (undefined === jsonObj.precision) // precision is required\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} does not have the required 'precision' attribute.`);\r\n else if (typeof (jsonObj.precision) !== \"number\") // must be a number\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be of type 'number'.`);\r\n else if (!Number.isInteger(jsonObj.precision)) // must be an integer\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n this._precision = Format.parsePrecision(jsonObj.precision, this.name, this._type);\r\n\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === jsonObj.scientificType) // if format type is scientific and scientific type is undefined, throw\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has type 'Scientific' therefore attribute 'scientificType' is required.`);\r\n if (typeof (jsonObj.scientificType) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'scientificType' attribute. It should be of type 'string'.`);\r\n this._scientificType = Format.parseScientificType(jsonObj.scientificType.toLowerCase(), this.name);\r\n }\r\n\r\n if (this.type === FormatType.Station) {\r\n if (undefined === jsonObj.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has type 'Station' therefore attribute 'stationOffsetSize' is required.`);\r\n if (typeof (jsonObj.stationOffsetSize) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be of type 'number'.`);\r\n if (!Number.isInteger(jsonObj.stationOffsetSize) || jsonObj.stationOffsetSize <= 0) // must be a positive int > 0\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = jsonObj.stationOffsetSize;\r\n }\r\n\r\n if (undefined !== jsonObj.roundFactor) { // optional; default is 0.0\r\n if (typeof (jsonObj.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (jsonObj.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = jsonObj.roundFactor;\r\n }\r\n\r\n if (undefined !== jsonObj.minWidth) { // optional\r\n if (typeof (jsonObj.minWidth) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be of type 'number'.`);\r\n if (!Number.isInteger(jsonObj.minWidth) || jsonObj.minWidth < 0) // must be a positive int\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = jsonObj.minWidth;\r\n }\r\n\r\n if (undefined !== jsonObj.showSignOption) { // optional; default is \"onlyNegative\"\r\n if (typeof (jsonObj.showSignOption) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'showSignOption' attribute. It should be of type 'string'.`);\r\n this._showSignOption = Format.parseShowSignOption(jsonObj.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== jsonObj.formatTraits && jsonObj.formatTraits.length !== 0) { // FormatTraits is optional\r\n if (!Array.isArray(jsonObj.formatTraits) && typeof (jsonObj.formatTraits) !== \"string\") // must be either an array of strings or a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.verifyFormatTraitsOptions(jsonObj.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\r\n }\r\n\r\n if (undefined !== jsonObj.decimalSeparator) { // optional\r\n if (typeof (jsonObj.decimalSeparator) !== \"string\") // not a string or not a one character string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.decimalSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It must be a one character string.`);\r\n this._decimalSeparator = jsonObj.decimalSeparator;\r\n }\r\n\r\n if (undefined !== jsonObj.thousandSeparator) { // optional\r\n if (typeof (jsonObj.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.thousandSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It must be a one character string.`);\r\n this._thousandSeparator = jsonObj.thousandSeparator;\r\n }\r\n\r\n if (undefined !== jsonObj.uomSeparator) { // optional; default is \" \"\r\n if (typeof (jsonObj.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.uomSeparator.length < 0 || jsonObj.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It must be empty or a string with a single character.`);\r\n this._uomSeparator = jsonObj.uomSeparator;\r\n }\r\n\r\n if (undefined !== jsonObj.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (jsonObj.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (jsonObj.stationSeparator.length !== 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It must be a one character string.`);\r\n this._stationSeparator = jsonObj.stationSeparator;\r\n }\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n this.loadFormatProperties(jsonObj);\r\n\r\n if (undefined !== jsonObj.composite) { // optional\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length < 0 || jsonObj.composite.spacer.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be empty or a string with a single character.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\r\n try {\r\n const createUnitPromises: Array<Promise<void>> = [];\r\n for (const unit of jsonObj.composite.units) {\r\n createUnitPromises.push(this.createUnit(unitsProvider, unit.name, unit.label));\r\n }\r\n\r\n await Promise.all(createUnitPromises);\r\n } catch (e) {\r\n throw e;\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { name: value[0].name, label: value[1] };\r\n else\r\n return { name: value[0].name };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n if (this.customProps)\r\n return {\r\n type: Format.formatTypeToString(this.type),\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: Format.showSignOptionToString(this.showSignOption),\r\n formatTraits: Format.formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? Format.scientificTypeToString(this.scientificType) : undefined,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n composite,\r\n custom: this.customProps,\r\n } as CustomFormatProps;\r\n\r\n return {\r\n type: Format.formatTypeToString(this.type),\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: Format.showSignOptionToString(this.showSignOption),\r\n formatTraits: Format.formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? Format.scientificTypeToString(this.scientificType) : undefined,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n composite,\r\n };\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Format.js","sourceRoot":"","sources":["../../../src/Formatter/Format.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CA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mB,CAAC,IAAI,CAAC,YAAY,CAAC;gBACpD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;gBAC7F,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;gBACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,SAAS;gBACT,MAAM,EAAE,IAAI,CAAC,WAAW;aACJ,CAAC;QAEzB,OAAO;YACL,IAAI,EAAE,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC;YACnC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,cAAc,EAAE,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC;YAC3D,YAAY,EAAE,mBAAmB,CAAC,IAAI,CAAC,YAAY,CAAC;YACpD,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,cAAc,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,SAAS;YAC7F,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,SAAS;SACV,CAAC;IACJ,CAAC;CACF","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 Quantity\r\n */\r\n\r\nimport { QuantityConstants } from \"../Constants\";\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\nimport { UnitProps, UnitsProvider } from \"../Interfaces\";\r\nimport { DecimalPrecision, FormatTraits, formatTraitsToArray, FormatType, formatTypeToString, FractionalPrecision,\r\n getTraitString, parseFormatTrait, parseFormatType, parsePrecision, parseScientificType, parseShowSignOption, ScientificType,\r\n scientificTypeToString, ShowSignOption, showSignOptionToString } from \"./FormatEnums\";\r\nimport { CloneOptions, CustomFormatProps, FormatProps, isCustomFormatProps } from \"./Interfaces\";\r\n\r\n// cSpell:ignore ZERONORMALIZED, nosign, onlynegative, signalways, negativeparentheses\r\n// cSpell:ignore trailzeroes, keepsinglezero, zeroempty, keepdecimalpoint, applyrounding, fractiondash, showunitlabel, prependunitlabel, exponentonlynegative\r\n\r\n/** A base Format class with shared properties and functionality between quantity and ecschema-metadata Format classes\r\n * @beta\r\n */\r\nexport class BaseFormat {\r\n private _name = \"\";\r\n protected _roundFactor: number = 0.0;\r\n protected _type: FormatType = FormatType.Decimal; // required; options are decimal, fractional, scientific, station\r\n protected _precision: number = DecimalPrecision.Six; // required\r\n protected _showSignOption: ShowSignOption = ShowSignOption.OnlyNegative; // options: noSign, onlyNegative, signAlways, negativeParentheses\r\n protected _decimalSeparator: string = QuantityConstants.LocaleSpecificDecimalSeparator;\r\n protected _thousandSeparator: string = QuantityConstants.LocaleSpecificThousandSeparator;\r\n protected _uomSeparator = \" \"; // optional; default is \" \"; defined separator between magnitude and the unit\r\n protected _stationSeparator = \"+\"; // optional; default is \"+\"\r\n protected _formatTraits: FormatTraits = FormatTraits.Uninitialized;\r\n protected _spacer: string = \" \"; // optional; default is \" \"\r\n protected _includeZero: boolean = true; // optional; default is true\r\n protected _minWidth?: number; // optional; positive int\r\n protected _scientificType?: ScientificType; // required if type is scientific; options: normalized, zeroNormalized\r\n protected _stationOffsetSize?: number; // required when type is station; positive integer > 0\r\n\r\n constructor(name: string) {\r\n this._name = name;\r\n }\r\n\r\n public get name(): string { return this._name; }\r\n\r\n public get roundFactor(): number { return this._roundFactor; }\r\n public set roundFactor(roundFactor: number) { this._roundFactor = roundFactor; }\r\n\r\n public get type(): FormatType { return this._type; }\r\n public set type(formatType: FormatType) { this._type = formatType; }\r\n\r\n public get precision(): DecimalPrecision | FractionalPrecision { return this._precision; }\r\n public set precision(precision: DecimalPrecision | FractionalPrecision) { this._precision = precision; }\r\n\r\n public get minWidth(): number | undefined { return this._minWidth; }\r\n public set minWidth(minWidth: number | undefined) { this._minWidth = minWidth; }\r\n\r\n public get scientificType(): ScientificType | undefined { return this._scientificType; }\r\n public set scientificType(scientificType: ScientificType | undefined) { this._scientificType = scientificType; }\r\n\r\n public get showSignOption(): ShowSignOption { return this._showSignOption; }\r\n public set showSignOption(showSignOption: ShowSignOption) { this._showSignOption = showSignOption; }\r\n\r\n public get decimalSeparator(): string { return this._decimalSeparator; }\r\n public set decimalSeparator(decimalSeparator: string) { this._decimalSeparator = decimalSeparator; }\r\n\r\n public get thousandSeparator(): string { return this._thousandSeparator; }\r\n public set thousandSeparator(thousandSeparator: string) { this._thousandSeparator = thousandSeparator; }\r\n\r\n public get uomSeparator(): string { return this._uomSeparator; }\r\n public set uomSeparator(uomSeparator: string) { this._uomSeparator = uomSeparator; }\r\n\r\n public get stationSeparator(): string { return this._stationSeparator; }\r\n public set stationSeparator(stationSeparator: string) { this._stationSeparator = stationSeparator; }\r\n\r\n public get stationOffsetSize(): number | undefined { return this._stationOffsetSize; }\r\n public set stationOffsetSize(stationOffsetSize: number | undefined) {stationOffsetSize = this._stationOffsetSize = stationOffsetSize; }\r\n\r\n public get formatTraits(): FormatTraits { return this._formatTraits; }\r\n public set formatTraits(formatTraits: FormatTraits) { this._formatTraits = formatTraits; }\r\n\r\n public get spacer(): string | undefined { return this._spacer; }\r\n public set spacer(spacer: string | undefined) { this._spacer = spacer ?? this._spacer; }\r\n\r\n public get includeZero(): boolean | undefined { return this._includeZero; }\r\n public set includeZero(includeZero: boolean | undefined) { this._includeZero = includeZero ?? this._includeZero; }\r\n\r\n /** This method parses input string that is typically extracted for persisted JSON data and validates that the string is a valid FormatType. Throws exception if not valid. */\r\n public parseFormatTraits(formatTraitsFromJson: string | string[]) {\r\n const formatTraits = (Array.isArray(formatTraitsFromJson)) ? formatTraitsFromJson : formatTraitsFromJson.split(/,|;|\\|/);\r\n formatTraits.forEach((formatTraitsString: string) => { // for each element in the string array\r\n const formatTrait = parseFormatTrait(formatTraitsString, this.name);\r\n this._formatTraits = this.formatTraits | formatTrait;\r\n });\r\n }\r\n\r\n /** This method returns true if the formatTrait is set in this Format object. */\r\n public hasFormatTraitSet(formatTrait: FormatTraits): boolean {\r\n return (this._formatTraits & formatTrait) === formatTrait;\r\n }\r\n\r\n public loadFormatProperties(formatProps: FormatProps) {\r\n this._type = parseFormatType(formatProps.type, this.name);\r\n\r\n if (formatProps.precision !== undefined) {\r\n if (!Number.isInteger(formatProps.precision)) // mut be an integer\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'precision' attribute. It should be an integer.`);\r\n\r\n this._precision = parsePrecision(formatProps.precision, this._type, this.name);\r\n }\r\n if (this.type === FormatType.Scientific) {\r\n if (undefined === formatProps.scientificType) // if format type is scientific and scientific type is undefined, throw\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Scientific' type therefore the attribute 'scientificType' is required.`);\r\n\r\n this._scientificType = parseScientificType(formatProps.scientificType, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.roundFactor) { // optional; default is 0.0\r\n if (typeof (formatProps.roundFactor) !== \"number\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'roundFactor' attribute. It should be of type 'number'.`);\r\n if (formatProps.roundFactor !== this.roundFactor) // if roundFactor isn't default value of 0.0, reassign roundFactor variable\r\n this._roundFactor = formatProps.roundFactor;\r\n }\r\n\r\n if (undefined !== formatProps.minWidth) { // optional\r\n if (!Number.isInteger(formatProps.minWidth) || formatProps.minWidth < 0) // must be a positive int\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'minWidth' attribute. It should be a positive integer.`);\r\n this._minWidth = formatProps.minWidth;\r\n }\r\n if (FormatType.Station === this.type) {\r\n if (undefined === formatProps.stationOffsetSize)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} is 'Station' type therefore the attribute 'stationOffsetSize' is required.`);\r\n if (!Number.isInteger(formatProps.stationOffsetSize) || formatProps.stationOffsetSize < 0) // must be a positive int > 0\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationOffsetSize' attribute. It should be a positive integer.`);\r\n this._stationOffsetSize = formatProps.stationOffsetSize;\r\n }\r\n\r\n if (undefined !== formatProps.showSignOption) { // optional; default is \"onlyNegative\"\r\n this._showSignOption = parseShowSignOption(formatProps.showSignOption, this.name);\r\n }\r\n\r\n if (undefined !== formatProps.formatTraits && formatProps.formatTraits.length !== 0) { // FormatTraits is optional\r\n if (!Array.isArray(formatProps.formatTraits) && typeof (formatProps.formatTraits) !== \"string\") // must be either an array of strings or a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'formatTraits' attribute. It should be of type 'string' or 'string[]'.`);\r\n this.parseFormatTraits(formatProps.formatTraits); // check that all of the options for formatTraits are valid. If now, throw\r\n }\r\n\r\n if (undefined !== formatProps.decimalSeparator) { // optional\r\n if (typeof (formatProps.decimalSeparator) !== \"string\") // not a string or not a one character string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.decimalSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'decimalSeparator' attribute. It should be an empty or one character string.`);\r\n this._decimalSeparator = formatProps.decimalSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.thousandSeparator) { // optional\r\n if (typeof (formatProps.thousandSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.thousandSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'thousandSeparator' attribute. It should be an empty or one character string.`);\r\n this._thousandSeparator = formatProps.thousandSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.uomSeparator) { // optional; default is \" \"\r\n if (typeof (formatProps.uomSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.uomSeparator.length < 0 || formatProps.uomSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'uomSeparator' attribute. It should be an empty or one character string.`);\r\n this._uomSeparator = formatProps.uomSeparator;\r\n }\r\n\r\n if (undefined !== formatProps.stationSeparator) { // optional; default is \"+\"\r\n if (typeof (formatProps.stationSeparator) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be of type 'string'.`);\r\n if (formatProps.stationSeparator.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has an invalid 'stationSeparator' attribute. It should be an empty or one character string.`);\r\n this._stationSeparator = formatProps.stationSeparator;\r\n }\r\n }\r\n}\r\n\r\n/** A class used to define the specifications for formatting quantity values. This class is typically loaded by reading [[FormatProps]].\r\n * @beta\r\n */\r\nexport class Format extends BaseFormat {\r\n protected _units?: Array<[UnitProps, string | undefined]>;\r\n protected _customProps?: any; // used by custom formatters and parsers\r\n\r\n /** Constructor\r\n * @param name The name of a format specification. TODO: make optional or remove\r\n */\r\n constructor(name: string) {\r\n super(name);\r\n }\r\n\r\n public get units(): Array<[UnitProps, string | undefined]> | undefined { return this._units; }\r\n public get hasUnits(): boolean { return this._units !== undefined && this._units.length > 0; }\r\n public get customProps(): any { return this._customProps; }\r\n\r\n public static isFormatTraitSetInProps(formatProps: FormatProps, trait: FormatTraits) {\r\n if (!formatProps.formatTraits)\r\n return false;\r\n const formatTraits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : formatProps.formatTraits.split(/,|;|\\|/);\r\n const traitStr = getTraitString(trait);\r\n return formatTraits.find((traitEntry) => traitStr === traitEntry) ? true : false;\r\n }\r\n\r\n private async createUnit(unitsProvider: UnitsProvider, name: string, label?: string): Promise<void> {\r\n if (name === undefined || typeof (name) !== \"string\" || (label !== undefined && typeof (label) !== \"string\")) // throws if name is undefined or name isn't a string or if label is defined and isn't a string\r\n throw new QuantityError(QuantityStatus.InvalidJson, `This Composite has a unit with an invalid 'name' or 'label' attribute.`);\r\n for (const unit of this.units!) {\r\n const unitObj = unit[0].name;\r\n if (unitObj.toLowerCase() === name.toLowerCase()) // duplicate names are not allowed\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The unit ${unitObj} has a duplicate name.`);\r\n }\r\n const newUnit: UnitProps = await unitsProvider.findUnitByName(name);\r\n if (!newUnit || !newUnit.isValid)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `Invalid unit name '${name}'.`);\r\n this.units!.push([newUnit, label]);\r\n }\r\n\r\n /**\r\n * Clone Format\r\n */\r\n public clone(options?: CloneOptions): Format {\r\n const newFormat = new Format(this.name);\r\n newFormat._roundFactor = this._roundFactor;\r\n newFormat._type = this._type;\r\n newFormat._precision = this._precision;\r\n newFormat._minWidth = this._minWidth;\r\n newFormat._scientificType = this._scientificType;\r\n newFormat._showSignOption = this._showSignOption;\r\n newFormat._decimalSeparator = this._decimalSeparator;\r\n newFormat._thousandSeparator = this._thousandSeparator;\r\n newFormat._uomSeparator = this._uomSeparator;\r\n newFormat._stationSeparator = this._stationSeparator;\r\n newFormat._stationOffsetSize = this._stationOffsetSize;\r\n newFormat._formatTraits = this._formatTraits;\r\n newFormat._spacer = this._spacer;\r\n newFormat._includeZero = this._includeZero;\r\n newFormat._customProps = this._customProps;\r\n this._units && (newFormat._units = [...this._units]);\r\n\r\n if (newFormat._units) {\r\n if (options?.showOnlyPrimaryUnit) {\r\n if (newFormat._units.length > 1)\r\n newFormat._units.length = 1;\r\n }\r\n }\r\n\r\n if (undefined !== options?.traits)\r\n newFormat._formatTraits = options?.traits;\r\n\r\n if (undefined !== options?.type)\r\n newFormat._type = options.type;\r\n\r\n if (undefined !== options?.precision) {\r\n // ensure specified precision is valid\r\n const precision = parsePrecision(options?.precision, newFormat._type, newFormat.name);\r\n newFormat._precision = precision;\r\n }\r\n\r\n if (undefined !== options?.primaryUnit) {\r\n if (options.primaryUnit.unit) {\r\n const newUnits = new Array<[UnitProps, string | undefined]>();\r\n newUnits.push([options.primaryUnit.unit, options.primaryUnit.label]);\r\n newFormat._units = newUnits;\r\n } else if (options.primaryUnit.label && newFormat._units?.length) {\r\n // update label only\r\n newFormat._units[0][1] = options.primaryUnit.label;\r\n }\r\n }\r\n return newFormat;\r\n }\r\n\r\n /**\r\n * Populates this Format with the values from the provided.\r\n */\r\n public async fromJSON(unitsProvider: UnitsProvider, jsonObj: FormatProps): Promise<void> {\r\n this.loadFormatProperties(jsonObj);\r\n\r\n if (isCustomFormatProps(jsonObj))\r\n this._customProps = jsonObj.custom;\r\n\r\n if (undefined !== jsonObj.composite) { // optional\r\n this._units = new Array<[UnitProps, string | undefined]>();\r\n if (jsonObj.composite.includeZero !== undefined) {\r\n if (typeof (jsonObj.composite.includeZero) !== \"boolean\") // includeZero must be a boolean IF it is defined\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'includeZero' attribute. It should be of type 'boolean'.`);\r\n this._includeZero = jsonObj.composite.includeZero;\r\n }\r\n if (jsonObj.composite.spacer !== undefined) { // spacer must be a string IF it is defined\r\n if (typeof (jsonObj.composite.spacer) !== \"string\")\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It must be of type 'string'.`);\r\n if (jsonObj.composite.spacer.length > 1)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'spacer' attribute. It should be an empty or one character string.`);\r\n this._spacer = jsonObj.composite.spacer;\r\n }\r\n if (jsonObj.composite.units !== undefined) { // if composite is defined, it must be an array with 1-4 units\r\n if (!Array.isArray(jsonObj.composite.units)) { // must be an array\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with an invalid 'units' attribute. It must be of type 'array'`);\r\n }\r\n if (jsonObj.composite.units.length > 0 && jsonObj.composite.units.length <= 4) { // Composite requires 1-4 units\r\n try {\r\n const createUnitPromises: Array<Promise<void>> = [];\r\n for (const unit of jsonObj.composite.units) {\r\n createUnitPromises.push(this.createUnit(unitsProvider, unit.name, unit.label));\r\n }\r\n\r\n await Promise.all(createUnitPromises);\r\n } catch (e) {\r\n throw e;\r\n }\r\n }\r\n }\r\n if (undefined === this.units || this.units.length === 0)\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${this.name} has a Composite with no valid 'units'`);\r\n }\r\n }\r\n\r\n /** Create a Format from FormatProps */\r\n public static async createFromJSON(name: string, unitsProvider: UnitsProvider, formatProps: FormatProps) {\r\n const actualFormat = new Format(name);\r\n await actualFormat.fromJSON(unitsProvider, formatProps);\r\n return actualFormat;\r\n }\r\n\r\n /**\r\n * Returns a JSON object that contain the specification for this Format.\r\n */\r\n public toJSON(): FormatProps {\r\n let composite;\r\n if (this.units) {\r\n const units = this.units.map((value) => {\r\n if (undefined !== value[1])\r\n return { name: value[0].name, label: value[1] };\r\n else\r\n return { name: value[0].name };\r\n });\r\n\r\n composite = {\r\n spacer: this.spacer,\r\n includeZero: this.includeZero,\r\n units,\r\n };\r\n }\r\n\r\n if (this.customProps)\r\n return {\r\n type: formatTypeToString(this.type),\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: showSignOptionToString(this.showSignOption),\r\n formatTraits: formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? scientificTypeToString(this.scientificType) : undefined,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n composite,\r\n custom: this.customProps,\r\n } as CustomFormatProps;\r\n\r\n return {\r\n type: formatTypeToString(this.type),\r\n precision: this.precision,\r\n roundFactor: this.roundFactor,\r\n minWidth: this.minWidth,\r\n showSignOption: showSignOptionToString(this.showSignOption),\r\n formatTraits: formatTraitsToArray(this.formatTraits),\r\n decimalSeparator: this.decimalSeparator,\r\n thousandSeparator: this.thousandSeparator,\r\n uomSeparator: this.uomSeparator,\r\n scientificType: this.scientificType ? scientificTypeToString(this.scientificType) : undefined,\r\n stationOffsetSize: this.stationOffsetSize,\r\n stationSeparator: this.stationSeparator,\r\n composite,\r\n };\r\n }\r\n}\r\n"]}
|
|
@@ -1,9 +1,30 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module Quantity
|
|
3
3
|
*/
|
|
4
|
+
/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)
|
|
5
|
+
* provided in serialized formats as well as the full name of an [[OverrideFormat]].
|
|
6
|
+
*
|
|
7
|
+
* `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`
|
|
8
|
+
*
|
|
9
|
+
* Explanation of the regex:
|
|
10
|
+
* - ([\w.:]+)
|
|
11
|
+
* - Grabs the format full name
|
|
12
|
+
* - (\(([^\)]+)\))?
|
|
13
|
+
* - Grabs the precision part with and without the `()`.
|
|
14
|
+
* - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)
|
|
15
|
+
* - (\[([^\|\]]+)([\|])?([^\]]+)?\])?
|
|
16
|
+
* - 4 of these make up the rest of the regex, none of them are required so each end in `?`
|
|
17
|
+
* - Grabs the unit name and label including the `[]`
|
|
18
|
+
* - Grabs the unit name, `|` and label separately
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const formatStringRgx: RegExp;
|
|
22
|
+
/** @internal */
|
|
23
|
+
export declare function getItemNamesFromFormatString(formatString: string): Iterable<string>;
|
|
4
24
|
/** @beta */
|
|
5
25
|
export declare enum FormatTraits {
|
|
6
|
-
|
|
26
|
+
Uninitialized = 0,
|
|
27
|
+
/** Show trailing zeroes to requested precision. */
|
|
7
28
|
TrailZeroes = 1,
|
|
8
29
|
/** Indicates that the fractional part of the number is required when the fraction is zero */
|
|
9
30
|
KeepSingleZero = 2,
|
|
@@ -86,4 +107,28 @@ export declare enum ShowSignOption {
|
|
|
86
107
|
/** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */
|
|
87
108
|
NegativeParentheses = 3
|
|
88
109
|
}
|
|
110
|
+
/** @beta */
|
|
111
|
+
export declare function parseScientificType(scientificType: string, formatName: string): ScientificType;
|
|
112
|
+
/** @beta */
|
|
113
|
+
export declare function scientificTypeToString(scientificType: ScientificType): string;
|
|
114
|
+
/** @beta */
|
|
115
|
+
export declare function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption;
|
|
116
|
+
/** @beta */
|
|
117
|
+
export declare function showSignOptionToString(showSign: ShowSignOption): string;
|
|
118
|
+
/** @beta */
|
|
119
|
+
export declare function parseFormatTrait(formatTraitsString: string, formatName: string): FormatTraits;
|
|
120
|
+
/** @beta */
|
|
121
|
+
export declare function getTraitString(trait: FormatTraits): "trailZeroes" | "keepSingleZero" | "zeroEmpty" | "keepDecimalPoint" | "applyRounding" | "fractionDash" | "showUnitLabel" | "prependUnitLabel" | "use1000Separator" | "exponentOnlyNegative";
|
|
122
|
+
/** @beta */
|
|
123
|
+
export declare function formatTraitsToArray(currentFormatTrait: FormatTraits): string[];
|
|
124
|
+
/** @beta */
|
|
125
|
+
export declare function parseFormatType(jsonObjType: string, formatName: string): FormatType;
|
|
126
|
+
/** @beta */
|
|
127
|
+
export declare function formatTypeToString(type: FormatType): string;
|
|
128
|
+
/** @beta */
|
|
129
|
+
export declare function parseDecimalPrecision(jsonObjPrecision: number, formatName: string): DecimalPrecision;
|
|
130
|
+
/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */
|
|
131
|
+
export declare function parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision;
|
|
132
|
+
/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */
|
|
133
|
+
export declare function parsePrecision(precision: number, type: FormatType, formatName: string): DecimalPrecision | FractionalPrecision;
|
|
89
134
|
//# sourceMappingURL=FormatEnums.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormatEnums.d.ts","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":"AAIA;;GAEG;
|
|
1
|
+
{"version":3,"file":"FormatEnums.d.ts","sourceRoot":"","sources":["../../../src/Formatter/FormatEnums.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,eAAe,QAAiK,CAAC;AAE9L,gBAAgB;AAChB,wBAAiB,4BAA4B,CAAC,YAAY,EAAE,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAWpF;AACD,YAAY;AACZ,oBAAY,YAAY;IACtB,aAAa,IAAM;IACnB,mDAAmD;IACnD,WAAW,IAAM;IACjB,6FAA6F;IAC7F,cAAc,IAAM;IACpB,iDAAiD;IACjD,SAAS,IAAM;IACf,iEAAiE;IACjE,gBAAgB,IAAM;IACtB,kDAAkD;IAClD,aAAa,KAAO;IACpB,2DAA2D;IAC3D,YAAY,KAAO;IACnB,uCAAuC;IACvC,aAAa,KAAO;IACpB,4CAA4C;IAC5C,gBAAgB,MAAO;IACvB,6CAA6C;IAC7C,gBA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gB,sBAAsB,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAOvE;AAED,cAAc;AACd,wBAAgB,gBAAgB,CAAC,kBAAkB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,YAAY,CAe7F;AAED,YAAY;AACZ,wBAAgB,cAAc,CAAC,KAAK,EAAE,YAAY,+LAwBjD;AAED,cAAc;AACd,wBAAgB,mBAAmB,CAAC,kBAAkB,EAAE,YAAY,GAAG,MAAM,EAAE,CAuB9E;AAED,gBAAgB;AAChB,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CASnF;AAED,eAAe;AACf,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAO3D;AAED,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,CAkBpG;AAED,4HAA4H;AAC5H,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAc1G;AAED,iJAAiJ;AACjJ,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,gBAAgB,GAAG,mBAAmB,CAW9H"}
|
|
@@ -5,10 +5,43 @@
|
|
|
5
5
|
/** @packageDocumentation
|
|
6
6
|
* @module Quantity
|
|
7
7
|
*/
|
|
8
|
+
import { QuantityError, QuantityStatus } from "../Exception";
|
|
9
|
+
/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)
|
|
10
|
+
* provided in serialized formats as well as the full name of an [[OverrideFormat]].
|
|
11
|
+
*
|
|
12
|
+
* `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`
|
|
13
|
+
*
|
|
14
|
+
* Explanation of the regex:
|
|
15
|
+
* - ([\w.:]+)
|
|
16
|
+
* - Grabs the format full name
|
|
17
|
+
* - (\(([^\)]+)\))?
|
|
18
|
+
* - Grabs the precision part with and without the `()`.
|
|
19
|
+
* - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)
|
|
20
|
+
* - (\[([^\|\]]+)([\|])?([^\]]+)?\])?
|
|
21
|
+
* - 4 of these make up the rest of the regex, none of them are required so each end in `?`
|
|
22
|
+
* - Grabs the unit name and label including the `[]`
|
|
23
|
+
* - Grabs the unit name, `|` and label separately
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export const formatStringRgx = /([\w.:]+)(\(([^\)]+)\))?(\[([^\|\]]+)([\|])?([^\]]+)?\])?(\[([^\|\]]+)([\|])?([^\]]+)?\])?(\[([^\|\]]+)([\|])?([^\]]+)?\])?(\[([^\|\]]+)([\|])?([^\]]+)?\])?/;
|
|
27
|
+
/** @internal */
|
|
28
|
+
export function* getItemNamesFromFormatString(formatString) {
|
|
29
|
+
const match = formatString.split(formatStringRgx);
|
|
30
|
+
yield match[1]; // the Format Name
|
|
31
|
+
let index = 4;
|
|
32
|
+
while (index < match.length - 1) { // index 0 and 21 are empty strings
|
|
33
|
+
if (match[index] !== undefined)
|
|
34
|
+
yield match[index + 1]; // Unit Name
|
|
35
|
+
else
|
|
36
|
+
break;
|
|
37
|
+
index += 4;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
8
40
|
/** @beta */
|
|
9
41
|
export var FormatTraits;
|
|
10
42
|
(function (FormatTraits) {
|
|
11
|
-
|
|
43
|
+
FormatTraits[FormatTraits["Uninitialized"] = 0] = "Uninitialized";
|
|
44
|
+
/** Show trailing zeroes to requested precision. */
|
|
12
45
|
FormatTraits[FormatTraits["TrailZeroes"] = 1] = "TrailZeroes";
|
|
13
46
|
/** Indicates that the fractional part of the number is required when the fraction is zero */
|
|
14
47
|
FormatTraits[FormatTraits["KeepSingleZero"] = 2] = "KeepSingleZero";
|
|
@@ -96,4 +129,175 @@ export var ShowSignOption;
|
|
|
96
129
|
/** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */
|
|
97
130
|
ShowSignOption[ShowSignOption["NegativeParentheses"] = 3] = "NegativeParentheses";
|
|
98
131
|
})(ShowSignOption || (ShowSignOption = {}));
|
|
132
|
+
// parse and toString methods
|
|
133
|
+
/** @beta */
|
|
134
|
+
export function parseScientificType(scientificType, formatName) {
|
|
135
|
+
switch (scientificType.toLowerCase()) {
|
|
136
|
+
case "normalized": return ScientificType.Normalized;
|
|
137
|
+
case "zeronormalized": return ScientificType.ZeroNormalized;
|
|
138
|
+
default:
|
|
139
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'scientificType' attribute.`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/** @beta */
|
|
143
|
+
export function scientificTypeToString(scientificType) {
|
|
144
|
+
return (scientificType === ScientificType.Normalized) ? "Normalized" : "ZeroNormalized";
|
|
145
|
+
}
|
|
146
|
+
/** @beta */
|
|
147
|
+
export function parseShowSignOption(showSignOption, formatName) {
|
|
148
|
+
switch (showSignOption.toLowerCase()) {
|
|
149
|
+
case "nosign": return ShowSignOption.NoSign;
|
|
150
|
+
case "onlynegative": return ShowSignOption.OnlyNegative;
|
|
151
|
+
case "signalways": return ShowSignOption.SignAlways;
|
|
152
|
+
case "negativeparentheses": return ShowSignOption.NegativeParentheses;
|
|
153
|
+
default:
|
|
154
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** @beta */
|
|
158
|
+
export function showSignOptionToString(showSign) {
|
|
159
|
+
switch (showSign) {
|
|
160
|
+
case ShowSignOption.NegativeParentheses: return "NegativeParentheses";
|
|
161
|
+
case ShowSignOption.NoSign: return "NoSign";
|
|
162
|
+
case ShowSignOption.OnlyNegative: return "OnlyNegative";
|
|
163
|
+
case ShowSignOption.SignAlways: return "SignAlways";
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
/** @beta */
|
|
167
|
+
export function parseFormatTrait(formatTraitsString, formatName) {
|
|
168
|
+
switch (formatTraitsString.toLowerCase()) {
|
|
169
|
+
case "trailzeroes": return FormatTraits.TrailZeroes;
|
|
170
|
+
case "keepsinglezero": return FormatTraits.KeepSingleZero;
|
|
171
|
+
case "zeroempty": return FormatTraits.ZeroEmpty;
|
|
172
|
+
case "keepdecimalpoint": return FormatTraits.KeepDecimalPoint;
|
|
173
|
+
case "applyrounding": return FormatTraits.ApplyRounding;
|
|
174
|
+
case "fractiondash": return FormatTraits.FractionDash;
|
|
175
|
+
case "showunitlabel": return FormatTraits.ShowUnitLabel;
|
|
176
|
+
case "prependunitlabel": return FormatTraits.PrependUnitLabel;
|
|
177
|
+
case "use1000separator": return FormatTraits.Use1000Separator;
|
|
178
|
+
case "exponentonlynegative": return FormatTraits.ExponentOnlyNegative;
|
|
179
|
+
default:
|
|
180
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'formatTraits' attribute.`);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
/** @beta */
|
|
184
|
+
export function getTraitString(trait) {
|
|
185
|
+
switch (trait) {
|
|
186
|
+
case FormatTraits.TrailZeroes:
|
|
187
|
+
return "trailZeroes";
|
|
188
|
+
case FormatTraits.KeepSingleZero:
|
|
189
|
+
return "keepSingleZero";
|
|
190
|
+
case FormatTraits.ZeroEmpty:
|
|
191
|
+
return "zeroEmpty";
|
|
192
|
+
case FormatTraits.KeepDecimalPoint:
|
|
193
|
+
return "keepDecimalPoint";
|
|
194
|
+
case FormatTraits.ApplyRounding:
|
|
195
|
+
return "applyRounding";
|
|
196
|
+
case FormatTraits.FractionDash:
|
|
197
|
+
return "fractionDash";
|
|
198
|
+
case FormatTraits.ShowUnitLabel:
|
|
199
|
+
return "showUnitLabel";
|
|
200
|
+
case FormatTraits.PrependUnitLabel:
|
|
201
|
+
return "prependUnitLabel";
|
|
202
|
+
case FormatTraits.Use1000Separator:
|
|
203
|
+
return "use1000Separator";
|
|
204
|
+
case FormatTraits.ExponentOnlyNegative:
|
|
205
|
+
default:
|
|
206
|
+
return "exponentOnlyNegative";
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
/** @beta */
|
|
210
|
+
export function formatTraitsToArray(currentFormatTrait) {
|
|
211
|
+
const formatTraitsArr = Array();
|
|
212
|
+
if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes)
|
|
213
|
+
formatTraitsArr.push("TrailZeroes");
|
|
214
|
+
if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero)
|
|
215
|
+
formatTraitsArr.push("KeepSingleZero");
|
|
216
|
+
if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty)
|
|
217
|
+
formatTraitsArr.push("ZeroEmpty");
|
|
218
|
+
if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint)
|
|
219
|
+
formatTraitsArr.push("KeepDecimalPoint");
|
|
220
|
+
if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding)
|
|
221
|
+
formatTraitsArr.push("ApplyRounding");
|
|
222
|
+
if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash)
|
|
223
|
+
formatTraitsArr.push("FractionDash");
|
|
224
|
+
if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel)
|
|
225
|
+
formatTraitsArr.push("ShowUnitLabel");
|
|
226
|
+
if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel)
|
|
227
|
+
formatTraitsArr.push("PrependUnitLabel");
|
|
228
|
+
if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator)
|
|
229
|
+
formatTraitsArr.push("Use1000Separator");
|
|
230
|
+
if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative)
|
|
231
|
+
formatTraitsArr.push("ExponentOnlyNegative");
|
|
232
|
+
return formatTraitsArr;
|
|
233
|
+
}
|
|
234
|
+
/** @beta */
|
|
235
|
+
export function parseFormatType(jsonObjType, formatName) {
|
|
236
|
+
switch (jsonObjType.toLowerCase()) {
|
|
237
|
+
case "decimal": return FormatType.Decimal;
|
|
238
|
+
case "scientific": return FormatType.Scientific;
|
|
239
|
+
case "station": return FormatType.Station;
|
|
240
|
+
case "fractional": return FormatType.Fractional;
|
|
241
|
+
default:
|
|
242
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
/** @beta */
|
|
246
|
+
export function formatTypeToString(type) {
|
|
247
|
+
switch (type) {
|
|
248
|
+
case FormatType.Decimal: return "Decimal";
|
|
249
|
+
case FormatType.Scientific: return "Scientific";
|
|
250
|
+
case FormatType.Station: return "Station";
|
|
251
|
+
case FormatType.Fractional: return "Fractional";
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
/** @beta */
|
|
255
|
+
export function parseDecimalPrecision(jsonObjPrecision, formatName) {
|
|
256
|
+
switch (jsonObjPrecision) {
|
|
257
|
+
case 0: return DecimalPrecision.Zero;
|
|
258
|
+
case 1: return DecimalPrecision.One;
|
|
259
|
+
case 2: return DecimalPrecision.Two;
|
|
260
|
+
case 3: return DecimalPrecision.Three;
|
|
261
|
+
case 4: return DecimalPrecision.Four;
|
|
262
|
+
case 5: return DecimalPrecision.Five;
|
|
263
|
+
case 6: return DecimalPrecision.Six;
|
|
264
|
+
case 7: return DecimalPrecision.Seven;
|
|
265
|
+
case 8: return DecimalPrecision.Eight;
|
|
266
|
+
case 9: return DecimalPrecision.Nine;
|
|
267
|
+
case 10: return DecimalPrecision.Ten;
|
|
268
|
+
case 11: return DecimalPrecision.Eleven;
|
|
269
|
+
case 12: return DecimalPrecision.Twelve;
|
|
270
|
+
default:
|
|
271
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */
|
|
275
|
+
export function parseFractionalPrecision(jsonObjPrecision, formatName) {
|
|
276
|
+
switch (jsonObjPrecision) {
|
|
277
|
+
case 1: return FractionalPrecision.One;
|
|
278
|
+
case 2: return FractionalPrecision.Two;
|
|
279
|
+
case 4: return FractionalPrecision.Four;
|
|
280
|
+
case 8: return FractionalPrecision.Eight;
|
|
281
|
+
case 16: return FractionalPrecision.Sixteen;
|
|
282
|
+
case 32: return FractionalPrecision.ThirtyTwo;
|
|
283
|
+
case 64: return FractionalPrecision.SixtyFour;
|
|
284
|
+
case 128: return FractionalPrecision.OneHundredTwentyEight;
|
|
285
|
+
case 256: return FractionalPrecision.TwoHundredFiftySix;
|
|
286
|
+
default:
|
|
287
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */
|
|
291
|
+
export function parsePrecision(precision, type, formatName) {
|
|
292
|
+
switch (type) { // type must be decimal, fractional, scientific, or station
|
|
293
|
+
case FormatType.Decimal:
|
|
294
|
+
case FormatType.Scientific:
|
|
295
|
+
case FormatType.Station:
|
|
296
|
+
return parseDecimalPrecision(precision, formatName);
|
|
297
|
+
case FormatType.Fractional:
|
|
298
|
+
return parseFractionalPrecision(precision, formatName);
|
|
299
|
+
default:
|
|
300
|
+
throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);
|
|
301
|
+
}
|
|
302
|
+
}
|
|
99
303
|
//# sourceMappingURL=FormatEnums.js.map
|
|
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AAED;YACY;AACZ,MAAM,CAAN,IAAY,UASX;AATD,WAAY,UAAU;IACpB,iCAAiC;IACjC,iDAAO,CAAA;IACP,oCAAoC;IACpC,uDAAU,CAAA;IACV,sCAAsC;IACtC,uDAAU,CAAA;IACV,8CAA8C;IAC9C,iDAAO,CAAA;AACT,CAAC,EATW,UAAU,KAAV,UAAU,QASrB;AAED;WACW;AACX,MAAM,CAAN,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,yDAAyD;IACzD,+DAAU,CAAA;IACV,sDAAsD;IACtD,uEAAc,CAAA;AAChB,CAAC,EALW,cAAc,KAAd,cAAc,QAKzB;AAED;WACW;AACX,MAAM,CAAN,IAAY,cASX;AATD,WAAY,cAAc;IACxB,uDAAuD;IACvD,uDAAM,CAAA;IACN,mDAAmD;IACnD,mEAAY,CAAA;IACZ,oEAAoE;IACpE,+DAAU,CAAA;IACV,2IAA2I;IAC3I,iFAAmB,CAAA;AACrB,CAAC,EATW,cAAc,KAAd,cAAc,QASzB","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 Quantity\r\n */\r\n\r\n/** @beta */\r\nexport enum FormatTraits {\r\n /** Show trailing zeroes to requested precision */\r\n TrailZeroes = 0x1,\r\n /** Indicates that the fractional part of the number is required when the fraction is zero */\r\n KeepSingleZero = 0x2,\r\n /** Zero magnitude returns blank display value */\r\n ZeroEmpty = 0x4,\r\n /** Show decimal point when value to right of decimal is empty */\r\n KeepDecimalPoint = 0x8,\r\n /** Use the rounding factor. Not yet supported */\r\n ApplyRounding = 0x10,\r\n /** Show a dash between whole value and fractional value */\r\n FractionDash = 0x20,\r\n /** Append the quantity's unit label */\r\n ShowUnitLabel = 0x40,\r\n /** Prepend unit label. Not yet supported */\r\n PrependUnitLabel = 0x80,\r\n /** show a grouping in each group of 1000. */\r\n Use1000Separator = 0x100,\r\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\r\n ExponentOnlyNegative = 0x200,\r\n}\r\n\r\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\r\n * @beta */\r\nexport enum FractionalPrecision {\r\n One = 1,\r\n Two = 2,\r\n Four = 4,\r\n Eight = 8,\r\n Sixteen = 16,\r\n ThirtyTwo = 32,\r\n SixtyFour = 64,\r\n OneHundredTwentyEight = 128,\r\n TwoHundredFiftySix = 256,\r\n}\r\n\r\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\r\n * @beta */\r\nexport enum DecimalPrecision {\r\n Zero = 0,\r\n One = 1,\r\n Two = 2,\r\n Three = 3,\r\n Four = 4,\r\n Five = 5,\r\n Six = 6,\r\n Seven = 7,\r\n Eight = 8,\r\n Nine = 9,\r\n Ten = 10,\r\n Eleven = 11,\r\n Twelve = 12,\r\n}\r\n\r\n/** Supported format types\r\n * @beta */\r\nexport enum FormatType {\r\n /** Decimal display (ie 2.125) */\r\n Decimal,\r\n /** Fractional display (ie 2-1/8) */\r\n Fractional,\r\n /** Scientific Notation (ie 1.04e3) */\r\n Scientific,\r\n /** Civil Engineering Stationing (ie 1+00). */\r\n Station,\r\n}\r\n\r\n/** required if type is scientific\r\n * @beta */\r\nexport enum ScientificType {\r\n /** Non-zero value left of decimal point (ie 1.2345e3) */\r\n Normalized,\r\n /** Zero value left of decimal point (ie 0.12345e4) */\r\n ZeroNormalized,\r\n}\r\n\r\n/** Determines how the sign of values are displayed\r\n * @beta */\r\nexport enum ShowSignOption {\r\n /** Never show a sign even if the value is negative. */\r\n NoSign,\r\n /** Only show a sign when the value is negative. */\r\n OnlyNegative,\r\n /** Always show a sign whether the value is positive or negative. */\r\n SignAlways,\r\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\r\n NegativeParentheses,\r\n}\r\n"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esContent":["/*---------------------------------------------------------------------------------------------\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 Quantity\r\n */\r\n\r\nimport { QuantityError, QuantityStatus } from \"../Exception\";\r\n\r\n/** The regular expression to parse [format strings]($docs/bis/ec/kindofquantity.md#format-string)\r\n * provided in serialized formats as well as the full name of an [[OverrideFormat]].\r\n *\r\n * `formatName(precision)[unitName|unitLabel][unitName|unitLabel][unitName|unitLabel][unitName|unitLabel]`\r\n *\r\n * Explanation of the regex:\r\n * - ([\\w.:]+)\r\n * - Grabs the format full name\r\n * - (\\(([^\\)]+)\\))?\r\n * - Grabs the precision part with and without the `()`.\r\n * - The parentheses are needed to validate the entire string. (TODO: Need to check if this is true)\r\n * - (\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?\r\n * - 4 of these make up the rest of the regex, none of them are required so each end in `?`\r\n * - Grabs the unit name and label including the `[]`\r\n * - Grabs the unit name, `|` and label separately\r\n * @internal\r\n */\r\nexport const formatStringRgx = /([\\w.:]+)(\\(([^\\)]+)\\))?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?(\\[([^\\|\\]]+)([\\|])?([^\\]]+)?\\])?/;\r\n\r\n/** @internal */\r\nexport function* getItemNamesFromFormatString(formatString: string): Iterable<string> {\r\n const match = formatString.split(formatStringRgx);\r\n yield match[1]; // the Format Name\r\n let index = 4;\r\n while (index < match.length - 1) { // index 0 and 21 are empty strings\r\n if (match[index] !== undefined)\r\n yield match[index + 1]; // Unit Name\r\n else\r\n break;\r\n index += 4;\r\n }\r\n}\r\n/** @beta */\r\nexport enum FormatTraits {\r\n Uninitialized = 0x0,\r\n /** Show trailing zeroes to requested precision. */\r\n TrailZeroes = 0x1,\r\n /** Indicates that the fractional part of the number is required when the fraction is zero */\r\n KeepSingleZero = 0x2,\r\n /** Zero magnitude returns blank display value */\r\n ZeroEmpty = 0x4,\r\n /** Show decimal point when value to right of decimal is empty */\r\n KeepDecimalPoint = 0x8,\r\n /** Use the rounding factor. Not yet supported */\r\n ApplyRounding = 0x10,\r\n /** Show a dash between whole value and fractional value */\r\n FractionDash = 0x20,\r\n /** Append the quantity's unit label */\r\n ShowUnitLabel = 0x40,\r\n /** Prepend unit label. Not yet supported */\r\n PrependUnitLabel = 0x80,\r\n /** show a grouping in each group of 1000. */\r\n Use1000Separator = 0x100,\r\n /** Indicates that if an exponent value is positive to not include a `+`. By default a sign, `+` or `-`, is always shown. Not yet supported */\r\n ExponentOnlyNegative = 0x200,\r\n}\r\n\r\n/** Precision for Fractional formatted value types. Range from Whole (1/1) through 1/256.\r\n * @beta */\r\nexport enum FractionalPrecision {\r\n One = 1,\r\n Two = 2,\r\n Four = 4,\r\n Eight = 8,\r\n Sixteen = 16,\r\n ThirtyTwo = 32,\r\n SixtyFour = 64,\r\n OneHundredTwentyEight = 128,\r\n TwoHundredFiftySix = 256,\r\n}\r\n\r\n/** Precision for Decimal, Scientific, and Station formatted value types. Range from 1/(10^0) through 1/(10^12).\r\n * @beta */\r\nexport enum DecimalPrecision {\r\n Zero = 0,\r\n One = 1,\r\n Two = 2,\r\n Three = 3,\r\n Four = 4,\r\n Five = 5,\r\n Six = 6,\r\n Seven = 7,\r\n Eight = 8,\r\n Nine = 9,\r\n Ten = 10,\r\n Eleven = 11,\r\n Twelve = 12,\r\n}\r\n\r\n/** Supported format types\r\n * @beta */\r\nexport enum FormatType {\r\n /** Decimal display (ie 2.125) */\r\n Decimal,\r\n /** Fractional display (ie 2-1/8) */\r\n Fractional,\r\n /** Scientific Notation (ie 1.04e3) */\r\n Scientific,\r\n /** Civil Engineering Stationing (ie 1+00). */\r\n Station,\r\n}\r\n\r\n/** required if type is scientific\r\n * @beta */\r\nexport enum ScientificType {\r\n /** Non-zero value left of decimal point (ie 1.2345e3) */\r\n Normalized,\r\n /** Zero value left of decimal point (ie 0.12345e4) */\r\n ZeroNormalized,\r\n}\r\n\r\n/** Determines how the sign of values are displayed\r\n * @beta */\r\nexport enum ShowSignOption {\r\n /** Never show a sign even if the value is negative. */\r\n NoSign,\r\n /** Only show a sign when the value is negative. */\r\n OnlyNegative,\r\n /** Always show a sign whether the value is positive or negative. */\r\n SignAlways,\r\n /** Only show a sign when the value is negative but use parentheses instead of a negative sign. For example, -10 is formatted as `(10)`. */\r\n NegativeParentheses,\r\n}\r\n\r\n// parse and toString methods\r\n\r\n/** @beta */\r\n\r\nexport function parseScientificType(scientificType: string, formatName: string): ScientificType {\r\n switch (scientificType.toLowerCase()) {\r\n case \"normalized\": return ScientificType.Normalized;\r\n case \"zeronormalized\": return ScientificType.ZeroNormalized;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'scientificType' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function scientificTypeToString(scientificType: ScientificType): string {\r\n return (scientificType === ScientificType.Normalized) ? \"Normalized\" : \"ZeroNormalized\";\r\n}\r\n\r\n/** @beta */\r\nexport function parseShowSignOption(showSignOption: string, formatName: string): ShowSignOption {\r\n switch (showSignOption.toLowerCase()) {\r\n case \"nosign\": return ShowSignOption.NoSign;\r\n case \"onlynegative\": return ShowSignOption.OnlyNegative;\r\n case \"signalways\": return ShowSignOption.SignAlways;\r\n case \"negativeparentheses\": return ShowSignOption.NegativeParentheses;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'showSignOption' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function showSignOptionToString(showSign: ShowSignOption): string {\r\n switch (showSign) {\r\n case ShowSignOption.NegativeParentheses: return \"NegativeParentheses\";\r\n case ShowSignOption.NoSign: return \"NoSign\";\r\n case ShowSignOption.OnlyNegative: return \"OnlyNegative\";\r\n case ShowSignOption.SignAlways: return \"SignAlways\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function parseFormatTrait(formatTraitsString: string, formatName: string): FormatTraits {\r\n switch (formatTraitsString.toLowerCase()) {\r\n case \"trailzeroes\": return FormatTraits.TrailZeroes;\r\n case \"keepsinglezero\": return FormatTraits.KeepSingleZero;\r\n case \"zeroempty\": return FormatTraits.ZeroEmpty;\r\n case \"keepdecimalpoint\": return FormatTraits.KeepDecimalPoint;\r\n case \"applyrounding\": return FormatTraits.ApplyRounding;\r\n case \"fractiondash\": return FormatTraits.FractionDash;\r\n case \"showunitlabel\": return FormatTraits.ShowUnitLabel;\r\n case \"prependunitlabel\": return FormatTraits.PrependUnitLabel;\r\n case \"use1000separator\": return FormatTraits.Use1000Separator;\r\n case \"exponentonlynegative\": return FormatTraits.ExponentOnlyNegative;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'formatTraits' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function getTraitString(trait: FormatTraits) {\r\n switch (trait) {\r\n case FormatTraits.TrailZeroes:\r\n return \"trailZeroes\";\r\n case FormatTraits.KeepSingleZero:\r\n return \"keepSingleZero\";\r\n case FormatTraits.ZeroEmpty:\r\n return \"zeroEmpty\";\r\n case FormatTraits.KeepDecimalPoint:\r\n return \"keepDecimalPoint\";\r\n case FormatTraits.ApplyRounding:\r\n return \"applyRounding\";\r\n case FormatTraits.FractionDash:\r\n return \"fractionDash\";\r\n case FormatTraits.ShowUnitLabel:\r\n return \"showUnitLabel\";\r\n case FormatTraits.PrependUnitLabel:\r\n return \"prependUnitLabel\";\r\n case FormatTraits.Use1000Separator:\r\n return \"use1000Separator\";\r\n case FormatTraits.ExponentOnlyNegative:\r\n default:\r\n return \"exponentOnlyNegative\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function formatTraitsToArray(currentFormatTrait: FormatTraits): string[] {\r\n const formatTraitsArr = Array<string>();\r\n if ((currentFormatTrait & FormatTraits.TrailZeroes) === FormatTraits.TrailZeroes)\r\n formatTraitsArr.push(\"TrailZeroes\");\r\n if ((currentFormatTrait & FormatTraits.KeepSingleZero) === FormatTraits.KeepSingleZero)\r\n formatTraitsArr.push(\"KeepSingleZero\");\r\n if ((currentFormatTrait & FormatTraits.ZeroEmpty) === FormatTraits.ZeroEmpty)\r\n formatTraitsArr.push(\"ZeroEmpty\");\r\n if ((currentFormatTrait & FormatTraits.KeepDecimalPoint) === FormatTraits.KeepDecimalPoint)\r\n formatTraitsArr.push(\"KeepDecimalPoint\");\r\n if ((currentFormatTrait & FormatTraits.ApplyRounding) === FormatTraits.ApplyRounding)\r\n formatTraitsArr.push(\"ApplyRounding\");\r\n if ((currentFormatTrait & FormatTraits.FractionDash) === FormatTraits.FractionDash)\r\n formatTraitsArr.push(\"FractionDash\");\r\n if ((currentFormatTrait & FormatTraits.ShowUnitLabel) === FormatTraits.ShowUnitLabel)\r\n formatTraitsArr.push(\"ShowUnitLabel\");\r\n if ((currentFormatTrait & FormatTraits.PrependUnitLabel) === FormatTraits.PrependUnitLabel)\r\n formatTraitsArr.push(\"PrependUnitLabel\");\r\n if ((currentFormatTrait & FormatTraits.Use1000Separator) === FormatTraits.Use1000Separator)\r\n formatTraitsArr.push(\"Use1000Separator\");\r\n if ((currentFormatTrait & FormatTraits.ExponentOnlyNegative) === FormatTraits.ExponentOnlyNegative)\r\n formatTraitsArr.push(\"ExponentOnlyNegative\");\r\n return formatTraitsArr;\r\n}\r\n\r\n/** @beta */\r\nexport function parseFormatType(jsonObjType: string, formatName: string): FormatType {\r\n switch (jsonObjType.toLowerCase()) {\r\n case \"decimal\": return FormatType.Decimal;\r\n case \"scientific\": return FormatType.Scientific;\r\n case \"station\": return FormatType.Station;\r\n case \"fractional\": return FormatType.Fractional;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'type' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function formatTypeToString(type: FormatType): string {\r\n switch (type) {\r\n case FormatType.Decimal: return \"Decimal\";\r\n case FormatType.Scientific: return \"Scientific\";\r\n case FormatType.Station: return \"Station\";\r\n case FormatType.Fractional: return \"Fractional\";\r\n }\r\n}\r\n\r\n/** @beta */\r\nexport function parseDecimalPrecision(jsonObjPrecision: number, formatName: string): DecimalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 0: return DecimalPrecision.Zero;\r\n case 1: return DecimalPrecision.One;\r\n case 2: return DecimalPrecision.Two;\r\n case 3: return DecimalPrecision.Three;\r\n case 4: return DecimalPrecision.Four;\r\n case 5: return DecimalPrecision.Five;\r\n case 6: return DecimalPrecision.Six;\r\n case 7: return DecimalPrecision.Seven;\r\n case 8: return DecimalPrecision.Eight;\r\n case 9: return DecimalPrecision.Nine;\r\n case 10: return DecimalPrecision.Ten;\r\n case 11: return DecimalPrecision.Eleven;\r\n case 12: return DecimalPrecision.Twelve;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid FractionalPrecision */\r\nexport function parseFractionalPrecision(jsonObjPrecision: number, formatName: string): FractionalPrecision {\r\n switch (jsonObjPrecision) {\r\n case 1: return FractionalPrecision.One;\r\n case 2: return FractionalPrecision.Two;\r\n case 4: return FractionalPrecision.Four;\r\n case 8: return FractionalPrecision.Eight;\r\n case 16: return FractionalPrecision.Sixteen;\r\n case 32: return FractionalPrecision.ThirtyTwo;\r\n case 64: return FractionalPrecision.SixtyFour;\r\n case 128: return FractionalPrecision.OneHundredTwentyEight;\r\n case 256: return FractionalPrecision.TwoHundredFiftySix;\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n}\r\n\r\n/** @beta validates the input value, that is typically extracted for persisted JSON data, is a valid DecimalPrecision or FractionalPrecision. */\r\nexport function parsePrecision(precision: number, type: FormatType, formatName: string): DecimalPrecision | FractionalPrecision {\r\n switch (type) { // type must be decimal, fractional, scientific, or station\r\n case FormatType.Decimal:\r\n case FormatType.Scientific:\r\n case FormatType.Station:\r\n return parseDecimalPrecision(precision, formatName);\r\n case FormatType.Fractional:\r\n return parseFractionalPrecision(precision, formatName);\r\n default:\r\n throw new QuantityError(QuantityStatus.InvalidJson, `The Format ${formatName} has an invalid 'precision' attribute.`);\r\n }\r\n}\r\n"]}
|
|
@@ -62,7 +62,7 @@ export class FormatterSpec {
|
|
|
62
62
|
unitConversion = await unitsProvider.getConversion(convertFromUnit, unit[0]);
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
|
-
unitConversion =
|
|
65
|
+
unitConversion = { factor: 1.0, offset: 0.0 };
|
|
66
66
|
}
|
|
67
67
|
const unitLabel = (unit[1] && unit[1].length > 0) ? unit[1] : unit[0].label;
|
|
68
68
|
const spec = ({ name: unit[0].name, label: unitLabel, conversion: unitConversion, system: unit[0].system });
|