@ni/nimble-components 21.6.7 → 21.7.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.
Files changed (36) hide show
  1. package/dist/all-components-bundle.js +124 -65
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +2793 -2792
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/dialog/index.d.ts +1 -10
  6. package/dist/esm/dialog/index.js.map +1 -1
  7. package/dist/esm/drawer/index.d.ts +1 -2
  8. package/dist/esm/drawer/index.js.map +1 -1
  9. package/dist/esm/icons/all-icons.d.ts +6 -0
  10. package/dist/esm/icons/all-icons.js +6 -0
  11. package/dist/esm/icons/all-icons.js.map +1 -1
  12. package/dist/esm/icons/eye-dash.d.ts +13 -0
  13. package/dist/esm/icons/eye-dash.js +15 -0
  14. package/dist/esm/icons/eye-dash.js.map +1 -0
  15. package/dist/esm/icons/horizontal-triangle-outline.d.ts +13 -0
  16. package/dist/esm/icons/horizontal-triangle-outline.js +15 -0
  17. package/dist/esm/icons/horizontal-triangle-outline.js.map +1 -0
  18. package/dist/esm/icons/inward-squares-three.d.ts +13 -0
  19. package/dist/esm/icons/inward-squares-three.js +15 -0
  20. package/dist/esm/icons/inward-squares-three.js.map +1 -0
  21. package/dist/esm/icons/outward-squares-three.d.ts +13 -0
  22. package/dist/esm/icons/outward-squares-three.js +15 -0
  23. package/dist/esm/icons/outward-squares-three.js.map +1 -0
  24. package/dist/esm/icons/square-x.d.ts +13 -0
  25. package/dist/esm/icons/square-x.js +15 -0
  26. package/dist/esm/icons/square-x.js.map +1 -0
  27. package/dist/esm/icons/three-circles-ascending-container.d.ts +13 -0
  28. package/dist/esm/icons/three-circles-ascending-container.js +15 -0
  29. package/dist/esm/icons/three-circles-ascending-container.js.map +1 -0
  30. package/dist/esm/utilities/unit-format/decimal-unit-format.d.ts +0 -2
  31. package/dist/esm/utilities/unit-format/decimal-unit-format.js +6 -11
  32. package/dist/esm/utilities/unit-format/decimal-unit-format.js.map +1 -1
  33. package/dist/esm/utilities/unit-format/default-unit-format.d.ts +0 -3
  34. package/dist/esm/utilities/unit-format/default-unit-format.js +20 -52
  35. package/dist/esm/utilities/unit-format/default-unit-format.js.map +1 -1
  36. package/package.json +2 -2
@@ -13,13 +13,10 @@ export declare class DefaultUnitFormat extends UnitFormat {
13
13
  private readonly unitScale;
14
14
  private readonly defaultIntlNumberFormatOptions;
15
15
  private readonly defaultScaledUnitFormatters;
16
- private readonly leadingZeroIntlNumberFormatOptions;
17
- private readonly leadingZeroScaledUnitFormatters;
18
16
  private readonly exponentialIntlNumberFormatOptions;
19
17
  private readonly exponentialScaledUnitFormatter;
20
18
  constructor(locale: string, { unitScale }?: DefaultUnitFormatOptions);
21
19
  resolvedOptions(): ResolvedDefaultUnitFormatOptions;
22
20
  protected tryFormat(number: number): string;
23
- private resolveNumberStyle;
24
21
  }
25
22
  export {};
@@ -1,5 +1,9 @@
1
1
  import { UnitFormat } from './unit-format';
2
2
  import { passthroughUnitScale } from './unit-scale/passthrough-unit-scale';
