@ni/ok-components 0.1.23 → 0.1.24

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.
@@ -76889,7 +76889,7 @@ focus outline in that case.
76889
76889
  /**
76890
76890
  * A formatter for units that can be formatted/translated by Intl.NumberFormat
76891
76891
  */
76892
- class IntlNumberFormatScaledUnitFormat extends ScaledUnitFormat {
76892
+ class ScaledUnitFormatIntlNumberFormat extends ScaledUnitFormat {
76893
76893
  constructor(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions) {
76894
76894
  super(scaledUnitFormatFactoryOptions);
76895
76895
  this.formatter = new Intl.NumberFormat(this.locale, {
@@ -76899,7 +76899,7 @@ focus outline in that case.
76899
76899
  });
76900
76900
  }
76901
76901
  static createFactory(unitSpecificIntlNumberFormatOptions) {
76902
- return (scaledUnitFormatFactoryOptions) => new IntlNumberFormatScaledUnitFormat(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions);
76902
+ return (scaledUnitFormatFactoryOptions) => new ScaledUnitFormatIntlNumberFormat(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions);
76903
76903
  }
76904
76904
  format(value) {
76905
76905
  return this.formatter.format(value);
@@ -76971,14 +76971,14 @@ focus outline in that case.
76971
76971
  /**
76972
76972
  * Unit scale that is used to passthrough a number without applying scaling or units
76973
76973
  */
76974
- class PassthroughUnitScale extends UnitScale {
76974
+ class UnitScalePassthrough extends UnitScale {
76975
76975
  constructor() {
76976
76976
  super([
76977
- new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory({}))
76977
+ new ScaledUnit(10 ** 0, ScaledUnitFormatIntlNumberFormat.createFactory({}))
76978
76978
  ]);
76979
76979
  }
76980
76980
  }
76981
- const passthroughUnitScale = new PassthroughUnitScale();
76981
+ const unitScalePassthrough = new UnitScalePassthrough();
76982
76982
 
76983
76983
  // Workaround to avoid ts errors about signDisplay not accepting the value 'negative'.
76984
76984
  // It has been supported by browsers since 8/23, but TypeScript still hasn't
@@ -76988,15 +76988,15 @@ focus outline in that case.
76988
76988
  * Format for numbers with units to show in a tabular form.
76989
76989
  * Large and tiny numbers are shown exponentially and the rest as decimal.
76990
76990
  */
76991
- class DefaultUnitFormat extends UnitFormat {
76992
- constructor(locale, { unitScale = passthroughUnitScale } = {
76993
- unitScale: passthroughUnitScale
76991
+ class UnitFormatDefault extends UnitFormat {
76992
+ constructor(locale, { unitScale = unitScalePassthrough } = {
76993
+ unitScale: unitScalePassthrough
76994
76994
  }) {
76995
76995
  super();
76996
76996
  // Format options to use by default. It renders the number with a maximum of 6 signficant digits (including zero before decimal point).
76997
76997
  this.defaultIntlNumberFormatOptions = {
76998
- maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
76999
- maximumFractionDigits: DefaultUnitFormat.maximumDigits - 1,
76998
+ maximumSignificantDigits: UnitFormatDefault.maximumDigits,
76999
+ maximumFractionDigits: UnitFormatDefault.maximumDigits - 1,
77000
77000
  roundingPriority: 'lessPrecision',
77001
77001
  signDisplay
77002
77002
  };
@@ -77004,7 +77004,7 @@ focus outline in that case.
77004
77004
  // Format options for numbers that should be displayed in exponential notation. This should be used
77005
77005
  // for numbers with magintudes over 'exponentialUpperBound' or under 'exponentialLowerBound'.
77006
77006
  this.exponentialIntlNumberFormatOptions = {
77007
- maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
77007
+ maximumSignificantDigits: UnitFormatDefault.maximumDigits,
77008
77008
  notation: 'scientific',
77009
77009
  signDisplay
77010
77010
  };
@@ -77029,8 +77029,8 @@ focus outline in that case.
77029
77029
  const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(number);
77030
77030
  const absoluteValue = Math.abs(scaledValue);
77031
77031
  const useExponential = absoluteValue !== 0
77032
- && (absoluteValue >= DefaultUnitFormat.exponentialUpperBound
77033
- || absoluteValue < DefaultUnitFormat.exponentialLowerBound);
77032
+ && (absoluteValue >= UnitFormatDefault.exponentialUpperBound
77033
+ || absoluteValue < UnitFormatDefault.exponentialLowerBound);
77034
77034
  return useExponential
77035
77035
  ? this.exponentialScaledUnitFormatter.format(number)
77036
77036
  : this.defaultScaledUnitFormatters
@@ -77039,23 +77039,23 @@ focus outline in that case.
77039
77039
  }
77040
77040
  }
77041
77041
  // The maximum number of digits that should be rendered for any given value.
77042
- DefaultUnitFormat.maximumDigits = 6;
77042
+ UnitFormatDefault.maximumDigits = 6;
77043
77043
  // Use exponential notation for numbers that will be rendered with 3 leading 0s or more.
77044
77044
  // Because a maximum of 6 digits are rendered, showing more than 3 leading 0s is not ideal
77045
77045
  // because then at least half of the displayed digits will be leading 0s.
77046
- DefaultUnitFormat.exponentialLowerBound = 0.000995;
77046
+ UnitFormatDefault.exponentialLowerBound = 0.000995;
77047
77047
  // Use exponential formatting for numbers whose magnitude cannot otherwise be displayed
77048
77048
  // with 6 digits or less.
77049
- DefaultUnitFormat.exponentialUpperBound = 999999.5;
77049
+ UnitFormatDefault.exponentialUpperBound = 999999.5;
77050
77050
 
77051
77051
  /**
77052
77052
  * Format for decimal numbers with units.
77053
77053
  */
77054
- class DecimalUnitFormat extends UnitFormat {
77055
- constructor(locale, { minimumFractionDigits = 0, maximumFractionDigits = Math.max(3, minimumFractionDigits), unitScale = passthroughUnitScale } = {
77054
+ class UnitFormatDecimal extends UnitFormat {
77055
+ constructor(locale, { minimumFractionDigits = 0, maximumFractionDigits = Math.max(3, minimumFractionDigits), unitScale = unitScalePassthrough } = {
77056
77056
  minimumFractionDigits: 0,
77057
77057
  maximumFractionDigits: 3,
77058
- unitScale: passthroughUnitScale
77058
+ unitScale: unitScalePassthrough
77059
77059
  }) {
77060
77060
  super();
77061
77061
  this.scaledUnitFormatters = new Map();
@@ -77095,7 +77095,7 @@ focus outline in that case.
77095
77095
  /**
77096
77096
  * Format for numbers (with optional units) in a number-text table column.
77097
77097
  */
77098
- class NumberTextUnitFormat extends UnitFormat {
77098
+ class UnitFormatNumberText extends UnitFormat {
77099
77099
  constructor(locale, options) {
77100
77100
  super();
77101
77101
  this._resolvedOptions = this.resolveOptions(options);
@@ -77120,18 +77120,18 @@ focus outline in that case.
77120
77120
  resolveUnitFormat(locale, options) {
77121
77121
  const { numberTextFormat, decimalMaximumDigits, decimalDigits, unitScale } = options;
77122
77122
  if (numberTextFormat === NumberTextFormat.default) {
77123
- return new DefaultUnitFormat(locale, {
77123
+ return new UnitFormatDefault(locale, {
77124
77124
  unitScale
77125
77125
  });
77126
77126
  }
77127
77127
  if (typeof decimalDigits === 'number') {
77128
- return new DecimalUnitFormat(locale, {
77128
+ return new UnitFormatDecimal(locale, {
77129
77129
  minimumFractionDigits: decimalDigits,
77130
77130
  maximumFractionDigits: decimalDigits,
77131
77131
  unitScale
77132
77132
  });
77133
77133
  }
77134
- return new DecimalUnitFormat(locale, {
77134
+ return new UnitFormatDecimal(locale, {
77135
77135
  minimumFractionDigits: 0,
77136
77136
  maximumFractionDigits: decimalMaximumDigits,
77137
77137
  unitScale
@@ -77143,7 +77143,7 @@ focus outline in that case.
77143
77143
  numberTextFormat: NumberTextFormat.default,
77144
77144
  decimalDigits: undefined,
77145
77145
  decimalMaximumDigits: undefined,
77146
- unitScale: options?.unitScale ?? passthroughUnitScale
77146
+ unitScale: options?.unitScale ?? unitScalePassthrough
77147
77147
  };
77148
77148
  }
77149
77149
  const hasDecimalDigits = typeof options.decimalDigits === 'number';
@@ -77154,20 +77154,20 @@ focus outline in that case.
77154
77154
  if (!hasDecimalDigits && !hasDecimalMaximumDigits) {
77155
77155
  return {
77156
77156
  numberTextFormat: NumberTextFormat.decimal,
77157
- decimalDigits: NumberTextUnitFormat.defaultDecimalDigits,
77157
+ decimalDigits: UnitFormatNumberText.defaultDecimalDigits,
77158
77158
  decimalMaximumDigits: undefined,
77159
- unitScale: options.unitScale ?? passthroughUnitScale
77159
+ unitScale: options.unitScale ?? unitScalePassthrough
77160
77160
  };
77161
77161
  }
77162
77162
  return {
77163
77163
  numberTextFormat: NumberTextFormat.decimal,
77164
77164
  decimalDigits: options.decimalDigits,
77165
77165
  decimalMaximumDigits: options.decimalMaximumDigits,
77166
- unitScale: options.unitScale ?? passthroughUnitScale
77166
+ unitScale: options.unitScale ?? unitScalePassthrough
77167
77167
  };
77168
77168
  }
77169
77169
  }
77170
- NumberTextUnitFormat.defaultDecimalDigits = 2;
77170
+ UnitFormatNumberText.defaultDecimalDigits = 2;
77171
77171
 
77172
77172
  const numberTextValidityFlagNames = [
77173
77173
  'invalidDecimalDigits',
@@ -77326,7 +77326,7 @@ focus outline in that case.
77326
77326
  }
77327
77327
  createFormatter() {
77328
77328
  const unitScale = this.unit?.resolvedUnitScale;
77329
- return new NumberTextUnitFormat(lang.getValueFor(this), {
77329
+ return new UnitFormatNumberText(lang.getValueFor(this), {
77330
77330
  // Attribute values sometimes resolve to either null or undefined
77331
77331
  // See https://github.com/microsoft/fast/issues/6630
77332
77332
  numberTextFormat: this.format ?? undefined,
@@ -78922,8 +78922,6 @@ focus outline in that case.
78922
78922
  });
78923
78923
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTreeView());
78924
78924
 
78925
- const template$6 = html `<template slot="unit"></template>`;
78926
-
78927
78925
  /**
78928
78926
  * Representations of a unit in a particular language
78929
78927
  */
@@ -78937,7 +78935,7 @@ focus outline in that case.
78937
78935
  /**
78938
78936
  * A formatter for units that are not supported by Intl.NumberFormat
78939
78937
  */
78940
- class ManuallyTranslatedScaledUnitFormat extends ScaledUnitFormat {
78938
+ class ScaledUnitFormatManuallyTranslated extends ScaledUnitFormat {
78941
78939
  constructor(scaledUnitFormatFactoryOptions, { unitTranslations, scaledPrefixText }) {
78942
78940
  super(scaledUnitFormatFactoryOptions);
78943
78941
  if (!unitTranslations.get('en')) {
@@ -78948,8 +78946,8 @@ focus outline in that case.
78948
78946
  this.unitTranslation = this.getTranslationToUse(unitTranslations, this.locale);
78949
78947
  this.scaledPrefixText = scaledPrefixText;
78950
78948
  }
78951
- static createFactory(manuallyTranslatedScaledUnitFormatOptions) {
78952
- return (scaledUnitFormatFactoryOptions) => new ManuallyTranslatedScaledUnitFormat(scaledUnitFormatFactoryOptions, manuallyTranslatedScaledUnitFormatOptions);
78949
+ static createFactory(scaledUnitFormatManuallyTranslatedOptions) {
78950
+ return (scaledUnitFormatFactoryOptions) => new ScaledUnitFormatManuallyTranslated(scaledUnitFormatFactoryOptions, scaledUnitFormatManuallyTranslatedOptions);
78953
78951
  }
78954
78952
  format(value) {
78955
78953
  const formatted = this.formatter.format(value);
@@ -79004,17 +79002,17 @@ focus outline in that case.
79004
79002
  /**
79005
79003
  * Byte units (1024-based)
79006
79004
  */
79007
- class Byte1024UnitScale extends UnitScale {
79005
+ class UnitScaleByte1024 extends UnitScale {
79008
79006
  constructor() {
79009
- super(byte1024Prefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory({
79007
+ super(byte1024Prefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ScaledUnitFormatManuallyTranslated.createFactory({
79010
79008
  unitTranslations: unitTranslations$1,
79011
79009
  scaledPrefixText
79012
79010
  }))));
79013
79011
  }
79014
79012
  }
79015
- const byte1024UnitScale = new Byte1024UnitScale();
79013
+ const unitScaleByte1024 = new UnitScaleByte1024();
79016
79014
 
79017
- const byteUnitScaleOptions = [
79015
+ const unitScaleByteConfig = [
79018
79016
  [1000 ** 0, 'byte', 'long'],
79019
79017
  [1000 ** 1, 'kilobyte', 'short'],
79020
79018
  [1000 ** 2, 'megabyte', 'short'],
@@ -79025,16 +79023,18 @@ focus outline in that case.
79025
79023
  /**
79026
79024
  * Byte units (1000-based)
79027
79025
  */
79028
- class ByteUnitScale extends UnitScale {
79026
+ class UnitScaleByte extends UnitScale {
79029
79027
  constructor() {
79030
- super(byteUnitScaleOptions.map(([scaleFactor, unit, unitDisplay]) => new ScaledUnit(scaleFactor, IntlNumberFormatScaledUnitFormat.createFactory({
79028
+ super(unitScaleByteConfig.map(([scaleFactor, unit, unitDisplay]) => new ScaledUnit(scaleFactor, ScaledUnitFormatIntlNumberFormat.createFactory({
79031
79029
  style: 'unit',
79032
79030
  unit,
79033
79031
  unitDisplay
79034
79032
  }))));
79035
79033
  }
79036
79034
  }
79037
- const byteUnitScale = new ByteUnitScale();
79035
+ const unitScaleByte = new UnitScaleByte();
79036
+
79037
+ const template$6 = html `<template slot="unit"></template>`;
79038
79038
 
79039
79039
  const styles$6 = css `
79040
79040
  ${display$2('none')}
@@ -79051,12 +79051,12 @@ focus outline in that case.
79051
79051
  * the default of decimal (base 1000 scale with metric prefixes)
79052
79052
  */
79053
79053
  this.binary = false;
79054
- this.resolvedUnitScale = byteUnitScale;
79054
+ this.resolvedUnitScale = unitScaleByte;
79055
79055
  }
79056
79056
  binaryChanged() {
79057
79057
  this.resolvedUnitScale = this.binary
79058
- ? byte1024UnitScale
79059
- : byteUnitScale;
79058
+ ? unitScaleByte1024
79059
+ : unitScaleByte;
79060
79060
  }
79061
79061
  }
79062
79062
  __decorate([
@@ -79096,15 +79096,15 @@ focus outline in that case.
79096
79096
  /**
79097
79097
  * Voltage unit scale
79098
79098
  */
79099
- class VoltUnitScale extends UnitScale {
79099
+ class UnitScaleVolt extends UnitScale {
79100
79100
  constructor() {
79101
- super(metricPrefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory({
79101
+ super(metricPrefixes.map(([scaleFactor, scaledPrefixText]) => new ScaledUnit(scaleFactor, ScaledUnitFormatManuallyTranslated.createFactory({
79102
79102
  unitTranslations,
79103
79103
  scaledPrefixText
79104
79104
  }))));
79105
79105
  }
79106
79106
  }
79107
- const voltUnitScale = new VoltUnitScale();
79107
+ const unitScaleVolt = new UnitScaleVolt();
79108
79108
 
79109
79109
  /**
79110
79110
  * Element representing units for volts
@@ -79112,7 +79112,7 @@ focus outline in that case.
79112
79112
  class UnitVolt extends Unit {
79113
79113
  constructor() {
79114
79114
  super();
79115
- this.resolvedUnitScale = voltUnitScale;
79115
+ this.resolvedUnitScale = unitScaleVolt;
79116
79116
  }
79117
79117
  }
79118
79118
  const nimbleUnitVolt = UnitVolt.compose({