@itwin/imodel-components-react 4.13.4 → 4.14.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 (200) hide show
  1. package/CHANGELOG.md +3 -8
  2. package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js +1 -2
  4. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  6. package/lib/cjs/imodel-components-react/color/AlphaSlider.js +0 -16
  7. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  8. package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  9. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +0 -1
  10. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  11. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +0 -1
  13. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  14. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  15. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +0 -4
  16. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  17. package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/HueSlider.js +0 -21
  19. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  20. package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  21. package/lib/cjs/imodel-components-react/color/SaturationPicker.js +0 -25
  22. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  23. package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
  24. package/lib/cjs/imodel-components-react/color/Swatch.js +0 -1
  25. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  27. package/lib/cjs/imodel-components-react/editors/ColorEditor.js +2 -13
  28. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  29. package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  30. package/lib/cjs/imodel-components-react/editors/WeightEditor.js +2 -11
  31. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  32. package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  33. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +0 -6
  34. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  35. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  36. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +1 -15
  37. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
  39. package/lib/cjs/imodel-components-react/lineweight/Swatch.js +0 -1
  40. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  42. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +0 -9
  43. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  44. package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
  45. package/lib/cjs/imodel-components-react/navigationaids/Cube.js +0 -1
  46. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  47. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  48. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +1 -27
  49. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  51. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +9 -34
  52. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  53. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  54. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +0 -1
  55. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  57. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -6
  58. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  59. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  60. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +2 -12
  61. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  62. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  63. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +2 -7
  64. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  65. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  66. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +0 -7
  67. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  68. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  69. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +0 -1
  70. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  71. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  72. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +0 -1
  73. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  74. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  75. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -5
  76. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  77. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
  78. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +6 -12
  79. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  80. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  81. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +0 -1
  82. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  83. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts.map +1 -1
  84. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +2 -10
  85. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  86. package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
  87. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +0 -2
  88. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  89. package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  90. package/lib/cjs/imodel-components-react/timeline/Scrubber.js +0 -6
  91. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  92. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
  93. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +0 -1
  94. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  95. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  96. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +0 -17
  97. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  98. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
  99. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +0 -1
  100. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  101. package/lib/esm/imodel-components-react/UiIModelComponents.d.ts.map +1 -1
  102. package/lib/esm/imodel-components-react/UiIModelComponents.js +1 -2
  103. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  104. package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
  105. package/lib/esm/imodel-components-react/color/AlphaSlider.js +0 -16
  106. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  107. package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.map +1 -1
  108. package/lib/esm/imodel-components-react/color/ColorPickerButton.js +0 -1
  109. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  110. package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
  111. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +0 -1
  112. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  113. package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
  114. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +0 -4
  115. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  116. package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
  117. package/lib/esm/imodel-components-react/color/HueSlider.js +0 -21
  118. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  119. package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
  120. package/lib/esm/imodel-components-react/color/SaturationPicker.js +0 -25
  121. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  122. package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
  123. package/lib/esm/imodel-components-react/color/Swatch.js +0 -1
  124. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  125. package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts.map +1 -1
  126. package/lib/esm/imodel-components-react/editors/ColorEditor.js +2 -13
  127. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  128. package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts.map +1 -1
  129. package/lib/esm/imodel-components-react/editors/WeightEditor.js +2 -11
  130. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  131. package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
  132. package/lib/esm/imodel-components-react/inputs/QuantityInput.js +0 -6
  133. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  134. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts.map +1 -1
  135. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +1 -15
  136. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  137. package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
  138. package/lib/esm/imodel-components-react/lineweight/Swatch.js +0 -1
  139. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  140. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
  141. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +0 -9
  142. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  143. package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
  144. package/lib/esm/imodel-components-react/navigationaids/Cube.js +0 -1
  145. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  146. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
  147. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +1 -27
  148. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  149. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
  150. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +9 -34
  151. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  152. package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
  153. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +0 -1
  154. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  155. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
  156. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +2 -6
  157. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  158. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
  159. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +2 -12
  160. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  161. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
  162. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +2 -7
  163. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  164. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
  165. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +0 -7
  166. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  167. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
  168. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +0 -1
  169. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  170. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
  171. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +0 -1
  172. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  173. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
  174. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +2 -5
  175. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  176. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
  177. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +6 -12
  178. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  179. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  180. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +0 -1
  181. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  182. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts.map +1 -1
  183. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +2 -10
  184. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  185. package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts.map +1 -1
  186. package/lib/esm/imodel-components-react/timeline/InlineEdit.js +0 -2
  187. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  188. package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
  189. package/lib/esm/imodel-components-react/timeline/Scrubber.js +0 -6
  190. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  191. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
  192. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +0 -1
  193. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  194. package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
  195. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +0 -17
  196. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  197. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts.map +1 -1
  198. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +0 -1
  199. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  200. package/package.json +5 -5
@@ -52,7 +52,6 @@ function UomSeparatorSelector(props) {
52
52
  { value: "-", label: translate("QuantityFormat.dash") },
53
53
  ];
54
54
  const completeListOfEntries = [];
