@ni/nimble-components 20.17.7 → 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.
Files changed (97) hide show
  1. package/dist/all-components-bundle.js +643 -163
  2. package/dist/all-components-bundle.js.map +1 -1
  3. package/dist/all-components-bundle.min.js +1150 -1107
  4. package/dist/all-components-bundle.min.js.map +1 -1
  5. package/dist/esm/all-components.d.ts +2 -0
  6. package/dist/esm/all-components.js +2 -0
  7. package/dist/esm/all-components.js.map +1 -1
  8. package/dist/esm/rich-text/base/index.js +2 -4
  9. package/dist/esm/rich-text/base/index.js.map +1 -1
  10. package/dist/esm/table/index.js +2 -4
  11. package/dist/esm/table/index.js.map +1 -1
  12. package/dist/esm/table-column/number-text/cell-view/index.js +1 -2
  13. package/dist/esm/table-column/number-text/cell-view/index.js.map +1 -1
  14. package/dist/esm/table-column/number-text/group-header-view/index.js +1 -2
  15. package/dist/esm/table-column/number-text/group-header-view/index.js.map +1 -1
  16. package/dist/esm/table-column/number-text/index.d.ts +11 -2
  17. package/dist/esm/table-column/number-text/index.js +61 -14
  18. package/dist/esm/table-column/number-text/index.js.map +1 -1
  19. package/dist/esm/table-column/number-text/models/table-column-number-text-validator.d.ts +2 -1
  20. package/dist/esm/table-column/number-text/models/table-column-number-text-validator.js +6 -1
  21. package/dist/esm/table-column/number-text/models/table-column-number-text-validator.js.map +1 -1
  22. package/dist/esm/table-column/number-text/template.d.ts +2 -0
  23. package/dist/esm/table-column/number-text/template.js +14 -0
  24. package/dist/esm/table-column/number-text/template.js.map +1 -0
  25. package/dist/esm/unit/base/template.d.ts +1 -0
  26. package/dist/esm/unit/base/template.js +3 -0
  27. package/dist/esm/unit/base/template.js.map +1 -0
  28. package/dist/esm/unit/base/unit.d.ts +9 -0
  29. package/dist/esm/unit/base/unit.js +12 -0
  30. package/dist/esm/unit/base/unit.js.map +1 -0
  31. package/dist/esm/unit/byte/index.d.ts +19 -0
  32. package/dist/esm/unit/byte/index.js +36 -0
  33. package/dist/esm/unit/byte/index.js.map +1 -0
  34. package/dist/esm/unit/volt/index.d.ts +13 -0
  35. package/dist/esm/unit/volt/index.js +20 -0
  36. package/dist/esm/unit/volt/index.js.map +1 -0
  37. package/dist/esm/utilities/unit-format/base/unit-format.d.ts +16 -0
  38. package/dist/esm/utilities/unit-format/base/unit-format.js +21 -0
  39. package/dist/esm/utilities/unit-format/base/unit-format.js.map +1 -0
  40. package/dist/esm/utilities/unit-format/decimal-unit-format.d.ts +22 -0
  41. package/dist/esm/utilities/unit-format/decimal-unit-format.js +51 -0
  42. package/dist/esm/utilities/unit-format/decimal-unit-format.js.map +1 -0
  43. package/dist/esm/utilities/unit-format/default-unit-format.d.ts +21 -0
  44. package/dist/esm/utilities/unit-format/default-unit-format.js +102 -0
  45. package/dist/esm/utilities/unit-format/default-unit-format.js.map +1 -0
  46. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.d.ts +18 -0
  47. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.js +49 -0
  48. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-scaled-unit-format.js.map +1 -0
  49. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.d.ts +10 -0
  50. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.js +19 -0
  51. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/manually-translated-unit-scale.js.map +1 -0
  52. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.d.ts +10 -0
  53. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.js +17 -0
  54. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefix.js.map +1 -0
  55. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.d.ts +5 -0
  56. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js +21 -0
  57. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-prefixes-metric.js.map +1 -0
  58. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.d.ts +9 -0
  59. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js +11 -0
  60. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/base/unit-translation.js.map +1 -0
  61. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.d.ts +9 -0
  62. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js +26 -0
  63. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/byte-1024-unit-scale.js.map +1 -0
  64. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.d.ts +9 -0
  65. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.js +19 -0
  66. package/dist/esm/utilities/unit-format/manually-translated-unit-scale/volt-unit-scale.js.map +1 -0
  67. package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.d.ts +11 -0
  68. package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js +21 -0
  69. package/dist/esm/utilities/unit-format/unit-scale/base/intl-number-format-scaled-unit-format.js.map +1 -0
  70. package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit-format.d.ts +10 -0
  71. package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit-format.js +10 -0
  72. package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit-format.js.map +1 -0
  73. package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.d.ts +16 -0
  74. package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.js +13 -0
  75. package/dist/esm/utilities/unit-format/unit-scale/base/scaled-unit.js.map +1 -0
  76. package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.d.ts +15 -0
  77. package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.js +49 -0
  78. package/dist/esm/utilities/unit-format/unit-scale/base/unit-scale.js.map +1 -0
  79. package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.d.ts +9 -0
  80. package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.js +44 -0
  81. package/dist/esm/utilities/unit-format/unit-scale/byte-unit-scale.js.map +1 -0
  82. package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.d.ts +9 -0
  83. package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.js +15 -0
  84. package/dist/esm/utilities/unit-format/unit-scale/passthrough-unit-scale.js.map +1 -0
  85. package/dist/esm/utilities/wait-until-custom-elements-defined-async.d.ts +1 -0
  86. package/dist/esm/utilities/wait-until-custom-elements-defined-async.js +7 -0
  87. package/dist/esm/utilities/wait-until-custom-elements-defined-async.js.map +1 -0
  88. package/package.json +1 -1
  89. package/dist/esm/table-column/number-text/models/decimal-formatter.d.ts +0 -11
  90. package/dist/esm/table-column/number-text/models/decimal-formatter.js +0 -27
  91. package/dist/esm/table-column/number-text/models/decimal-formatter.js.map +0 -1
  92. package/dist/esm/table-column/number-text/models/default-formatter.d.ts +0 -15
  93. package/dist/esm/table-column/number-text/models/default-formatter.js +0 -55
  94. package/dist/esm/table-column/number-text/models/default-formatter.js.map +0 -1
  95. package/dist/esm/table-column/number-text/models/number-formatter.d.ts +0 -11
  96. package/dist/esm/table-column/number-text/models/number-formatter.js +0 -21
  97. package/dist/esm/table-column/number-text/models/number-formatter.js.map +0 -1
@@ -16301,7 +16301,7 @@
16301
16301
 
16302
16302
  /**
16303
16303
  * Do not edit directly
16304
- * Generated on Wed, 17 Jan 2024 00:34:10 GMT
16304
+ * Generated on Wed, 17 Jan 2024 14:08:42 GMT
16305
16305
  */
16306
16306
 
16307
16307
  const Information100DarkUi = "#a46eff";
@@ -16704,7 +16704,7 @@
16704
16704
  return `${prefix}${uniqueIdCounter++}`;
16705
16705
  }
16706
16706
 
16707
- const template$D = html `<slot></slot>`;
16707
+ const template$F = html `<slot></slot>`;
16708
16708
 
16709
16709
  const styles$X = css `
16710
16710
  :host {
@@ -16824,7 +16824,7 @@
16824
16824
  const nimbleDesignSystemProvider = ThemeProvider.compose({
16825
16825
  baseName: 'theme-provider',
16826
16826
  styles: styles$X,
16827
- template: template$D
16827
+ template: template$F
16828
16828
  });
16829
16829
  DesignSystem.getOrCreate()
16830
16830
  .withPrefix('nimble')
@@ -17116,7 +17116,7 @@
17116
17116
  `;
17117
17117
 
17118
17118
  // prettier-ignore
17119
- const template$C = (_context, definition) => html `${
17119
+ const template$E = (_context, definition) => html `${
17120
17120
  /* top-container div is necessary because setting contenteditable directly on the native anchor instead
17121
17121
  leaves it focusable, unlike the behavior you get when the anchor is _within_ a contenteditable element.
17122
17122
  */ ''}<div
