@ni/nimble-components 20.17.7 → 20.18.1
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 +599 -163
- package/dist/all-components-bundle.js.map +1 -1
- package/dist/all-components-bundle.min.js +1151 -1107
- 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/table/index.js +2 -4
- package/dist/esm/table/index.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/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/scaled-unit/scaled-unit.d.ts +16 -0
- package/dist/esm/utilities/unit-format/scaled-unit/scaled-unit.js +13 -0
- package/dist/esm/utilities/unit-format/scaled-unit/scaled-unit.js.map +1 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/intl-number-format-scaled-unit-format.d.ts +11 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/intl-number-format-scaled-unit-format.js +21 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/intl-number-format-scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/manually-translated-scaled-unit-format.d.ts +43 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/manually-translated-scaled-unit-format.js +62 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/manually-translated-scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/scaled-unit-format.d.ts +10 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/scaled-unit-format.js +10 -0
- package/dist/esm/utilities/unit-format/scaled-unit-format/scaled-unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-format.d.ts +16 -0
- package/dist/esm/utilities/unit-format/unit-format.js +21 -0
- package/dist/esm/utilities/unit-format/unit-format.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-1024-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-1024-unit-scale.js +31 -0
- package/dist/esm/utilities/unit-format/unit-scale/byte-1024-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 +25 -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/unit-format/unit-scale/unit-scale.d.ts +15 -0
- package/dist/esm/utilities/unit-format/unit-scale/unit-scale.js +49 -0
- package/dist/esm/utilities/unit-format/unit-scale/unit-scale.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/utilities/metrix-prefixes.d.ts +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/utilities/metrix-prefixes.js +17 -0
- package/dist/esm/utilities/unit-format/unit-scale/utilities/metrix-prefixes.js.map +1 -0
- package/dist/esm/utilities/unit-format/unit-scale/volt-unit-scale.d.ts +9 -0
- package/dist/esm/utilities/unit-format/unit-scale/volt-unit-scale.js +24 -0
- package/dist/esm/utilities/unit-format/unit-scale/volt-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 +1 -1
- 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
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScaledUnit } from '../scaled-unit/scaled-unit';
|
|
2
|
+
interface ScaledNumber {
|
|
3
|
+
readonly scaledValue: number;
|
|
4
|
+
readonly scaledUnit: ScaledUnit;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* A unit scale consisting of a set of scaled units.
|
|
8
|
+
*/
|
|
9
|
+
export declare abstract class UnitScale {
|
|
10
|
+
readonly supportedScaledUnits: readonly ScaledUnit[];
|
|
11
|
+
readonly baseScaledUnit: ScaledUnit;
|
|
12
|
+
constructor(supportedScaledUnits: readonly ScaledUnit[]);
|
|
13
|
+
scaleNumber(number: number): ScaledNumber;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unit scale consisting of a set of scaled units.
|
|
3
|
+
*/
|
|
4
|
+
export class UnitScale {
|
|
5
|
+
constructor(supportedScaledUnits) {
|
|
6
|
+
this.supportedScaledUnits = supportedScaledUnits;
|
|
7
|
+
const unitsSorted = supportedScaledUnits.every((curr, i, arr) => i === 0 || arr[i - 1].scaleFactor < curr.scaleFactor);
|
|
8
|
+
if (!unitsSorted) {
|
|
9
|
+
throw new Error('Supported scaled units must have unique and ordered scale factors');
|
|
10
|
+
}
|
|
11
|
+
const baseScaledUnit = supportedScaledUnits.find(x => x.isBase());
|
|
12
|
+
if (!baseScaledUnit) {
|
|
13
|
+
throw new Error('Supported scaled units must include a base scaled unit (scale factor=1)');
|
|
14
|
+
}
|
|
15
|
+
this.supportedScaledUnits = supportedScaledUnits;
|
|
16
|
+
this.baseScaledUnit = baseScaledUnit;
|
|
17
|
+
}
|
|
18
|
+
// Note that for the sake of reducing complexity in the implementation,
|
|
19
|
+
// we do NOT consider the effects of rounding when picking the unit to
|
|
20
|
+
// use for a given value. If formatting results in rounding, a value
|
|
21
|
+
// may be shown with an unexpected unit. Examples:
|
|
22
|
+
// - 999 bytes with two significant digits => "1000 bytes" (instead of "1 kB")
|
|
23
|
+
// - 0.00000000000000001 volts (= 0.01 fV) with one fractional digit => "0 fV" (instead of "0 volts")
|
|
24
|
+
scaleNumber(number) {
|
|
25
|
+
const magnitude = Math.abs(number);
|
|
26
|
+
const onlyBaseScaledUnit = this.supportedScaledUnits.length === 1;
|
|
27
|
+
if (onlyBaseScaledUnit
|
|
28
|
+
|| magnitude === 0
|
|
29
|
+
|| magnitude === Infinity
|
|
30
|
+
|| Number.isNaN(magnitude)) {
|
|
31
|
+
return { scaledValue: number, scaledUnit: this.baseScaledUnit };
|
|
32
|
+
}
|
|
33
|
+
for (let i = this.supportedScaledUnits.length - 1; i >= 0; i -= 1) {
|
|
34
|
+
const scaledUnit = this.supportedScaledUnits[i];
|
|
35
|
+
if (magnitude / scaledUnit.scaleFactor >= 1) {
|
|
36
|
+
return {
|
|
37
|
+
scaledValue: number / scaledUnit.scaleFactor,
|
|
38
|
+
scaledUnit
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
const smallestUnit = this.supportedScaledUnits[0];
|
|
43
|
+
return {
|
|
44
|
+
scaledValue: number / smallestUnit.scaleFactor,
|
|
45
|
+
scaledUnit: smallestUnit
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=unit-scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-scale.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/unit-scale/unit-scale.ts"],"names":[],"mappings":"AAOA;;GAEG;AACH,MAAM,OAAgB,SAAS;IAG3B,YACoB,oBAA2C;QAA3C,yBAAoB,GAApB,oBAAoB,CAAuB;QAE3D,MAAM,WAAW,GAAG,oBAAoB,CAAC,KAAK,CAC1C,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,EAAE,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AW,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW;oBAC5C,UAAU;iBACb,CAAC;aACL;SACJ;QACD,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAE,CAAC;QACnD,OAAO;YACH,WAAW,EAAE,MAAM,GAAG,YAAY,CAAC,WAAW;YAC9C,UAAU,EAAE,YAAY;SAC3B,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const metricPrefixes: readonly [readonly [number, "f"], readonly [number, "p"], readonly [number, "n"], readonly [number, "μ"], readonly [number, "m"], readonly [number, "c"], readonly [number, "d"], readonly [number, ""], readonly [number, "k"], readonly [number, "M"], readonly [number, "G"], readonly [number, "T"], readonly [number, "P"], readonly [number, "E"]];
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const metricPrefixes = [
|
|
2
|
+
[10 ** -15, 'f'],
|
|
3
|
+
[10 ** -12, 'p'],
|
|
4
|
+
[10 ** -9, 'n'],
|
|
5
|
+
[10 ** -6, 'μ'],
|
|
6
|
+
[10 ** -3, 'm'],
|
|
7
|
+
[10 ** -2, 'c'],
|
|
8
|
+
[10 ** -1, 'd'],
|
|
9
|
+
[10 ** 0, ''],
|
|
10
|
+
[10 ** 3, 'k'],
|
|
11
|
+
[10 ** 6, 'M'],
|
|
12
|
+
[10 ** 9, 'G'],
|
|
13
|
+
[10 ** 12, 'T'],
|
|
14
|
+
[10 ** 15, 'P'],
|
|
15
|
+
[10 ** 18, 'E']
|
|
16
|
+
];
|
|
17
|
+
//# sourceMappingURL=metrix-prefixes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metrix-prefixes.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/unit-scale/utilities/metrix-prefixes.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG;IAC1B,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC;IAChB,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC;IAChB,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IACb,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IACd,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IACd,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IACd,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC;IACf,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC;CACT,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ScaledUnit } from '../scaled-unit/scaled-unit';
|
|
2
|
+
import { UnitScale } from './unit-scale';
|
|
3
|
+
import { metricPrefixes } from './utilities/metrix-prefixes';
|
|
4
|
+
import { ManuallyTranslatedScaledUnitFormat, UnitTranslation } from '../scaled-unit-format/manually-translated-scaled-unit-format';
|
|
5
|
+
const unitTranslations = new Map([
|
|
6
|
+
['en', new UnitTranslation('volt', 'volts', 'V')],
|
|
7
|
+
['fr', new UnitTranslation('volt', 'volts', 'V')],
|
|
8
|
+
['de', new UnitTranslation('Volt', 'Volt', 'V')],
|
|
9
|
+
['ja', new UnitTranslation('ボルト', 'ボルト', 'V')],
|
|
10
|
+
['zh', new UnitTranslation('伏特', '伏特', 'V')]
|
|
11
|
+
]);
|
|
12
|
+
/**
|
|
13
|
+
* Voltage unit scale
|
|
14
|
+
*/
|
|
15
|
+
class VoltUnitScale extends UnitScale {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(metricPrefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory({
|
|
18
|
+
unitTranslations,
|
|
19
|
+
scaledPrefixText
|
|
20
|
+
}))));
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export const voltUnitScale = new VoltUnitScale();
|
|
24
|
+
//# sourceMappingURL=volt-unit-scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volt-unit-scale.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/unit-scale/volt-unit-scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACH,kCAAkC,EAElC,eAAe,EAClB,MAAM,8DAA8D,CAAC;AAEtE,MAAM,gBAAgB,GAAqB,IAAI,GAAG,CAAC;IAC/C,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IAC9C,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;CAC/C,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,aAAc,SAAQ,SAAS;IACjC;QACI,KAAK,CACD,cAAc,CAAC,GAAG,CACd,CAAC,CAAC,WAAW,EAAE,gBAAgB,CAAC,EAAE,EAAE,CAAC,IAAI,UAAU,CAC/C,WAAW,EACX,kCAAkC,CAAC,aAAa,CAAC;YAC7C,gBAAgB;YAChB,gBAAgB;SACnB,CAAC,CACL,CACJ,CACJ,CAAC;IACN,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function waitUntilCustomElementsDefinedAsync(elements: Element[]): Promise<void>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export async function waitUntilCustomElementsDefinedAsync(elements) {
|
|
2
|
+
const definedElements = elements.map(async (item) => (item.matches(':not(:defined)')
|
|
3
|
+
? customElements.whenDefined(item.localName)
|
|
4
|
+
: Promise.resolve()));
|
|
5
|
+
await Promise.all(definedElements);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=wait-until-custom-elements-defined-async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wait-until-custom-elements-defined-async.js","sourceRoot":"","sources":["../../../src/utilities/wait-until-custom-elements-defined-async.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,KAAK,UAAU,mCAAmC,CACrD,QAAmB;IAEnB,MAAM,eAAe,GAAG,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAC,IAAI,EAAC,EAAE,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC;QAC9E,CAAC,CAAC,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC;QAC5C,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;IAC1B,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;AACvC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ni/nimble-components",
|
|
3
|
-
"version": "20.
|
|
3
|
+
"version": "20.18.1",
|
|
4
4
|
"description": "Styled web components for the NI Nimble Design System",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "npm run generate-icons && npm run build-components && npm run bundle-components && npm run generate-scss && npm run build-storybook",
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { NumberFormatter } from './number-formatter';
|
|
2
|
-
/**
|
|
3
|
-
* The formatter for a number-text column whose format is configured to be 'decimal'.
|
|
4
|
-
*/
|
|
5
|
-
export declare class DecimalFormatter extends NumberFormatter {
|
|
6
|
-
private readonly formatter;
|
|
7
|
-
private readonly tenPowDecimalDigits;
|
|
8
|
-
constructor(locale: string, minimumFractionDigits: number, maximumFractionDigits: number);
|
|
9
|
-
protected format(number: number): string;
|
|
10
|
-
private willRoundToZero;
|
|
11
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { NumberFormatter } from './number-formatter';
|
|
2
|
-
/**
|
|
3
|
-
* The formatter for a number-text column whose format is configured to be 'decimal'.
|
|
4
|
-
*/
|
|
5
|
-
export class DecimalFormatter extends NumberFormatter {
|
|
6
|
-
constructor(locale, minimumFractionDigits, maximumFractionDigits) {
|
|
7
|
-
super();
|
|
8
|
-
this.formatter = new Intl.NumberFormat(locale, {
|
|
9
|
-
maximumFractionDigits,
|
|
10
|
-
minimumFractionDigits,
|
|
11
|
-
useGrouping: true
|
|
12
|
-
});
|
|
13
|
-
this.tenPowDecimalDigits = 10 ** maximumFractionDigits;
|
|
14
|
-
}
|
|
15
|
-
format(number) {
|
|
16
|
-
// The NumberFormat option of `signDisplay: "negative"` is not supported in all browsers nimble supports.
|
|
17
|
-
// Because that option cannot be used to avoid rendering "-0", coerce the value -0 to 0 prior to formatting.
|
|
18
|
-
const valueToFormat = this.willRoundToZero(number) ? 0 : number;
|
|
19
|
-
return this.formatter.format(valueToFormat);
|
|
20
|
-
}
|
|
21
|
-
willRoundToZero(number) {
|
|
22
|
-
// Multiply the value by 10 raised to decimal-digits so that Math.round can be used to emulate rounding to
|
|
23
|
-
// decimal-digits decimal places. If that rounded value is 0, then the value will be rendered with only 0s.
|
|
24
|
-
return Math.round(number * this.tenPowDecimalDigits) === 0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=decimal-formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decimal-formatter.js","sourceRoot":"","sources":["../../../../../src/table-column/number-text/models/decimal-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IAIjD,YACI,MAAc,EACd,qBAA6B,EAC7B,qBAA6B;QAE7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAC3C,qBAAqB;YACrB,qBAAqB;YACrB,WAAW,EAAE,IAAI;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,mBAAmB,GAAG,EAAE,IAAI,qBAAqB,CAAC;IAC3D,CAAC;IAES,MAAM,CAAC,MAAc;QAC3B,yGAAyG;QACzG,4GAA4G;QAC5G,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAChE,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAChD,CAAC;IAEO,eAAe,CAAC,MAAc;QAClC,0GAA0G;QAC1G,2GAA2G;QAC3G,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC;IAC/D,CAAC;CACJ"}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { NumberFormatter } from './number-formatter';
|
|
2
|
-
/**
|
|
3
|
-
* The formatter for a number-text column whose format is configured to be 'default'.
|
|
4
|
-
*/
|
|
5
|
-
export declare class DefaultFormatter extends NumberFormatter {
|
|
6
|
-
private static readonly maximumDigits;
|
|
7
|
-
private static readonly exponentialLowerBound;
|
|
8
|
-
private static readonly exponentialUpperBound;
|
|
9
|
-
private readonly defaultFormatter;
|
|
10
|
-
private readonly leadingZeroFormatter;
|
|
11
|
-
private readonly exponentialFormatter;
|
|
12
|
-
constructor(locale: string);
|
|
13
|
-
protected format(number: number): string;
|
|
14
|
-
private getFormatterForNumber;
|
|
15
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { NumberFormatter } from './number-formatter';
|
|
2
|
-
/**
|
|
3
|
-
* The formatter for a number-text column whose format is configured to be 'default'.
|
|
4
|
-
*/
|
|
5
|
-
export class DefaultFormatter extends NumberFormatter {
|
|
6
|
-
constructor(locale) {
|
|
7
|
-
super();
|
|
8
|
-
this.defaultFormatter = new Intl.NumberFormat(locale, {
|
|
9
|
-
maximumSignificantDigits: DefaultFormatter.maximumDigits,
|
|
10
|
-
useGrouping: true
|
|
11
|
-
});
|
|
12
|
-
this.leadingZeroFormatter = new Intl.NumberFormat(locale, {
|
|
13
|
-
maximumFractionDigits: DefaultFormatter.maximumDigits - 1,
|
|
14
|
-
useGrouping: true
|
|
15
|
-
});
|
|
16
|
-
this.exponentialFormatter = new Intl.NumberFormat(locale, {
|
|
17
|
-
maximumSignificantDigits: DefaultFormatter.maximumDigits,
|
|
18
|
-
notation: 'scientific'
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
format(number) {
|
|
22
|
-
// The NumberFormat option of `signDisplay: "negative"` is not supported in all browsers nimble supports.
|
|
23
|
-
// Because that option cannot be used to avoid rendering "-0", coerce the value -0 to 0 prior to formatting.
|
|
24
|
-
const valueToFormat = number === 0 ? 0 : number;
|
|
25
|
-
const formatter = this.getFormatterForNumber(valueToFormat);
|
|
26
|
-
return formatter.format(valueToFormat);
|
|
27
|
-
}
|
|
28
|
-
getFormatterForNumber(number) {
|
|
29
|
-
if (number === 0) {
|
|
30
|
-
return this.defaultFormatter;
|
|
31
|
-
}
|
|
32
|
-
const absoluteValue = Math.abs(number);
|
|
33
|
-
if (absoluteValue >= DefaultFormatter.exponentialUpperBound
|
|
34
|
-
|| absoluteValue < DefaultFormatter.exponentialLowerBound) {
|
|
35
|
-
return this.exponentialFormatter;
|
|
36
|
-
}
|
|
37
|
-
// Ideally, we could set 'roundingPriority: "lessPrecision"' with a formatter that has both 'maximumSignificantDigits' and
|
|
38
|
-
// 'maximumFractionDigits' configured instead of having two different formatters that we conditionally choose between. However,
|
|
39
|
-
// 'roundingPrioirty' is not supported yet in all browsers nimble supports.
|
|
40
|
-
if (absoluteValue < 1) {
|
|
41
|
-
return this.leadingZeroFormatter;
|
|
42
|
-
}
|
|
43
|
-
return this.defaultFormatter;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
// The maximum number of digits that should be rendered for any given value.
|
|
47
|
-
DefaultFormatter.maximumDigits = 6;
|
|
48
|
-
// Use exponential notation for numbers that will be rendered with 3 leading 0s or more.
|
|
49
|
-
// Because a maximum of 6 digits are rendered, showing more than 3 leading 0s is not ideal
|
|
50
|
-
// because then at least half of the displayed digits will be leading 0s.
|
|
51
|
-
DefaultFormatter.exponentialLowerBound = 0.000995;
|
|
52
|
-
// Use exponential formatting for numbers whose magnitude cannot otherwise be displayed
|
|
53
|
-
// with 6 digits or less.
|
|
54
|
-
DefaultFormatter.exponentialUpperBound = 999999.5;
|
|
55
|
-
//# sourceMappingURL=default-formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"default-formatter.js","sourceRoot":"","sources":["../../../../../src/table-column/number-text/models/default-formatter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,eAAe;IAyBjD,YAAmB,MAAc;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,gBA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IACjC,CAAC;;AAnED,4EAA4E;AACpD,8BAAa,GAAG,CAAC,CAAC;AAE1C,wFAAwF;AACxF,0FAA0F;AAC1F,yEAAyE;AACjD,sCAAqB,GAAG,QAAQ,CAAC;AAEzD,uFAAuF;AACvF,yBAAyB;AACD,sCAAqB,GAAG,QAAQ,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base class for number formatters used by the number-text column.
|
|
3
|
-
*/
|
|
4
|
-
export declare abstract class NumberFormatter {
|
|
5
|
-
/**
|
|
6
|
-
* Tries to format the passed value using the `format()` function implemented by a concrete implementation of the class.
|
|
7
|
-
* Returns an empty string if the value is not a number or if `format()` throws an error.
|
|
8
|
-
*/
|
|
9
|
-
formatValue(value: number | undefined | null): string;
|
|
10
|
-
protected abstract format(number: number): string;
|
|
11
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The base class for number formatters used by the number-text column.
|
|
3
|
-
*/
|
|
4
|
-
export class NumberFormatter {
|
|
5
|
-
/**
|
|
6
|
-
* Tries to format the passed value using the `format()` function implemented by a concrete implementation of the class.
|
|
7
|
-
* Returns an empty string if the value is not a number or if `format()` throws an error.
|
|
8
|
-
*/
|
|
9
|
-
formatValue(value) {
|
|
10
|
-
if (typeof value !== 'number') {
|
|
11
|
-
return '';
|
|
12
|
-
}
|
|
13
|
-
try {
|
|
14
|
-
return this.format(value);
|
|
15
|
-
}
|
|
16
|
-
catch {
|
|
17
|
-
return '';
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=number-formatter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"number-formatter.js","sourceRoot":"","sources":["../../../../../src/table-column/number-text/models/number-formatter.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAgB,eAAe;IACjC;;;OAGG;IACI,WAAW,CAAC,KAAgC;QAC/C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC3B,OAAO,EAAE,CAAC;SACb;QAED,IAAI;YACA,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;SAC7B;QAAC,MAAM;YACJ,OAAO,EAAE,CAAC;SACb;IACL,CAAC;CAGJ"}
|