55
- // istanbul ignore next (only used if format already has a character that does not match standard options)
56
55
  if (undefined ===
57
56
  uomDefaultEntries.find((option) => option.value === separator)) {
58
57
  completeListOfEntries.push({ value: separator, label: separator });
@@ -79,12 +78,10 @@ function FormatUnitLabel(props) {
79
78
  let formatTraits = [traitStr];
80
79
  if (setActive) {
81
80
  // setting trait
82
- // istanbul ignore else
83
81
  if (formatProps.formatTraits) {
84
82
  const traits = Array.isArray(formatProps.formatTraits)
85
83
  ? formatProps.formatTraits
86
- : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
87
- // istanbul ignore else
84
+ : formatProps.formatTraits.split(/,|;|\|/);
88
85
  if (!traits.find((traitEntry) => traitStr === traitEntry)) {
89
86
  formatTraits = [...traits, traitStr];
90
87
  }
@@ -92,12 +89,11 @@ function FormatUnitLabel(props) {
92
89
  }
93
90
  else {
94
91
  // clearing trait
95
- // istanbul ignore next
96
92
  if (!formatProps.formatTraits)
97
93
  return;
98
94
  const traits = Array.isArray(formatProps.formatTraits)
99
95
  ? formatProps.formatTraits
100
- : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
96
+ : formatProps.formatTraits.split(/,|;|\|/);
101
97
  formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);
102
98
  }
103
99
  const newFormatProps = { ...formatProps, formatTraits };
@@ -1 +1 @@
1
- {"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAG/B,wDAA4E;AAE5E,wDAAwD;AACxD,sDAAmD;AAQnD,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAEvC,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,iBAAiB,GAA2B;YAChD,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,CAAC,EAAE;YACtD,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,sBAAsB,CAAC,EAAE;YACxD,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,SAAS,CAAC,qBAAqB,CAAC,EAAE;SACxD,CAAC;QACF,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QAEzD,0GAA0G;QAC1G,IACE,SAAS;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EAC9D,CAAC;YACD,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,CAA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CAAsC,EAAE,EAAE;QACzC,cAAc,CAAC,4BAAY,CAAC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/D,CAAC,EACD,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAC5B,SAAS,CAAC,uCAAuC,CAAC,CAC9C;QACP,oBAAC,wBAAQ,mBACK,0BAA0B,EACtC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,EACrD,QAAQ,EAAE,yBAAyB,GACnC;QACF,8BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,cAAc,EACd,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,IAAI,iBAAiB,CACnE,IAEA,SAAS,CAAC,sCAAsC,CAAC,CAC7C;QACP,oBAAC,oBAAoB,mBACP,sBAAsB,EAClC,SAAS,EAAE,WAAW,CAAC,YAAY,IAAI,EAAE,EACzC,QAAQ,EAAE,wBAAwB,EAClC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,GACvD,CACD,CACJ,CAAC;AACJ,CAAC;AA5FD,0CA4FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Checkbox, Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../useTranslation\";\n\ninterface UomSeparatorSelectorProps extends CommonProps {\n separator: string;\n disabled?: boolean;\n onChange: (value: string) => void;\n}\n\nfunction UomSeparatorSelector(props: UomSeparatorSelectorProps) {\n const { separator, onChange, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n { value: \"\", label: translate(\"QuantityFormat.none\") },\n { value: \" \", label: translate(\"QuantityFormat.space\") },\n { value: \"-\", label: translate(\"QuantityFormat.dash\") },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n\n // istanbul ignore next (only used if format already has a character that does not match standard options)\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n onChange={handleOnChange}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n\n/** Properties of [[FormatUnitLabel]] component.\n * @alpha\n */\nexport interface FormatUnitLabelProps extends CommonProps {\n formatProps: FormatProps;\n onUnitLabelChange?: (format: FormatProps) => void;\n}\n\n/** Component to set the label separator definition in a Quantity Format and if it the label is to be displayed.\n * @alpha\n */\nexport function FormatUnitLabel(props: FormatUnitLabelProps) {\n const { formatProps, onUnitLabelChange } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n onUnitLabelChange && onUnitLabelChange(newProps);\n },\n [onUnitLabelChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n // istanbul ignore else\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n // istanbul ignore next\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUomSeparatorChange = React.useCallback(\n (newSeparator: string) => {\n const newFormatProps = { ...formatProps, uomSeparator: newSeparator };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowUnitLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ShowUnitLabel, e.target.checked);\n },\n [setFormatTrait]\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.appendUnitLabel\")}\n </span>\n <Checkbox\n data-testid=\"show-unit-label-checkbox\"\n checked={isFormatTraitSet(FormatTraits.ShowUnitLabel)}\n onChange={handleShowUnitLabelChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.ShowUnitLabel) && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.labelSeparator\")}\n </span>\n <UomSeparatorSelector\n data-testid=\"uom-separator-select\"\n separator={formatProps.uomSeparator ?? \"\"}\n onChange={handleUomSeparatorChange}\n disabled={!isFormatTraitSet(FormatTraits.ShowUnitLabel)}\n />\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":";AAAA;;;gGAGg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SAAS,CAAC,uCAAuC,CAAC,CAC9C;QACP,oBAAC,wBAAQ,mBACK,0BAA0B,EACtC,OAAO,EAAE,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,EACrD,QAAQ,EAAE,yBAAyB,GACnC;QACF,8BACE,SAAS,EAAE,IAAA,oBAAU,EACnB,cAAc,EACd,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,IAAI,iBAAiB,CACnE,IAEA,SAAS,CAAC,sCAAsC,CAAC,CAC7C;QACP,oBAAC,oBAAoB,mBACP,sBAAsB,EAClC,SAAS,EAAE,WAAW,CAAC,YAAY,IAAI,EAAE,EACzC,QAAQ,EAAE,wBAAwB,EAClC,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,GACvD,CACD,CACJ,CAAC;AACJ,CAAC;AAvFD,0CAuFC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Checkbox, Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../useTranslation\";\n\ninterface UomSeparatorSelectorProps extends CommonProps {\n separator: string;\n disabled?: boolean;\n onChange: (value: string) => void;\n}\n\nfunction UomSeparatorSelector(props: UomSeparatorSelectorProps) {\n const { separator, onChange, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n { value: \"\", label: translate(\"QuantityFormat.none\") },\n { value: \" \", label: translate(\"QuantityFormat.space\") },\n { value: \"-\", label: translate(\"QuantityFormat.dash\") },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n onChange={handleOnChange}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n\n/** Properties of [[FormatUnitLabel]] component.\n * @alpha\n */\nexport interface FormatUnitLabelProps extends CommonProps {\n formatProps: FormatProps;\n onUnitLabelChange?: (format: FormatProps) => void;\n}\n\n/** Component to set the label separator definition in a Quantity Format and if it the label is to be displayed.\n * @alpha\n */\nexport function FormatUnitLabel(props: FormatUnitLabelProps) {\n const { formatProps, onUnitLabelChange } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n onUnitLabelChange && onUnitLabelChange(newProps);\n },\n [onUnitLabelChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUomSeparatorChange = React.useCallback(\n (newSeparator: string) => {\n const newFormatProps = { ...formatProps, uomSeparator: newSeparator };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowUnitLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ShowUnitLabel, e.target.checked);\n },\n [setFormatTrait]\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.appendUnitLabel\")}\n </span>\n <Checkbox\n data-testid=\"show-unit-label-checkbox\"\n checked={isFormatTraitSet(FormatTraits.ShowUnitLabel)}\n onChange={handleShowUnitLabelChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.ShowUnitLabel) && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.labelSeparator\")}\n </span>\n <UomSeparatorSelector\n data-testid=\"uom-separator-select\"\n separator={formatProps.uomSeparator ?? \"\"}\n onChange={handleUomSeparatorChange}\n disabled={!isFormatTraitSet(FormatTraits.ShowUnitLabel)}\n />\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatUnits.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAK9B;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,aAAa,EAAE,WAAW,CAAC;IAC3B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAiKlD"}
1
+ {"version":3,"file":"FormatUnits.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EACV,WAAW,EACX,SAAS,EACT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAK9B;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,WAAW;IACnD,aAAa,EAAE,WAAW,CAAC;IAC3B,eAAe,CAAC,EAAE,SAAS,CAAC;IAC5B,aAAa,EAAE,aAAa,CAAC;IAC7B,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC/C;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,qBAuJlD"}
@@ -54,12 +54,10 @@ function FormatUnits(props) {
54
54
  onUnitsChange && onUnitsChange(newProps);
55
55
  }, [onUnitsChange]);
56
56
  const handleUnitLabelChange = React.useCallback((newLabel, index) => {
57
- // istanbul ignore else
58
57
  if (formatProps.composite &&
59
58
  formatProps.composite.units.length > index &&
60
59
  index >= 0) {
61
60
  const units = formatProps.composite.units.map((entry, ndx) => {
62
- // istanbul ignore else
63
61
  if (index === ndx)
64
62
  return { name: entry.name, label: newLabel };
65
63
  else
@@ -73,7 +71,6 @@ function FormatUnits(props) {
73
71
  const handleUnitChange = React.useCallback((newUnit, index) => {
74
72
  const unitParts = newUnit.split(/:/);
75
73
  if (unitParts[0] === "REMOVEUNIT") {
76
- // istanbul ignore else
77
74
  if (formatProps.composite && formatProps.composite.units.length > 1) {
78
75
  const units = [...formatProps.composite.units];
79
76
  units.pop();
@@ -88,20 +85,16 @@ function FormatUnits(props) {
88
85
  ...formatProps.composite.units,
89
86
  { name: unitParts[1], label: unitParts[2] },
90
87
  ]
91
- : /* istanbul ignore next*/ [
92
- { name: unitParts[1], label: unitParts[2] },
93
- ];
88
+ : [{ name: unitParts[1], label: unitParts[2] }];
94
89
  const composite = { ...formatProps.composite, units };
95
90
  const newFormatProps = { ...formatProps, composite };
96
91
  handleSetFormatProps(newFormatProps);
97
92
  }
98
93
  else {
99
- // istanbul ignore else
100
94
  if (formatProps.composite &&
101
95
  formatProps.composite.units.length > index &&
102
96
  index >= 0) {
103
97
  const units = formatProps.composite.units.map((entry, ndx) => {
104
- // istanbul ignore else
105
98
  if (index === ndx)
106
99
  return { name: unitParts[0], label: unitParts[1] };
107
100
  else
@@ -121,11 +114,8 @@ function FormatUnits(props) {
121
114
  }
122
115
  }, [formatProps, handleSetFormatProps]);
123
116
  const handleOnSpacerChange = React.useCallback((e) => {
124
- // istanbul ignore else
125
117
  if (formatProps.composite) {
126
- const spacerValue = e.target.value.length
127
- ? e.target.value[0]
128
- : /* istanbul ignore next */ ""; // spacer can only be empty or a single character
118
+ const spacerValue = e.target.value.length ? e.target.value[0] : ""; // spacer can only be empty or a single character
129
119
  const composite = { ...formatProps.composite, spacer: spacerValue };
130
120
  const newFormatProps = { ...formatProps, composite };
131
121
  handleSetFormatProps(newFormatProps);
@@ -1 +1 @@
1
- {"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAO/B,wDAA6C;AAC7C,gDAA6C;AAC7C,sDAAmD;AAYnD;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,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a,EAC5B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,qBAAqB,EACpC,QAAQ,EAAE,KAAK,GAAG,WAAW,CAAC,SAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,GACzD,CACH,CAAC;YACJ,CAAC,CAAC,eAAe,IAAI,CACjB,oBAAC,qBAAS,IACR,GAAG,EAAE,eAAe,CAAC,IAAI,EACzB,IAAI,EAAE,eAAe,CAAC,IAAI,EAC1B,KAAK,EAAE,eAAe,CAAC,KAAK,EAC5B,aAAa,EAAE,aAAa,EAC5B,KAAK,EAAE,CAAC,EACR,YAAY,EAAE,gBAAgB,EAC9B,aAAa,EAAE,qBAAqB,GACpC,CACH;QAEJ,WAAW,CAAC,SAAS,EAAE,KAAK;YAC3B,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CACxC;YACE,8BAAM,GAAG,EAAE,wBAAwB,EAAE,SAAS,EAAE,cAAc,IAC3D,SAAS,CAAC,uCAAuC,CAAC,CAC9C;YACP,oBAAC,qBAAK,IACJ,GAAG,EAAE,kBAAkB,iBACX,kBAAkB,EAC9B,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EACzC,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CACF,CACJ,CAAC;AACJ,CAAC;AAjKD,kCAiKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatUnits]] component.\n * @alpha\n */\nexport interface FormatUnitsProps extends CommonProps {\n initialFormat: FormatProps;\n persistenceUnit?: UnitProps;\n unitsProvider: UnitsProvider;\n onUnitsChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Units used for Quantity Formatting.\n * @alpha\n */\nexport function FormatUnits(props: FormatUnitsProps) {\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } =\n props;\n const { translate } = useTranslation();\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n\n React.useEffect(() => {\n if (initialFormatRef.current !== initialFormat) {\n initialFormatRef.current = initialFormat;\n setFormatProps(initialFormat);\n }\n }, [initialFormat]);\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n },\n [onUnitsChange]\n );\n\n const handleUnitLabelChange = React.useCallback(\n (newLabel: string, index: number) => {\n // istanbul ignore else\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx) return { name: entry.name, label: newLabel };\n else return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUnitChange = React.useCallback(\n (newUnit: string, index: number) => {\n const unitParts = newUnit.split(/:/);\n if (unitParts[0] === \"REMOVEUNIT\") {\n // istanbul ignore else\n if (formatProps.composite && formatProps.composite.units.length > 1) {\n const units = [...formatProps.composite.units];\n units.pop();\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\n const units =\n formatProps.composite && formatProps.composite.units.length\n ? [\n ...formatProps.composite.units,\n { name: unitParts[1], label: unitParts[2] },\n ]\n : /* istanbul ignore next*/ [\n { name: unitParts[1], label: unitParts[2] },\n ];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n // istanbul ignore else\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx)\n return { name: unitParts[0], label: unitParts[1] };\n else return entry;\n });\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else if (!formatProps.composite) {\n const composite = {\n units: [{ name: unitParts[0], label: unitParts[1] }],\n };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleOnSpacerChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (formatProps.composite) {\n const spacerValue = e.target.value.length\n ? e.target.value[0]\n : /* istanbul ignore next */ \"\"; // spacer can only be empty or a single character\n const composite = { ...formatProps.composite, spacer: spacerValue };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {formatProps.composite?.units\n ? formatProps.composite.units.map((value, index) => (\n <UnitDescr\n key={value.name}\n name={value.name}\n label={value.label ?? \"\"}\n parentUnitName={\n index > 0\n ? formatProps.composite!.units[index - 1].name\n : undefined\n }\n unitsProvider={unitsProvider}\n index={index}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n readonly={index < formatProps.composite!.units.length - 1}\n />\n ))\n : persistenceUnit && (\n <UnitDescr\n key={persistenceUnit.name}\n name={persistenceUnit.name}\n label={persistenceUnit.label}\n unitsProvider={unitsProvider}\n index={0}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n />\n )}\n\n {formatProps.composite?.units &&\n formatProps.composite.units.length > 1 && (\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.compositeSpacer\")}\n </span>\n <Input\n key={\"composite-spacer\"}\n data-testid=\"composite-spacer\"\n value={formatProps.composite.spacer ?? \"\"}\n onChange={handleOnSpacerChange}\n size=\"small\"\n />\n </>\n )}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAO/B,wDAA6C;AAC7C,gDAA6C;AAC7C,sDAAmD;AAYnD;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GACpE,KAAK,CAAC;IACR,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IACvC,MAAM,gBAAgB,GAAG,KAAK,CAAC,MAAM,CAAc,aAAa,CAAC,CAAC;IAClE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IAEpE,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,gBAAgB,CAAC,OAAO,KAAK,aAAa,EAAE,CAAC;YAC/C,gBAAgB,CAAC,OAAO,GAAG,aAAa,CAAC;YACzC,cAAc,CAAC,aAAa,CAAC,CAAC;QAChC,CAAC;IACH,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC;IAEpB,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAC5C,CAAC,QAAqB,EAAE,EAAE;QACxB,cAAc,CAAC,QAAQ,CAAC,CAAC;QACzB,aAAa,IAAI,aAAa,CAAC,QAAQ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AC,MAAM,IAAI,EAAE,EACzC,QAAQ,EAAE,oBAAoB,EAC9B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CACF,CACJ,CAAC;AACJ,CAAC;AAvJD,kCAuJC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[FormatUnits]] component.\n * @alpha\n */\nexport interface FormatUnitsProps extends CommonProps {\n initialFormat: FormatProps;\n persistenceUnit?: UnitProps;\n unitsProvider: UnitsProvider;\n onUnitsChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Units used for Quantity Formatting.\n * @alpha\n */\nexport function FormatUnits(props: FormatUnitsProps) {\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } =\n props;\n const { translate } = useTranslation();\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n\n React.useEffect(() => {\n if (initialFormatRef.current !== initialFormat) {\n initialFormatRef.current = initialFormat;\n setFormatProps(initialFormat);\n }\n }, [initialFormat]);\n\n const handleSetFormatProps = React.useCallback(\n (newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n },\n [onUnitsChange]\n );\n\n const handleUnitLabelChange = React.useCallback(\n (newLabel: string, index: number) => {\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n if (index === ndx) return { name: entry.name, label: newLabel };\n else return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUnitChange = React.useCallback(\n (newUnit: string, index: number) => {\n const unitParts = newUnit.split(/:/);\n if (unitParts[0] === \"REMOVEUNIT\") {\n if (formatProps.composite && formatProps.composite.units.length > 1) {\n const units = [...formatProps.composite.units];\n units.pop();\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\n const units =\n formatProps.composite && formatProps.composite.units.length\n ? [\n ...formatProps.composite.units,\n { name: unitParts[1], label: unitParts[2] },\n ]\n : [{ name: unitParts[1], label: unitParts[2] }];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n if (\n formatProps.composite &&\n formatProps.composite.units.length > index &&\n index >= 0\n ) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n if (index === ndx)\n return { name: unitParts[0], label: unitParts[1] };\n else return entry;\n });\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else if (!formatProps.composite) {\n const composite = {\n units: [{ name: unitParts[0], label: unitParts[1] }],\n };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleOnSpacerChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n if (formatProps.composite) {\n const spacerValue = e.target.value.length ? e.target.value[0] : \"\"; // spacer can only be empty or a single character\n const composite = { ...formatProps.composite, spacer: spacerValue };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {formatProps.composite?.units\n ? formatProps.composite.units.map((value, index) => (\n <UnitDescr\n key={value.name}\n name={value.name}\n label={value.label ?? \"\"}\n parentUnitName={\n index > 0\n ? formatProps.composite!.units[index - 1].name\n : undefined\n }\n unitsProvider={unitsProvider}\n index={index}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n readonly={index < formatProps.composite!.units.length - 1}\n />\n ))\n : persistenceUnit && (\n <UnitDescr\n key={persistenceUnit.name}\n name={persistenceUnit.name}\n label={persistenceUnit.label}\n unitsProvider={unitsProvider}\n index={0}\n onUnitChange={handleUnitChange}\n onLabelChange={handleUnitLabelChange}\n />\n )}\n\n {formatProps.composite?.units &&\n formatProps.composite.units.length > 1 && (\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.compositeSpacer\")}\n </span>\n <Input\n key={\"composite-spacer\"}\n data-testid=\"composite-spacer\"\n value={formatProps.composite.spacer ?? \"\"}\n onChange={handleOnSpacerChange}\n size=\"small\"\n />\n </>\n )}\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MiscFormatOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAqBxE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBA0W9D"}
1
+ {"version":3,"file":"MiscFormatOptions.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAqBxE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACzC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,WAAW,EAAE,OAAO,CAAC;IACrB,iBAAiB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAmW9D"}
@@ -71,12 +71,10 @@ function MiscFormatOptions(props) {
71
71
  let formatTraits = [traitStr];
72
72
  if (setActive) {
73
73
  // setting trait
74
- // istanbul ignore else
75
74
  if (formatProps.formatTraits) {
76
75
  const traits = Array.isArray(formatProps.formatTraits)
77
76
  ? formatProps.formatTraits
78
- : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
79
- // istanbul ignore else
77
+ : formatProps.formatTraits.split(/,|;|\|/);
80
78
  if (!traits.find((traitEntry) => traitStr === traitEntry)) {
81
79
  formatTraits = [...traits, traitStr];
82
80
  }
@@ -84,12 +82,11 @@ function MiscFormatOptions(props) {
84
82
  }
85
83
  else {
86
84
  // clearing trait
87
- // istanbul ignore next
88
85
  if (!formatProps.formatTraits)
89
86
  return;
90
87
  const traits = Array.isArray(formatProps.formatTraits)
91
88
  ? formatProps.formatTraits
92
- : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
89
+ : formatProps.formatTraits.split(/,|;|\|/);
93
90
  formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);
94
91
  }
95
92
  const newFormatProps = { ...formatProps, formatTraits };
@@ -113,7 +110,6 @@ function MiscFormatOptions(props) {
113
110
  const handleDecimalSeparatorChange = React.useCallback((decimalSeparator) => {
114
111
  let thousandSeparator = formatProps.thousandSeparator;
115
112
  // make sure 1000 and decimal separator do not match
116
- // istanbul ignore else
117
113
  if (isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator)) {
118
114
  switch (decimalSeparator) {
119
115
  case ".":
@@ -147,7 +143,6 @@ function MiscFormatOptions(props) {
147
143
  onShowHideOptions(!showOptions);
148
144
  }, [onShowHideOptions, showOptions]);
149
145
  const handleKeyUpOnLink = React.useCallback((e) => {
150
- // istanbul ignore else
151
146
  if (e.key === ts_key_enum_1.Key.Enter.valueOf() || e.key === " ") {
152
147
  onShowHideOptions(!showOptions);
153
148
  e.preventDefault();
@@ -1 +1 @@
1
- {"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAElC,wDAAgD;AAEhD,wDAW8B;AAC9B,kDAAuD;AACvD,kEAA+D;AAC/D,8DAAmE;AACnE,0DAA+D;AAC/D,8EAA2E;AAC3E,oEAAiE;AACjE,sDAAmD;AAcnD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,uBAAuB,GACxB,GAAG,KAAK,C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AC;oBAC3D,CAAC,CAAC,8BAAc,CAAC,UAAU,EAE/B,QAAQ,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,EAC9C,QAAQ,EAAE,0BAA0B,GACpC;YAED,KAAK,CAAC,QAAQ;YAEd,uBAAuB,IAAI,WAAW,IAAI,CACzC,2BACE,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,qCAAqC,EAChD,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,IAEV,SAAS,CAAC,iCAAiC,CAAC,CAC3C,CACL,CACA,CACJ,CACA,CACJ,CAAC;AACJ,CAAC;AA1WD,8CA0WC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport type { FormatProps, ShowSignOption } from \"@itwin/core-quantity\";\nimport {\n Format,\n FormatTraits,\n FormatType,\n getTraitString,\n parseFormatType,\n parseScientificType,\n parseShowSignOption,\n ScientificType,\n scientificTypeToString,\n showSignOptionToString,\n} from \"@itwin/core-quantity\";\nimport { SignOptionSelector } from \"./misc/SignOption\";\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[MiscFormatOptions]] component.\n * @alpha\n */\nexport interface MiscFormatOptionsProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n enableMinimumProperties?: boolean;\n showOptions: boolean;\n onShowHideOptions: (show: boolean) => void;\n children?: React.ReactNode;\n}\n\n/** Component use to set miscellaneous properties is a Formatted Quantity.\n * @alpha\n */\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\n const {\n formatProps,\n onChange,\n showOptions,\n onShowHideOptions,\n enableMinimumProperties,\n } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newFormatProps: FormatProps) => {\n onChange && onChange(newFormatProps);\n },\n [onChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleShowSignChange = React.useCallback(\n (option: ShowSignOption) => {\n const newShowSignOption = showSignOptionToString(option);\n const newFormatProps = {\n ...formatProps,\n showSignOption: newShowSignOption,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n // istanbul ignore else\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n // istanbul ignore next\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowTrailingZeroesChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepDecimalPointChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepSingleZeroChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleZeroEmptyChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleUseFractionDashChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleDecimalSeparatorChange = React.useCallback(\n (decimalSeparator: string) => {\n let thousandSeparator = formatProps.thousandSeparator;\n // make sure 1000 and decimal separator do not match\n // istanbul ignore else\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n switch (decimalSeparator) {\n case \".\":\n thousandSeparator = \",\";\n break;\n case \",\":\n thousandSeparator = \".\";\n break;\n }\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const handleScientificTypeChange = React.useCallback(\n (type: ScientificType) => {\n const newFormatProps = {\n ...formatProps,\n scientificType: scientificTypeToString(type),\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleFormatChange = React.useCallback(\n (newFormatProps: FormatProps) => {\n handleSetFormatProps(newFormatProps);\n },\n [handleSetFormatProps]\n );\n\n const formatType = React.useMemo(\n () => parseFormatType(formatProps.type, \"format\"),\n [formatProps.type]\n );\n const showSignOption = React.useMemo(\n () =>\n parseShowSignOption(\n formatProps.showSignOption ?? \"onlyNegative\",\n \"format\"\n ),\n [formatProps.showSignOption]\n );\n\n const handleToggleButtonClick = React.useCallback(() => {\n onShowHideOptions(!showOptions);\n }, [onShowHideOptions, showOptions]);\n\n const handleKeyUpOnLink = React.useCallback(\n (e: React.KeyboardEvent<HTMLAnchorElement>) => {\n // istanbul ignore else\n if (e.key === Key.Enter.valueOf() || e.key === \" \") {\n onShowHideOptions(!showOptions);\n e.preventDefault();\n }\n },\n [onShowHideOptions, showOptions]\n );\n\n const handleStationSeparatorChange = React.useCallback(\n (value: string) => {\n const newFormatProps = { ...formatProps, stationSeparator: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleStationOffsetChange = React.useCallback(\n (value: number) => {\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {enableMinimumProperties && !showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.moreLabel\")}\n </a>\n )}\n {(!enableMinimumProperties || showOptions) && (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.signOptionLabel\")}\n </span>\n <SignOptionSelector\n data-testid=\"sign-option-selector\"\n signOption={showSignOption}\n onChange={handleShowSignChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.stationOffsetLabel\")}\n </span>\n <StationSizeSelector\n data-testid=\"station-size-selector\"\n value={formatProps.stationOffsetSize ?? 2}\n disabled={formatType !== FormatType.Station}\n onChange={handleStationOffsetChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.stationSeparatorLabel\")}\n </span>\n <StationSeparatorSelector\n data-testid=\"station-separator-selector\"\n separator={\n undefined !== formatProps.stationSeparator\n ? formatProps.stationSeparator\n : \"+\"\n }\n disabled={formatType !== FormatType.Station}\n onChange={handleStationSeparatorChange}\n />\n\n <ThousandsSeparator\n formatProps={formatProps}\n onChange={handleFormatChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.decimalSeparatorLabel\")}\n </span>\n <DecimalSeparatorSelector\n data-testid=\"decimal-separator-selector\"\n separator={formatProps.decimalSeparator ?? \".\"}\n onChange={handleDecimalSeparatorChange}\n disabled={formatType === FormatType.Fractional}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.showTrailZerosLabel\")}\n </span>\n <Checkbox\n data-testid=\"show-trail-zeros\"\n checked={isFormatTraitSet(FormatTraits.TrailZeroes)}\n onChange={handleShowTrailingZeroesChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.keepDecimalPointLabel\")}\n </span>\n <Checkbox\n data-testid=\"keep-decimal-point\"\n checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)}\n onChange={handleKeepDecimalPointChange}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.keepSingleZeroLabel\")}\n </span>\n <Checkbox\n data-testid=\"keep-single-zero\"\n checked={isFormatTraitSet(FormatTraits.KeepSingleZero)}\n onChange={handleKeepSingleZeroChange}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.zeroEmptyLabel\")}\n </span>\n <Checkbox\n data-testid=\"zero-empty\"\n checked={isFormatTraitSet(FormatTraits.ZeroEmpty)}\n onChange={handleZeroEmptyChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.fractionDashLabel\")}\n </span>\n <Checkbox\n data-testid=\"fraction-dash\"\n checked={isFormatTraitSet(FormatTraits.FractionDash)}\n onChange={handleUseFractionDashChange}\n disabled={formatType !== FormatType.Fractional}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Scientific && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.scientificTypeLabel\")}\n </span>\n <ScientificTypeSelector\n data-testid=\"scientific-type-selector\"\n type={\n formatProps.scientificType &&\n formatProps.scientificType.length > 0\n ? parseScientificType(formatProps.scientificType, \"custom\")\n : ScientificType.Normalized\n }\n disabled={formatType !== FormatType.Scientific}\n onChange={handleScientificTypeChange}\n />\n\n {props.children}\n\n {enableMinimumProperties && showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.lessLabel\")}\n </a>\n )}\n </>\n )}\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAElC,wDAAgD;AAEhD,wDAW8B;AAC9B,kDAAuD;AACvD,kEAA+D;AAC/D,8DAAmE;AACnE,0DAA+D;AAC/D,8EAA2E;AAC3E,oEAAiE;AACjE,sDAAmD;AAcnD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EACJ,WAAW,EACX,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,uBAAuB,GACxB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CAAC,UAAU,EAC9C,QAAQ,EAAE,0BAA0B,GACpC;YAED,KAAK,CAAC,QAAQ;YAEd,uBAAuB,IAAI,WAAW,IAAI,CACzC,2BACE,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,iBAAiB,EAC1B,SAAS,EAAE,qCAAqC,EAChD,IAAI,EAAC,MAAM,EACX,QAAQ,EAAE,CAAC,IAEV,SAAS,CAAC,iCAAiC,CAAC,CAC3C,CACL,CACA,CACJ,CACA,CACJ,CAAC;AACJ,CAAC;AAnWD,8CAmWC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport type { FormatProps, ShowSignOption } from \"@itwin/core-quantity\";\nimport {\n Format,\n FormatTraits,\n FormatType,\n getTraitString,\n parseFormatType,\n parseScientificType,\n parseShowSignOption,\n ScientificType,\n scientificTypeToString,\n showSignOptionToString,\n} from \"@itwin/core-quantity\";\nimport { SignOptionSelector } from \"./misc/SignOption\";\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties of [[MiscFormatOptions]] component.\n * @alpha\n */\nexport interface MiscFormatOptionsProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n enableMinimumProperties?: boolean;\n showOptions: boolean;\n onShowHideOptions: (show: boolean) => void;\n children?: React.ReactNode;\n}\n\n/** Component use to set miscellaneous properties is a Formatted Quantity.\n * @alpha\n */\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\n const {\n formatProps,\n onChange,\n showOptions,\n onShowHideOptions,\n enableMinimumProperties,\n } = props;\n const { translate } = useTranslation();\n\n const handleSetFormatProps = React.useCallback(\n (newFormatProps: FormatProps) => {\n onChange && onChange(newFormatProps);\n },\n [onChange]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleShowSignChange = React.useCallback(\n (option: ShowSignOption) => {\n const newShowSignOption = showSignOptionToString(option);\n const newFormatProps = {\n ...formatProps,\n showSignOption: newShowSignOption,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {\n // clearing trait\n if (!formatProps.formatTraits) return;\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleShowTrailingZeroesChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepDecimalPointChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleKeepSingleZeroChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleZeroEmptyChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleUseFractionDashChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const handleDecimalSeparatorChange = React.useCallback(\n (decimalSeparator: string) => {\n let thousandSeparator = formatProps.thousandSeparator;\n // make sure 1000 and decimal separator do not match\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n switch (decimalSeparator) {\n case \".\":\n thousandSeparator = \",\";\n break;\n case \",\":\n thousandSeparator = \".\";\n break;\n }\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const handleScientificTypeChange = React.useCallback(\n (type: ScientificType) => {\n const newFormatProps = {\n ...formatProps,\n scientificType: scientificTypeToString(type),\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleFormatChange = React.useCallback(\n (newFormatProps: FormatProps) => {\n handleSetFormatProps(newFormatProps);\n },\n [handleSetFormatProps]\n );\n\n const formatType = React.useMemo(\n () => parseFormatType(formatProps.type, \"format\"),\n [formatProps.type]\n );\n const showSignOption = React.useMemo(\n () =>\n parseShowSignOption(\n formatProps.showSignOption ?? \"onlyNegative\",\n \"format\"\n ),\n [formatProps.showSignOption]\n );\n\n const handleToggleButtonClick = React.useCallback(() => {\n onShowHideOptions(!showOptions);\n }, [onShowHideOptions, showOptions]);\n\n const handleKeyUpOnLink = React.useCallback(\n (e: React.KeyboardEvent<HTMLAnchorElement>) => {\n if (e.key === Key.Enter.valueOf() || e.key === \" \") {\n onShowHideOptions(!showOptions);\n e.preventDefault();\n }\n },\n [onShowHideOptions, showOptions]\n );\n\n const handleStationSeparatorChange = React.useCallback(\n (value: string) => {\n const newFormatProps = { ...formatProps, stationSeparator: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleStationOffsetChange = React.useCallback(\n (value: number) => {\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n return (\n <>\n {enableMinimumProperties && !showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.moreLabel\")}\n </a>\n )}\n {(!enableMinimumProperties || showOptions) && (\n <>\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.signOptionLabel\")}\n </span>\n <SignOptionSelector\n data-testid=\"sign-option-selector\"\n signOption={showSignOption}\n onChange={handleShowSignChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.stationOffsetLabel\")}\n </span>\n <StationSizeSelector\n data-testid=\"station-size-selector\"\n value={formatProps.stationOffsetSize ?? 2}\n disabled={formatType !== FormatType.Station}\n onChange={handleStationOffsetChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Station && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.stationSeparatorLabel\")}\n </span>\n <StationSeparatorSelector\n data-testid=\"station-separator-selector\"\n separator={\n undefined !== formatProps.stationSeparator\n ? formatProps.stationSeparator\n : \"+\"\n }\n disabled={formatType !== FormatType.Station}\n onChange={handleStationSeparatorChange}\n />\n\n <ThousandsSeparator\n formatProps={formatProps}\n onChange={handleFormatChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.decimalSeparatorLabel\")}\n </span>\n <DecimalSeparatorSelector\n data-testid=\"decimal-separator-selector\"\n separator={formatProps.decimalSeparator ?? \".\"}\n onChange={handleDecimalSeparatorChange}\n disabled={formatType === FormatType.Fractional}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.showTrailZerosLabel\")}\n </span>\n <Checkbox\n data-testid=\"show-trail-zeros\"\n checked={isFormatTraitSet(FormatTraits.TrailZeroes)}\n onChange={handleShowTrailingZeroesChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType === FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.keepDecimalPointLabel\")}\n </span>\n <Checkbox\n data-testid=\"keep-decimal-point\"\n checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)}\n onChange={handleKeepDecimalPointChange}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.keepSingleZeroLabel\")}\n </span>\n <Checkbox\n data-testid=\"keep-single-zero\"\n checked={isFormatTraitSet(FormatTraits.KeepSingleZero)}\n onChange={handleKeepSingleZeroChange}\n />\n\n <span className={\"uicore-label\"}>\n {translate(\"QuantityFormat.labels.zeroEmptyLabel\")}\n </span>\n <Checkbox\n data-testid=\"zero-empty\"\n checked={isFormatTraitSet(FormatTraits.ZeroEmpty)}\n onChange={handleZeroEmptyChange}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Fractional && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.fractionDashLabel\")}\n </span>\n <Checkbox\n data-testid=\"fraction-dash\"\n checked={isFormatTraitSet(FormatTraits.FractionDash)}\n onChange={handleUseFractionDashChange}\n disabled={formatType !== FormatType.Fractional}\n />\n\n <span\n className={classnames(\n \"uicore-label\",\n formatType !== FormatType.Scientific && \"uicore-disabled\"\n )}\n >\n {translate(\"QuantityFormat.labels.scientificTypeLabel\")}\n </span>\n <ScientificTypeSelector\n data-testid=\"scientific-type-selector\"\n type={\n formatProps.scientificType &&\n formatProps.scientificType.length > 0\n ? parseScientificType(formatProps.scientificType, \"custom\")\n : ScientificType.Normalized\n }\n disabled={formatType !== FormatType.Scientific}\n onChange={handleScientificTypeChange}\n />\n\n {props.children}\n\n {enableMinimumProperties && showOptions && (\n <a // eslint-disable-line jsx-a11y/anchor-is-valid\n onClick={handleToggleButtonClick}\n onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"}\n role=\"link\"\n tabIndex={0}\n >\n {translate(\"QuantityFormat.labels.lessLabel\")}\n </a>\n )}\n </>\n )}\n </>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityFormatPanel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8FrD;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,YAAY,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qBA2KlE"}
1
+ {"version":3,"file":"QuantityFormatPanel.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAS9B,OAAO,KAAK,EACV,WAAW,EAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA8FrD;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,WAAW;IAC3D,YAAY,EAAE,eAAe,CAAC;IAC9B,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC/C,qDAAqD;IACrD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,wBAAwB,qBAsKlE"}
@@ -77,13 +77,11 @@ function QuantityFormatPanel(props) {
77
77
  const [persistenceUnit, setPersistenceUnit] = React.useState();
78
78
  React.useEffect(() => {
79
79
  const newFormatProps = core_frontend_1.IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);
80
- // istanbul ignore else
81
80
  if (!initialFormatProps.current)
82
81
  initialFormatProps.current = newFormatProps;
83
82
  setFormatProps(newFormatProps);
84
83
  const quantityTypeKey = (0, core_frontend_1.getQuantityTypeKey)(quantityType);
85
84
  const quantityTypeDefinition = core_frontend_1.IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);
86
- // istanbul ignore else
87
85
  if (quantityTypeDefinition)
88
86
  setPersistenceUnit(quantityTypeDefinition.persistenceUnit);
89
87
  else
@@ -93,7 +91,6 @@ function QuantityFormatPanel(props) {
93
91
  // eslint-disable-next-line react-hooks/exhaustive-deps
94
92
  React.useEffect(() => {
95
93
  const newFormatProps = core_frontend_1.IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);
96
- // istanbul ignore else
97
94
  if (initialFormatProps.current && newFormatProps) {
98
95
  if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {
99
96
  initialFormatProps.current = newFormatProps;
@@ -111,10 +108,8 @@ function QuantityFormatPanel(props) {
111
108
  return createCheckboxFormatPropEditor(`${spec.editorType}-${index}`, spec.label, inProps, spec.getBool, spec.setBool, fireFormatChange);
112
109
  if ((0, core_frontend_1.isTextSelectFormatPropEditorSpec)(spec))
113
110
  return createSelectFormatPropEditor(`${spec.editorType}-${index}`, spec.label, spec.selectOptions, inProps, spec.getString, spec.setString, fireFormatChange);
114
- /* istanbul ignore else */
115
111
  if ((0, core_frontend_1.isTextInputFormatPropEditorSpec)(spec))
116
112
  return createTextInputFormatPropEditor(`${spec.editorType}-${index}`, spec.label, inProps, spec.getString, spec.setString, fireFormatChange);
117
- /* istanbul ignore next */
118
113
  return React.createElement("div", { key: index });
119
114
  });
120
115
  }, []);
@@ -124,7 +119,6 @@ function QuantityFormatPanel(props) {
124
119
  if (quantityTypeDefinition &&
125
120
  (0, core_frontend_1.isCustomQuantityTypeDefinition)(quantityTypeDefinition) &&
126
121
  quantityTypeDefinition.isCompatibleFormatProps(inProps)) {
127
- // istanbul ignore else
128
122
  if (quantityTypeDefinition.primaryPropEditorSpecs)
129
123
  return createCustomPropEditors(quantityTypeDefinition.primaryPropEditorSpecs, inProps, fireFormatChange);
130
124
  }
@@ -136,7 +130,6 @@ function QuantityFormatPanel(props) {
136
130
  if (quantityTypeDefinition &&
137
131
  (0, core_frontend_1.isCustomQuantityTypeDefinition)(quantityTypeDefinition) &&
138
132
  quantityTypeDefinition.isCompatibleFormatProps(inProps)) {
139
- // istanbul ignore else
140
133
  if (quantityTypeDefinition.secondaryPropEditorSpecs)
141
134
  return createCustomPropEditors(quantityTypeDefinition.secondaryPropEditorSpecs, inProps, fireFormatChange);
142
135
  }
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAK/B,wDAO8B;AAO9B,wDAA+D;AAC/D,+CAA4C;AAC5C,wDAAmD;AAEnD,SAAS,+BAA+B,CACtC,GAAW,EACX,KAAa,EACb,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAAG,GAAG,EAAE;QAC3B,8BAAM,GAAG,EAAE,GAAG,GAAG,QAAQ,EAAE,SAAS,EAAE,cAAc,IACjD,KAAK,CACD;QACP,oBAAC,qBAAK,mBACS,GAAG,GAAG,SAAS,EAC5B,GAAG,EAAE,GAAG,GAAG,SAAS,EACpB,KAAK,EAAE,KAAK,EACZ,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,QAAQ,GAAG,SAAS,CAAC,OAAO,EAAE,CAAC,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAC3D,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC7B,CAAC,GACD,CACa,CAClB,CAAC;AACJ,CAAC;AACD,SAAS,4BAA4B,CACnC,GAAW,EACX,KAAa,EACb,OAA2C,EAC3C,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,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,IAAI,sBAAsB,CAAC,wBAAwB;gBACjD,OAAO,uBAAuB,CAC5B,sBAAsB,CAAC,wBAAwB,EAC/C,OAAO,EACP,gBAAgB,CACjB,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EACD,CAAC,uBAAuB,EAAE,YAAY,CAAC,CACxC,CAAC;IAEF,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,KAAK,EACH,OAAoB,EACpB,gBAA2B,EAC3B,cAA6B,EAC7B,EAAE;QACF,OAAO,yBAAS,CAAC,iBAAiB,CAAC,2BAA2B,CAC5D,YAAY,EACZ,OAAO,CACR,CAAC;IACJ,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,OAAO,CACL,6BAAK,SAAS,EAAC,yCAAyC,IACrD,eAAe,IAAI,WAAW,IAAI,CACjC,oBAAC,yBAAW,IACV,cAAc,EAAE,qBAAqB,KACjC,UAAU,EACd,aAAa,EAAE,WAAW,EAC1B,aAAa,EAAE,yBAAS,CAAC,iBAAiB,CAAC,aAAa,EACxD,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CACG,CACP,CAAC;AACJ,CAAC;AA3KD,kDA2KC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type {\n CustomFormatPropEditorSpec,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport {\n getQuantityTypeKey,\n IModelApp,\n isCheckboxFormatPropEditorSpec,\n isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec,\n isTextSelectFormatPropEditorSpec,\n} from \"@itwin/core-frontend\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\nimport { FormatPanel } from \"./FormatPanel\";\nimport { DeepCompare } from \"@itwin/core-geometry\";\n\nfunction createTextInputFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Input\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n size=\"small\"\n onChange={(e) => {\n const newProps = setString(inProps, e.currentTarget.value);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\nfunction createSelectFormatPropEditor(\n key: string,\n label: string,\n options: { label: string; value: string }[],\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Select\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n options={options}\n size={\"small\"}\n onChange={(newValue) => {\n const newProps = setString(inProps, newValue);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction createCheckboxFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getBool: (props: FormatProps) => boolean,\n setBool: (props: FormatProps, isChecked: boolean) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Checkbox\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\n const compare = new DeepCompare();\n return compare.compare(obj1, obj2);\n}\n\n/** Properties of [[QuantityFormatPanel]] component.\n * @alpha\n */\nexport interface QuantityFormatPanelProps extends CommonProps {\n quantityType: QuantityTypeArg;\n onFormatChange?: (format: FormatProps) => void;\n /** props below are to be passed on to FormatPanel */\n showSample?: boolean;\n initialMagnitude?: number;\n enableMinimumProperties?: boolean;\n}\n\n/** Component to set properties that control Quantity Formatting.\n * @alpha\n */\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\n const { quantityType, onFormatChange, ...otherProps } = props;\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\n const initialFormatProps = React.useRef<FormatProps>();\n\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\n\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n // istanbul ignore else\n if (!initialFormatProps.current)\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n // istanbul ignore else\n if (quantityTypeDefinition)\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\n else\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\n }, [quantityType]); // no dependencies defined as we want this to run on every render\n\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n // istanbul ignore else\n if (initialFormatProps.current && newFormatProps) {\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n }\n }\n }); // no dependencies defined as we want this to run on every render\n\n const handleOnFormatChanged = React.useCallback(\n async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const createCustomPropEditors = React.useCallback(\n (\n specs: CustomFormatPropEditorSpec[],\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getBool,\n spec.setBool,\n fireFormatChange\n );\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n spec.selectOptions,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n /* istanbul ignore else */\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n /* istanbul ignore next */\n return <div key={index} />;\n });\n },\n []\n );\n\n const providePrimaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n // istanbul ignore else\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.primaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideSecondaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n // istanbul ignore else\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.secondaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideFormatSpec = React.useCallback(\n async (\n inProps: FormatProps,\n _persistenceUnit: UnitProps,\n _unitsProvider: UnitsProvider\n ) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(\n quantityType,\n inProps\n );\n },\n [quantityType]\n );\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps && (\n <FormatPanel\n onFormatChange={handleOnFormatChanged}\n {...otherProps}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />\n )}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAK/B,wDAO8B;AAO9B,wDAA+D;AAC/D,+CAA4C;AAC5C,wDAAmD;AAEnD,SAAS,+BAA+B,CACtC,GAAW,EACX,KAAa,EACb,OAAoB,EACpB,SAAyC,EACzC,SAA6D,EAC7D,gBAAiD;IAEjD,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,GAAG,EAAE,GAA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AC,aAAa,EACxD,eAAe,EAAE,eAAe,EAChC,sBAAsB,EAAE,sBAAsB,EAC9C,wBAAwB,EAAE,wBAAwB,EAClD,iBAAiB,EAAE,iBAAiB,GACpC,CACH,CACG,CACP,CAAC;AACJ,CAAC;AAtKD,kDAsKC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type {\n CustomFormatPropEditorSpec,\n QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport {\n getQuantityTypeKey,\n IModelApp,\n isCheckboxFormatPropEditorSpec,\n isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec,\n isTextSelectFormatPropEditorSpec,\n} from \"@itwin/core-frontend\";\nimport type {\n FormatProps,\n UnitProps,\n UnitsProvider,\n} from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\nimport { FormatPanel } from \"./FormatPanel\";\nimport { DeepCompare } from \"@itwin/core-geometry\";\n\nfunction createTextInputFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Input\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n size=\"small\"\n onChange={(e) => {\n const newProps = setString(inProps, e.currentTarget.value);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\nfunction createSelectFormatPropEditor(\n key: string,\n label: string,\n options: { label: string; value: string }[],\n inProps: FormatProps,\n getString: (props: FormatProps) => string,\n setString: (props: FormatProps, value: string) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Select\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n value={value}\n options={options}\n size={\"small\"}\n onChange={(newValue) => {\n const newProps = setString(inProps, newValue);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction createCheckboxFormatPropEditor(\n key: string,\n label: string,\n inProps: FormatProps,\n getBool: (props: FormatProps) => boolean,\n setBool: (props: FormatProps, isChecked: boolean) => FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>\n {label}\n </span>\n <Checkbox\n data-testid={`${key}-editor`}\n key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\n }}\n />\n </React.Fragment>\n );\n}\n\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\n const compare = new DeepCompare();\n return compare.compare(obj1, obj2);\n}\n\n/** Properties of [[QuantityFormatPanel]] component.\n * @alpha\n */\nexport interface QuantityFormatPanelProps extends CommonProps {\n quantityType: QuantityTypeArg;\n onFormatChange?: (format: FormatProps) => void;\n /** props below are to be passed on to FormatPanel */\n showSample?: boolean;\n initialMagnitude?: number;\n enableMinimumProperties?: boolean;\n}\n\n/** Component to set properties that control Quantity Formatting.\n * @alpha\n */\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\n const { quantityType, onFormatChange, ...otherProps } = props;\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\n const initialFormatProps = React.useRef<FormatProps>();\n\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\n\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (!initialFormatProps.current)\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition)\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\n else\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\n }, [quantityType]); // no dependencies defined as we want this to run on every render\n\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\n // eslint-disable-next-line react-hooks/exhaustive-deps\n React.useEffect(() => {\n const newFormatProps =\n IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\n if (initialFormatProps.current && newFormatProps) {\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\n initialFormatProps.current = newFormatProps;\n setFormatProps(newFormatProps);\n }\n }\n }); // no dependencies defined as we want this to run on every render\n\n const handleOnFormatChanged = React.useCallback(\n async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n },\n [onFormatChange]\n );\n\n const createCustomPropEditors = React.useCallback(\n (\n specs: CustomFormatPropEditorSpec[],\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getBool,\n spec.setBool,\n fireFormatChange\n );\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n spec.selectOptions,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(\n `${spec.editorType}-${index}`,\n spec.label,\n inProps,\n spec.getString,\n spec.setString,\n fireFormatChange\n );\n\n return <div key={index} />;\n });\n },\n []\n );\n\n const providePrimaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.primaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideSecondaryChildren = React.useCallback(\n (\n inProps: FormatProps,\n fireFormatChange: (newProps: FormatProps) => void\n ) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition =\n IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (\n quantityTypeDefinition &&\n isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)\n ) {\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(\n quantityTypeDefinition.secondaryPropEditorSpecs,\n inProps,\n fireFormatChange\n );\n }\n return null;\n },\n [createCustomPropEditors, quantityType]\n );\n\n const provideFormatSpec = React.useCallback(\n async (\n inProps: FormatProps,\n _persistenceUnit: UnitProps,\n _unitsProvider: UnitsProvider\n ) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(\n quantityType,\n inProps\n );\n },\n [quantityType]\n );\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps && (\n <FormatPanel\n onFormatChange={handleOnFormatChanged}\n {...otherProps}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />\n )}\n </div>\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"StationSeparatorSelector.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/StationSeparatorSelector.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,WAAW;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,qBAoD5E"}
1
+ {"version":3,"file":"StationSeparatorSelector.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/StationSeparatorSelector.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;GAEG;AACH,MAAM,WAAW,6BAA8B,SAAQ,WAAW;IAChE,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,6BAA6B,qBAmD5E"}
@@ -63,7 +63,6 @@ function StationSeparatorSelector(props) {
63
63
  },
64
64
  ];
65
65
  const completeListOfEntries = [];
66
- // istanbul ignore next (only used if format already has a character that does not match standard options)
67
66
  if (undefined ===
68
67
  uomDefaultEntries.find((option) => option.value === separator)) {
69
68
  completeListOfEntries.push({ value: separator, label: separator });
@@ -1 +1 @@
1
- {"version":3,"file":"StationSeparatorSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/StationSeparatorSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA8C;AAC9C,yDAAsD;AAWtD;;GAEG;AACH,SAAgB,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAEvC,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,iBAAiB,GAA2B;YAChD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,uCAAuC,CAAC;aAC1D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;aAC3D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;aAC3D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;aAC3D;SACF,CAAC;QACF,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,0GAA0G;QAC1G,IACE,SAAS;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EAC9D,CAAC;YACD,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AApDD,4DAoDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation\";\n\n/** Properties of [[StationSeparatorSelector]] component.\n * @internal\n */\nexport interface StationSeparatorSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to setStation separator.\n * @internal\n */\nexport function StationSeparatorSelector(props: StationSeparatorSelectorProps) {\n const { separator, disabled, onChange, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n {\n value: \"+\",\n label: translate(\"QuantityFormat.station_separator.plus\"),\n },\n {\n value: \"-\",\n label: translate(\"QuantityFormat.station_separator.minus\"),\n },\n {\n value: \" \",\n label: translate(\"QuantityFormat.station_separator.blank\"),\n },\n {\n value: \"^\",\n label: translate(\"QuantityFormat.station_separator.caret\"),\n },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n // istanbul ignore next (only used if format already has a character that does not match standard options)\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n disabled={disabled}\n value={separator}\n onChange={handleOnChange}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"StationSeparatorSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/StationSeparatorSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA8C;AAC9C,yDAAsD;AAWtD;;GAEG;AACH,SAAgB,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC/D,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAEvC,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,QAAgB,EAAE,EAAE;QACnB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,iBAAiB,GAA2B;YAChD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,uCAAuC,CAAC;aAC1D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;aAC3D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;aAC3D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,wCAAwC,CAAC;aAC3D;SACF,CAAC;QACF,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,IACE,SAAS;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EAC9D,CAAC;YACD,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,SAAS,EAChB,QAAQ,EAAE,cAAc,EACxB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AAnDD,4DAmDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation\";\n\n/** Properties of [[StationSeparatorSelector]] component.\n * @internal\n */\nexport interface StationSeparatorSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to setStation separator.\n * @internal\n */\nexport function StationSeparatorSelector(props: StationSeparatorSelectorProps) {\n const { separator, disabled, onChange, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const handleOnChange = React.useCallback(\n (newValue: string) => {\n onChange && onChange(newValue);\n },\n [onChange]\n );\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n {\n value: \"+\",\n label: translate(\"QuantityFormat.station_separator.plus\"),\n },\n {\n value: \"-\",\n label: translate(\"QuantityFormat.station_separator.minus\"),\n },\n {\n value: \" \",\n label: translate(\"QuantityFormat.station_separator.blank\"),\n },\n {\n value: \"^\",\n label: translate(\"QuantityFormat.station_separator.caret\"),\n },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n disabled={disabled}\n value={separator}\n onChange={handleOnChange}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThousandsSelector.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAmC9D"}
1
+ {"version":3,"file":"ThousandsSelector.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAkC9D"}
@@ -52,7 +52,6 @@ function ThousandsSelector(props) {
52
52
  },
53
53
  ];
54
54
  const completeListOfEntries = [];
55
- // istanbul ignore next (only used if format already has a character that does not match standard options)
56
55
  if (undefined ===
57
56
  uomDefaultEntries.find((option) => option.value === separator)) {
58
57
  completeListOfEntries.push({ value: separator, label: separator });
@@ -1 +1 @@
1
- {"version":3,"file":"ThousandsSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA8C;AAC9C,yDAAsD;AAWtD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAEvC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,iBAAiB,GAA2B;YAChD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;aAC5D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;aAC5D;SACF,CAAC;QACF,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,0GAA0G;QAC1G,IACE,SAAS;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EAC9D,CAAC;YACD,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AAnCD,8CAmCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation\";\n\n/** Properties of [[ThousandsSelector]] component.\n * @internal\n */\nexport interface ThousandsSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSelector(props: ThousandsSelectorProps) {\n const { separator, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n {\n value: \",\",\n label: translate(\"QuantityFormat.thousand_separator.comma\"),\n },\n {\n value: \".\",\n label: translate(\"QuantityFormat.thousand_separator.point\"),\n },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n // istanbul ignore next (only used if format already has a character that does not match standard options)\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
1
+ {"version":3,"file":"ThousandsSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA8C;AAC9C,yDAAsD;AAWtD;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,+BAAc,GAAE,CAAC;IAEvC,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,iBAAiB,GAA2B;YAChD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;aAC5D;YACD;gBACE,KAAK,EAAE,GAAG;gBACV,KAAK,EAAE,SAAS,CAAC,yCAAyC,CAAC;aAC5D;SACF,CAAC;QACF,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,IACE,SAAS;YACT,iBAAiB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EAC9D,CAAC;YACD,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QACrE,CAAC;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,CAAC;QACjD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AAlCD,8CAkCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\nimport { useTranslation } from \"../../useTranslation\";\n\n/** Properties of [[ThousandsSelector]] component.\n * @internal\n */\nexport interface ThousandsSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSelector(props: ThousandsSelectorProps) {\n const { separator, ...otherProps } = props;\n const { translate } = useTranslation();\n\n const separatorOptions = React.useMemo(() => {\n const uomDefaultEntries: SelectOption<string>[] = [\n {\n value: \",\",\n label: translate(\"QuantityFormat.thousand_separator.comma\"),\n },\n {\n value: \".\",\n label: translate(\"QuantityFormat.thousand_separator.point\"),\n },\n ];\n const completeListOfEntries: SelectOption<string>[] = [];\n if (\n undefined ===\n uomDefaultEntries.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries);\n return completeListOfEntries;\n }, [separator, translate]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qBAwGhE"}
1
+ {"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qBAiGhE"}