@@ -17215,7 +17215,7 @@
17215
17215
  const nimbleAnchor = Anchor.compose({
17216
17216
  baseName: 'anchor',
17217
17217
  baseClass: Anchor$1,
17218
- template: template$C,
17218
+ template: template$E,
17219
17219
  styles: styles$W,
17220
17220
  shadowOptions: {
17221
17221
  delegatesFocus: true
@@ -17605,7 +17605,7 @@
17605
17605
  }
17606
17606
  `;
17607
17607
 
17608
- const template$B = (context, definition) => html `
17608
+ const template$D = (context, definition) => html `
17609
17609
  <a
17610
17610
  class="control"
17611
17611
  part="control"
@@ -17687,7 +17687,7 @@
17687
17687
  ], AnchorButton.prototype, "disabled", void 0);
17688
17688
  const nimbleAnchorButton = AnchorButton.compose({
17689
17689
  baseName: 'anchor-button',
17690
- template: template$B,
17690
+ template: template$D,
17691
17691
  styles: styles$U,
17692
17692
  shadowOptions: {
17693
17693
  delegatesFocus: true
@@ -17773,7 +17773,7 @@
17773
17773
  }
17774
17774
  `;
17775
17775
 
17776
- const template$A = (context, definition) => html `
17776
+ const template$C = (context, definition) => html `
17777
17777
  <template
17778
17778
  role="menuitem"
17779
17779
  class="${x => (typeof x.startColumnCount === 'number'
@@ -17874,7 +17874,7 @@
17874
17874
  // FoundationAnchor already applies the StartEnd mixin, so we don't need to do it here.
17875
17875
  const nimbleAnchorMenuItem = AnchorMenuItem.compose({
17876
17876
  baseName: 'anchor-menu-item',
17877
- template: template$A,
17877
+ template: template$C,
17878
17878
  styles: styles$T,
17879
17879
  shadowOptions: {
17880
17880
  delegatesFocus: true
@@ -18014,7 +18014,7 @@
18014
18014
  }
18015
18015
  `;
18016
18016
 
18017
- const template$z = (context, definition) => html `
18017
+ const template$B = (context, definition) => html `
18018
18018
  <template slot="anchortab" role="tab" aria-disabled="${x => x.disabled}">
18019
18019
  <a
18020
18020
  download="${x => x.download}"
@@ -18066,7 +18066,7 @@
18066
18066
  // FoundationAnchor already applies the StartEnd mixin, so we don't need to do it here.
18067
18067
  const nimbleAnchorTab = AnchorTab.compose({
18068
18068
  baseName: 'anchor-tab',
18069
- template: template$z,
18069
+ template: template$B,
18070
18070
  styles: styles$S,
18071
18071
  shadowOptions: {
18072
18072
  delegatesFocus: true
@@ -18096,7 +18096,7 @@
18096
18096
  }
18097
18097
  `;
18098
18098
 
18099
- const template$y = (context, definition) => html `
18099
+ const template$A = (context, definition) => html `
18100
18100
  ${startSlotTemplate(context, definition)}
18101
18101
  <div ${ref('tablist')} class="tablist" part="tablist" role="tablist">
18102
18102
  <slot name="anchortab" ${slotted('tabs')}></slot>
@@ -18302,7 +18302,7 @@
18302
18302
  applyMixins(AnchorTabs, StartEnd);
18303
18303
  const nimbleAnchorTabs = AnchorTabs.compose({
18304
18304
  baseName: 'anchor-tabs',
18305
- template: template$y,
18305
+ template: template$A,
18306
18306
  styles: styles$R,
18307
18307
  shadowOptions: {
18308
18308
  delegatesFocus: false
@@ -18420,7 +18420,7 @@
18420
18420
  }
18421
18421
  `;
18422
18422
 
18423
- const template$x = (context, definition) => html `
18423
+ const template$z = (context, definition) => html `
18424
18424
  <template
18425
18425
  role="treeitem"
18426
18426
  slot="${x => (x.isNestedItem() ? 'item' : null)}"
@@ -18557,7 +18557,7 @@
18557
18557
  // FoundationAnchor already applies the StartEnd mixin, so we don't need to do it here.
18558
18558
  const nimbleAnchorTreeItem = AnchorTreeItem.compose({
18559
18559
  baseName: 'anchor-tree-item',
18560
- template: template$x,
18560
+ template: template$z,
18561
18561
  styles: styles$Q,
18562
18562
  shadowOptions: {
18563
18563
  delegatesFocus: true
@@ -19579,7 +19579,7 @@
19579
19579
  };
19580
19580
 
19581
19581
  // Avoiding any whitespace in the template because this is an inline element
19582
- const template$w = html `<div
19582
+ const template$y = html `<div
19583
19583
  class="icon"
19584
19584
  aria-hidden="true"
19585
19585
  :innerHTML=${x => x.icon.data}
@@ -19638,7 +19638,7 @@
19638
19638
  const registerIcon = (baseName, iconClass) => {
19639
19639
  const composedIcon = iconClass.compose({
19640
19640
  baseName,
19641
- template: template$w,
19641
+ template: template$y,
19642
19642
  styles: styles$M,
19643
19643
  baseClass: iconClass
19644
19644
  });
@@ -19743,7 +19743,7 @@
19743
19743
  }).withDefault(coreLabelDefaults.informationIconLabel);
19744
19744
 
19745
19745
  // prettier-ignore
19746
- const template$v = html `
19746
+ const template$x = html `
19747
19747
  <div class="container"
19748
19748
  role="status"
19749
19749
  aria-atomic="${x => x.ariaAtomic}"
@@ -19859,7 +19859,7 @@
19859
19859
  applyMixins(Banner, ARIAGlobalStatesAndProperties);
19860
19860
  const nimbleBanner = Banner.compose({
19861
19861
  baseName: 'banner',
19862
- template: template$v,
19862
+ template: template$x,
19863
19863
  styles: styles$O
19864
19864
  });
19865
19865
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleBanner());
@@ -20014,7 +20014,7 @@
20014
20014
  }
20015
20015
  `;
20016
20016
 
20017
- const template$u = html `
20017
+ const template$w = html `
20018
20018
  ${'' /* Explicitly set role to work around Lighthouse error. See https://github.com/ni/nimble/issues/1650. */}
20019
20019
  <section role="region" aria-labelledby="title-slot">
20020
20020
  <slot name="title" id="title-slot"></slot>
@@ -20030,7 +20030,7 @@
20030
20030
  const nimbleCard = Card.compose({
20031
20031
  baseName: 'card',
20032
20032
  baseClass: Card$1,
20033
- template: template$u,
20033
+ template: template$w,
20034
20034
  styles: styles$J
20035
20035
  });
20036
20036
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleCard());
@@ -20406,7 +20406,7 @@
20406
20406
  }
20407
20407
  `;
20408
20408
 
20409
- const template$t = (context, definition) => html `
20409
+ const template$v = (context, definition) => html `
20410
20410
  <div
20411
20411
  role="button"
20412
20412
  part="control"
@@ -20481,7 +20481,7 @@
20481
20481
  applyMixins(ToggleButton, StartEnd, DelegatesARIAButton);
20482
20482
  const nimbleToggleButton = ToggleButton.compose({
20483
20483
  baseName: 'toggle-button',
20484
- template: template$t,
20484
+ template: template$v,
20485
20485
  styles: styles$G,
20486
20486
  shadowOptions: {
20487
20487
  delegatesFocus: true
@@ -20915,7 +20915,7 @@
20915
20915
  }
20916
20916
 
20917
20917
  // prettier-ignore
20918
- const template$s = (context, definition) => html `
20918
+ const template$u = (context, definition) => html `
20919
20919
  <template
20920
20920
  aria-disabled="${x => x.ariaDisabled}"
20921
20921
  autocomplete="${x => x.autocomplete}"
@@ -21193,7 +21193,7 @@
21193
21193
  const nimbleCombobox = Combobox.compose({
21194
21194
  baseName: 'combobox',
21195
21195
  baseClass: Combobox$1,
21196
- template: template$s,
21196
+ template: template$u,
21197
21197
  styles: styles$D,
21198
21198
  shadowOptions: {
21199
21199
  delegatesFocus: true
@@ -21340,7 +21340,7 @@
21340
21340
  }
21341
21341
  `));
21342
21342
 
21343
- const template$r = html `
21343
+ const template$t = html `
21344
21344
  <template>
21345
21345
  <dialog
21346
21346
  ${ref('dialogElement')}
@@ -21467,7 +21467,7 @@
21467
21467
  applyMixins(Dialog, ARIAGlobalStatesAndProperties);
21468
21468
  const nimbleDialog = Dialog.compose({
21469
21469
  baseName: 'dialog',
21470
- template: template$r,
21470
+ template: template$t,
21471
21471
  styles: styles$C,
21472
21472
  baseClass: Dialog
21473
21473
  });
@@ -21626,7 +21626,7 @@
21626
21626
  }
21627
21627
  `));
21628
21628
 
21629
- const template$q = html `
21629
+ const template$s = html `
21630
21630
  <dialog
21631
21631
  ${ref('dialog')}
21632
21632
  aria-label="${x => x.ariaLabel}"
@@ -21740,7 +21740,7 @@
21740
21740
  applyMixins(Drawer, ARIAGlobalStatesAndProperties);
21741
21741
  const nimbleDrawer = Drawer.compose({
21742
21742
  baseName: 'drawer',
21743
- template: template$q,
21743
+ template: template$s,
21744
21744
  styles: styles$B
21745
21745
  });
21746
21746
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleDrawer());
@@ -24104,7 +24104,7 @@
24104
24104
  * @public
24105
24105
  */
24106
24106
  // prettier-ignore
24107
- const template$p = (context, definition) => html `
24107
+ const template$r = (context, definition) => html `
24108
24108
  <template
24109
24109
  aria-checked="${x => x.ariaChecked}"
24110
24110
  aria-disabled="${x => x.ariaDisabled}"
@@ -24152,7 +24152,7 @@
24152
24152
  const nimbleListOption = ListOption.compose({
24153
24153
  baseName: 'list-option',
24154
24154
  baseClass: ListboxOption,
24155
- template: template$p,
24155
+ template: template$r,
24156
24156
  styles: styles$A
24157
24157
  });
24158
24158
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleListOption());
@@ -24167,7 +24167,7 @@
24167
24167
  attr()
24168
24168
  ], Mapping$1.prototype, "key", void 0);
24169
24169
 
24170
- const template$o = html `<template slot="mapping"></template>`;
24170
+ const template$q = html `<template slot="mapping"></template>`;
24171
24171
 
24172
24172
  /**
24173
24173
  * Defines a mapping from one data value ('key' property) to display text ('text' property).
@@ -24181,7 +24181,7 @@
24181
24181
  ], MappingText.prototype, "text", void 0);
24182
24182
  const textMapping = MappingText.compose({
24183
24183
  baseName: 'mapping-text',
24184
- template: template$o
24184
+ template: template$q
24185
24185
  });
24186
24186
  DesignSystem.getOrCreate().withPrefix('nimble').register(textMapping());
24187
24187
 
@@ -24244,7 +24244,7 @@
24244
24244
  ], MappingIcon.prototype, "resolvedIcon", void 0);
24245
24245
  const iconMapping = MappingIcon.compose({
24246
24246
  baseName: 'mapping-icon',
24247
- template: template$o
24247
+ template: template$q
24248
24248
  });
24249
24249
  DesignSystem.getOrCreate().withPrefix('nimble').register(iconMapping());
24250
24250
 
@@ -24260,7 +24260,7 @@
24260
24260
  ], MappingSpinner.prototype, "text", void 0);
24261
24261
  const spinnerMapping = MappingSpinner.compose({
24262
24262
  baseName: 'mapping-spinner',
24263
- template: template$o
24263
+ template: template$q
24264
24264
  });
24265
24265
  DesignSystem.getOrCreate().withPrefix('nimble').register(spinnerMapping());
24266
24266
 
@@ -24354,7 +24354,7 @@
24354
24354
  `;
24355
24355
 
24356
24356
  // prettier-ignore
24357
- const template$n = html `
24357
+ const template$p = html `
24358
24358
  <template
24359
24359
  ?open="${x => x.open}"
24360
24360
  @focusout="${(x, c) => x.focusoutHandler(c.event)}"
@@ -24609,7 +24609,7 @@
24609
24609
  ], MenuButton.prototype, "slottedMenus", void 0);
