@ni/nimble-components 20.17.6 → 20.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/all-components-bundle.js +667 -167
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1171 -1109
- package/dist/all-components-bundle.min.js.map +1 -1
- package/dist/esm/all-components.d.ts +2 -0
- package/dist/esm/all-components.js +2 -0
- package/dist/esm/all-components.js.map +1 -1
- package/dist/esm/rich-text/base/index.js +2 -4
- package/dist/esm/rich-text/base/index.js.map +1 -1
- package/dist/esm/rich-text/editor/styles.js +29 -5
- package/dist/esm/rich-text/editor/styles.js.map +1 -1
- package/dist/esm/table/index.js +2 -4
- package/dist/esm/table/index.js.map +1 -1
- package/dist/esm/table/testing/table.pageobject.d.ts +1 -1
- package/dist/esm/table/testing/table.pageobject.js +9 -5
- package/dist/esm/table/testing/table.pageobject.js.map +1 -1
- package/dist/esm/table-column/number-text/cell-view/index.js +1 -2
- package/dist/esm/table-column/number-text/cell-view/index.js.map +1 -1
- package/dist/esm/table-column/number-text/group-header-view/index.js +1 -2
- package/dist/esm/table-column/number-text/group-header-view/index.js.map +1 -1
- package/dist/esm/table-column/number-text/index.d.ts +11 -2
- package/dist/esm/table-column/number-text/index.js +61 -14
- package/dist/esm/table-column/number-text/index.js.map +1 -1
- package/dist/esm/table-column/number-text/models/table-column-number-text-validator.d.ts +2 -1
- package/dist/esm/table-column/number-text/models/table-column-number-text-validator.js +6 -1
- package/dist/esm/table-column/number-text/models/table-column-number-text-validator.js.map +1 -1
- package/dist/esm/table-column/number-text/template.d.ts +2 -0
- package/dist/esm/table-column/number-text/template.js +14 -0
- package/dist/esm/table-column/number-text/template.js.map +1 -0
- package/dist/esm/unit/base/template.d.ts +1 -0
- package/dist/esm/unit/base/template.js +3 -0
- package/dist/esm/unit/base/template.js.map +1 -0
- package/dist/esm/unit/base/unit.d.ts +9 -0
- package/dist/esm/unit/base/unit.js +12 -0
- package/dist/esm/unit/base/unit.js.map +1 -0
- package/dist/esm/unit/byte/index.d.ts +19 -0
- package/dist/esm/unit/byte/index.js +36 -0
- package/dist/esm/unit/byte/index.js.map +1 -0
- package/dist/esm/unit/volt/index.d.ts +13 -0
- package/dist/esm/unit/volt/index.js +20 -0
- package/dist/esm/unit/volt/index.js.map +1 -0
- package/dist/esm/utilities/unit-format/base/unit-format.d.ts +16 -0
- package/dist/esm/utilities/unit-format/base/unit-format.js +21 -0
- package/dist/esm/utilities/unit-format/base/unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/decimal-unit-format.d.ts +22 -0
- package/dist/esm/utilities/unit-format/decimal-unit-format.js +51 -0
- package/dist/esm/utilities/unit-format/decimal-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/default-unit-format.d.ts +21 -0
- package/dist/esm/utilities/unit-format/default-unit-format.js +102 -0
- package/dist/esm/utilities/unit-format/default-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.d.ts +18 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.js +49 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.d.ts +10 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.js +19 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.d.ts +10 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.js +17 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.d.ts +5 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js +21 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.d.ts +9 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js +11 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js +26 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.js +19 -0
- package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.d.ts +11 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js +21 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit-format.d.ts +10 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit-format.js +10 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.d.ts +16 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.js +13 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.d.ts +15 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.js +49 -0
- package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.js +44 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.js +15 -0
- package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.js.map +1 -0
- package/dist/esm/utilities/wait-until-custom-elements-defined-async.d.ts +1 -0
- package/dist/esm/utilities/wait-until-custom-elements-defined-async.js +7 -0
- package/dist/esm/utilities/wait-until-custom-elements-defined-async.js.map +1 -0
- package/package.json +2 -2
- package/dist/esm/table-column/number-text/models/decimal-formatter.d.ts +0 -11
- package/dist/esm/table-column/number-text/models/decimal-formatter.js +0 -27
- package/dist/esm/table-column/number-text/models/decimal-formatter.js.map +0 -1
- package/dist/esm/table-column/number-text/models/default-formatter.d.ts +0 -15
- package/dist/esm/table-column/number-text/models/default-formatter.js +0 -55
- package/dist/esm/table-column/number-text/models/default-formatter.js.map +0 -1
- package/dist/esm/table-column/number-text/models/number-formatter.d.ts +0 -11
- package/dist/esm/table-column/number-text/models/number-formatter.js +0 -21
- package/dist/esm/table-column/number-text/models/number-formatter.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/number-text/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,YAAY,EAEf,MAAM,4BAA4B,CAAC;AACpC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/table-column/number-text/index.ts"],"names":[],"mappings":";AAAA,OAAO,EACH,YAAY,EAEf,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACH,IAAI,EAEJ,uBAAuB,EACvB,UAAU,EACV,UAAU,EAEb,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ADC,IAAI;wDACiC;AAGtC;IADC,IAAI,CAAC,EAAE,SAAS,EAAE,gBAAgB,EAAE,SAAS,EAAE,uBAAuB,EAAE,CAAC;4DAC5C;AAM9B;IAJC,IAAI,CAAC;QACF,SAAS,EAAE,wBAAwB;QACnC,SAAS,EAAE,uBAAuB;KACrC,CAAC;mEACmC;AAIrC;IADC,UAAU;2DACqB;AAGhC;IADC,UAAU;mDACS;AA8JxB,MAAM,2BAA2B,GAAG,qBAAqB,CAAC,OAAO,CAAC;IAC9D,QAAQ,EAAE,0BAA0B;IACpC,QAAQ;IACR,MAAM;CACT,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE;KACrB,UAAU,CAAC,QAAQ,CAAC;KACpB,QAAQ,CAAC,2BAA2B,EAAE,CAAC,CAAC;AAC7C,MAAM,CAAC,MAAM,wBAAwB,GAAG,iCAAiC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ColumnInternals } from '../../base/models/column-internals';
|
|
2
2
|
import { ColumnValidator } from '../../base/models/column-validator';
|
|
3
3
|
import { NumberTextFormat } from '../types';
|
|
4
|
-
declare const numberTextValidityFlagNames: readonly ["invalidDecimalDigits", "invalidDecimalMaximumDigits", "decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits"];
|
|
4
|
+
declare const numberTextValidityFlagNames: readonly ["invalidDecimalDigits", "invalidDecimalMaximumDigits", "decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits", "moreThanOneUnitSpecified"];
|
|
5
5
|
/**
|
|
6
6
|
* Validator for TableColumnNumberText.
|
|
7
7
|
*/
|
|
@@ -10,6 +10,7 @@ export declare class TableColumnNumberTextValidator extends ColumnValidator<type
|
|
|
10
10
|
validateDecimalDigits(format: NumberTextFormat, decimalDigits: number | undefined): void;
|
|
11
11
|
validateDecimalMaximumDigits(format: NumberTextFormat, decimalMaximumDigits: number | undefined): void;
|
|
12
12
|
validateNoMutuallyExclusiveProperties(format: NumberTextFormat, decimalDigits: number | undefined, decimalMaximumDigits: number | undefined): void;
|
|
13
|
+
validateAtMostOneUnit(unitElements: Element[]): void;
|
|
13
14
|
private isInvalidDecimalDigitsValue;
|
|
14
15
|
}
|
|
15
16
|
export {};
|
|
@@ -3,7 +3,8 @@ import { NumberTextFormat } from '../types';
|
|
|
3
3
|
const numberTextValidityFlagNames = [
|
|
4
4
|
'invalidDecimalDigits',
|
|
5
5
|
'invalidDecimalMaximumDigits',
|
|
6
|
-
'decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits'
|
|
6
|
+
'decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits',
|
|
7
|
+
'moreThanOneUnitSpecified'
|
|
7
8
|
];
|
|
8
9
|
// The maximum and minimum allowed configuration for 'maximumFractionDigits'
|
|
9
10
|
// and 'minimumFractionDigits' on the NumberFormat.
|
|
@@ -40,6 +41,10 @@ export class TableColumnNumberTextValidator extends ColumnValidator {
|
|
|
40
41
|
: false;
|
|
41
42
|
this.setConditionValue('decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits', invalid);
|
|
42
43
|
}
|
|
44
|
+
validateAtMostOneUnit(unitElements) {
|
|
45
|
+
const invalid = unitElements.length > 1;
|
|
46
|
+
this.setConditionValue('moreThanOneUnitSpecified', invalid);
|
|
47
|
+
}
|
|
43
48
|
isInvalidDecimalDigitsValue(decimalDigits) {
|
|
44
49
|
return (decimalDigits < minimumValidDecimalDigits
|
|
45
50
|
|| decimalDigits > maximumValidDecimalDigits);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"table-column-number-text-validator.js","sourceRoot":"","sources":["../../../../../src/table-column/number-text/models/table-column-number-text-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,2BAA2B,GAAG;IAChC,sBAAsB;IACtB,6BAA6B;IAC7B,wDAAwD;
|
|
1
|
+
{"version":3,"file":"table-column-number-text-validator.js","sourceRoot":"","sources":["../../../../../src/table-column/number-text/models/table-column-number-text-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAE5C,MAAM,2BAA2B,GAAG;IAChC,sBAAsB;IACtB,6BAA6B;IAC7B,wDAAwD;IACxD,0BAA0B;CACpB,CAAC;AAEX,4EAA4E;AAC5E,mDAAmD;AACnD,MAAM,yBAAyB,GAAG,CAAC,CAAC;AACpC,MAAM,yBAAyB,GAAG,EAAE,CAAC;AAErC;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,eAEnD;IACG,YAAmB,eAAyC;QACxD,KAAK,CAAC,eAAe,EAAE,2BAA2B,CAAC,CAAC;IACxD,CAAC;IAEM,qBAAqB,CACxB,MAAwB,EACxB,aAAiC;QAEjC,MAAM,gCAAgC,GAAG,MAAM,KAAK,gBAAgB,CAAC,OAAO;eACrE,OAAO,aAAa,KAAK,QAAQ,CAAC;QACzC,MAAM,OAAO,GAAG,gCAAgC;YAC5C,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,aAAa,CAAC;YACjD,CAAC,CAAC,KAAK,CAAC;QACZ,IAAI,CAAC,iBAAiB,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAEM,4BAA4B,CAC/B,MAAwB,EACxB,oBAAwC;QAExC,MAAM,gCAAgC,GAAG,MAAM,KAAK,gBAAgB,CAAC,OAAO;eACrE,OAAO,oBAAoB,KAAK,QAAQ,CAAC;QAChD,MAAM,OAAO,GAAG,gCAAgC;YAC5C,CAAC,CAAC,IAAI,CAAC,2BAA2B,CAAC,oBAAoB,CAAC;YACxD,CAAC,CAAC,KAAK,CAAC;QACZ,IAAI,CAAC,iBAAiB,CAAC,6BAA6B,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAEM,qCAAqC,CACxC,MAAwB,EACxB,aAAiC,EACjC,oBAAwC;QAExC,MAAM,yCAAyC,GAAG,MAAM,KAAK,gBAAgB,CAAC,OAAO,CAAC;QACtF,MAAM,OAAO,GAAG,yCAAyC;YACrD,CAAC,CAAC,OAAO,aAAa,KAAK,QAAQ;mBAC9B,OAAO,oBAAoB,KAAK,QAAQ;YAC7C,CAAC,CAAC,KAAK,CAAC;QACZ,IAAI,CAAC,iBAAiB,CAClB,wDAAwD,EACxD,OAAO,CACV,CAAC;IACN,CAAC;IAEM,qBAAqB,CAAC,YAAuB;QAChD,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,iBAAiB,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAEO,2BAA2B,CAAC,aAAqB;QACrD,OAAO,CACH,aAAa,GAAG,yBAAyB;eACtC,aAAa,GAAG,yBAAyB,CAC/C,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { elements, html, ref, slotted } from '@microsoft/fast-element';
|
|
2
|
+
import { overflow } from '../../utilities/directive/overflow';
|
|
3
|
+
// Avoiding a wrapping <template> and be careful about starting and ending whitespace
|
|
4
|
+
// so the template can be composed into other column header templates
|
|
5
|
+
// prettier-ignore
|
|
6
|
+
export const template = html `<span
|
|
7
|
+
${overflow('hasOverflow')}
|
|
8
|
+
class="header-content"
|
|
9
|
+
title=${x => (x.hasOverflow && x.headerTextContent ? x.headerTextContent : null)}
|
|
10
|
+
>
|
|
11
|
+
<slot ${ref('contentSlot')}></slot>
|
|
12
|
+
<slot ${slotted({ property: 'unitElements', filter: elements() })} name="unit"></slot>
|
|
13
|
+
</span>`;
|
|
14
|
+
//# sourceMappingURL=template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/table-column/number-text/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,EAAE,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAG9D,qFAAqF;AACrF,qEAAqE;AACrE,kBAAkB;AAClB,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAuB;MAC7C,QAAQ,CAAC,aAAa,CAAC;;YAEjB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,CAAC;;YAExE,GAAG,CAAC,aAAa,CAAC;YAClB,OAAO,CAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,CAAC;QAC7D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const template: import("@microsoft/fast-element").ViewTemplate<any, any>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"template.js","sourceRoot":"","sources":["../../../../src/unit/base/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAE/C,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAA,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
2
|
+
import type { UnitScale } from '../../utilities/unit-format/unit-scale/base/unit-scale';
|
|
3
|
+
/**
|
|
4
|
+
* The base class for an element that provides a unit scale for scaled unit conversions
|
|
5
|
+
*/
|
|
6
|
+
export declare abstract class Unit extends FoundationElement {
|
|
7
|
+
/** @internal */
|
|
8
|
+
resolvedUnitScale?: UnitScale;
|
|
9
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { observable } from '@microsoft/fast-element';
|
|
3
|
+
import { FoundationElement } from '@microsoft/fast-foundation';
|
|
4
|
+
/**
|
|
5
|
+
* The base class for an element that provides a unit scale for scaled unit conversions
|
|
6
|
+
*/
|
|
7
|
+
export class Unit extends FoundationElement {
|
|
8
|
+
}
|
|
9
|
+
__decorate([
|
|
10
|
+
observable
|
|
11
|
+
], Unit.prototype, "resolvedUnitScale", void 0);
|
|
12
|
+
//# sourceMappingURL=unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit.js","sourceRoot":"","sources":["../../../../src/unit/base/unit.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAG/D;;GAEG;AACH,MAAM,OAAgB,IAAK,SAAQ,iBAAiB;CAInD;AADG;IADC,UAAU;+CAC0B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Unit } from '../base/unit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'nimble-unit-byte': UnitByte;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Element that provides a unit scale for conversion of bytes
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnitByte extends Unit {
|
|
11
|
+
/**
|
|
12
|
+
* Use binary (base 1024 scale with binary prefixes) instead of
|
|
13
|
+
* the default of decimal (base 1000 scale with metric prefixes)
|
|
14
|
+
*/
|
|
15
|
+
binary: boolean;
|
|
16
|
+
constructor();
|
|
17
|
+
private binaryChanged;
|
|
18
|
+
}
|
|
19
|
+
export declare const unitByteTag = "nimble-unit-byte";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { attr } from '@microsoft/fast-element';
|
|
3
|
+
import { DesignSystem } from '@microsoft/fast-foundation';
|
|
4
|
+
import { template } from '../base/template';
|
|
5
|
+
import { byte1024UnitScale } from '../../utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale';
|
|
6
|
+
import { byteUnitScale } from '../../utilities/unit-format/unit-scale/byte-unit-scale';
|
|
7
|
+
import { Unit } from '../base/unit';
|
|
8
|
+
/**
|
|
9
|
+
* Element that provides a unit scale for conversion of bytes
|
|
10
|
+
*/
|
|
11
|
+
export class UnitByte extends Unit {
|
|
12
|
+
constructor() {
|
|
13
|
+
super();
|
|
14
|
+
/**
|
|
15
|
+
* Use binary (base 1024 scale with binary prefixes) instead of
|
|
16
|
+
* the default of decimal (base 1000 scale with metric prefixes)
|
|
17
|
+
*/
|
|
18
|
+
this.binary = false;
|
|
19
|
+
this.resolvedUnitScale = byteUnitScale;
|
|
20
|
+
}
|
|
21
|
+
binaryChanged() {
|
|
22
|
+
this.resolvedUnitScale = this.binary
|
|
23
|
+
? byte1024UnitScale
|
|
24
|
+
: byteUnitScale;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
__decorate([
|
|
28
|
+
attr({ mode: 'boolean' })
|
|
29
|
+
], UnitByte.prototype, "binary", void 0);
|
|
30
|
+
const nimbleUnitByte = UnitByte.compose({
|
|
31
|
+
baseName: 'unit-byte',
|
|
32
|
+
template
|
|
33
|
+
});
|
|
34
|
+
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleUnitByte());
|
|
35
|
+
export const unitByteTag = 'nimble-unit-byte';
|
|
36
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/unit/byte/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,yBAAyB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,iFAAiF,CAAC;AACpH,OAAO,EAAE,aAAa,EAAE,MAAM,wDAAwD,CAAC;AACvF,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQpC;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI;IAQ9B;QACI,KAAK,EAAE,CAAC;QARZ;;;WAGG;QAEI,WAAM,GAAG,KAAK,CAAC;QAIlB,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC;IAC3C,CAAC;IAEO,aAAa;QACjB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAC,MAAM;YAChC,CAAC,CAAC,iBAAiB;YACnB,CAAC,CAAC,aAAa,CAAC;IACxB,CAAC;CACJ;AAZG;IADC,IAAI,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;wCACJ;AAc1B,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC;IACpC,QAAQ,EAAE,WAAW;IACrB,QAAQ;CACX,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Unit } from '../base/unit';
|
|
2
|
+
declare global {
|
|
3
|
+
interface HTMLElementTagNameMap {
|
|
4
|
+
'nimble-unit-volt': UnitVolt;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Element representing units for volts
|
|
9
|
+
*/
|
|
10
|
+
export declare class UnitVolt extends Unit {
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
export declare const unitVoltTag = "nimble-unit-volt";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DesignSystem } from '@microsoft/fast-foundation';
|
|
2
|
+
import { template } from '../base/template';
|
|
3
|
+
import { Unit } from '../base/unit';
|
|
4
|
+
import { voltUnitScale } from '../../utilities/unit-format/manually-translated-unit-scale/volt-unit-scale';
|
|
5
|
+
/**
|
|
6
|
+
* Element representing units for volts
|
|
7
|
+
*/
|
|
8
|
+
export class UnitVolt extends Unit {
|
|
9
|
+
constructor() {
|
|
10
|
+
super();
|
|
11
|
+
this.resolvedUnitScale = voltUnitScale;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const nimbleUnitVolt = UnitVolt.compose({
|
|
15
|
+
baseName: 'unit-volt',
|
|
16
|
+
template
|
|
17
|
+
});
|
|
18
|
+
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleUnitVolt());
|
|
19
|
+
export const unitVoltTag = 'nimble-unit-volt';
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/unit/volt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,4EAA4E,CAAC;AAQ3G;;GAEG;AACH,MAAM,OAAO,QAAS,SAAQ,IAAI;IAC9B;QACI,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,iBAAiB,GAAG,aAAa,CAAC;IAC3C,CAAC;CACJ;AAED,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC;IACpC,QAAQ,EAAE,WAAW;IACrB,QAAQ;CACX,CAAC,CAAC;AAEH,YAAY,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;AAC3E,MAAM,CAAC,MAAM,WAAW,GAAG,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { UnitScale } from '../unit-scale/base/unit-scale';
|
|
2
|
+
export interface UnitFormatOptions {
|
|
3
|
+
unitScale?: UnitScale;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The base class for unit formats.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class UnitFormat<Options extends UnitFormatOptions = UnitFormatOptions> {
|
|
9
|
+
/**
|
|
10
|
+
* Formats a number value to a string.
|
|
11
|
+
* For nullish values or values that result in an exception being thrown, empty string is returned
|
|
12
|
+
*/
|
|
13
|
+
format(value: number | undefined | null): string;
|
|
14
|
+
abstract resolvedOptions(): Required<Options>;
|
|
15
|
+
protected abstract tryFormat(number: number): string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The base class for unit formats.
|
|
3
|
+
*/
|
|
4
|
+
export class UnitFormat {
|
|
5
|
+
/**
|
|
6
|
+
* Formats a number value to a string.
|
|
7
|
+
* For nullish values or values that result in an exception being thrown, empty string is returned
|
|
8
|
+
*/
|
|
9
|
+
format(value) {
|
|
10
|
+
if (typeof value !== 'number') {
|
|
11
|
+
return '';
|
|
12
|
+
}
|
|
13
|
+
try {
|
|
14
|
+
return this.tryFormat(value);
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return '';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=unit-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-format.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/base/unit-format.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,OAAgB,UAAU;IAG5B;;;OAGG;IACI,MAAM,CAAC,KAAgC;QAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC3B,OAAO,EAAE,CAAC;SACb;QAED,IAAI;YACA,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;SAChC;QAAC,MAAM;YACJ,OAAO,EAAE,CAAC;SACb;IACL,CAAC;CAKJ"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UnitFormat, UnitFormatOptions } from './base/unit-format';
|
|
2
|
+
import type { UnitScale } from './unit-scale/base/unit-scale';
|
|
3
|
+
interface DecimalUnitFormatOptions extends UnitFormatOptions {
|
|
4
|
+
minimumFractionDigits?: number;
|
|
5
|
+
maximumFractionDigits?: number;
|
|
6
|
+
unitScale?: UnitScale;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Format for decimal numbers with units.
|
|
10
|
+
*/
|
|
11
|
+
export declare class DecimalUnitFormat extends UnitFormat<DecimalUnitFormatOptions> {
|
|
12
|
+
private readonly unitScale;
|
|
13
|
+
private readonly minimumFractionDigits;
|
|
14
|
+
private readonly maximumFractionDigits;
|
|
15
|
+
private readonly scaledUnitFormatters;
|
|
16
|
+
private readonly tenPowDecimalDigits;
|
|
17
|
+
constructor(locale: string, { minimumFractionDigits, maximumFractionDigits, unitScale }?: DecimalUnitFormatOptions);
|
|
18
|
+
resolvedOptions(): Required<DecimalUnitFormatOptions>;
|
|
19
|
+
protected tryFormat(number: number): string;
|
|
20
|
+
private willRoundToZero;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { UnitFormat } from './base/unit-format';
|
|
2
|
+
import { passthroughUnitScale } from './unit-scale/passthrough-unit-scale';
|
|
3
|
+
/**
|
|
4
|
+
* Format for decimal numbers with units.
|
|
5
|
+
*/
|
|
6
|
+
export class DecimalUnitFormat extends UnitFormat {
|
|
7
|
+
constructor(locale, { minimumFractionDigits = 0, maximumFractionDigits = Math.max(3, minimumFractionDigits), unitScale = passthroughUnitScale } = {
|
|
8
|
+
minimumFractionDigits: 0,
|
|
9
|
+
maximumFractionDigits: 3,
|
|
10
|
+
unitScale: passthroughUnitScale
|
|
11
|
+
}) {
|
|
12
|
+
super();
|
|
13
|
+
this.scaledUnitFormatters = new Map();
|
|
14
|
+
const intlNumberFormatOptions = {
|
|
15
|
+
maximumFractionDigits,
|
|
16
|
+
minimumFractionDigits,
|
|
17
|
+
useGrouping: true
|
|
18
|
+
};
|
|
19
|
+
for (const scaledUnit of unitScale.supportedScaledUnits) {
|
|
20
|
+
this.scaledUnitFormatters.set(scaledUnit.scaleFactor, scaledUnit.scaledUnitFormatFactory({
|
|
21
|
+
locale,
|
|
22
|
+
intlNumberFormatOptions
|
|
23
|
+
}));
|
|
24
|
+
}
|
|
25
|
+
this.tenPowDecimalDigits = 10 ** maximumFractionDigits;
|
|
26
|
+
this.unitScale = unitScale;
|
|
27
|
+
this.minimumFractionDigits = minimumFractionDigits;
|
|
28
|
+
this.maximumFractionDigits = maximumFractionDigits;
|
|
29
|
+
}
|
|
30
|
+
resolvedOptions() {
|
|
31
|
+
return {
|
|
32
|
+
unitScale: this.unitScale,
|
|
33
|
+
maximumFractionDigits: this.maximumFractionDigits,
|
|
34
|
+
minimumFractionDigits: this.minimumFractionDigits
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
tryFormat(number) {
|
|
38
|
+
const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(number);
|
|
39
|
+
const numberNormalized = this.willRoundToZero(scaledValue)
|
|
40
|
+
? 0
|
|
41
|
+
: scaledValue;
|
|
42
|
+
const scaledUnitFormatter = this.scaledUnitFormatters.get(scaledUnit.scaleFactor);
|
|
43
|
+
return scaledUnitFormatter.format(numberNormalized);
|
|
44
|
+
}
|
|
45
|
+
willRoundToZero(number) {
|
|
46
|
+
// Multiply the value by 10 raised to maximumFractionDigits so that Math.round can be used to emulate rounding to
|
|
47
|
+
// maximumFractionDigits decimal places. If that rounded value is 0, then the value will be rendered with only 0s.
|
|
48
|
+
return Math.round(number * this.tenPowDecimalDigits) === 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=decimal-unit-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decimal-unit-format.js","sourceRoot":"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EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;QAEvE,MAAM,gBAAgB,GAAG,IAAI,CAAC,eAAe,CAAC,WAAW,CAAC;YACtD,CAAC,CAAC,CAAC;YACH,CAAC,CAAC,WAAW,CAAC;QAClB,MAAM,mBAAmB,GAAG,IAAI,CAAC,oBAAoB,CAAC,GAAG,CACrD,UAAU,CAAC,WAAW,CACxB,CAAC;QACH,OAAO,mBAAmB,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;IACxD,CAAC;IAEO,eAAe,CAAC,MAAc;QAClC,iHAAiH;QACjH,kHAAkH;QAClH,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;CACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UnitFormat, UnitFormatOptions } from './base/unit-format';
|
|
2
|
+
/**
|
|
3
|
+
* Format for numbers with units to show in a tabular form.
|
|
4
|
+
* Large and tiny numbers are shown exponentially and the rest as decimal.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DefaultUnitFormat extends UnitFormat {
|
|
7
|
+
private static readonly maximumDigits;
|
|
8
|
+
private static readonly exponentialLowerBound;
|
|
9
|
+
private static readonly exponentialUpperBound;
|
|
10
|
+
private readonly unitScale;
|
|
11
|
+
private readonly defaultIntlNumberFormatOptions;
|
|
12
|
+
private readonly defaultScaledUnitFormatters;
|
|
13
|
+
private readonly leadingZeroIntlNumberFormatOptions;
|
|
14
|
+
private readonly leadingZeroScaledUnitFormatters;
|
|
15
|
+
private readonly exponentialIntlNumberFormatOptions;
|
|
16
|
+
private readonly exponentialScaledUnitFormatter;
|
|
17
|
+
constructor(locale: string, { unitScale }?: UnitFormatOptions);
|
|
18
|
+
resolvedOptions(): Required<UnitFormatOptions>;
|
|
19
|
+
protected tryFormat(number: number): string;
|
|
20
|
+
private resolveNumberStyle;
|
|
21
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { UnitFormat } from './base/unit-format';
|
|
2
|
+
import { passthroughUnitScale } from './unit-scale/passthrough-unit-scale';
|
|
3
|
+
/**
|
|
4
|
+
* Format for numbers with units to show in a tabular form.
|
|
5
|
+
* Large and tiny numbers are shown exponentially and the rest as decimal.
|
|
6
|
+
*/
|
|
7
|
+
export class DefaultUnitFormat extends UnitFormat {
|
|
8
|
+
constructor(locale, { unitScale = passthroughUnitScale } = {
|
|
9
|
+
unitScale: passthroughUnitScale
|
|
10
|
+
}) {
|
|
11
|
+
super();
|
|
12
|
+
// Format options to use by default. It renders the number with a maximum of 6 signficant digits.
|
|
13
|
+
this.defaultIntlNumberFormatOptions = {
|
|
14
|
+
maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
|
|
15
|
+
useGrouping: true
|
|
16
|
+
};
|
|
17
|
+
this.defaultScaledUnitFormatters = new Map();
|
|
18
|
+
// Format options to use for numbers that have leading zeros. It limits the number of rendered
|
|
19
|
+
// digits using 'maximumFractionDigits', which will result in less than 6 significant digits
|
|
20
|
+
// in order to render no more than 6 total digits.
|
|
21
|
+
this.leadingZeroIntlNumberFormatOptions = {
|
|
22
|
+
maximumFractionDigits: DefaultUnitFormat.maximumDigits - 1,
|
|
23
|
+
useGrouping: true
|
|
24
|
+
};
|
|
25
|
+
this.leadingZeroScaledUnitFormatters = new Map();
|
|
26
|
+
// Format options for numbers that should be displayed in exponential notation. This should be used
|
|
27
|
+
// for numbers with magintudes over 'exponentialUpperBound' or under 'exponentialLowerBound'.
|
|
28
|
+
this.exponentialIntlNumberFormatOptions = {
|
|
29
|
+
maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
|
|
30
|
+
notation: 'scientific'
|
|
31
|
+
};
|
|
32
|
+
for (const unit of unitScale.supportedScaledUnits) {
|
|
33
|
+
this.defaultScaledUnitFormatters.set(unit.scaleFactor, unit.scaledUnitFormatFactory({
|
|
34
|
+
locale,
|
|
35
|
+
intlNumberFormatOptions: this.defaultIntlNumberFormatOptions
|
|
36
|
+
}));
|
|
37
|
+
this.leadingZeroScaledUnitFormatters.set(unit.scaleFactor, unit.scaledUnitFormatFactory({
|
|
38
|
+
locale,
|
|
39
|
+
intlNumberFormatOptions: this.leadingZeroIntlNumberFormatOptions
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
this.exponentialScaledUnitFormatter = unitScale.baseScaledUnit.scaledUnitFormatFactory({
|
|
43
|
+
locale,
|
|
44
|
+
intlNumberFormatOptions: this.exponentialIntlNumberFormatOptions
|
|
45
|
+
});
|
|
46
|
+
this.unitScale = unitScale;
|
|
47
|
+
}
|
|
48
|
+
resolvedOptions() {
|
|
49
|
+
return {
|
|
50
|
+
unitScale: this.unitScale
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
tryFormat(number) {
|
|
54
|
+
// Normalize +0 / -0 --> +0
|
|
55
|
+
const numberNormalized = number === 0 ? 0 : number;
|
|
56
|
+
const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(numberNormalized);
|
|
57
|
+
const numberStyle = this.resolveNumberStyle(scaledValue);
|
|
58
|
+
switch (numberStyle) {
|
|
59
|
+
case 'default': {
|
|
60
|
+
const scaledUnitFormatter = this.defaultScaledUnitFormatters.get(scaledUnit.scaleFactor);
|
|
61
|
+
return scaledUnitFormatter.format(scaledValue);
|
|
62
|
+
}
|
|
63
|
+
case 'leadingZero': {
|
|
64
|
+
const scaledUnitFormatter = this.leadingZeroScaledUnitFormatters.get(scaledUnit.scaleFactor);
|
|
65
|
+
return scaledUnitFormatter.format(scaledValue);
|
|
66
|
+
}
|
|
67
|
+
case 'exponential': {
|
|
68
|
+
const scaledUnitFormatter = this.exponentialScaledUnitFormatter;
|
|
69
|
+
return scaledUnitFormatter.format(numberNormalized);
|
|
70
|
+
}
|
|
71
|
+
default:
|
|
72
|
+
throw new Error('Unexpected number format style');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
resolveNumberStyle(number) {
|
|
76
|
+
if (number === 0) {
|
|
77
|
+
return 'default';
|
|
78
|
+
}
|
|
79
|
+
const absoluteValue = Math.abs(number);
|
|
80
|
+
if (absoluteValue >= DefaultUnitFormat.exponentialUpperBound
|
|
81
|
+
|| absoluteValue < DefaultUnitFormat.exponentialLowerBound) {
|
|
82
|
+
return 'exponential';
|
|
83
|
+
}
|
|
84
|
+
// Ideally, we could set 'roundingPriority: "lessPrecision"' with a formatter that has both 'maximumSignificantDigits' and
|
|
85
|
+
// 'maximumFractionDigits' configured instead of having two different formatters that we conditionally choose between. However,
|
|
86
|
+
// 'roundingPrioirty' is not supported yet in all browsers.
|
|
87
|
+
if (absoluteValue < 1) {
|
|
88
|
+
return 'leadingZero';
|
|
89
|
+
}
|
|
90
|
+
return 'default';
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
// The maximum number of digits that should be rendered for any given value.
|
|
94
|
+
DefaultUnitFormat.maximumDigits = 6;
|
|
95
|
+
// Use exponential notation for numbers that will be rendered with 3 leading 0s or more.
|
|
96
|
+
// Because a maximum of 6 digits are rendered, showing more than 3 leading 0s is not ideal
|
|
97
|
+
// because then at least half of the displayed digits will be leading 0s.
|
|
98
|
+
DefaultUnitFormat.exponentialLowerBound = 0.000995;
|
|
99
|
+
// Use exponential formatting for numbers whose magnitude cannot otherwise be displayed
|
|
100
|
+
// with 6 digits or less.
|
|
101
|
+
DefaultUnitFormat.exponentialUpperBound = 999999.5;
|
|
102
|
+
//# sourceMappingURL=default-unit-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-unit-format.js","sourceRoot":"","sources":["../../../../src/utilities/unit-format/default-unit-format.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAqB,MAAM,oBAAoB,CAAC;AAGnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAI3E;;;GAGG;AACH,MAAM,OAAO,iBAAkB,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GAAG,iBAAiB,CAAC,qBAAqB,EAC5D;YACE,OAAO,aAAa,CAAC;SACxB;QACD,0HAA0H;QAC1H,+HAA+H;QAC/H,2DAA2D;QAC3D,IAAI,aAAa,GAAG,CAAC,EAAE;YACnB,OAAO,aAAa,CAAC;SACxB;QACD,OAAO,SAAS,CAAC;IACrB,CAAC;;AApID,4EAA4E;AACpD,+BAAa,GAAG,CAAC,CAAC;AAE1C,wFAAwF;AACxF,0FAA0F;AAC1F,yEAAyE;AACjD,uCAAqB,GAAG,QAAQ,CAAC;AAEzD,uFAAuF;AACvF,yBAAyB;AACD,uCAAqB,GAAG,QAAQ,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ScaledUnitFormatFactoryOptions } from '../../unit-scale/base/scaled-unit';
|
|
2
|
+
import { ScaledUnitFormat } from '../../unit-scale/base/scaled-unit-format';
|
|
3
|
+
import type { UnitPrefix } from './unit-prefix';
|
|
4
|
+
import type { UnitTranslation } from './unit-translation';
|
|
5
|
+
/**
|
|
6
|
+
* A formatter for units that are not supported by Intl.NumberFormat
|
|
7
|
+
*/
|
|
8
|
+
export declare class ManuallyTranslatedScaledUnitFormat extends ScaledUnitFormat {
|
|
9
|
+
private readonly unitTranslations;
|
|
10
|
+
private readonly unitPrefix;
|
|
11
|
+
private readonly pluralRules;
|
|
12
|
+
private readonly formatter;
|
|
13
|
+
private readonly unitTranslation;
|
|
14
|
+
protected constructor(scaledUnitFormatFactoryOptions: ScaledUnitFormatFactoryOptions, unitTranslations: ReadonlyMap<string, UnitTranslation>, unitPrefix: UnitPrefix);
|
|
15
|
+
static createFactory(unitTranslations: ReadonlyMap<string, UnitTranslation>, unitPrefix: UnitPrefix): (scaledUnitFormatFactoryOptions: ScaledUnitFormatFactoryOptions) => ManuallyTranslatedScaledUnitFormat;
|
|
16
|
+
format(value: number): string;
|
|
17
|
+
private getTranslationToUse;
|
|
18
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ScaledUnitFormat } from '../../unit-scale/base/scaled-unit-format';
|
|
2
|
+
/**
|
|
3
|
+
* A formatter for units that are not supported by Intl.NumberFormat
|
|
4
|
+
*/
|
|
5
|
+
export class ManuallyTranslatedScaledUnitFormat extends ScaledUnitFormat {
|
|
6
|
+
constructor(scaledUnitFormatFactoryOptions, unitTranslations, unitPrefix) {
|
|
7
|
+
super(scaledUnitFormatFactoryOptions);
|
|
8
|
+
this.unitTranslations = unitTranslations;
|
|
9
|
+
this.unitPrefix = unitPrefix;
|
|
10
|
+
this.pluralRules = new Intl.PluralRules(this.locale);
|
|
11
|
+
this.formatter = new Intl.NumberFormat(this.locale, this.intlNumberFormatOptions);
|
|
12
|
+
this.unitTranslation = this.getTranslationToUse(this.locale);
|
|
13
|
+
}
|
|
14
|
+
static createFactory(unitTranslations, unitPrefix) {
|
|
15
|
+
return (scaledUnitFormatFactoryOptions) => new ManuallyTranslatedScaledUnitFormat(scaledUnitFormatFactoryOptions, unitTranslations, unitPrefix);
|
|
16
|
+
}
|
|
17
|
+
format(value) {
|
|
18
|
+
const formatted = this.formatter.format(value);
|
|
19
|
+
if (!this.unitPrefix.isBase()) {
|
|
20
|
+
return `${formatted} ${this.unitPrefix.text}${this.unitTranslation.symbol}`;
|
|
21
|
+
}
|
|
22
|
+
// Some languages have more than two forms (singular/plural) of cardinal
|
|
23
|
+
// numbers, but we are treating anything other than the 'one' form as plural.
|
|
24
|
+
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules#description
|
|
25
|
+
//
|
|
26
|
+
// Because PluralRules.select() takes a number (not a string), it cannot differentiate
|
|
27
|
+
// between 1 and 1.0. When NumberFormat is configured to format with a set number
|
|
28
|
+
// of fractional digits, those fractional digits can have an effect on the pluralization
|
|
29
|
+
// of the unit. E.g. in English, it formats "1 byte" vs "1.0 bytes". Thus there is
|
|
30
|
+
// sometimes an inconsistency between unit pluralization for the same number, based
|
|
31
|
+
// on whether it's supported by NumberFormat, or manually translated.
|
|
32
|
+
const unitLabel = this.pluralRules.select(value) === 'one'
|
|
33
|
+
? this.unitTranslation.singular
|
|
34
|
+
: this.unitTranslation.plural;
|
|
35
|
+
return `${formatted} ${unitLabel}`;
|
|
36
|
+
}
|
|
37
|
+
getTranslationToUse(locale) {
|
|
38
|
+
const localeObject = new Intl.Locale(locale ?? 'en');
|
|
39
|
+
const language = localeObject.language;
|
|
40
|
+
const region = localeObject.region;
|
|
41
|
+
const regionSpecificMatchedTranslations = region
|
|
42
|
+
? this.unitTranslations.get(`${language}-${region}`) // do not include any other subtags that might be in the given locale string
|
|
43
|
+
: null;
|
|
44
|
+
return (regionSpecificMatchedTranslations
|
|
45
|
+
?? this.unitTranslations.get(language)
|
|
46
|
+
?? this.unitTranslations.get('en'));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=manually-translated-scaled-unit-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manually-translated-scaled-unit-format.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAI5E;;GAEG;AACH,MAAM,OAAO,kCAAmC,SAAQ,gBAAgB;IAKpE,YACI,8BAA8D,EAC7C,gBAAsD,EACtD,UAAsB;QAEvC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAHrB,qBAAgB,GAAhB,gBAAgB,CAAsC;QACtD,eAAU,GAAV,UAAU,CAAY;QAGvC,IAAI,CAAC,WAAW,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrD,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAClC,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,uBAAuB,CAC/B,CAAC;QACF,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,m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,CAAC,CAAC,4EAA4E;YACjI,CAAC,CAAC,IAAI,CAAC;QACX,OAAO,CACH,iCAAiC;eAC9B,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,QAAQ,CAAC;eACnC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAE,CACtC,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { UnitPrefix } from './unit-prefix';
|
|
2
|
+
import type { UnitTranslation } from './unit-translation';
|
|
3
|
+
import { UnitScale } from '../../unit-scale/base/unit-scale';
|
|
4
|
+
/**
|
|
5
|
+
* A unit scale that is not supported by Intl.NumberFormat and has manually provided translation strings
|
|
6
|
+
*/
|
|
7
|
+
export declare abstract class ManuallyTranslatedUnitScale extends UnitScale {
|
|
8
|
+
constructor(unitTranslations: ReadonlyMap<string, UnitTranslation>, supportedUnitPrefixes: readonly UnitPrefix[]);
|
|
9
|
+
private static createSupportedScaledUnits;
|
|
10
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ManuallyTranslatedScaledUnitFormat } from './manually-translated-scaled-unit-format';
|
|
2
|
+
import { ScaledUnit } from '../../unit-scale/base/scaled-unit';
|
|
3
|
+
import { UnitScale } from '../../unit-scale/base/unit-scale';
|
|
4
|
+
/**
|
|
5
|
+
* A unit scale that is not supported by Intl.NumberFormat and has manually provided translation strings
|
|
6
|
+
*/
|
|
7
|
+
export class ManuallyTranslatedUnitScale extends UnitScale {
|
|
8
|
+
constructor(unitTranslations, supportedUnitPrefixes) {
|
|
9
|
+
super(ManuallyTranslatedUnitScale.createSupportedScaledUnits(unitTranslations, supportedUnitPrefixes));
|
|
10
|
+
}
|
|
11
|
+
static createSupportedScaledUnits(unitTranslations, supportedUnitPrefixes) {
|
|
12
|
+
if (!unitTranslations.get('en')) {
|
|
13
|
+
throw new Error('English translations must exist');
|
|
14
|
+
}
|
|
15
|
+
const supportedUnits = supportedUnitPrefixes.map(unitPrefix => new ScaledUnit(unitPrefix.scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory(unitTranslations, unitPrefix)));
|
|
16
|
+
return supportedUnits;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=manually-translated-unit-scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"manually-translated-unit-scale.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kCAAkC,EAAE,MAAM,0CAA0C,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,mCAAmC,CAAC;AAG/D,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAC;AAE7D;;GAEG;AACH,MAAM,OAAgB,2BAA4B,SAAQ,SAAS;IAC/D,YACI,gBAAsD,EACtD,qBAA4C;QAE5C,KAAK,CACD,2BAA2B,CAAC,0BAA0B,CAClD,gBAAgB,EAChB,qBAAqB,CACxB,CACJ,CAAC;IACN,CAAC;IAEO,MAAM,CAAC,0BAA0B,CACrC,gBAAsD,EACtD,qBAA4C;QAE5C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;SACtD;QACD,MAAM,cAAc,GAAG,qBAAqB,CAAC,GAAG,CAC5C,UAAU,CAAC,EAAE,CAAC,IAAI,UAAU,CACxB,UAAU,CAAC,WAAW,EACtB,kCAAkC,CAAC,aAAa,CAC5C,gBAAgB,EAChB,UAAU,CACb,CACJ,CACJ,CAAC;QAEF,OAAO,cAAc,CAAC;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A prefix that represents a scaling factor when applied to a base unit.
|
|
3
|
+
* A base unit is represented as scale factor 1 and empty text.
|
|
4
|
+
*/
|
|
5
|
+
export declare class UnitPrefix {
|
|
6
|
+
readonly scaleFactor: number;
|
|
7
|
+
readonly text: string;
|
|
8
|
+
constructor(scaleFactor: number, text: string);
|
|
9
|
+
isBase(): boolean;
|
|
10
|
+
}
|