@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
|
@@ -0,0 +1,17 @@
|
|
|
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 class UnitPrefix {
|
|
6
|
+
constructor(scaleFactor, text) {
|
|
7
|
+
this.scaleFactor = scaleFactor;
|
|
8
|
+
this.text = text;
|
|
9
|
+
if (scaleFactor === 1 && text !== '') {
|
|
10
|
+
throw new Error('Base scale factor of 1 has unused text and should be empty string');
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
isBase() {
|
|
14
|
+
return this.scaleFactor === 1;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=unit-prefix.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-prefix.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,UAAU;IACnB,YACoB,WAAmB,EACnB,IAAY;QADZ,gBAAW,GAAX,WAAW,CAAQ;QACnB,SAAI,GAAJ,IAAI,CAAQ;QAE5B,IAAI,WAAW,KAAK,CAAC,IAAI,IAAI,KAAK,EAAE,EAAE;YAClC,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAC;SACL;IACL,CAAC;IAEM,MAAM;QACT,OAAO,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC;IAClC,CAAC;CACJ"}
|
package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { UnitPrefix } from './unit-prefix';
|
|
2
|
+
/**
|
|
3
|
+
* The metric unit prefixes for at least English, French, German, Japanese, and Chinese.
|
|
4
|
+
*/
|
|
5
|
+
export declare const unitPrefixesMetric: readonly [UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix, UnitPrefix];
|
package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { UnitPrefix } from './unit-prefix';
|
|
2
|
+
/**
|
|
3
|
+
* The metric unit prefixes for at least English, French, German, Japanese, and Chinese.
|
|
4
|
+
*/
|
|
5
|
+
export const unitPrefixesMetric = [
|
|
6
|
+
new UnitPrefix(10 ** -15, 'f'),
|
|
7
|
+
new UnitPrefix(10 ** -12, 'p'),
|
|
8
|
+
new UnitPrefix(10 ** -9, 'n'),
|
|
9
|
+
new UnitPrefix(10 ** -6, 'μ'),
|
|
10
|
+
new UnitPrefix(10 ** -3, 'm'),
|
|
11
|
+
new UnitPrefix(10 ** -2, 'c'),
|
|
12
|
+
new UnitPrefix(10 ** -1, 'd'),
|
|
13
|
+
new UnitPrefix(10 ** 0, ''),
|
|
14
|
+
new UnitPrefix(10 ** 3, 'k'),
|
|
15
|
+
new UnitPrefix(10 ** 6, 'M'),
|
|
16
|
+
new UnitPrefix(10 ** 9, 'G'),
|
|
17
|
+
new UnitPrefix(10 ** 12, 'T'),
|
|
18
|
+
new UnitPrefix(10 ** 15, 'P'),
|
|
19
|
+
new UnitPrefix(10 ** 18, 'E')
|
|
20
|
+
];
|
|
21
|
+
//# sourceMappingURL=unit-prefixes-metric.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-prefixes-metric.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAC9B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC;IAC9B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC;IAC9B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC;IAC3B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAC5B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAC5B,IAAI,UAAU,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC;IAC5B,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC;IAC7B,IAAI,UAAU,CAAC,EAAE,IAAI,EAAE,EAAE,GAAG,CAAC;CACvB,CAAC"}
|
package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Representations of a base unit in a particular language
|
|
3
|
+
*/
|
|
4
|
+
export class UnitTranslation {
|
|
5
|
+
constructor(singular, plural, symbol) {
|
|
6
|
+
this.singular = singular;
|
|
7
|
+
this.plural = plural;
|
|
8
|
+
this.symbol = symbol;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=unit-translation.js.map
|
package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unit-translation.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,OAAO,eAAe;IACxB,YACoB,QAAgB,EAChB,MAAc,EACd,MAAc;QAFd,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAQ;IAC/B,CAAC;CACP"}
|
package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManuallyTranslatedUnitScale } from './base/manually-translated-unit-scale';
|
|
2
|
+
/**
|
|
3
|
+
* Byte units (1024-based)
|
|
4
|
+
*/
|
|
5
|
+
declare class Byte1024UnitScale extends ManuallyTranslatedUnitScale {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare const byte1024UnitScale: Byte1024UnitScale;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ManuallyTranslatedUnitScale } from './base/manually-translated-unit-scale';
|
|
2
|
+
import { UnitPrefix } from './base/unit-prefix';
|
|
3
|
+
import { UnitTranslation } from './base/unit-translation';
|
|
4
|
+
/**
|
|
5
|
+
* Byte units (1024-based)
|
|
6
|
+
*/
|
|
7
|
+
class Byte1024UnitScale extends ManuallyTranslatedUnitScale {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(new Map([
|
|
10
|
+
['en', new UnitTranslation('byte', 'bytes', 'B')],
|
|
11
|
+
['fr', new UnitTranslation('octet', 'octets', 'o')],
|
|
12
|
+
['de', new UnitTranslation('Byte', 'Byte', 'B')],
|
|
13
|
+
['ja', new UnitTranslation('バイト', 'バイト', 'B')],
|
|
14
|
+
['zh', new UnitTranslation('字节', '字节', 'B')]
|
|
15
|
+
]), [
|
|
16
|
+
new UnitPrefix(1024 ** 0, ''),
|
|
17
|
+
new UnitPrefix(1024 ** 1, 'Ki'),
|
|
18
|
+
new UnitPrefix(1024 ** 2, 'Mi'),
|
|
19
|
+
new UnitPrefix(1024 ** 3, 'Gi'),
|
|
20
|
+
new UnitPrefix(1024 ** 4, 'Ti'),
|
|
21
|
+
new UnitPrefix(1024 ** 5, 'Pi')
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export const byte1024UnitScale = new Byte1024UnitScale();
|
|
26
|
+
//# sourceMappingURL=byte-1024-unit-scale.js.map
|
package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byte-1024-unit-scale.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,MAAM,iBAAkB,SAAQ,2BAA2B;IACvD;QACI,KAAK,CACD,IAAI,GAAG,CAAC;YACJ,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,OAAO,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;YACnD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAChD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9C,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SAC/C,CAAC,EACF;YACI,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YAC7B,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC;YAC/B,IAAI,UAAU,CAAC,IAAI,IAAI,CAAC,EAAE,IAAI,CAAC;SAClC,CACJ,CAAC;IACN,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ManuallyTranslatedUnitScale } from './base/manually-translated-unit-scale';
|
|
2
|
+
/**
|
|
3
|
+
* Voltage unit scale
|
|
4
|
+
*/
|
|
5
|
+
declare class VoltUnitScale extends ManuallyTranslatedUnitScale {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare const voltUnitScale: VoltUnitScale;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ManuallyTranslatedUnitScale } from './base/manually-translated-unit-scale';
|
|
2
|
+
import { unitPrefixesMetric } from './base/unit-prefixes-metric';
|
|
3
|
+
import { UnitTranslation } from './base/unit-translation';
|
|
4
|
+
/**
|
|
5
|
+
* Voltage unit scale
|
|
6
|
+
*/
|
|
7
|
+
class VoltUnitScale extends ManuallyTranslatedUnitScale {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(new Map([
|
|
10
|
+
['en', new UnitTranslation('volt', 'volts', 'V')],
|
|
11
|
+
['fr', new UnitTranslation('volt', 'volts', 'V')],
|
|
12
|
+
['de', new UnitTranslation('Volt', 'Volt', 'V')],
|
|
13
|
+
['ja', new UnitTranslation('ボルト', 'ボルト', 'V')],
|
|
14
|
+
['zh', new UnitTranslation('伏特', '伏特', 'V')]
|
|
15
|
+
]), unitPrefixesMetric);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export const voltUnitScale = new VoltUnitScale();
|
|
19
|
+
//# sourceMappingURL=volt-unit-scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volt-unit-scale.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,uCAAuC,CAAC;AACpF,OAAO,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AACjE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;GAEG;AACH,MAAM,aAAc,SAAQ,2BAA2B;IACnD;QACI,KAAK,CACD,IAAI,GAAG,CAAC;YACJ,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;YACjD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;YAChD,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9C,CAAC,IAAI,EAAE,IAAI,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;SAC/C,CAAC,EACF,kBAAkB,CACrB,CAAC;IACN,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScaledUnitFormatFactoryOptions } from './scaled-unit';
|
|
2
|
+
import { ScaledUnitFormat } from './scaled-unit-format';
|
|
3
|
+
/**
|
|
4
|
+
* A formatter for units that can be formatted/translated by Intl.NumberFormat
|
|
5
|
+
*/
|
|
6
|
+
export declare class IntlNumberFormatScaledUnitFormat extends ScaledUnitFormat {
|
|
7
|
+
private readonly formatter;
|
|
8
|
+
protected constructor(scaledUnitFormatFactoryOptions: ScaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions?: Intl.NumberFormatOptions);
|
|
9
|
+
static createFactory(unitSpecificIntlNumberFormatOptions?: Intl.NumberFormatOptions): (scaledUnitFormatFactoryOptions: ScaledUnitFormatFactoryOptions) => IntlNumberFormatScaledUnitFormat;
|
|
10
|
+
format(value: number): string;
|
|
11
|
+
}
|
package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ScaledUnitFormat } from './scaled-unit-format';
|
|
2
|
+
/**
|
|
3
|
+
* A formatter for units that can be formatted/translated by Intl.NumberFormat
|
|
4
|
+
*/
|
|
5
|
+
export class IntlNumberFormatScaledUnitFormat extends ScaledUnitFormat {
|
|
6
|
+
constructor(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions = {}) {
|
|
7
|
+
super(scaledUnitFormatFactoryOptions);
|
|
8
|
+
this.formatter = new Intl.NumberFormat(this.locale, {
|
|
9
|
+
...unitSpecificIntlNumberFormatOptions,
|
|
10
|
+
// Application configured options override unit specific options
|
|
11
|
+
...this.intlNumberFormatOptions
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
static createFactory(unitSpecificIntlNumberFormatOptions = {}) {
|
|
15
|
+
return (scaledUnitFormatFactoryOptions) => new IntlNumberFormatScaledUnitFormat(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions);
|
|
16
|
+
}
|
|
17
|
+
format(value) {
|
|
18
|
+
return this.formatter.format(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=intl-number-format-scaled-unit-format.js.map
|
package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intl-number-format-scaled-unit-format.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAExD;;GAEG;AACH,MAAM,OAAO,gCAAiC,SAAQ,gBAAgB;IAGlE,YACI,8BAA8D,EAC9D,sCAAgE,EAAE;QAElE,KAAK,CAAC,8BAA8B,CAAC,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,EAAE;YAChD,GAAG,mCAAmC;YACtC,gEAAgE;YAChE,GAAG,IAAI,CAAC,uBAAuB;SAClC,CAAC,CAAC;IACP,CAAC;IAEM,MAAM,CAAC,aAAa,CACvB,sCAAgE,EAAE;QAElE,OAAO,CACH,8BAA8D,EAC9B,EAAE,CAAC,IAAI,gCAAgC,CACvE,8BAA8B,EAC9B,mCAAmC,CACtC,CAAC;IACN,CAAC;IAEM,MAAM,CAAC,KAAa;QACvB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ScaledUnitFormatFactoryOptions } from './scaled-unit';
|
|
2
|
+
/**
|
|
3
|
+
* A class that knows how to format a numeric value as a string that includes units.
|
|
4
|
+
*/
|
|
5
|
+
export declare abstract class ScaledUnitFormat {
|
|
6
|
+
protected readonly locale: string;
|
|
7
|
+
protected readonly intlNumberFormatOptions?: Intl.NumberFormatOptions;
|
|
8
|
+
protected constructor(scaledUnitFormatFactoryOptions: ScaledUnitFormatFactoryOptions);
|
|
9
|
+
abstract format(value: number): string;
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A class that knows how to format a numeric value as a string that includes units.
|
|
3
|
+
*/
|
|
4
|
+
export class ScaledUnitFormat {
|
|
5
|
+
constructor(scaledUnitFormatFactoryOptions) {
|
|
6
|
+
this.locale = scaledUnitFormatFactoryOptions.locale;
|
|
7
|
+
this.intlNumberFormatOptions = scaledUnitFormatFactoryOptions.intlNumberFormatOptions;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=scaled-unit-format.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaled-unit-format.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/unit-scale/base/scaled-unit-format.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAgB,gBAAgB;IAIlC,YACI,8BAA8D;QAE9D,IAAI,CAAC,MAAM,GAAG,8BAA8B,CAAC,MAAM,CAAC;QACpD,IAAI,CAAC,uBAAuB,GAAG,8BAA8B,CAAC,uBAAuB,CAAC;IAC1F,CAAC;CAGJ"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ScaledUnitFormat } from './scaled-unit-format';
|
|
2
|
+
export interface ScaledUnitFormatFactoryOptions {
|
|
3
|
+
readonly locale: string;
|
|
4
|
+
readonly intlNumberFormatOptions?: Intl.NumberFormatOptions;
|
|
5
|
+
}
|
|
6
|
+
declare type ScaledUnitFormatFactory = (scaledUnitFormatFactoryOptions: ScaledUnitFormatFactoryOptions) => ScaledUnitFormat;
|
|
7
|
+
/**
|
|
8
|
+
* A unit that represents a scaled version of a base unit.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ScaledUnit {
|
|
11
|
+
readonly scaleFactor: number;
|
|
12
|
+
readonly scaledUnitFormatFactory: ScaledUnitFormatFactory;
|
|
13
|
+
constructor(scaleFactor: number, scaledUnitFormatFactory: ScaledUnitFormatFactory);
|
|
14
|
+
isBase(): boolean;
|
|
15
|
+
}
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A unit that represents a scaled version of a base unit.
|
|
3
|
+
*/
|
|
4
|
+
export class ScaledUnit {
|
|
5
|
+
constructor(scaleFactor, scaledUnitFormatFactory) {
|
|
6
|
+
this.scaleFactor = scaleFactor;
|
|
7
|
+
this.scaledUnitFormatFactory = scaledUnitFormatFactory;
|
|
8
|
+
}
|
|
9
|
+
isBase() {
|
|
10
|
+
return this.scaleFactor === 1;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=scaled-unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scaled-unit.js","sourceRoot":"","sources":["../../../../../../src/utilities/unit-format/unit-scale/base/scaled-unit.ts"],"names":[],"mappings":"AAWA;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB,YACoB,WAAmB,EACnB,uBAAgD;QADhD,gBAAW,GAAX,WAAW,CAAQ;QACnB,4BAAuB,GAAvB,uBAAuB,CAAyB;IACjE,CAAC;IAEG,MAAM;QACT,OAAO,IAAI,CAAC,WAAW,KAAK,CAAC,CAAC;IAClC,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ScaledUnit } from './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/base/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,CAAC,CAAC,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,CAAE,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAC1E,CAAC;QACF,IAAI,CAAC,WAAW,EAAE;YACd,MAAM,IAAI,KAAK,CACX,mEAAmE,CACtE,CAAC;SACL;QACD,MAAM,cAAc,GAAG,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;QAClE,IAAI,CAAC,cAAc,EAAE;YACjB,MAAM,IAAI,KAAK,CACX,yEAAyE,CAC5E,CAAC;SACL;QACD,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACzC,CAAC;IAED,uEAAuE;IACvE,sEAAsE;IACtE,oEAAoE;IACpE,kDAAkD;IAClD,8EAA8E;IAC9E,qGAAqG;IAC9F,WAAW,CAAC,MAAc;QAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnC,MAAM,kBAAkB,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,KAAK,CAAC,CAAC;QAClE,IACI,kBAAkB;eACf,SAAS,KAAK,CAAC;eACf,SAAS,KAAK,QAAQ;eACtB,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAC5B;YACE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,CAAC,cAAc,EAAE,CAAC;SACnE;QACD,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE;YAC/D,MAAM,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAE,CAAC;YACjD,IAAI,SAAS,GAAG,UAAU,CAAC,WAAW,IAAI,CAAC,EAAE;gBACzC,OAAO;oBACH,WAAW,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,44 @@
|
|
|
1
|
+
import { IntlNumberFormatScaledUnitFormat } from './base/intl-number-format-scaled-unit-format';
|
|
2
|
+
import { ScaledUnit } from './base/scaled-unit';
|
|
3
|
+
import { UnitScale } from './base/unit-scale';
|
|
4
|
+
/**
|
|
5
|
+
* Byte units (1000-based)
|
|
6
|
+
*/
|
|
7
|
+
class ByteUnitScale extends UnitScale {
|
|
8
|
+
constructor() {
|
|
9
|
+
super([
|
|
10
|
+
new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
11
|
+
style: 'unit',
|
|
12
|
+
unit: 'byte',
|
|
13
|
+
unitDisplay: 'long'
|
|
14
|
+
})),
|
|
15
|
+
new ScaledUnit(10 ** 3, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
16
|
+
style: 'unit',
|
|
17
|
+
unit: 'kilobyte',
|
|
18
|
+
unitDisplay: 'short'
|
|
19
|
+
})),
|
|
20
|
+
new ScaledUnit(10 ** 6, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
21
|
+
style: 'unit',
|
|
22
|
+
unit: 'megabyte',
|
|
23
|
+
unitDisplay: 'short'
|
|
24
|
+
})),
|
|
25
|
+
new ScaledUnit(10 ** 9, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
26
|
+
style: 'unit',
|
|
27
|
+
unit: 'gigabyte',
|
|
28
|
+
unitDisplay: 'short'
|
|
29
|
+
})),
|
|
30
|
+
new ScaledUnit(10 ** 12, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
31
|
+
style: 'unit',
|
|
32
|
+
unit: 'terabyte',
|
|
33
|
+
unitDisplay: 'short'
|
|
34
|
+
})),
|
|
35
|
+
new ScaledUnit(10 ** 15, IntlNumberFormatScaledUnitFormat.createFactory({
|
|
36
|
+
style: 'unit',
|
|
37
|
+
unit: 'petabyte',
|
|
38
|
+
unitDisplay: 'short'
|
|
39
|
+
}))
|
|
40
|
+
]);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export const byteUnitScale = new ByteUnitScale();
|
|
44
|
+
//# sourceMappingURL=byte-unit-scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"byte-unit-scale.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/unit-scale/byte-unit-scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C;;GAEG;AACH,MAAM,aAAc,SAAQ,SAAS;IACjC;QACI,KAAK,CAAC;YACF,IAAI,UAAU,CACV,EAAE,IAAI,CAAC,EACP,gCAAgC,CAAC,aAAa,CAAC;gBAC3C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,MAAM;gBACZ,WAAW,EAAE,MAAM;aACtB,CAAC,CACL;YACD,IAAI,UAAU,CACV,EAAE,IAAI,CAAC,EACP,gCAAgC,CAAC,aAAa,CAAC;gBAC3C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,OAAO;aACvB,CAAC,CACL;YACD,IAAI,UAAU,CACV,EAAE,IAAI,CAAC,EACP,gCAAgC,CAAC,aAAa,CAAC;gBAC3C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,OAAO;aACvB,CAAC,CACL;YACD,IAAI,UAAU,CACV,EAAE,IAAI,CAAC,EACP,gCAAgC,CAAC,aAAa,CAAC;gBAC3C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,OAAO;aACvB,CAAC,CACL;YACD,IAAI,UAAU,CACV,EAAE,IAAI,EAAE,EACR,gCAAgC,CAAC,aAAa,CAAC;gBAC3C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,OAAO;aACvB,CAAC,CACL;YACD,IAAI,UAAU,CACV,EAAE,IAAI,EAAE,EACR,gCAAgC,CAAC,aAAa,CAAC;gBAC3C,KAAK,EAAE,MAAM;gBACb,IAAI,EAAE,UAAU;gBAChB,WAAW,EAAE,OAAO;aACvB,CAAC,CACL;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UnitScale } from './base/unit-scale';
|
|
2
|
+
/**
|
|
3
|
+
* Unit scale that is used to passthrough a number without applying scaling or units
|
|
4
|
+
*/
|
|
5
|
+
declare class PassthroughUnitScale extends UnitScale {
|
|
6
|
+
constructor();
|
|
7
|
+
}
|
|
8
|
+
export declare const passthroughUnitScale: PassthroughUnitScale;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IntlNumberFormatScaledUnitFormat } from './base/intl-number-format-scaled-unit-format';
|
|
2
|
+
import { ScaledUnit } from './base/scaled-unit';
|
|
3
|
+
import { UnitScale } from './base/unit-scale';
|
|
4
|
+
/**
|
|
5
|
+
* Unit scale that is used to passthrough a number without applying scaling or units
|
|
6
|
+
*/
|
|
7
|
+
class PassthroughUnitScale extends UnitScale {
|
|
8
|
+
constructor() {
|
|
9
|
+
super([
|
|
10
|
+
new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory())
|
|
11
|
+
]);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export const passthroughUnitScale = new PassthroughUnitScale();
|
|
15
|
+
//# sourceMappingURL=passthrough-unit-scale.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passthrough-unit-scale.js","sourceRoot":"","sources":["../../../../../src/utilities/unit-format/unit-scale/passthrough-unit-scale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE9C;;GAEG;AACH,MAAM,oBAAqB,SAAQ,SAAS;IACxC;QACI,KAAK,CAAC;YACF,IAAI,UAAU,CACV,EAAE,IAAI,CAAC,EACP,gCAAgC,CAAC,aAAa,EAAE,CACnD;SACJ,CAAC,CAAC;IACP,CAAC;CACJ;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,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.0",
|
|
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",
|
|
@@ -138,7 +138,7 @@
|
|
|
138
138
|
"karma-spec-reporter": "^0.0.36",
|
|
139
139
|
"karma-webkit-launcher": "^2.1.0",
|
|
140
140
|
"karma-webpack": "^5.0.0",
|
|
141
|
-
"playwright": "
|
|
141
|
+
"playwright": "1.40.0",
|
|
142
142
|
"prettier": "^2.8.8",
|
|
143
143
|
"prettier-eslint": "^15.0.1",
|
|
144
144
|
"prettier-eslint-cli": "^7.1.0",
|
|
@@ -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,gBAAgB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YAClD,wBAAwB,EAAE,gBAAgB,CAAC,aAAa;YACxD,WAAW,EAAE,IAAI;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,oBAAoB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACtD,qBAAqB,EAAE,gBAAgB,CAAC,aAAa,GAAG,CAAC;YACzD,WAAW,EAAE,IAAI;SACpB,CAAC,CAAC;QACH,IAAI,CAAC,oBAAoB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE;YACtD,wBAAwB,EAAE,gBAAgB,CAAC,aAAa;YACxD,QAAQ,EAAE,YAAY;SACzB,CAAC,CAAC;IACP,CAAC;IAES,MAAM,CAAC,MAAc;QAC3B,yGAAyG;QACzG,4GAA4G;QAC5G,MAAM,aAAa,GAAG,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAChD,MAAM,SAAS,GAAG,IAAI,CAAC,qBAAqB,CAAC,aAAa,CAAC,CAAC;QAC5D,OAAO,SAAS,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;IAC3C,CAAC;IAEO,qBAAqB,CAAC,MAAc;QACxC,IAAI,MAAM,KAAK,CAAC,EAAE;YACd,OAAO,IAAI,CAAC,gBAAgB,CAAC;SAChC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACvC,IACI,aAAa,IAAI,gBAAgB,CAAC,qBAAqB;eACpD,aAAa,GAAG,gBAAgB,CAAC,qBAAqB,EAC3D;YACE,OAAO,IAAI,CAAC,oBAAoB,CAAC;SACpC;QACD,0HAA0H;QAC1H,+HAA+H;QAC/H,2EAA2E;QAC3E,IAAI,aAAa,GAAG,CAAC,EAAE;YACnB,OAAO,IAAI,CAAC,oBAAoB,CAAC;SACpC;QACD,OAAO,IAAI,CAAC,gBAAgB,CAAC;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
|