24610
24610
  const nimbleMenuButton = MenuButton.compose({
24611
24611
  baseName: 'menu-button',
24612
- template: template$n,
24612
+ template: template$p,
24613
24613
  styles: styles$y,
24614
24614
  shadowOptions: {
24615
24615
  delegatesFocus: true
@@ -42158,7 +42158,7 @@ img.ProseMirror-separator {
42158
42158
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleListbox());
42159
42159
 
42160
42160
  // prettier-ignore
42161
- const template$m = html `
42161
+ const template$o = html `
42162
42162
  <template>
42163
42163
  <${anchoredRegionTag}
42164
42164
  ${ref('region')}
@@ -42419,7 +42419,7 @@ img.ProseMirror-separator {
42419
42419
  ], RichTextMentionListbox.prototype, "anchorElement", void 0);
42420
42420
  const nimbleRichTextMentionListbox = RichTextMentionListbox.compose({
42421
42421
  baseName: 'rich-text-mention-listbox',
42422
- template: template$m,
42422
+ template: template$o,
42423
42423
  styles: styles$s
42424
42424
  });
42425
42425
  DesignSystem.getOrCreate()
@@ -42428,7 +42428,7 @@ img.ProseMirror-separator {
42428
42428
  const richTextMentionListboxTag = 'nimble-rich-text-mention-listbox';
42429
42429
 
42430
42430
  // prettier-ignore
42431
- const template$l = html `
42431
+ const template$n = html `
42432
42432
  <template
42433
42433
  ${children$1({ property: 'childItems', filter: elements() })}
42434
42434
  @focusout="${x => x.focusoutHandler()}"
@@ -52380,6 +52380,13 @@ img.ProseMirror-separator {
52380
52380
  }
52381
52381
  }
52382
52382
 
52383
+ async function waitUntilCustomElementsDefinedAsync(elements) {
52384
+ const definedElements = elements.map(async (item) => (item.matches(':not(:defined)')
52385
+ ? customElements.whenDefined(item.localName)
52386
+ : Promise.resolve()));
52387
+ await Promise.all(definedElements);
52388
+ }
52389
+
52383
52390
  /**
52384
52391
  * Base class for rich text components
52385
52392
  */
@@ -52415,10 +52422,7 @@ img.ProseMirror-separator {
52415
52422
  void this.updateMentionElementsFromChildItems();
52416
52423
  }
52417
52424
  async updateMentionElementsFromChildItems() {
52418
- const definedElements = this.childItems.map(async (item) => (item.matches(':not(:defined)')
52419
- ? customElements.whenDefined(item.localName)
52420
- : Promise.resolve()));
52421
- await Promise.all(definedElements);
52425
+ await waitUntilCustomElementsDefinedAsync(this.childItems);
52422
52426
  this.mentionElements = this.childItems.filter((x) => x instanceof RichTextMention);
52423
52427
  }
52424
52428
  observeMentionInternals() {
@@ -56873,7 +56877,7 @@ img.ProseMirror-separator {
56873
56877
  applyMixins(RichTextEditor, ARIAGlobalStatesAndProperties);
56874
56878
  const nimbleRichTextEditor = RichTextEditor.compose({
56875
56879
  baseName: 'rich-text-editor',
56876
- template: template$l,
56880
+ template: template$n,
56877
56881
  styles: styles$q,
56878
56882
  shadowOptions: {
56879
56883
  delegatesFocus: true
@@ -56883,7 +56887,7 @@ img.ProseMirror-separator {
56883
56887
  .withPrefix('nimble')
56884
56888
  .register(nimbleRichTextEditor());
56885
56889
 
56886
- const template$k = html `
56890
+ const template$m = html `
56887
56891
  <template ${children$1({ property: 'childItems', filter: elements() })}>
56888
56892
  <div ${ref('viewer')} class="viewer"></div>
56889
56893
  </template>
@@ -56998,7 +57002,7 @@ img.ProseMirror-separator {
56998
57002
  ], RichTextViewer.prototype, "markdown", void 0);
56999
57003
  const nimbleRichTextViewer = RichTextViewer.compose({
57000
57004
  baseName: 'rich-text-viewer',
57001
- template: template$k,
57005
+ template: template$m,
57002
57006
  styles: styles$p
57003
57007
  });
57004
57008
  DesignSystem.getOrCreate()
@@ -57035,7 +57039,7 @@ img.ProseMirror-separator {
57035
57039
  `));
57036
57040
 
57037
57041
  // prettier-ignore
57038
- const template$j = (context, definition) => html `
57042
+ const template$l = (context, definition) => html `
57039
57043
  <template
57040
57044
  class="${x => [
57041
57045
  x.collapsible && 'collapsible',
@@ -57178,7 +57182,7 @@ img.ProseMirror-separator {
57178
57182
  const nimbleSelect = Select.compose({
57179
57183
  baseName: 'select',
57180
57184
  baseClass: Select$1,
57181
- template: template$j,
57185
+ template: template$l,
57182
57186
  styles: styles$o,
57183
57187
  indicator: arrowExpanderDown16X16.data,
57184
57188
  end: html `
@@ -57353,7 +57357,7 @@ img.ProseMirror-separator {
57353
57357
  }
57354
57358
  `));
57355
57359
 
57356
- const template$i = html `
57360
+ const template$k = html `
57357
57361
  <template role="progressbar">
57358
57362
  <div class="container">
57359
57363
  <div class="bit1"></div>
@@ -57391,7 +57395,7 @@ img.ProseMirror-separator {
57391
57395
  ], Spinner.prototype, "appearance", void 0);
57392
57396
  const nimbleSpinner = Spinner.compose({
57393
57397
  baseName: 'spinner',
57394
- template: template$i,
57398
+ template: template$k,
57395
57399
  styles: styles$n
57396
57400
  });
57397
57401
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleSpinner());
@@ -57560,7 +57564,7 @@ img.ProseMirror-separator {
57560
57564
  `));
57561
57565
 
57562
57566
  // prettier-ignore
57563
- const template$h = html `
57567
+ const template$j = html `
57564
57568
  <template
57565
57569
  role="switch"
57566
57570
  aria-checked="${x => x.checked}"
@@ -57604,7 +57608,7 @@ img.ProseMirror-separator {
57604
57608
  const nimbleSwitch = Switch.compose({
57605
57609
  baseClass: Switch$1,
57606
57610
  baseName: 'switch',
57607
- template: template$h,
57611
+ template: template$j,
57608
57612
  styles: styles$m
57609
57613
  });
57610
57614
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleSwitch());
@@ -61784,7 +61788,7 @@ img.ProseMirror-separator {
61784
61788
  `;
61785
61789
 
61786
61790
  // prettier-ignore
61787
- const template$g = html `
61791
+ const template$i = html `
61788
61792
  <template role="columnheader"
61789
61793
  aria-sort="${x => x.ariaSort}"
61790
61794
  ${'' /* Prevent header double clicks from selecting text */}
@@ -61858,7 +61862,7 @@ img.ProseMirror-separator {
61858
61862
  ], TableHeader.prototype, "isGrouped", void 0);
61859
61863
  const nimbleTableHeader = TableHeader.compose({
61860
61864
  baseName: 'table-header',
61861
- template: template$g,
61865
+ template: template$i,
61862
61866
  styles: styles$i
61863
61867
  });
61864
61868
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTableHeader());
@@ -62029,7 +62033,7 @@ img.ProseMirror-separator {
62029
62033
  `;
62030
62034
 
62031
62035
  // prettier-ignore
62032
- const template$f = html `
62036
+ const template$h = html `
62033
62037
  <template role="cell" style="--ni-private-table-cell-nesting-level: ${x => x.nestingLevel}">
62034
62038
  ${x => x.cellViewTemplate}
62035
62039
  ${when(x => x.hasActionMenu, html `
@@ -62098,14 +62102,14 @@ img.ProseMirror-separator {
62098
62102
  ], TableCell.prototype, "nestingLevel", void 0);
62099
62103
  const nimbleTableCell = TableCell.compose({
62100
62104
  baseName: 'table-cell',
62101
- template: template$f,
62105
+ template: template$h,
62102
62106
  styles: styles$f
62103
62107
  });
62104
62108
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTableCell());
62105
62109
  const tableCellTag = 'nimble-table-cell';
62106
62110
 
62107
62111
  // prettier-ignore
62108
- const template$e = html `
62112
+ const template$g = html `
62109
62113
  <template
62110
62114
  role="row"
62111
62115
  aria-selected=${x => x.ariaSelected}
@@ -62412,7 +62416,7 @@ img.ProseMirror-separator {
62412
62416
  ], TableRow.prototype, "ariaSelected", null);
62413
62417
  const nimbleTableRow = TableRow.compose({
62414
62418
  baseName: 'table-row',
62415
- template: template$e,
62419
+ template: template$g,
62416
62420
  styles: styles$g
62417
62421
  });
62418
62422
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTableRow());
@@ -62507,7 +62511,7 @@ img.ProseMirror-separator {
62507
62511
 
62508
62512
  /* eslint-disable @typescript-eslint/indent */
62509
62513
  // prettier-ignore
62510
- const template$d = html `
62514
+ const template$f = html `
62511
62515
  <template
62512
62516
  role="row"
62513
62517
  @click=${x => x.onGroupExpandToggle()}
@@ -62645,14 +62649,14 @@ img.ProseMirror-separator {
62645
62649
  ], TableGroupRow.prototype, "animationClass", void 0);
62646
62650
  const nimbleTableGroupRow = TableGroupRow.compose({
62647
62651
  baseName: 'table-group-row',
62648
- template: template$d,
62652
+ template: template$f,
62649
62653
  styles: styles$e
62650
62654
  });
62651
62655
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTableGroupRow());
62652
62656
  const tableGroupRowTag = 'nimble-table-group-row';
62653
62657
 
62654
62658
  // prettier-ignore
62655
- const template$c = html `
62659
+ const template$e = html `
62656
62660
  <template
62657
62661
  role="grid"
62658
62662
  aria-multiselectable="${x => x.ariaMultiSelectable}"
@@ -64733,10 +64737,7 @@ img.ProseMirror-separator {
64733
64737
  void this.updateColumnsFromChildItems();
64734
64738
  }
64735
64739
  async updateColumnsFromChildItems() {
64736
- const definedElements = this.childItems.map(async (item) => (item.matches(':not(:defined)')
64737
- ? customElements.whenDefined(item.localName)
64738
- : Promise.resolve()));
64739
- await Promise.all(definedElements);
64740
+ await waitUntilCustomElementsDefinedAsync(this.childItems);
64740
64741
  this.columns = this.childItems.filter((x) => x instanceof TableColumn);
64741
64742
  }
64742
64743
  updateTanStack() {
@@ -65039,7 +65040,7 @@ img.ProseMirror-separator {
65039
65040
  ], Table.prototype, "documentShiftKeyDown", void 0);
65040
65041
  const nimbleTable = Table.compose({
65041
65042
  baseName: 'table',
65042
- template: template$c,
65043
+ template: template$e,
65043
65044
  styles: styles$j
65044
65045
  });
65045
65046
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTable());
@@ -65059,7 +65060,7 @@ img.ProseMirror-separator {
65059
65060
  // Avoiding a wrapping <template> and be careful about starting and ending whitspace
65060
65061
  // so the template can be composed into other column header templates
65061
65062
  // prettier-ignore
65062
- const template$b = html `<span
65063
+ const template$d = html `<span
65063
65064
  ${overflow('hasOverflow')}
65064
65065
  class="header-content"
65065
65066
  title=${x => (x.hasOverflow && x.headerTextContent ? x.headerTextContent : null)}
@@ -65160,7 +65161,7 @@ img.ProseMirror-separator {
65160
65161
 
65161
65162
  /* eslint-disable @typescript-eslint/indent */
65162
65163
  // prettier-ignore
65163
- const template$a = html `
65164
+ const template$c = html `
65164
65165
  <template
65165
65166
  @click="${(x, c) => {
65166
65167
  if (typeof x.cellRecord?.href === 'string') {
@@ -65227,7 +65228,7 @@ img.ProseMirror-separator {
65227
65228
  ], TableColumnAnchorCellView.prototype, "text", null);
65228
65229
  const anchorCellView = TableColumnAnchorCellView.compose({
65229
65230
  baseName: 'table-column-anchor-cell-view',
65230
- template: template$a,
65231
+ template: template$c,
65231
65232
  styles: styles$c
65232
65233
  });
65233
65234
  DesignSystem.getOrCreate().withPrefix('nimble').register(anchorCellView());
@@ -65254,7 +65255,7 @@ img.ProseMirror-separator {
65254
65255
  observable
65255
65256
  ], TableColumnTextGroupHeaderViewBase.prototype, "text", void 0);
65256
65257
 
65257
- const template$9 = html `
65258
+ const template$b = html `
65258
65259
  <span
65259
65260
  ${overflow('hasOverflow')}
65260
65261
  title="${x => (x.hasOverflow && x.text ? x.text : null)}"
@@ -65285,7 +65286,7 @@ img.ProseMirror-separator {
65285
65286
  }
65286
65287
  const tableColumnTextGroupHeaderView = TableColumnTextGroupHeaderView.compose({
65287
65288
  baseName: 'table-column-text-group-header-view',
65288
- template: template$9,
65289
+ template: template$b,
65289
65290
  styles: styles$b
65290
65291
  });
65291
65292
  DesignSystem.getOrCreate()
@@ -65399,7 +65400,7 @@ img.ProseMirror-separator {
65399
65400
  ], TableColumnAnchor.prototype, "download", void 0);
65400
65401
  const nimbleTableColumnAnchor = TableColumnAnchor.compose({
65401
65402
  baseName: 'table-column-anchor',
65402
- template: template$b,
65403
+ template: template$d,
65403
65404
  styles: styles$d
65404
65405
  });
65405
65406
  DesignSystem.getOrCreate()
@@ -65454,7 +65455,7 @@ img.ProseMirror-separator {
65454
65455
  }
65455
65456
  const tableColumnDateTextGroupHeaderView = TableColumnDateTextGroupHeaderView.compose({
65456
65457
  baseName: 'table-column-date-text-group-header-view',
65457
- template: template$9,
65458
+ template: template$b,
65458
65459
  styles: styles$b
65459
65460
  });
65460
65461
  DesignSystem.getOrCreate()
@@ -65470,7 +65471,7 @@ img.ProseMirror-separator {
65470
65471
  right: 'right'
65471
65472
  };
65472
65473
 
65473
- const template$8 = html `
65474
+ const template$a = html `
65474
65475
  <template
65475
65476
  class="${x => (x.alignment === TextCellViewBaseAlignment.right
65476
65477
  ? 'right-align'
@@ -65548,7 +65549,7 @@ img.ProseMirror-separator {
65548
65549
  }
65549
65550
  const dateTextCellView = TableColumnDateTextCellView.compose({
65550
65551
  baseName: 'table-column-date-text-cell-view',
65551
- template: template$8,
65552
+ template: template$a,
65552
65553
  styles: styles$a
65553
65554
  });
65554
65555
  DesignSystem.getOrCreate().withPrefix('nimble').register(dateTextCellView());
@@ -65852,7 +65853,7 @@ img.ProseMirror-separator {
65852
65853
  ], TableColumnDateText.prototype, "customHourCycle", void 0);
65853
65854
  const nimbleTableColumnDateText = TableColumnDateText.compose({
65854
65855
  baseName: 'table-column-date-text',
65855
- template: template$b,
65856
+ template: template$d,
65856
65857
  styles: styles$d
65857
65858
  });
65858
65859
  DesignSystem.getOrCreate()
@@ -65875,7 +65876,7 @@ img.ProseMirror-separator {
65875
65876
  }
65876
65877
  const durationTextCellView = TableColumnDurationTextCellView.compose({
65877
65878
  baseName: 'table-column-duration-text-cell-view',
65878
- template: template$8,
65879
+ template: template$a,
65879
65880
  styles: styles$a
65880
65881
  });
65881
65882
  DesignSystem.getOrCreate()
@@ -65983,7 +65984,7 @@ img.ProseMirror-separator {
65983
65984
  }
65984
65985
  const tableColumnDurationTextGroupHeaderView = TableColumnDurationTextGroupHeaderView.compose({
65985
65986
  baseName: 'table-column-duration-text-group-header-view',
65986
- template: template$9,
65987
+ template: template$b,
65987
65988
  styles: styles$b
65988
65989
  });
65989
65990
  DesignSystem.getOrCreate()
@@ -66036,7 +66037,7 @@ img.ProseMirror-separator {
66036
66037
  }
66037
66038
  const nimbleTableColumnDurationText = TableColumnDurationText.compose({
66038
66039
  baseName: 'table-column-duration-text',
66039
- template: template$b,
66040
+ template: template$d,
66040
66041
  styles: styles$d
66041
66042
  });
66042
66043
  DesignSystem.getOrCreate()
@@ -66157,7 +66158,7 @@ img.ProseMirror-separator {
66157
66158
  }
66158
66159
  `;
66159
66160
 
66160
- const template$7 = html `${template$b}<slot ${slotted('mappings')} name="mapping"></slot>`;
66161
+ const template$9 = html `${template$d}<slot ${slotted('mappings')} name="mapping"></slot>`;
66161
66162
 
66162
66163
  const enumBaseValidityFlagNames = [
66163
66164
  'invalidMappingKeyValueForType',
@@ -66268,7 +66269,7 @@ img.ProseMirror-separator {
66268
66269
  }
66269
66270
  const enumTextCellView = TableColumnEnumTextCellView.compose({
66270
66271
  baseName: 'table-column-enum-text-cell-view',
66271
- template: template$8,
66272
+ template: template$a,
66272
66273
  styles: styles$a
66273
66274
  });
66274
66275
  DesignSystem.getOrCreate().withPrefix('nimble').register(enumTextCellView());
@@ -66298,7 +66299,7 @@ img.ProseMirror-separator {
66298
66299
  }
66299
66300
  const enumTextGroupHeaderView = TableColumnEnumTextGroupHeaderView.compose({
66300
66301
  baseName: 'table-column-enum-text-group-header-view',
66301
- template: template$9,
66302
+ template: template$b,
66302
66303
  styles: styles$b
66303
66304
  });
66304
66305
  DesignSystem.getOrCreate()
@@ -66341,13 +66342,25 @@ img.ProseMirror-separator {
66341
66342
  }
66342
66343
  const nimbleTableColumnEnumText = TableColumnEnumText.compose({
66343
66344
  baseName: 'table-column-enum-text',
66344
- template: template$7,
66345
+ template: template$9,
66345
66346
  styles: styles$9
66346
66347
  });
66347
66348
  DesignSystem.getOrCreate()
66348
66349
  .withPrefix('nimble')
66349
66350
  .register(nimbleTableColumnEnumText());
66350
66351
 
66352
+ // Avoiding a wrapping <template> and be careful about starting and ending whitespace
66353
+ // so the template can be composed into other column header templates
66354
+ // prettier-ignore
66355
+ const template$8 = html `<span
66356
+ ${overflow('hasOverflow')}
66357
+ class="header-content"
66358
+ title=${x => (x.hasOverflow && x.headerTextContent ? x.headerTextContent : null)}
66359
+ >
66360
+ <slot ${ref('contentSlot')}></slot>
66361
+ <slot ${slotted({ property: 'unitElements', filter: elements() })} name="unit"></slot>
66362
+ </span>`;
66363
+
66351
66364
  /**
66352
66365
  * The group header view for displaying number fields as text.
66353
66366
  */
@@ -66359,13 +66372,12 @@ img.ProseMirror-separator {
66359
66372
  this.updateText();
66360
66373
  }
66361
66374
  updateText() {
66362
- this.text = this.columnConfig?.formatter?.formatValue(this.groupHeaderValue)
66363
- ?? '';
66375
+ this.text = this.columnConfig?.formatter?.format(this.groupHeaderValue) ?? '';
66364
66376
  }
66365
66377
  }
66366
66378
  const tableColumnNumberTextGroupHeaderView = TableColumnNumberTextGroupHeaderView.compose({
66367
66379
  baseName: 'table-column-number-text-group-header-view',
66368
- template: template$9,
66380
+ template: template$b,
66369
66381
  styles: styles$b
66370
66382
  });
66371
66383
  DesignSystem.getOrCreate()
@@ -66385,13 +66397,12 @@ img.ProseMirror-separator {
66385
66397
  this.updateText();
66386
66398
  }
66387
66399
  updateText() {
66388
- this.text = this.columnConfig?.formatter?.formatValue(this.cellRecord?.value)
66389
- ?? '';
66400
+ this.text = this.columnConfig?.formatter?.format(this.cellRecord?.value) ?? '';
66390
66401
  }
66391
66402
  }
66392
66403
  const numberTextCellView = TableColumnNumberTextCellView.compose({
66393
66404
  baseName: 'table-column-number-text-cell-view',
66394
- template: template$8,
66405
+ template: template$a,
66395
66406
  styles: styles$a
66396
66407
  });
66397
66408
  DesignSystem.getOrCreate().withPrefix('nimble').register(numberTextCellView());
@@ -66415,19 +66426,19 @@ img.ProseMirror-separator {
66415
66426
  };
66416
66427
 
66417
66428
  /**
66418
- * The base class for number formatters used by the number-text column.
66429
+ * The base class for unit formats.
66419
66430
  */
66420
- class NumberFormatter {
66431
+ class UnitFormat {
66421
66432
  /**
66422
- * Tries to format the passed value using the `format()` function implemented by a concrete implementation of the class.
66423
- * Returns an empty string if the value is not a number or if `format()` throws an error.
66433
+ * Formats a number value to a string.
66434
+ * For nullish values or values that result in an exception being thrown, empty string is returned
66424
66435
  */
66425
- formatValue(value) {
66436
+ format(value) {
66426
66437
  if (typeof value !== 'number') {
66427
66438
  return '';
66428
66439
  }
66429
66440
  try {
66430
- return this.format(value);
66441
+ return this.tryFormat(value);
66431
66442
  }
66432
66443
  catch {
66433
66444
  return '';
@@ -66436,81 +66447,254 @@ img.ProseMirror-separator {
66436
66447
  }
66437
66448
 
66438
66449
  /**
66439
- * The formatter for a number-text column whose format is configured to be 'default'.
66450
+ * A class that knows how to format a numeric value as a string that includes units.
66451
+ */
66452
+ class ScaledUnitFormat {
66453
+ constructor(scaledUnitFormatFactoryOptions) {
66454
+ this.locale = scaledUnitFormatFactoryOptions.locale;
66455
+ this.intlNumberFormatOptions = scaledUnitFormatFactoryOptions.intlNumberFormatOptions;
66456
+ }
66457
+ }
66458
+
66459
+ /**
66460
+ * A formatter for units that can be formatted/translated by Intl.NumberFormat
66461
+ */
66462
+ class IntlNumberFormatScaledUnitFormat extends ScaledUnitFormat {
66463
+ constructor(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions = {}) {
66464
+ super(scaledUnitFormatFactoryOptions);
66465
+ this.formatter = new Intl.NumberFormat(this.locale, {
66466
+ ...unitSpecificIntlNumberFormatOptions,
66467
+ // Application configured options override unit specific options
66468
+ ...this.intlNumberFormatOptions
66469
+ });
66470
+ }
66471
+ static createFactory(unitSpecificIntlNumberFormatOptions = {}) {
66472
+ return (scaledUnitFormatFactoryOptions) => new IntlNumberFormatScaledUnitFormat(scaledUnitFormatFactoryOptions, unitSpecificIntlNumberFormatOptions);
66473
+ }
66474
+ format(value) {
66475
+ return this.formatter.format(value);
66476
+ }
66477
+ }
66478
+
66479
+ /**
66480
+ * A unit that represents a scaled version of a base unit.
66481
+ */
66482
+ class ScaledUnit {
66483
+ constructor(scaleFactor, scaledUnitFormatFactory) {
66484
+ this.scaleFactor = scaleFactor;
66485
+ this.scaledUnitFormatFactory = scaledUnitFormatFactory;
66486
+ }
66487
+ isBase() {
66488
+ return this.scaleFactor === 1;
66489
+ }
66490
+ }
66491
+
66492
+ /**
66493
+ * A unit scale consisting of a set of scaled units.
66494
+ */
66495
+ class UnitScale {
66496
+ constructor(supportedScaledUnits) {
66497
+ this.supportedScaledUnits = supportedScaledUnits;
66498
+ const unitsSorted = supportedScaledUnits.every((curr, i, arr) => i === 0 || arr[i - 1].scaleFactor < curr.scaleFactor);
66499
+ if (!unitsSorted) {
66500
+ throw new Error('Supported scaled units must have unique and ordered scale factors');
66501
+ }
66502
+ const baseScaledUnit = supportedScaledUnits.find(x => x.isBase());
66503
+ if (!baseScaledUnit) {
66504
+ throw new Error('Supported scaled units must include a base scaled unit (scale factor=1)');
66505
+ }
66506
+ this.supportedScaledUnits = supportedScaledUnits;
66507
+ this.baseScaledUnit = baseScaledUnit;
66508
+ }
66509
+ // Note that for the sake of reducing complexity in the implementation,
66510
+ // we do NOT consider the effects of rounding when picking the unit to
66511
+ // use for a given value. If formatting results in rounding, a value
66512
+ // may be shown with an unexpected unit. Examples:
66513
+ // - 999 bytes with two significant digits => "1000 bytes" (instead of "1 kB")
66514
+ // - 0.00000000000000001 volts (= 0.01 fV) with one fractional digit => "0 fV" (instead of "0 volts")
66515
+ scaleNumber(number) {
66516
+ const magnitude = Math.abs(number);
66517
+ const onlyBaseScaledUnit = this.supportedScaledUnits.length === 1;
66518
+ if (onlyBaseScaledUnit
66519
+ || magnitude === 0
66520
+ || magnitude === Infinity
66521
+ || Number.isNaN(magnitude)) {
66522
+ return { scaledValue: number, scaledUnit: this.baseScaledUnit };
66523
+ }
66524
+ for (let i = this.supportedScaledUnits.length - 1; i >= 0; i -= 1) {
66525
+ const scaledUnit = this.supportedScaledUnits[i];
66526
+ if (magnitude / scaledUnit.scaleFactor >= 1) {
66527
+ return {
66528
+ scaledValue: number / scaledUnit.scaleFactor,
66529
+ scaledUnit
66530
+ };
66531
+ }
66532
+ }
66533
+ const smallestUnit = this.supportedScaledUnits[0];
66534
+ return {
66535
+ scaledValue: number / smallestUnit.scaleFactor,
66536
+ scaledUnit: smallestUnit
66537
+ };
66538
+ }
66539
+ }
66540
+
66541
+ /**
66542
+ * Unit scale that is used to passthrough a number without applying scaling or units
66440
66543
  */
66441
- class DefaultFormatter extends NumberFormatter {
66442
- constructor(locale) {
66544
+ class PassthroughUnitScale extends UnitScale {
66545
+ constructor() {
66546
+ super([
66547
+ new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory())
66548
+ ]);
66549
+ }
66550
+ }
66551
+ const passthroughUnitScale = new PassthroughUnitScale();
66552
+
66553
+ /**
66554
+ * Format for numbers with units to show in a tabular form.
66555
+ * Large and tiny numbers are shown exponentially and the rest as decimal.
66556
+ */
66557
+ class DefaultUnitFormat extends UnitFormat {
66558
+ constructor(locale, { unitScale = passthroughUnitScale } = {
66559
+ unitScale: passthroughUnitScale
66560
+ }) {
66443
66561
  super();
66444
- this.defaultFormatter = new Intl.NumberFormat(locale, {
66445
- maximumSignificantDigits: DefaultFormatter.maximumDigits,
66562
+ // Format options to use by default. It renders the number with a maximum of 6 signficant digits.
66563
+ this.defaultIntlNumberFormatOptions = {
66564
+ maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
66446
66565
  useGrouping: true
66447
- });
66448
- this.leadingZeroFormatter = new Intl.NumberFormat(locale, {
66449
- maximumFractionDigits: DefaultFormatter.maximumDigits - 1,
66566
+ };
66567
+ this.defaultScaledUnitFormatters = new Map();
66568
+ // Format options to use for numbers that have leading zeros. It limits the number of rendered
66569
+ // digits using 'maximumFractionDigits', which will result in less than 6 significant digits
66570
+ // in order to render no more than 6 total digits.
66571
+ this.leadingZeroIntlNumberFormatOptions = {
66572
+ maximumFractionDigits: DefaultUnitFormat.maximumDigits - 1,
66450
66573
  useGrouping: true
66451
- });
66452
- this.exponentialFormatter = new Intl.NumberFormat(locale, {
66453
- maximumSignificantDigits: DefaultFormatter.maximumDigits,
66574
+ };
66575
+ this.leadingZeroScaledUnitFormatters = new Map();
66576
+ // Format options for numbers that should be displayed in exponential notation. This should be used
66577
+ // for numbers with magintudes over 'exponentialUpperBound' or under 'exponentialLowerBound'.
66578
+ this.exponentialIntlNumberFormatOptions = {
66579
+ maximumSignificantDigits: DefaultUnitFormat.maximumDigits,
66454
66580
  notation: 'scientific'
66581
+ };
66582
+ for (const unit of unitScale.supportedScaledUnits) {
66583
+ this.defaultScaledUnitFormatters.set(unit.scaleFactor, unit.scaledUnitFormatFactory({
66584
+ locale,
66585
+ intlNumberFormatOptions: this.defaultIntlNumberFormatOptions
66586
+ }));
66587
+ this.leadingZeroScaledUnitFormatters.set(unit.scaleFactor, unit.scaledUnitFormatFactory({
66588
+ locale,
66589
+ intlNumberFormatOptions: this.leadingZeroIntlNumberFormatOptions
66590
+ }));
66591
+ }
66592
+ this.exponentialScaledUnitFormatter = unitScale.baseScaledUnit.scaledUnitFormatFactory({
66593
+ locale,
66594
+ intlNumberFormatOptions: this.exponentialIntlNumberFormatOptions
66455
66595
  });
66596
+ this.unitScale = unitScale;
66456
66597
  }
66457
- format(number) {
66458
- // The NumberFormat option of `signDisplay: "negative"` is not supported in all browsers nimble supports.
66459
- // Because that option cannot be used to avoid rendering "-0", coerce the value -0 to 0 prior to formatting.
66460
- const valueToFormat = number === 0 ? 0 : number;
66461
- const formatter = this.getFormatterForNumber(valueToFormat);
66462
- return formatter.format(valueToFormat);
66598
+ resolvedOptions() {
66599
+ return {
66600
+ unitScale: this.unitScale
66601
+ };
66463
66602
  }
66464
- getFormatterForNumber(number) {
66603
+ tryFormat(number) {
66604
+ // Normalize +0 / -0 --> +0
66605
+ const numberNormalized = number === 0 ? 0 : number;
66606
+ const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(numberNormalized);
66607
+ const numberStyle = this.resolveNumberStyle(scaledValue);
66608
+ switch (numberStyle) {
66609
+ case 'default': {
66610
+ const scaledUnitFormatter = this.defaultScaledUnitFormatters.get(scaledUnit.scaleFactor);
66611
+ return scaledUnitFormatter.format(scaledValue);
66612
+ }
66613
+ case 'leadingZero': {
66614
+ const scaledUnitFormatter = this.leadingZeroScaledUnitFormatters.get(scaledUnit.scaleFactor);
66615
+ return scaledUnitFormatter.format(scaledValue);
66616
+ }
66617
+ case 'exponential': {
66618
+ const scaledUnitFormatter = this.exponentialScaledUnitFormatter;
66619
+ return scaledUnitFormatter.format(numberNormalized);
66620
+ }
66621
+ default:
66622
+ throw new Error('Unexpected number format style');
66623
+ }
66624
+ }
66625
+ resolveNumberStyle(number) {
66465
66626
  if (number === 0) {
66466
- return this.defaultFormatter;
66627
+ return 'default';
66467
66628
  }
66468
66629
  const absoluteValue = Math.abs(number);
66469
- if (absoluteValue >= DefaultFormatter.exponentialUpperBound
66470
- || absoluteValue < DefaultFormatter.exponentialLowerBound) {
66471
- return this.exponentialFormatter;
66630
+ if (absoluteValue >= DefaultUnitFormat.exponentialUpperBound
66631
+ || absoluteValue < DefaultUnitFormat.exponentialLowerBound) {
66632
+ return 'exponential';
66472
66633
  }
66473
66634
  // Ideally, we could set 'roundingPriority: "lessPrecision"' with a formatter that has both 'maximumSignificantDigits' and
66474
66635
  // 'maximumFractionDigits' configured instead of having two different formatters that we conditionally choose between. However,
66475
- // 'roundingPrioirty' is not supported yet in all browsers nimble supports.
66636
+ // 'roundingPrioirty' is not supported yet in all browsers.
66476
66637
  if (absoluteValue < 1) {
66477
- return this.leadingZeroFormatter;
66638
+ return 'leadingZero';
66478
66639
  }
66479
- return this.defaultFormatter;
66640
+ return 'default';
66480
66641
  }
66481
66642
  }
66482
66643
  // The maximum number of digits that should be rendered for any given value.
66483
- DefaultFormatter.maximumDigits = 6;
66644
+ DefaultUnitFormat.maximumDigits = 6;
66484
66645
  // Use exponential notation for numbers that will be rendered with 3 leading 0s or more.
66485
66646
  // Because a maximum of 6 digits are rendered, showing more than 3 leading 0s is not ideal
66486
66647
  // because then at least half of the displayed digits will be leading 0s.
66487
- DefaultFormatter.exponentialLowerBound = 0.000995;
66648
+ DefaultUnitFormat.exponentialLowerBound = 0.000995;
66488
66649
  // Use exponential formatting for numbers whose magnitude cannot otherwise be displayed
66489
66650
  // with 6 digits or less.
66490
- DefaultFormatter.exponentialUpperBound = 999999.5;
66651
+ DefaultUnitFormat.exponentialUpperBound = 999999.5;
66491
66652
 
66492
66653
  /**
66493
- * The formatter for a number-text column whose format is configured to be 'decimal'.
66654
+ * Format for decimal numbers with units.
66494
66655
  */
66495
- class DecimalFormatter extends NumberFormatter {
66496
- constructor(locale, minimumFractionDigits, maximumFractionDigits) {
66656
+ class DecimalUnitFormat extends UnitFormat {
66657
+ constructor(locale, { minimumFractionDigits = 0, maximumFractionDigits = Math.max(3, minimumFractionDigits), unitScale = passthroughUnitScale } = {
66658
+ minimumFractionDigits: 0,
66659
+ maximumFractionDigits: 3,
66660
+ unitScale: passthroughUnitScale
66661
+ }) {
66497
66662
  super();
66498
- this.formatter = new Intl.NumberFormat(locale, {
66663
+ this.scaledUnitFormatters = new Map();
66664
+ const intlNumberFormatOptions = {
66499
66665
  maximumFractionDigits,
66500
66666
  minimumFractionDigits,
66501
66667
  useGrouping: true
66502
- });
66668
+ };
66669
+ for (const scaledUnit of unitScale.supportedScaledUnits) {
66670
+ this.scaledUnitFormatters.set(scaledUnit.scaleFactor, scaledUnit.scaledUnitFormatFactory({
66671
+ locale,
66672
+ intlNumberFormatOptions
66673
+ }));
66674
+ }
66503
66675
  this.tenPowDecimalDigits = 10 ** maximumFractionDigits;
66676
+ this.unitScale = unitScale;
66677
+ this.minimumFractionDigits = minimumFractionDigits;
66678
+ this.maximumFractionDigits = maximumFractionDigits;
66679
+ }
66680
+ resolvedOptions() {
66681
+ return {
66682
+ unitScale: this.unitScale,
66683
+ maximumFractionDigits: this.maximumFractionDigits,
66684
+ minimumFractionDigits: this.minimumFractionDigits
66685
+ };
66504
66686
  }
66505
- format(number) {
66506
- // The NumberFormat option of `signDisplay: "negative"` is not supported in all browsers nimble supports.
66507
- // Because that option cannot be used to avoid rendering "-0", coerce the value -0 to 0 prior to formatting.
66508
- const valueToFormat = this.willRoundToZero(number) ? 0 : number;
66509
- return this.formatter.format(valueToFormat);
66687
+ tryFormat(number) {
66688
+ const { scaledValue, scaledUnit } = this.unitScale.scaleNumber(number);
66689
+ const numberNormalized = this.willRoundToZero(scaledValue)
66690
+ ? 0
66691
+ : scaledValue;
66692
+ const scaledUnitFormatter = this.scaledUnitFormatters.get(scaledUnit.scaleFactor);
66693
+ return scaledUnitFormatter.format(numberNormalized);
66510
66694
  }
66511
66695
  willRoundToZero(number) {
66512
- // Multiply the value by 10 raised to decimal-digits so that Math.round can be used to emulate rounding to
66513
- // decimal-digits decimal places. If that rounded value is 0, then the value will be rendered with only 0s.
66696
+ // Multiply the value by 10 raised to maximumFractionDigits so that Math.round can be used to emulate rounding to
66697
+ // maximumFractionDigits decimal places. If that rounded value is 0, then the value will be rendered with only 0s.
66514
66698
  return Math.round(number * this.tenPowDecimalDigits) === 0;
66515
66699
  }
66516
66700
  }
@@ -66518,7 +66702,8 @@ img.ProseMirror-separator {
66518
66702
  const numberTextValidityFlagNames = [
66519
66703
  'invalidDecimalDigits',
66520
66704
  'invalidDecimalMaximumDigits',
66521
- 'decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits'
66705
+ 'decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits',
66706
+ 'moreThanOneUnitSpecified'
66522
66707
  ];
66523
66708
  // The maximum and minimum allowed configuration for 'maximumFractionDigits'
66524
66709
  // and 'minimumFractionDigits' on the NumberFormat.
@@ -66555,12 +66740,25 @@ img.ProseMirror-separator {
66555
66740
  : false;
66556
66741
  this.setConditionValue('decimalDigitsMutuallyExclusiveWithDecimalMaximumDigits', invalid);
66557
66742
  }
66743
+ validateAtMostOneUnit(unitElements) {
66744
+ const invalid = unitElements.length > 1;
66745
+ this.setConditionValue('moreThanOneUnitSpecified', invalid);
66746
+ }
66558
66747
  isInvalidDecimalDigitsValue(decimalDigits) {
66559
66748
  return (decimalDigits < minimumValidDecimalDigits
66560
66749
  || decimalDigits > maximumValidDecimalDigits);
66561
66750
  }
66562
66751
  }
66563
66752
 
66753
+ /**
66754
+ * The base class for an element that provides a unit scale for scaled unit conversions
66755
+ */
66756
+ class Unit extends FoundationElement {
66757
+ }
66758
+ __decorate$1([
66759
+ observable
66760
+ ], Unit.prototype, "resolvedUnitScale", void 0);
66761
+
66564
66762
  const defaultDecimalDigits = 2;
66565
66763
  /**
66566
66764
  * The table column for displaying numbers as text.
@@ -66575,6 +66773,11 @@ img.ProseMirror-separator {
66575
66773
  this.updateColumnConfig();
66576
66774
  }
66577
66775
  };
66776
+ this.unitSubscriber = {
66777
+ handleChange: () => {
66778
+ this.updateColumnConfig();
66779
+ }
66780
+ };
66578
66781
  }
66579
66782
  connectedCallback() {
66580
66783
  super.connectedCallback();
@@ -66597,6 +66800,17 @@ img.ProseMirror-separator {
66597
66800
  sortOperation: TableColumnSortOperation.basic
66598
66801
  };
66599
66802
  }
66803
+ updateUnitNotifier() {
66804
+ if (this.unitNotifier) {
66805
+ this.unitNotifier.unsubscribe(this.unitSubscriber);
66806
+ this.unitNotifier = undefined;
66807
+ }
66808
+ if (this.unit) {
66809
+ const notifier = Observable.getNotifier(this.unit);
66810
+ notifier.subscribe(this.unitSubscriber, 'resolvedUnitScale');
66811
+ this.unitNotifier = notifier;
66812
+ }
66813
+ }
66600
66814
  formatChanged() {
66601
66815
  this.updateColumnConfig();
66602
66816
  }
@@ -66609,10 +66823,25 @@ img.ProseMirror-separator {
66609
66823
  decimalMaximumDigitsChanged() {
66610
66824
  this.updateColumnConfig();
66611
66825
  }
66826
+ unitElementsChanged() {
66827
+ void this.updateUnit();
66828
+ }
66829
+ async updateUnit() {
66830
+ this.unit = undefined;
66831
+ if (this.unitElements) {
66832
+ await waitUntilCustomElementsDefinedAsync(this.unitElements);
66833
+ this.unit = this.unitElements.find((x) => x instanceof Unit);
66834
+ }
66835
+ this.updateUnitNotifier();
66836
+ }
66837
+ unitChanged() {
66838
+ this.updateColumnConfig();
66839
+ }
66612
66840
  updateColumnConfig() {
66613
66841
  this.validator.validateDecimalDigits(this.format, this.decimalDigits);
66614
66842
  this.validator.validateDecimalMaximumDigits(this.format, this.decimalMaximumDigits);
66615
66843
  this.validator.validateNoMutuallyExclusiveProperties(this.format, this.decimalDigits, this.decimalMaximumDigits);
66844
+ this.validator.validateAtMostOneUnit(this.unitElements ?? []);
66616
66845
  if (this.validator.isValid()) {
66617
66846
  const columnConfig = {
66618
66847
  formatter: this.createFormatter(),
@@ -66625,19 +66854,26 @@ img.ProseMirror-separator {
66625
66854
  }
66626
66855
  }
66627
66856
  createFormatter() {
66628
- let minimumDigits;
66629
- let maximumDigits;
66857
+ const unitScale = this.unit?.resolvedUnitScale;
66630
66858
  switch (this.format) {
66631
- case NumberTextFormat.decimal:
66632
- minimumDigits = typeof this.decimalMaximumDigits === 'number'
66859
+ case NumberTextFormat.decimal: {
66860
+ const minimumFractionDigits = typeof this.decimalMaximumDigits === 'number'
66633
66861
  ? 0
66634
66862
  : this.decimalDigits ?? defaultDecimalDigits;
66635
- maximumDigits = this.decimalMaximumDigits
66863
+ const maximumFractionDigits = this.decimalMaximumDigits
66636
66864
  ?? this.decimalDigits
66637
66865
  ?? defaultDecimalDigits;
66638
- return new DecimalFormatter(lang.getValueFor(this), minimumDigits, maximumDigits);
66639
- default:
66640
- return new DefaultFormatter(lang.getValueFor(this));
66866
+ return new DecimalUnitFormat(lang.getValueFor(this), {
66867
+ minimumFractionDigits,
66868
+ maximumFractionDigits,
66869
+ unitScale
66870
+ });
66871
+ }
66872
+ default: {
66873
+ return new DefaultUnitFormat(lang.getValueFor(this), {
66874
+ unitScale
66875
+ });
66876
+ }
66641
66877
  }
66642
66878
  }
66643
66879
  determineCellContentAlignment() {
@@ -66647,9 +66883,10 @@ img.ProseMirror-separator {
66647
66883
  if (this.alignment === NumberTextAlignment.right) {
66648
66884
  return TextCellViewBaseAlignment.right;
66649
66885
  }
66650
- // Look at format and decimal max digits to determine the default alignment
66886
+ // Look at format and decimal max digits and unit to determine the default alignment
66651
66887
  if (this.format === NumberTextFormat.decimal
66652
- && typeof this.decimalMaximumDigits !== 'number') {
66888
+ && typeof this.decimalMaximumDigits !== 'number'
66889
+ && !this.unit) {
66653
66890
  return TextCellViewBaseAlignment.right;
66654
66891
  }
66655
66892
  return TextCellViewBaseAlignment.left;
@@ -66670,9 +66907,15 @@ img.ProseMirror-separator {
66670
66907
  converter: nullableNumberConverter
66671
66908
  })
66672
66909
  ], TableColumnNumberText.prototype, "decimalMaximumDigits", void 0);
66910
+ __decorate$1([
66911
+ observable
66912
+ ], TableColumnNumberText.prototype, "unitElements", void 0);
66913
+ __decorate$1([
66914
+ observable
66915
+ ], TableColumnNumberText.prototype, "unit", void 0);
66673
66916
  const nimbleTableColumnNumberText = TableColumnNumberText.compose({
66674
66917
  baseName: 'table-column-number-text',
66675
- template: template$b,
66918
+ template: template$8,
66676
66919
  styles: styles$d
66677
66920
  });
66678
66921
  DesignSystem.getOrCreate()
@@ -66745,7 +66988,7 @@ img.ProseMirror-separator {
66745
66988
  `;
66746
66989
 
66747
66990
  // prettier-ignore
66748
- const template$6 = html `
66991
+ const template$7 = html `
66749
66992
  ${when(x => x.visual === 'icon', html `
66750
66993
  ${x => x.iconTemplate}
66751
66994
  <span
@@ -66837,13 +67080,13 @@ img.ProseMirror-separator {
66837
67080
  ], TableColumnIconGroupHeaderView.prototype, "visual", void 0);
66838
67081
  const iconGroupHeaderView = TableColumnIconGroupHeaderView.compose({
66839
67082
  baseName: 'table-column-icon-group-header-view',
66840
- template: template$6,
67083
+ template: template$7,
66841
67084
  styles: styles$8
66842
67085
  });
66843
67086
  DesignSystem.getOrCreate().withPrefix('nimble').register(iconGroupHeaderView());
66844
67087
  const tableColumnIconGroupHeaderViewTag = 'nimble-table-column-icon-group-header-view';
66845
67088
 
66846
- const template$5 = html `
67089
+ const template$6 = html `
66847
67090
  ${when(x => x.visual === 'icon', x => x.iconTemplate)}
66848
67091
  ${when(x => x.visual === 'spinner', html `
66849
67092
  <${spinnerTag}
@@ -66900,7 +67143,7 @@ img.ProseMirror-separator {
66900
67143
  ], TableColumnIconCellView.prototype, "visual", void 0);
66901
67144
  const iconCellView = TableColumnIconCellView.compose({
66902
67145
  baseName: 'table-column-icon-cell-view',
66903
- template: template$5
67146
+ template: template$6
66904
67147
  });
66905
67148
  DesignSystem.getOrCreate().withPrefix('nimble').register(iconCellView());
66906
67149
  const tableColumnIconCellViewTag = 'nimble-table-column-icon-cell-view';
@@ -66946,7 +67189,7 @@ img.ProseMirror-separator {
66946
67189
  }
66947
67190
  const nimbleTableColumnIcon = TableColumnIcon.compose({
66948
67191
  baseName: 'table-column-icon',
66949
- template: template$7,
67192
+ template: template$9,
66950
67193
  styles: styles$9
66951
67194
  });
66952
67195
  DesignSystem.getOrCreate()
@@ -66965,7 +67208,7 @@ img.ProseMirror-separator {
66965
67208
  }
66966
67209
  const textCellView = TableColumnTextCellView.compose({
66967
67210
  baseName: 'table-column-text-cell-view',
66968
- template: template$8,
67211
+ template: template$a,
66969
67212
  styles: styles$a
66970
67213
  });
66971
67214
  DesignSystem.getOrCreate().withPrefix('nimble').register(textCellView());
@@ -66987,7 +67230,7 @@ img.ProseMirror-separator {
66987
67230
  }
66988
67231
  const nimbleTableColumnText = TableColumnText.compose({
66989
67232
  baseName: 'table-column-text',
66990
- template: template$b,
67233
+ template: template$d,
66991
67234
  styles: styles$d
66992
67235
  });
66993
67236
  DesignSystem.getOrCreate()
@@ -67061,7 +67304,7 @@ img.ProseMirror-separator {
67061
67304
  }
67062
67305
  `;
67063
67306
 
67064
- const template$4 = html `
67307
+ const template$5 = html `
67065
67308
  <template slot="end">
67066
67309
  <div class="separator"></div>
67067
67310
  <slot></slot>
@@ -67075,7 +67318,7 @@ img.ProseMirror-separator {
67075
67318
  }
67076
67319
  const nimbleTabsToolbar = TabsToolbar.compose({
67077
67320
  baseName: 'tabs-toolbar',
67078
- template: template$4,
67321
+ template: template$5,
67079
67322
  styles: styles$6
67080
67323
  });
67081
67324
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTabsToolbar());
@@ -67250,7 +67493,7 @@ img.ProseMirror-separator {
67250
67493
  }
67251
67494
  `));
67252
67495
 
67253
- const template$3 = () => html `
67496
+ const template$4 = () => html `
67254
67497
  <label
67255
67498
  part="label"
67256
67499
  for="control"
@@ -67413,7 +67656,7 @@ img.ProseMirror-separator {
67413
67656
  const nimbleTextArea = TextArea.compose({
67414
67657
  baseName: 'text-area',
67415
67658
  baseClass: TextArea$1,
67416
- template: template$3,
67659
+ template: template$4,
67417
67660
  styles: styles$5,
67418
67661
  shadowOptions: {
67419
67662
  delegatesFocus: true
@@ -67802,7 +68045,7 @@ img.ProseMirror-separator {
67802
68045
  `));
67803
68046
 
67804
68047
  // prettier-ignore
67805
- const template$2 = html `
68048
+ const template$3 = html `
67806
68049
  ${when(x => x.tooltipVisible, html `
67807
68050
  <${anchoredRegionTag}
67808
68051
  class="anchored-region"
@@ -67854,7 +68097,7 @@ img.ProseMirror-separator {
67854
68097
  const nimbleTooltip = Tooltip.compose({
67855
68098
  baseName: 'tooltip',
67856
68099
  baseClass: Tooltip$1,
67857
- template: template$2,
68100
+ template: template$3,
67858
68101
  styles: styles$3
67859
68102
  });
67860
68103
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTooltip());
@@ -68181,7 +68424,7 @@ img.ProseMirror-separator {
68181
68424
  `;
68182
68425
 
68183
68426
  // prettier-ignore
68184
- const template$1 = html `
68427
+ const template$2 = html `
68185
68428
  <template
68186
68429
  role="tree"
68187
68430
  ${ref('treeView')}
@@ -68277,11 +68520,248 @@ img.ProseMirror-separator {
68277
68520
  const nimbleTreeView = TreeView.compose({
68278
68521
  baseName: 'tree-view',
68279
68522
  baseClass: TreeView$1,
68280
- template: template$1,
68523
+ template: template$2,
68281
68524
  styles: styles$1
68282
68525
  });
68283
68526
  DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTreeView());
68284
68527
 
68528
+ const template$1 = html `<template slot="unit"></template>`;
68529
+
68530
+ /**
68531
+ * A formatter for units that are not supported by Intl.NumberFormat
68532
+ */
68533
+ class ManuallyTranslatedScaledUnitFormat extends ScaledUnitFormat {
68534
+ constructor(scaledUnitFormatFactoryOptions, unitTranslations, unitPrefix) {
68535
+ super(scaledUnitFormatFactoryOptions);
68536
+ this.unitTranslations = unitTranslations;
68537
+ this.unitPrefix = unitPrefix;
68538
+ this.pluralRules = new Intl.PluralRules(this.locale);
68539
+ this.formatter = new Intl.NumberFormat(this.locale, this.intlNumberFormatOptions);
68540
+ this.unitTranslation = this.getTranslationToUse(this.locale);
68541
+ }
68542
+ static createFactory(unitTranslations, unitPrefix) {
68543
+ return (scaledUnitFormatFactoryOptions) => new ManuallyTranslatedScaledUnitFormat(scaledUnitFormatFactoryOptions, unitTranslations, unitPrefix);
68544
+ }
68545
+ format(value) {
68546
+ const formatted = this.formatter.format(value);
68547
+ if (!this.unitPrefix.isBase()) {
68548
+ return `${formatted} ${this.unitPrefix.text}${this.unitTranslation.symbol}`;
68549
+ }
68550
+ // Some languages have more than two forms (singular/plural) of cardinal
68551
+ // numbers, but we are treating anything other than the 'one' form as plural.
68552
+ // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules#description
68553
+ //
68554
+ // Because PluralRules.select() takes a number (not a string), it cannot differentiate
68555
+ // between 1 and 1.0. When NumberFormat is configured to format with a set number
68556
+ // of fractional digits, those fractional digits can have an effect on the pluralization
68557
+ // of the unit. E.g. in English, it formats "1 byte" vs "1.0 bytes". Thus there is
68558
+ // sometimes an inconsistency between unit pluralization for the same number, based
68559
+ // on whether it's supported by NumberFormat, or manually translated.
68560
+ const unitLabel = this.pluralRules.select(value) === 'one'
68561
+ ? this.unitTranslation.singular
68562
+ : this.unitTranslation.plural;
68563
+ return `${formatted} ${unitLabel}`;
68564
+ }
68565
+ getTranslationToUse(locale) {
68566
+ const localeObject = new Intl.Locale(locale ?? 'en');
68567
+ const language = localeObject.language;
68568
+ const region = localeObject.region;
68569
+ const regionSpecificMatchedTranslations = region
68570
+ ? this.unitTranslations.get(`${language}-${region}`) // do not include any other subtags that might be in the given locale string
68571
+ : null;
68572
+ return (regionSpecificMatchedTranslations
68573
+ ?? this.unitTranslations.get(language)
68574
+ ?? this.unitTranslations.get('en'));
68575
+ }
68576
+ }
68577
+
68578
+ /**
68579
+ * A unit scale that is not supported by Intl.NumberFormat and has manually provided translation strings
68580
+ */
68581
+ class ManuallyTranslatedUnitScale extends UnitScale {
68582
+ constructor(unitTranslations, supportedUnitPrefixes) {
68583
+ super(ManuallyTranslatedUnitScale.createSupportedScaledUnits(unitTranslations, supportedUnitPrefixes));
68584
+ }
68585
+ static createSupportedScaledUnits(unitTranslations, supportedUnitPrefixes) {
68586
+ if (!unitTranslations.get('en')) {
68587
+ throw new Error('English translations must exist');
68588
+ }
68589
+ const supportedUnits = supportedUnitPrefixes.map(unitPrefix => new ScaledUnit(unitPrefix.scaleFactor, ManuallyTranslatedScaledUnitFormat.createFactory(unitTranslations, unitPrefix)));
68590
+ return supportedUnits;
68591
+ }
68592
+ }
68593
+
68594
+ /**
68595
+ * A prefix that represents a scaling factor when applied to a base unit.
68596
+ * A base unit is represented as scale factor 1 and empty text.
68597
+ */
68598
+ class UnitPrefix {
68599
+ constructor(scaleFactor, text) {
68600
+ this.scaleFactor = scaleFactor;
68601
+ this.text = text;
68602
+ if (scaleFactor === 1 && text !== '') {
68603
+ throw new Error('Base scale factor of 1 has unused text and should be empty string');
68604
+ }
68605
+ }
68606
+ isBase() {
68607
+ return this.scaleFactor === 1;
68608
+ }
68609
+ }
68610
+
68611
+ /**
68612
+ * Representations of a base unit in a particular language
68613
+ */
68614
+ class UnitTranslation {
68615
+ constructor(singular, plural, symbol) {
68616
+ this.singular = singular;
68617
+ this.plural = plural;
68618
+ this.symbol = symbol;
68619
+ }
68620
+ }
68621
+
68622
+ /**
68623
+ * Byte units (1024-based)
68624
+ */
68625
+ class Byte1024UnitScale extends ManuallyTranslatedUnitScale {
68626
+ constructor() {
68627
+ super(new Map([
68628
+ ['en', new UnitTranslation('byte', 'bytes', 'B')],
68629
+ ['fr', new UnitTranslation('octet', 'octets', 'o')],
68630
+ ['de', new UnitTranslation('Byte', 'Byte', 'B')],
68631
+ ['ja', new UnitTranslation('バイト', 'バイト', 'B')],
68632
+ ['zh', new UnitTranslation('字节', '字节', 'B')]
68633
+ ]), [
68634
+ new UnitPrefix(1024 ** 0, ''),
68635
+ new UnitPrefix(1024 ** 1, 'Ki'),
68636
+ new UnitPrefix(1024 ** 2, 'Mi'),
68637
+ new UnitPrefix(1024 ** 3, 'Gi'),
68638
+ new UnitPrefix(1024 ** 4, 'Ti'),
68639
+ new UnitPrefix(1024 ** 5, 'Pi')
68640
+ ]);
68641
+ }
68642
+ }
68643
+ const byte1024UnitScale = new Byte1024UnitScale();
68644
+
68645
+ /**
68646
+ * Byte units (1000-based)
68647
+ */
68648
+ class ByteUnitScale extends UnitScale {
68649
+ constructor() {
68650
+ super([
68651
+ new ScaledUnit(10 ** 0, IntlNumberFormatScaledUnitFormat.createFactory({
68652
+ style: 'unit',
68653
+ unit: 'byte',
68654
+ unitDisplay: 'long'
68655
+ })),
68656
+ new ScaledUnit(10 ** 3, IntlNumberFormatScaledUnitFormat.createFactory({
68657
+ style: 'unit',
68658
+ unit: 'kilobyte',
68659
+ unitDisplay: 'short'
68660
+ })),
68661
+ new ScaledUnit(10 ** 6, IntlNumberFormatScaledUnitFormat.createFactory({
68662
+ style: 'unit',
68663
+ unit: 'megabyte',
68664
+ unitDisplay: 'short'
68665
+ })),
68666
+ new ScaledUnit(10 ** 9, IntlNumberFormatScaledUnitFormat.createFactory({
68667
+ style: 'unit',
68668
+ unit: 'gigabyte',
68669
+ unitDisplay: 'short'
68670
+ })),
68671
+ new ScaledUnit(10 ** 12, IntlNumberFormatScaledUnitFormat.createFactory({
68672
+ style: 'unit',
68673
+ unit: 'terabyte',
68674
+ unitDisplay: 'short'
68675
+ })),
68676
+ new ScaledUnit(10 ** 15, IntlNumberFormatScaledUnitFormat.createFactory({
68677
+ style: 'unit',
68678
+ unit: 'petabyte',
68679
+ unitDisplay: 'short'
68680
+ }))
68681
+ ]);
68682
+ }
68683
+ }
68684
+ const byteUnitScale = new ByteUnitScale();
68685
+
68686
+ /**
68687
+ * Element that provides a unit scale for conversion of bytes
68688
+ */
68689
+ class UnitByte extends Unit {
68690
+ constructor() {
68691
+ super();
68692
+ /**
68693
+ * Use binary (base 1024 scale with binary prefixes) instead of
68694
+ * the default of decimal (base 1000 scale with metric prefixes)
68695
+ */
68696
+ this.binary = false;
68697
+ this.resolvedUnitScale = byteUnitScale;
68698
+ }
68699
+ binaryChanged() {
68700
+ this.resolvedUnitScale = this.binary
68701
+ ? byte1024UnitScale
68702
+ : byteUnitScale;
68703
+ }
68704
+ }
68705
+ __decorate$1([
68706
+ attr({ mode: 'boolean' })
68707
+ ], UnitByte.prototype, "binary", void 0);
68708
+ const nimbleUnitByte = UnitByte.compose({
68709
+ baseName: 'unit-byte',
68710
+ template: template$1
68711
+ });
68712
+ DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleUnitByte());
68713
+
68714
+ /**
68715
+ * The metric unit prefixes for at least English, French, German, Japanese, and Chinese.
68716
+ */
68717
+ const unitPrefixesMetric = [
68718
+ new UnitPrefix(10 ** -15, 'f'),
68719
+ new UnitPrefix(10 ** -12, 'p'),
68720
+ new UnitPrefix(10 ** -9, 'n'),
68721
+ new UnitPrefix(10 ** -6, 'μ'),
68722
+ new UnitPrefix(10 ** -3, 'm'),
68723
+ new UnitPrefix(10 ** -2, 'c'),
68724
+ new UnitPrefix(10 ** -1, 'd'),
68725
+ new UnitPrefix(10 ** 0, ''),
68726
+ new UnitPrefix(10 ** 3, 'k'),
68727
+ new UnitPrefix(10 ** 6, 'M'),
68728
+ new UnitPrefix(10 ** 9, 'G'),
68729
+ new UnitPrefix(10 ** 12, 'T'),
68730
+ new UnitPrefix(10 ** 15, 'P'),
68731
+ new UnitPrefix(10 ** 18, 'E')
68732
+ ];
68733
+
68734
+ /**
68735
+ * Voltage unit scale
68736
+ */
68737
+ class VoltUnitScale extends ManuallyTranslatedUnitScale {
68738
+ constructor() {
68739
+ super(new Map([
68740
+ ['en', new UnitTranslation('volt', 'volts', 'V')],
68741
+ ['fr', new UnitTranslation('volt', 'volts', 'V')],
68742
+ ['de', new UnitTranslation('Volt', 'Volt', 'V')],
68743
+ ['ja', new UnitTranslation('ボルト', 'ボルト', 'V')],
68744
+ ['zh', new UnitTranslation('伏特', '伏特', 'V')]
68745
+ ]), unitPrefixesMetric);
68746
+ }
68747
+ }
68748
+ const voltUnitScale = new VoltUnitScale();
68749
+
68750
+ /**
68751
+ * Element representing units for volts
68752
+ */
68753
+ class UnitVolt extends Unit {
68754
+ constructor() {
68755
+ super();
68756
+ this.resolvedUnitScale = voltUnitScale;
68757
+ }
68758
+ }
68759
+ const nimbleUnitVolt = UnitVolt.compose({
68760
+ baseName: 'unit-volt',
68761
+ template: template$1
68762
+ });
68763
+ DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleUnitVolt());
68764
+
68285
68765
  var noop = {value: () => {}};
68286
68766
 
68287
68767
  function dispatch() {