3
+ // Workaround to avoid ts errors about signDisplay not accepting the value 'negative'.
4
+ // It has been supported by browsers since 8/23, but TypeScript still hasn't
5
+ // added it to the type definitions. See https://github.com/microsoft/TypeScript/issues/56269
6
+ const signDisplay = 'negative';
3
7
  /**
4
8
  * Format for numbers with units to show in a tabular form.
5
9
  * Large and tiny numbers are shown exponentially and the rest as decimal.
@@ -9,35 +13,26 @@ export class DefaultUnitFormat extends UnitFormat {
9
13
  unitScale: passthroughUnitScale
10
14
  }) {
11
15
  super();
12
- // Format options to use by default. It renders the number with a maximum of 6 signficant digits.
16
+ // Format options to use by default. It renders the number with a maximum of 6 signficant digits (including zero before decimal point).
13
17
  this.defaultIntlNumberFormatOptions = {
14
18
  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
19
  maximumFractionDigits: DefaultUnitFormat.maximumDigits - 1,
23
- useGrouping: true
20
+ roundingPriority: 'lessPrecision',
21
+ signDisplay
24
22
  };
25
- this.leadingZeroScaledUnitFormatters = new Map();
23
+ this.defaultScaledUnitFormatters = new Map();
26
24
  // Format options for numbers that should be displayed in exponential notation. This should be used
27
25
  // for numbers with magintudes over 'exponentialUpperBound' or under 'exponentialLowerBound'.
28
26
  this.exponentialIntlNumberFormatOptions = {
29
27
  maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
30
- notation: 'scientific'
28
+ notation: 'scientific',
29
+ signDisplay
31
30
  };
32
31
  for (const unit of unitScale.supportedScaledUnits) {
33
32
  this.defaultScaledUnitFormatters.set(unit.scaleFactor, unit.scaledUnitFormatFactory({
34
33
  locale,
35
34
  intlNumberFormatOptions: this.defaultIntlNumberFormatOptions
36
35
  }));
37
- this.leadingZeroScaledUnitFormatters.set(unit.scaleFactor, unit.scaledUnitFormatFactory({
38
- locale,
39
- intlNumberFormatOptions: this.leadingZeroIntlNumberFormatOptions
40
- }));
41
36
  }
42
37
  this.exponentialScaledUnitFormatter = unitScale.baseScaledUnit.scaledUnitFormatFactory({
43
38
  locale,
@@ -51,43 +46,16 @@ export class DefaultUnitFormat extends UnitFormat {
51
46
  };
52
47
  }
53
48
  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';
49
+ const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(number);
50
+ const absoluteValue = Math.abs(scaledValue);
51
+ const useExponential = absoluteValue !== 0
52
+ && (absoluteValue >= DefaultUnitFormat.exponentialUpperBound
53
+ || absoluteValue < DefaultUnitFormat.exponentialLowerBound);
54
+ return useExponential
55
+ ? this.exponentialScaledUnitFormatter.format(number)
56
+ : this.defaultScaledUnitFormatters
57
+ .get(scaledUnit.scaleFactor)
58
+ .format(scaledValue);
91
59
  }
92
60
  }
93
61
  // The maximum number of digits that should be rendered for any given value.
@@ -1 +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,eAAe,CAAC;AAG9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAS3E;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAgD7C,YACI,MAAc,EACd,EAAE,SAAS,GAAG,oBAAoB,KA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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","sourcesContent":["import { UnitFormat, UnitFormatOptions } from './unit-format';\nimport type { ScaledUnitFormat } from './scaled-unit-format/scaled-unit-format';\nimport type { UnitScale } from './unit-scale/unit-scale';\nimport { passthroughUnitScale } from './unit-scale/passthrough-unit-scale';\n\ntype NumberStyle = 'default' | 'leadingZero' | 'exponential';\n\n// Allow consistent pattern for defining Options and ResolvedOptions\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface DefaultUnitFormatOptions extends UnitFormatOptions {}\ntype ResolvedDefaultUnitFormatOptions = Required<DefaultUnitFormatOptions>;\n\n/**\n * Format for numbers with units to show in a tabular form.\n * Large and tiny numbers are shown exponentially and the rest as decimal.\n */\nexport class DefaultUnitFormat extends UnitFormat {\n // The maximum number of digits that should be rendered for any given value.\n private static readonly maximumDigits = 6;\n\n // Use exponential notation for numbers that will be rendered with 3 leading 0s or more.\n // Because a maximum of 6 digits are rendered, showing more than 3 leading 0s is not ideal\n // because then at least half of the displayed digits will be leading 0s.\n private static readonly exponentialLowerBound = 0.000995;\n\n // Use exponential formatting for numbers whose magnitude cannot otherwise be displayed\n // with 6 digits or less.\n private static readonly exponentialUpperBound = 999999.5;\n\n private readonly unitScale: UnitScale;\n\n // Format options to use by default. It renders the number with a maximum of 6 signficant digits.\n private readonly defaultIntlNumberFormatOptions: Intl.NumberFormatOptions = {\n maximumSignificantDigits: DefaultUnitFormat.maximumDigits,\n useGrouping: true\n };\n\n private readonly defaultScaledUnitFormatters = new Map<\n number,\n ScaledUnitFormat\n >();\n\n // Format options to use for numbers that have leading zeros. It limits the number of rendered\n // digits using 'maximumFractionDigits', which will result in less than 6 significant digits\n // in order to render no more than 6 total digits.\n private readonly leadingZeroIntlNumberFormatOptions: Intl.NumberFormatOptions = {\n maximumFractionDigits: DefaultUnitFormat.maximumDigits - 1,\n useGrouping: true\n };\n\n private readonly leadingZeroScaledUnitFormatters = new Map<\n number,\n ScaledUnitFormat\n >();\n\n // Format options for numbers that should be displayed in exponential notation. This should be used\n // for numbers with magintudes over 'exponentialUpperBound' or under 'exponentialLowerBound'.\n private readonly exponentialIntlNumberFormatOptions: Intl.NumberFormatOptions = {\n maximumSignificantDigits: DefaultUnitFormat.maximumDigits,\n notation: 'scientific'\n };\n\n private readonly exponentialScaledUnitFormatter: ScaledUnitFormat;\n\n public constructor(\n locale: string,\n { unitScale = passthroughUnitScale }: DefaultUnitFormatOptions = {\n unitScale: passthroughUnitScale\n }\n ) {\n super();\n for (const unit of unitScale.supportedScaledUnits) {\n this.defaultScaledUnitFormatters.set(\n unit.scaleFactor,\n unit.scaledUnitFormatFactory({\n locale,\n intlNumberFormatOptions: this.defaultIntlNumberFormatOptions\n })\n );\n this.leadingZeroScaledUnitFormatters.set(\n unit.scaleFactor,\n unit.scaledUnitFormatFactory({\n locale,\n intlNumberFormatOptions:\n this.leadingZeroIntlNumberFormatOptions\n })\n );\n }\n this.exponentialScaledUnitFormatter = unitScale.baseScaledUnit.scaledUnitFormatFactory({\n locale,\n intlNumberFormatOptions: this.exponentialIntlNumberFormatOptions\n });\n this.unitScale = unitScale;\n }\n\n public override resolvedOptions(): ResolvedDefaultUnitFormatOptions {\n return {\n unitScale: this.unitScale\n };\n }\n\n protected tryFormat(number: number): string {\n // Normalize +0 / -0 --> +0\n const numberNormalized = number === 0 ? 0 : number;\n\n const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(numberNormalized);\n\n const numberStyle = this.resolveNumberStyle(scaledValue);\n switch (numberStyle) {\n case 'default': {\n const scaledUnitFormatter = this.defaultScaledUnitFormatters.get(\n scaledUnit.scaleFactor\n )!;\n return scaledUnitFormatter.format(scaledValue);\n }\n case 'leadingZero': {\n const scaledUnitFormatter = this.leadingZeroScaledUnitFormatters.get(\n scaledUnit.scaleFactor\n )!;\n return scaledUnitFormatter.format(scaledValue);\n }\n case 'exponential': {\n const scaledUnitFormatter = this.exponentialScaledUnitFormatter;\n return scaledUnitFormatter.format(numberNormalized);\n }\n default:\n throw new Error('Unexpected number format style');\n }\n }\n\n private resolveNumberStyle(number: number): NumberStyle {\n if (number === 0) {\n return 'default';\n }\n\n const absoluteValue = Math.abs(number);\n if (\n absoluteValue >= DefaultUnitFormat.exponentialUpperBound\n || absoluteValue < DefaultUnitFormat.exponentialLowerBound\n ) {\n return 'exponential';\n }\n // Ideally, we could set 'roundingPriority: \"lessPrecision\"' with a formatter that has both 'maximumSignificantDigits' and\n // 'maximumFractionDigits' configured instead of having two different formatters that we conditionally choose between. However,\n // 'roundingPrioirty' is not supported yet in all browsers.\n if (absoluteValue < 1) {\n return 'leadingZero';\n }\n return 'default';\n }\n}\n"]}
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,eAAe,CAAC;AAG9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qCAAqC,CAAC;AAE3E,sFAAsF;AACtF,4EAA4E;AAC5E,6FAA6F;AAC7F,MAAM,WAAW,GAAG,UAAqD,CAAC;AAO1E;;;GAGG;AACH,MAAM,OAAO,iBAAkB,SAAQ,UAAU;IAqC7C,YACI,MAAc,EACd,EAAE,SAAS,GAAG,oBAAoB,KAA+B;QAC7D,SAAS,EAAE,oBAAoB;KAClC;QAED,KAAK,EAAE,CAAC;QA7BZ,uIAAuI;QACtH,mCAA8B,GAA6B;YACxE,wBAAwB,EAAE,iBAAiB,CAAC,aAAa;YAC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D,CAAC,CAAC,IAAI,CAAC,2BAA2B;iBAC7B,GAAG,CAAC,UAAU,CAAC,WAAW,CAAE;iBAC5B,MAAM,CAAC,WAAW,CAAC,CAAC;IACjC,CAAC;;AA7ED,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","sourcesContent":["import { UnitFormat, UnitFormatOptions } from './unit-format';\nimport type { ScaledUnitFormat } from './scaled-unit-format/scaled-unit-format';\nimport type { UnitScale } from './unit-scale/unit-scale';\nimport { passthroughUnitScale } from './unit-scale/passthrough-unit-scale';\n\n// Workaround to avoid ts errors about signDisplay not accepting the value 'negative'.\n// It has been supported by browsers since 8/23, but TypeScript still hasn't\n// added it to the type definitions. See https://github.com/microsoft/TypeScript/issues/56269\nconst signDisplay = 'negative' as Intl.NumberFormatOptions['signDisplay'];\n\n// Allow consistent pattern for defining Options and ResolvedOptions\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\ninterface DefaultUnitFormatOptions extends UnitFormatOptions {}\ntype ResolvedDefaultUnitFormatOptions = Required<DefaultUnitFormatOptions>;\n\n/**\n * Format for numbers with units to show in a tabular form.\n * Large and tiny numbers are shown exponentially and the rest as decimal.\n */\nexport class DefaultUnitFormat extends UnitFormat {\n // The maximum number of digits that should be rendered for any given value.\n private static readonly maximumDigits = 6;\n\n // Use exponential notation for numbers that will be rendered with 3 leading 0s or more.\n // Because a maximum of 6 digits are rendered, showing more than 3 leading 0s is not ideal\n // because then at least half of the displayed digits will be leading 0s.\n private static readonly exponentialLowerBound = 0.000995;\n\n // Use exponential formatting for numbers whose magnitude cannot otherwise be displayed\n // with 6 digits or less.\n private static readonly exponentialUpperBound = 999999.5;\n\n private readonly unitScale: UnitScale;\n // Format options to use by default. It renders the number with a maximum of 6 signficant digits (including zero before decimal point).\n private readonly defaultIntlNumberFormatOptions: Intl.NumberFormatOptions = {\n maximumSignificantDigits: DefaultUnitFormat.maximumDigits,\n maximumFractionDigits: DefaultUnitFormat.maximumDigits - 1,\n roundingPriority: 'lessPrecision',\n signDisplay\n };\n\n private readonly defaultScaledUnitFormatters = new Map<\n number,\n ScaledUnitFormat\n >();\n\n // Format options for numbers that should be displayed in exponential notation. This should be used\n // for numbers with magintudes over 'exponentialUpperBound' or under 'exponentialLowerBound'.\n private readonly exponentialIntlNumberFormatOptions: Intl.NumberFormatOptions = {\n maximumSignificantDigits: DefaultUnitFormat.maximumDigits,\n notation: 'scientific',\n signDisplay\n };\n\n private readonly exponentialScaledUnitFormatter: ScaledUnitFormat;\n\n public constructor(\n locale: string,\n { unitScale = passthroughUnitScale }: DefaultUnitFormatOptions = {\n unitScale: passthroughUnitScale\n }\n ) {\n super();\n for (const unit of unitScale.supportedScaledUnits) {\n this.defaultScaledUnitFormatters.set(\n unit.scaleFactor,\n unit.scaledUnitFormatFactory({\n locale,\n intlNumberFormatOptions: this.defaultIntlNumberFormatOptions\n })\n );\n }\n this.exponentialScaledUnitFormatter = unitScale.baseScaledUnit.scaledUnitFormatFactory({\n locale,\n intlNumberFormatOptions: this.exponentialIntlNumberFormatOptions\n });\n this.unitScale = unitScale;\n }\n\n public override resolvedOptions(): ResolvedDefaultUnitFormatOptions {\n return {\n unitScale: this.unitScale\n };\n }\n\n protected tryFormat(number: number): string {\n const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(number);\n\n const absoluteValue = Math.abs(scaledValue);\n const useExponential = absoluteValue !== 0\n && (absoluteValue >= DefaultUnitFormat.exponentialUpperBound\n || absoluteValue < DefaultUnitFormat.exponentialLowerBound);\n return useExponential\n ? this.exponentialScaledUnitFormatter.format(number)\n : this.defaultScaledUnitFormatters\n .get(scaledUnit.scaleFactor)!\n .format(scaledValue);\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ni/nimble-components",
3
- "version": "21.6.7",
3
+ "version": "21.7.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",
@@ -64,7 +64,7 @@
64
64
  "@microsoft/fast-element": "^1.12.0",
65
65
  "@microsoft/fast-foundation": "2.49.4",
66
66
  "@microsoft/fast-web-utilities": "^6.0.0",
67
- "@ni/nimble-tokens": "^6.11.1",
67
+ "@ni/nimble-tokens": "^6.12.0",
68
68
  "@tanstack/table-core": "^8.10.7",
69
69
  "@tanstack/virtual-core": "^3.0.0-beta.68",
70
70
  "@tiptap/core": "^2.2.2",