@itwin/imodel-components-react 4.0.0-dev.13 → 4.0.0-dev.14

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 (152) hide show
  1. package/CHANGELOG.md +113 -1
  2. package/README.md +2 -2
  3. package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
  4. package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
  5. package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
  6. package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  7. package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +90 -90
  8. package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  9. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  10. package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  11. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  12. package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  13. package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
  14. package/lib/cjs/imodel-components-react/color/HueSlider.scss +61 -61
  15. package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
  16. package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
  17. package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
  18. package/lib/cjs/imodel-components-react/color/Swatch.scss +22 -22
  19. package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  20. package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
  21. package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
  22. package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
  23. package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
  24. package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  25. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  26. package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  27. package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
  28. package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
  29. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  30. package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +51 -51
  31. package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
  32. package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
  33. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  34. package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  35. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  36. package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  37. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  38. package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +59 -59
  39. package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  40. package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  41. package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  42. package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  43. package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  44. package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  45. package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  46. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  47. package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  48. package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  49. package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  50. package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  51. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  52. package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  53. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  54. package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  55. package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  56. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  57. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +0 -1
  58. package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  59. package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  60. package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  61. package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
  62. package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  63. package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +28 -28
  64. package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
  65. package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +105 -105
  66. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  67. package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  68. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  69. package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  70. package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
  71. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  72. package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +177 -177
  73. package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
  74. package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  75. package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  76. package/lib/cjs/imodel-components-react.js.map +1 -1
  77. package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
  78. package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
  79. package/lib/esm/imodel-components-react/color/AlphaSlider.scss +63 -63
  80. package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
  81. package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +90 -90
  82. package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
  83. package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
  84. package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +93 -93
  85. package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
  86. package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +62 -62
  87. package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
  88. package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
  89. package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
  90. package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
  91. package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
  92. package/lib/esm/imodel-components-react/color/Swatch.scss +22 -22
  93. package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
  94. package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
  95. package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
  96. package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
  97. package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
  98. package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
  99. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
  100. package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +106 -106
  101. package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
  102. package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
  103. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
  104. package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +51 -51
  105. package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
  106. package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
  107. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
  108. package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +178 -178
  109. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
  110. package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +135 -135
  111. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
  112. package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +59 -59
  113. package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
  114. package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
  115. package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
  116. package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
  117. package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
  118. package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
  119. package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
  120. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
  121. package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
  122. package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
  123. package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
  124. package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
  125. package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
  126. package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
  127. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
  128. package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
  129. package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
  130. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts.map +1 -1
  131. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +0 -1
  132. package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
  133. package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
  134. package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
  135. package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
  136. package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
  137. package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +28 -28
  138. package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
  139. package/lib/esm/imodel-components-react/timeline/Scrubber.scss +105 -105
  140. package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
  141. package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +359 -359
  142. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
  143. package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
  144. package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
  145. package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
  146. package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +177 -177
  147. package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
  148. package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
  149. package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
  150. package/lib/esm/imodel-components-react.js.map +1 -1
  151. package/lib/public/locales/en/UiIModelComponents.json +139 -139
  152. package/package.json +25 -23
@@ -1 +1 @@
1
- {"version":3,"file":"FormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPanel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAA4B;AAC5B,6CAA+B;AAC/B,wDAAoG;AAEpG,uDAAoD;AACpD,iDAA8C;AAC9C,6CAAgD;AAChD,uDAAoD;AACpD,+CAA4C;AAC5C,2DAAwD;AAmBxD,KAAK,UAAU,kBAAkB,CAAC,WAAwB,EAAE,eAA0B,EAAE,aAA4B;IAClH,MAAM,YAAY,GAAG,MAAM,sBAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IACvF,OAAO,6BAAa,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAC/F,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAiB,CAAC;IACpE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,KAAK,CAAC;IAC1J,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACpE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;IAE5D,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,cAAc,CAAC,aAAa,CAAC,CAAC;QAC9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------------------------------------------------\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 \"./FormatPanel.scss\";\nimport * as React from \"react\";\nimport { Format, FormatProps, FormatterSpec, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport { FormatPrecision } from \"./FormatPrecision\";\nimport { FormatSample } from \"./FormatSample\";\nimport { FormatTypeOption } from \"./FormatType\";\nimport { FormatUnitLabel } from \"./FormatUnitLabel\";\nimport { FormatUnits } from \"./FormatUnits\";\nimport { MiscFormatOptions } from \"./MiscFormatOptions\";\n\n/** Properties of [[FormatPanel]] component.\n * @alpha\n */\nexport interface FormatPanelProps extends CommonProps {\n initialFormat: FormatProps;\n unitsProvider: UnitsProvider;\n persistenceUnit: Promise<UnitProps> | UnitProps;\n showSample?: boolean;\n initialMagnitude?: number;\n // if true a only primary format properties are initially displayed and a \"More/Less\" link is added.\n enableMinimumProperties?: boolean;\n onFormatChange?: (format: FormatProps) => void;\n provideFormatSpec?: (formatProps: FormatProps, persistenceUnit: UnitProps, unitsProvider: UnitsProvider) => Promise<FormatterSpec>;\n providePrimaryChildren?: (formatProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => React.ReactNode;\n provideSecondaryChildren?: (formatProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => React.ReactNode;\n}\n\nasync function generateFormatSpec(formatProps: FormatProps, persistenceUnit: UnitProps, unitsProvider: UnitsProvider) {\n const actualFormat = await Format.createFromJSON(\"custom\", unitsProvider, formatProps);\n return FormatterSpec.create(actualFormat.name, actualFormat, unitsProvider, persistenceUnit);\n}\n\n/** Component to show/edit Quantity Format.\n * @alpha\n */\nexport function FormatPanel(props: FormatPanelProps) {\n const [formatSpec, setFormatSpec] = React.useState<FormatterSpec>();\n const { initialFormat, showSample, initialMagnitude, unitsProvider, persistenceUnit, onFormatChange, provideFormatSpec, enableMinimumProperties } = props;\n const [formatProps, setFormatProps] = React.useState(initialFormat);\n const [showOptions, setShowOptions] = React.useState(false);\n\n React.useEffect(() => {\n setFormatProps(initialFormat);\n setFormatSpec(undefined); // this will trigger the new spec to be created in the useEffect hook\n }, [initialFormat]);\n\n const handleUserFormatChanges = React.useCallback((newProps: FormatProps) => {\n setFormatProps(newProps);\n setFormatSpec(undefined); // this will trigger the new spec to be created in the useEffect hook\n onFormatChange && onFormatChange(newProps);\n }, [onFormatChange]);\n\n const isMounted = React.useRef(false);\n\n // runs returned function only when component is unmounted.\n React.useEffect(() => {\n isMounted.current = true;\n return (() => {\n isMounted.current = false;\n });\n }, []);\n\n React.useEffect(() => {\n async function fetchFormatSpec() {\n const pu = await persistenceUnit;\n let newFormatSpec: FormatterSpec;\n if (provideFormatSpec) {\n newFormatSpec = await provideFormatSpec(formatProps, pu, unitsProvider);\n } else {\n newFormatSpec = await generateFormatSpec(formatProps, pu, unitsProvider);\n }\n isMounted.current && setFormatSpec(newFormatSpec);\n }\n if (!formatSpec)\n fetchFormatSpec(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [formatProps, formatSpec, persistenceUnit, provideFormatSpec, unitsProvider]);\n\n const handleFormatChange = React.useCallback((newFormatProps: FormatProps) => {\n handleUserFormatChanges(newFormatProps);\n }, [handleUserFormatChanges]);\n\n const handleShowOptions = React.useCallback((show: boolean) => {\n setShowOptions(show);\n }, []);\n\n return (\n <div className=\"components-quantityFormat-panel\">\n {showSample &&\n <FormatSample formatSpec={formatSpec} initialMagnitude={initialMagnitude} />\n }\n <FormatUnits unitsProvider={unitsProvider} persistenceUnit={formatSpec?.persistenceUnit} initialFormat={formatProps} onUnitsChange={handleFormatChange} />\n <FormatUnitLabel formatProps={formatProps} onUnitLabelChange={handleFormatChange} />\n <FormatTypeOption formatProps={formatProps} onChange={handleFormatChange} />\n <FormatPrecision formatProps={formatProps} onChange={handleFormatChange} />\n {props.providePrimaryChildren && props.providePrimaryChildren(formatProps, handleFormatChange)}\n <MiscFormatOptions formatProps={formatProps} onChange={handleFormatChange} enableMinimumProperties={enableMinimumProperties} showOptions={showOptions} onShowHideOptions={handleShowOptions}>\n {props.provideSecondaryChildren && props.provideSecondaryChildren(formatProps, handleFormatChange)}\n </MiscFormatOptions>\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"FormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPanel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAA4B;AAC5B,6CAA+B;AAC/B,wDAAoG;AAEpG,uDAAoD;AACpD,iDAA8C;AAC9C,6CAAgD;AAChD,uDAAoD;AACpD,+CAA4C;AAC5C,2DAAwD;AAmBxD,KAAK,UAAU,kBAAkB,CAAC,WAAwB,EAAE,eAA0B,EAAE,aAA4B;IAClH,MAAM,YAAY,GAAG,MAAM,sBAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,aAAa,EAAE,WAAW,CAAC,CAAC;IACvF,OAAO,6BAAa,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,eAAe,CAAC,CAAC;AAC/F,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC,QAAQ,EAAiB,CAAC;IACpE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,gBAAgB,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,GAAG,KAAK,CAAC;IAC1J,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC;IACpE,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,K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AC,WAAW,EAAE,kBAAkB,CAAC,CAChF,CAChB,CACP,CAAC;AACJ,CAAC;AAjED,kCAiEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport \"./FormatPanel.scss\";\r\nimport * as React from \"react\";\r\nimport { Format, FormatProps, FormatterSpec, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { FormatPrecision } from \"./FormatPrecision\";\r\nimport { FormatSample } from \"./FormatSample\";\r\nimport { FormatTypeOption } from \"./FormatType\";\r\nimport { FormatUnitLabel } from \"./FormatUnitLabel\";\r\nimport { FormatUnits } from \"./FormatUnits\";\r\nimport { MiscFormatOptions } from \"./MiscFormatOptions\";\r\n\r\n/** Properties of [[FormatPanel]] component.\r\n * @alpha\r\n */\r\nexport interface FormatPanelProps extends CommonProps {\r\n initialFormat: FormatProps;\r\n unitsProvider: UnitsProvider;\r\n persistenceUnit: Promise<UnitProps> | UnitProps;\r\n showSample?: boolean;\r\n initialMagnitude?: number;\r\n // if true a only primary format properties are initially displayed and a \"More/Less\" link is added.\r\n enableMinimumProperties?: boolean;\r\n onFormatChange?: (format: FormatProps) => void;\r\n provideFormatSpec?: (formatProps: FormatProps, persistenceUnit: UnitProps, unitsProvider: UnitsProvider) => Promise<FormatterSpec>;\r\n providePrimaryChildren?: (formatProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => React.ReactNode;\r\n provideSecondaryChildren?: (formatProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => React.ReactNode;\r\n}\r\n\r\nasync function generateFormatSpec(formatProps: FormatProps, persistenceUnit: UnitProps, unitsProvider: UnitsProvider) {\r\n const actualFormat = await Format.createFromJSON(\"custom\", unitsProvider, formatProps);\r\n return FormatterSpec.create(actualFormat.name, actualFormat, unitsProvider, persistenceUnit);\r\n}\r\n\r\n/** Component to show/edit Quantity Format.\r\n * @alpha\r\n */\r\nexport function FormatPanel(props: FormatPanelProps) {\r\n const [formatSpec, setFormatSpec] = React.useState<FormatterSpec>();\r\n const { initialFormat, showSample, initialMagnitude, unitsProvider, persistenceUnit, onFormatChange, provideFormatSpec, enableMinimumProperties } = props;\r\n const [formatProps, setFormatProps] = React.useState(initialFormat);\r\n const [showOptions, setShowOptions] = React.useState(false);\r\n\r\n React.useEffect(() => {\r\n setFormatProps(initialFormat);\r\n setFormatSpec(undefined); // this will trigger the new spec to be created in the useEffect hook\r\n }, [initialFormat]);\r\n\r\n const handleUserFormatChanges = React.useCallback((newProps: FormatProps) => {\r\n setFormatProps(newProps);\r\n setFormatSpec(undefined); // this will trigger the new spec to be created in the useEffect hook\r\n onFormatChange && onFormatChange(newProps);\r\n }, [onFormatChange]);\r\n\r\n const isMounted = React.useRef(false);\r\n\r\n // runs returned function only when component is unmounted.\r\n React.useEffect(() => {\r\n isMounted.current = true;\r\n return (() => {\r\n isMounted.current = false;\r\n });\r\n }, []);\r\n\r\n React.useEffect(() => {\r\n async function fetchFormatSpec() {\r\n const pu = await persistenceUnit;\r\n let newFormatSpec: FormatterSpec;\r\n if (provideFormatSpec) {\r\n newFormatSpec = await provideFormatSpec(formatProps, pu, unitsProvider);\r\n } else {\r\n newFormatSpec = await generateFormatSpec(formatProps, pu, unitsProvider);\r\n }\r\n isMounted.current && setFormatSpec(newFormatSpec);\r\n }\r\n if (!formatSpec)\r\n fetchFormatSpec(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }, [formatProps, formatSpec, persistenceUnit, provideFormatSpec, unitsProvider]);\r\n\r\n const handleFormatChange = React.useCallback((newFormatProps: FormatProps) => {\r\n handleUserFormatChanges(newFormatProps);\r\n }, [handleUserFormatChanges]);\r\n\r\n const handleShowOptions = React.useCallback((show: boolean) => {\r\n setShowOptions(show);\r\n }, []);\r\n\r\n return (\r\n <div className=\"components-quantityFormat-panel\">\r\n {showSample &&\r\n <FormatSample formatSpec={formatSpec} initialMagnitude={initialMagnitude} />\r\n }\r\n <FormatUnits unitsProvider={unitsProvider} persistenceUnit={formatSpec?.persistenceUnit} initialFormat={formatProps} onUnitsChange={handleFormatChange} />\r\n <FormatUnitLabel formatProps={formatProps} onUnitLabelChange={handleFormatChange} />\r\n <FormatTypeOption formatProps={formatProps} onChange={handleFormatChange} />\r\n <FormatPrecision formatProps={formatProps} onChange={handleFormatChange} />\r\n {props.providePrimaryChildren && props.providePrimaryChildren(formatProps, handleFormatChange)}\r\n <MiscFormatOptions formatProps={formatProps} onChange={handleFormatChange} enableMinimumProperties={enableMinimumProperties} showOptions={showOptions} onShowHideOptions={handleShowOptions}>\r\n {props.provideSecondaryChildren && props.provideSecondaryChildren(formatProps, handleFormatChange)}\r\n </MiscFormatOptions>\r\n </div>\r\n );\r\n}\r\n"]}
@@ -1,59 +1,59 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- @import "~@itwin/core-react/lib/cjs/core-react/inputs/variables";
6
-
7
- .components-quantityFormat-panel {
8
- display: grid;
9
- grid-template-columns: auto 1fr;
10
- row-gap: 0;
11
- column-gap: 6px;
12
- align-items: center;
13
-
14
- > .uicore-label {
15
- font-size: var(--iui-font-size-1);
16
- margin: 4.4px 0;
17
-
18
- /* match margin on other select controls so it spaces properly in grid */
19
- &.uicore-disabled {
20
- color: var(--iui-color-text-disabled);
21
- }
22
- }
23
-
24
- > span.components-inline {
25
- display: flex;
26
- flex-direction: row;
27
- align-items: center;
28
- gap: 4px;
29
- }
30
-
31
- > button.components-quantityFormat-more-button {
32
- grid-column: 1 / span 2;
33
- border: none;
34
- outline: none;
35
- background: none;
36
- }
37
-
38
- .components-quantityFormat-more-button-label {
39
- margin-right: 0.25em;
40
- }
41
-
42
- > a.components-quantityFormat-more-less {
43
- font-size: var(--iui-font-size-1);
44
- color: var(--iui-color-text-negative);
45
- -webkit-transition: text-decoration 1s ease;
46
- -moz-transition: text-decoration 1s ease;
47
- -o-transition: text-decoration 1s ease;
48
- transition: text-decoration 0.1s ease;
49
-
50
- &:hover {
51
- text-decoration: underline;
52
- cursor: pointer;
53
- }
54
- }
55
-
56
- .iui-input {
57
- padding: $uicore-iui-input-padding;
58
- }
59
- }
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ @import "~@itwin/core-react/lib/cjs/core-react/inputs/variables";
6
+
7
+ .components-quantityFormat-panel {
8
+ display: grid;
9
+ grid-template-columns: auto 1fr;
10
+ row-gap: 0;
11
+ column-gap: 6px;
12
+ align-items: center;
13
+
14
+ > .uicore-label {
15
+ font-size: var(--iui-font-size-1);
16
+ margin: 4.4px 0;
17
+
18
+ /* match margin on other select controls so it spaces properly in grid */
19
+ &.uicore-disabled {
20
+ color: var(--iui-color-text-disabled);
21
+ }
22
+ }
23
+
24
+ > span.components-inline {
25
+ display: flex;
26
+ flex-direction: row;
27
+ align-items: center;
28
+ gap: 4px;
29
+ }
30
+
31
+ > button.components-quantityFormat-more-button {
32
+ grid-column: 1 / span 2;
33
+ border: none;
34
+ outline: none;
35
+ background: none;
36
+ }
37
+
38
+ .components-quantityFormat-more-button-label {
39
+ margin-right: 0.25em;
40
+ }
41
+
42
+ > a.components-quantityFormat-more-less {
43
+ font-size: var(--iui-font-size-1);
44
+ color: var(--iui-color-text-negative);
45
+ -webkit-transition: text-decoration 1s ease;
46
+ -moz-transition: text-decoration 1s ease;
47
+ -o-transition: text-decoration 1s ease;
48
+ transition: text-decoration 0.1s ease;
49
+
50
+ &:hover {
51
+ text-decoration: underline;
52
+ cursor: pointer;
53
+ }
54
+ }
55
+
56
+ .iui-input {
57
+ padding: $uicore-iui-input-padding;
58
+ }
59
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,wDAAgF;AAChF,8DAAmE;AACnE,gEAAqE;AACrE,8DAA2D;AAU3D;;GAEG;AACH,SAAgB,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,SAAiB,EAAE,EAAE;QACpE,MAAM,cAAc,GAAG,EAAE,GAAG,WAAW,EAAE,SAAS,EAAE,CAAC;QACrD,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5B,MAAM,UAAU,GAAG,IAAA,+BAAe,EAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,uCAAkB,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC5F,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAAG,KAAK,CAAC,OAAO,CAAQ;QACtD,UAAU,KAAK,0BAAU,CAAC,UAAU,CAAC,CAAC;YACrC,oBAAC,6CAAyB,mBAAa,6BAA6B,EAAC,SAAS,EAAE,WAAW,CAAC,SAAS,IAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAAC,CAAC;YACjJ,oBAAC,2CAAwB,mBAAa,4BAA4B,EAAC,SAAS,EAAE,WAAW,CAAC,SAAS,IAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAE9I,CACJ,CAAC;AACJ,CAAC;AApBD,0CAoBC","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 { CommonProps } from \"@itwin/core-react\";\nimport { FormatProps, FormatType, parseFormatType } from \"@itwin/core-quantity\";\nimport { DecimalPrecisionSelector } from \"./misc/DecimalPrecision\";\nimport { FractionPrecisionSelector } from \"./misc/FractionPrecision\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties of [[FormatPrecision]] component.\n * @alpha\n */\nexport interface FormatPrecisionProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component to show/edit Quantity Format Precision.\n * @alpha\n */\nexport function FormatPrecision(props: FormatPrecisionProps) {\n const { formatProps, onChange } = props;\n\n const handlePrecisionChange = React.useCallback((precision: number) => {\n const newFormatProps = { ...formatProps, precision };\n onChange && onChange(newFormatProps);\n }, [formatProps, onChange]);\n\n const formatType = parseFormatType(formatProps.type, \"format\");\n\n const label = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.precision\"));\n return (\n <>\n <span className={\"uicore-label\"}>{label.current}</span>\n {formatType === FormatType.Fractional ?\n <FractionPrecisionSelector data-testid=\"fraction-precision-selector\" precision={formatProps.precision ?? 0} onChange={handlePrecisionChange} /> :\n <DecimalPrecisionSelector data-testid=\"decimal-precision-selector\" precision={formatProps.precision ?? 0} onChange={handlePrecisionChange} />\n }\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"FormatPrecision.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatPrecision.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,wDAAgF;AAChF,8DAAmE;AACnE,gEAAqE;AACrE,8DAA2D;AAU3D;;GAEG;AACH,SAAgB,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,qBAAqB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,SAAiB,EAAE,EAAE;QACpE,MAAM,cAAc,GAAG,EAAE,GAAG,WAAW,EAAE,SAAS,EAAE,CAAC;QACrD,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5B,MAAM,UAAU,GAAG,IAAA,+BAAe,EAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAE/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,uCAAkB,CAAC,SAAS,CAAC,iCAAiC,CAAC,CAAC,CAAC;IAC5F,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,cAAc,IAAG,KAAK,CAAC,OAAO,CAAQ;QACtD,UAAU,KAAK,0BAAU,CAAC,UAAU,CAAC,CAAC;YACrC,oBAAC,6CAAyB,mBAAa,6BAA6B,EAAC,SAAS,EAAE,WAAW,CAAC,SAAS,IAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAAC,CAAC;YACjJ,oBAAC,2CAAwB,mBAAa,4BAA4B,EAAC,SAAS,EAAE,WAAW,CAAC,SAAS,IAAI,CAAC,EAAE,QAAQ,EAAE,qBAAqB,GAAI,CAE9I,CACJ,CAAC;AACJ,CAAC;AApBD,0CAoBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { FormatProps, FormatType, parseFormatType } from \"@itwin/core-quantity\";\r\nimport { DecimalPrecisionSelector } from \"./misc/DecimalPrecision\";\r\nimport { FractionPrecisionSelector } from \"./misc/FractionPrecision\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties of [[FormatPrecision]] component.\r\n * @alpha\r\n */\r\nexport interface FormatPrecisionProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to show/edit Quantity Format Precision.\r\n * @alpha\r\n */\r\nexport function FormatPrecision(props: FormatPrecisionProps) {\r\n const { formatProps, onChange } = props;\r\n\r\n const handlePrecisionChange = React.useCallback((precision: number) => {\r\n const newFormatProps = { ...formatProps, precision };\r\n onChange && onChange(newFormatProps);\r\n }, [formatProps, onChange]);\r\n\r\n const formatType = parseFormatType(formatProps.type, \"format\");\r\n\r\n const label = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.precision\"));\r\n return (\r\n <>\r\n <span className={\"uicore-label\"}>{label.current}</span>\r\n {formatType === FormatType.Fractional ?\r\n <FractionPrecisionSelector data-testid=\"fraction-precision-selector\" precision={formatProps.precision ?? 0} onChange={handlePrecisionChange} /> :\r\n <DecimalPrecisionSelector data-testid=\"decimal-precision-selector\" precision={formatProps.precision ?? 0} onChange={handlePrecisionChange} />\r\n }\r\n </>\r\n );\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatSample.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatSample.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,0DAAmD;AACnD,kDAAsD;AACtD,wDAA6C;AAC7C,8DAA2D;AAC3D,oEAAgE;AAWhE;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,gBAAgB,EAAE,UAAU,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G,CAAC,CAAC,IAAI,oBAAC,iBAAI,IAAC,QAAQ,EAAE,oBAAC,wCAAkB,OAAG,GAAI;YACxF,6CAAkB,yBAAyB,EAAC,SAAS,EAAE,mDAAmD,IAAG,cAAc,CAAQ,CAC9H,CACN,CACJ,CAAC;AACJ,CAAC;AAvDD,oCAuDC","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 { FormatterSpec } from \"@itwin/core-quantity\";\nimport { SpecialKey } from \"@itwin/appui-abstract\";\nimport { CommonProps, Icon } from \"@itwin/core-react\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { SvgProgressForward } from \"@itwin/itwinui-icons-react\";\n\n/** Properties of [[FormatSample]] component.\n * @alpha\n */\nexport interface FormatSampleProps extends CommonProps {\n formatSpec?: FormatterSpec;\n initialMagnitude?: number;\n hideLabels?: boolean;\n}\n\n/** Component to show the persistence value and formatted value given a FormatterSpec.\n * @alpha\n */\nexport function FormatSample(props: FormatSampleProps) {\n const { initialMagnitude, formatSpec, hideLabels } = props;\n const initialValue = initialMagnitude ?? 0;\n const [magnitude, setMagnitude] = React.useState(initialValue);\n const [sampleValue, setSampleValue] = React.useState(initialValue.toString());\n\n React.useEffect(() => {\n const value = initialMagnitude ?? 0;\n setMagnitude(value);\n setSampleValue(value.toString());\n }, [initialMagnitude]);\n\n const handleOnValueBlur = React.useCallback(() => {\n let newValue = Number.parseFloat(sampleValue);\n if (Number.isNaN(newValue))\n newValue = 0;\n setMagnitude(newValue);\n setSampleValue(newValue.toString());\n }, [sampleValue]);\n\n const handleOnValueChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\n setSampleValue(event.target.value);\n }, []);\n\n const handleKeyDown = React.useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (e.key === SpecialKey.Enter) {\n let newValue = Number.parseFloat(sampleValue);\n if (Number.isNaN(newValue))\n newValue = 0;\n setMagnitude(newValue);\n setSampleValue(newValue.toString());\n e.preventDefault();\n }\n }, [sampleValue]);\n\n const activePersistenceUnitLabel = formatSpec ? formatSpec.persistenceUnit.label : \"\";\n const formattedValue = formatSpec ? formatSpec.applyFormatting(magnitude) : \"\";\n\n const valueLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.value\"));\n const formattedLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.formatted\"));\n\n return (\n <>\n {!hideLabels && <span className={\"uicore-label\"}>{valueLabel.current}</span>}\n <span className=\"components-inline\">\n <Input data-testid=\"format-sample-input\" className={\"components-quantity-persistence-input\"} value={sampleValue} onChange={handleOnValueChange} onKeyDown={handleKeyDown} onBlur={handleOnValueBlur} size=\"small\" />{activePersistenceUnitLabel}\n </span>\n {!hideLabels && <span className={\"uicore-label\"}>{formattedLabel.current}</span>}\n <span data-testid=\"progress-forward\">\n {hideLabels && (formattedValue.length > 0) && <Icon iconSpec={<SvgProgressForward />} />}\n <span data-testid=\"format-sample-formatted\" className={\"uicore-label components-quantity-formatted-sample\"}>{formattedValue}</span>\n </span>\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"FormatSample.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatSample.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,0DAAmD;AACnD,kDAAsD;AACtD,wDAA6C;AAC7C,8DAA2D;AAC3D,oEAAgE;AAWhE;;GAEG;AACH,SAAgB,YAAY,CAAC,KAAwB;IACnD,MAAM,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3D,MAAM,YAAY,GAAG,gBAAgB,IAAI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,GAAI;YACxF,6CAAkB,yBAAyB,EAAC,SAAS,EAAE,mDAAmD,IAAG,cAAc,CAAQ,CAC9H,CACN,CACJ,CAAC;AACJ,CAAC;AAvDD,oCAuDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { FormatterSpec } from \"@itwin/core-quantity\";\r\nimport { SpecialKey } from \"@itwin/appui-abstract\";\r\nimport { CommonProps, Icon } from \"@itwin/core-react\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\nimport { SvgProgressForward } from \"@itwin/itwinui-icons-react\";\r\n\r\n/** Properties of [[FormatSample]] component.\r\n * @alpha\r\n */\r\nexport interface FormatSampleProps extends CommonProps {\r\n formatSpec?: FormatterSpec;\r\n initialMagnitude?: number;\r\n hideLabels?: boolean;\r\n}\r\n\r\n/** Component to show the persistence value and formatted value given a FormatterSpec.\r\n * @alpha\r\n */\r\nexport function FormatSample(props: FormatSampleProps) {\r\n const { initialMagnitude, formatSpec, hideLabels } = props;\r\n const initialValue = initialMagnitude ?? 0;\r\n const [magnitude, setMagnitude] = React.useState(initialValue);\r\n const [sampleValue, setSampleValue] = React.useState(initialValue.toString());\r\n\r\n React.useEffect(() => {\r\n const value = initialMagnitude ?? 0;\r\n setMagnitude(value);\r\n setSampleValue(value.toString());\r\n }, [initialMagnitude]);\r\n\r\n const handleOnValueBlur = React.useCallback(() => {\r\n let newValue = Number.parseFloat(sampleValue);\r\n if (Number.isNaN(newValue))\r\n newValue = 0;\r\n setMagnitude(newValue);\r\n setSampleValue(newValue.toString());\r\n }, [sampleValue]);\r\n\r\n const handleOnValueChange = React.useCallback((event: React.ChangeEvent<HTMLInputElement>) => {\r\n setSampleValue(event.target.value);\r\n }, []);\r\n\r\n const handleKeyDown = React.useCallback((e: React.KeyboardEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Enter) {\r\n let newValue = Number.parseFloat(sampleValue);\r\n if (Number.isNaN(newValue))\r\n newValue = 0;\r\n setMagnitude(newValue);\r\n setSampleValue(newValue.toString());\r\n e.preventDefault();\r\n }\r\n }, [sampleValue]);\r\n\r\n const activePersistenceUnitLabel = formatSpec ? formatSpec.persistenceUnit.label : \"\";\r\n const formattedValue = formatSpec ? formatSpec.applyFormatting(magnitude) : \"\";\r\n\r\n const valueLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.value\"));\r\n const formattedLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.formatted\"));\r\n\r\n return (\r\n <>\r\n {!hideLabels && <span className={\"uicore-label\"}>{valueLabel.current}</span>}\r\n <span className=\"components-inline\">\r\n <Input data-testid=\"format-sample-input\" className={\"components-quantity-persistence-input\"} value={sampleValue} onChange={handleOnValueChange} onKeyDown={handleKeyDown} onBlur={handleOnValueBlur} size=\"small\" />{activePersistenceUnitLabel}\r\n </span>\r\n {!hideLabels && <span className={\"uicore-label\"}>{formattedLabel.current}</span>}\r\n <span data-testid=\"progress-forward\">\r\n {hideLabels && (formattedValue.length > 0) && <Icon iconSpec={<SvgProgressForward />} />}\r\n <span data-testid=\"format-sample-formatted\" className={\"uicore-label components-quantity-formatted-sample\"}>{formattedValue}</span>\r\n </span>\r\n </>\r\n );\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,8DAA2D;AAC3D,wDAE8B;AAC9B,wDAA4D;AAU5D;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAA8B;IAC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I,EAAE,UAAU,EAAE,QAAQ,EAAE,sBAAsB,GAAI,CAC5G,CACJ,CAAC;AACJ,CAAC;AApCD,4CAoCC","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 { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\nimport { DecimalPrecision, FormatProps, FormatType, formatTypeToString, FractionalPrecision, parseFormatType,\n ScientificType, scientificTypeToString,\n} from \"@itwin/core-quantity\";\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\n\n/** Properties of [[FormatTypeSelector]] component.\n * @alpha\n */\ninterface FormatTypeSelectorProps extends CommonProps {\n type: FormatType;\n onChange: (value: FormatType) => void;\n}\n\n/** Component to select the format type.\n * @alpha\n */\nfunction FormatTypeSelector(props: FormatTypeSelectorProps) {\n const { type, onChange, ...otherProps } = props;\n const formatOptions = React.useRef<SelectOption<FormatType>[]>([\n { value: FormatType.Decimal, label: UiIModelComponents.translate(\"QuantityFormat.decimal\") },\n { value: FormatType.Scientific, label: UiIModelComponents.translate(\"QuantityFormat.scientific\") },\n { value: FormatType.Station, label: UiIModelComponents.translate(\"QuantityFormat.station\") },\n { value: FormatType.Fractional, label: UiIModelComponents.translate(\"QuantityFormat.fractional\") },\n ]);\n\n const handleOnChange = React.useCallback((newValue: FormatType) => {\n onChange && onChange(newValue);\n }, [onChange]);\n\n return (\n <Select options={formatOptions.current} value={type} onChange={handleOnChange} size=\"small\" {...otherProps} />\n );\n}\n\n/** Properties of [[FormatTypeOptionProps]] component.\n * @alpha\n */\nexport interface FormatTypeOptionProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component to set the Quantity Format type.\n * @alpha\n */\nexport function FormatTypeOption(props: FormatTypeOptionProps) {\n const { formatProps, onChange } = props;\n const handleFormatTypeChange = React.useCallback((newType: FormatType) => {\n const type = formatTypeToString(newType);\n let precision: number | undefined;\n let stationOffsetSize: number | undefined;\n let scientificType: string | undefined;\n switch (newType) { // type must be decimal, fractional, scientific, or station\n case FormatType.Scientific:\n precision = DecimalPrecision.Six;\n scientificType = scientificTypeToString(ScientificType.Normalized);\n break;\n case FormatType.Decimal:\n precision = DecimalPrecision.Four;\n break;\n case FormatType.Station:\n precision = DecimalPrecision.Two;\n stationOffsetSize = formatProps.composite?.units[0].name.toLocaleLowerCase().endsWith(\"m\") ? 3 : 2;\n break;\n case FormatType.Fractional:\n precision = FractionalPrecision.Eight;\n break;\n }\n const newFormatProps = { ...formatProps, type, precision, scientificType, stationOffsetSize };\n onChange && onChange(newFormatProps);\n }, [formatProps, onChange]);\n\n const formatType = parseFormatType(formatProps.type, \"format\");\n const label = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.type\"));\n\n return (\n <>\n <span className={\"uicore-label.current\"}>{label.current}</span>\n <FormatTypeSelector data-testid=\"format-type-selector\" type={formatType} onChange={handleFormatTypeChange} />\n </>\n );\n}\n\n"]}
1
+ {"version":3,"file":"FormatType.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatType.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,8DAA2D;AAC3D,wDAE8B;AAC9B,wDAA4D;AAU5D;;GAEG;AACH,SAAS,kBAAkB,CAAC,KAA8B;IACxD,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAChD,MAAM,aAAa,GAAG,KAAK,CAAC,MAAM,CAA6B;QAC7D,EAAE,KAAK,EAAE,0BAAU,CAAC,OAAO,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,wBAAwB,CAAC,EAAE;QAC5F,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AK,0BAAU,CAAC,OAAO;gBACrB,SAAS,GAAG,gCAAgB,CAAC,IAAI,CAAC;gBAClC,MAAM;YACR,KAAK,0BAAU,CAAC,OAAO;gBACrB,SAAS,GAAG,gCAAgB,CAAC,GAAG,CAAC;gBACjC,iBAAiB,GAAG,WAAW,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACnG,MAAM;YACR,KAAK,0BAAU,CAAC,UAAU;gBACxB,SAAS,GAAG,mCAAmB,CAAC,KAAK,CAAC;gBACtC,MAAM;SACT;QACD,MAAM,cAAc,GAAG,EAAE,GAAG,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,CAAC;QAC9F,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC;IACvC,CAAC,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC;IAE5B,MAAM,UAAU,GAAG,IAAA,+BAAe,EAAC,WAAW,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;IAC/D,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,uCAAkB,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC,CAAC;IAEvF,OAAO,CACL;QACE,8BAAM,SAAS,EAAE,sBAAsB,IAAG,KAAK,CAAC,OAAO,CAAQ;QAC/D,oBAAC,kBAAkB,mBAAa,sBAAsB,EAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,sBAAsB,GAAI,CAC5G,CACJ,CAAC;AACJ,CAAC;AApCD,4CAoCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\nimport { DecimalPrecision, FormatProps, FormatType, formatTypeToString, FractionalPrecision, parseFormatType,\r\n ScientificType, scientificTypeToString,\r\n} from \"@itwin/core-quantity\";\r\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties of [[FormatTypeSelector]] component.\r\n * @alpha\r\n */\r\ninterface FormatTypeSelectorProps extends CommonProps {\r\n type: FormatType;\r\n onChange: (value: FormatType) => void;\r\n}\r\n\r\n/** Component to select the format type.\r\n * @alpha\r\n */\r\nfunction FormatTypeSelector(props: FormatTypeSelectorProps) {\r\n const { type, onChange, ...otherProps } = props;\r\n const formatOptions = React.useRef<SelectOption<FormatType>[]>([\r\n { value: FormatType.Decimal, label: UiIModelComponents.translate(\"QuantityFormat.decimal\") },\r\n { value: FormatType.Scientific, label: UiIModelComponents.translate(\"QuantityFormat.scientific\") },\r\n { value: FormatType.Station, label: UiIModelComponents.translate(\"QuantityFormat.station\") },\r\n { value: FormatType.Fractional, label: UiIModelComponents.translate(\"QuantityFormat.fractional\") },\r\n ]);\r\n\r\n const handleOnChange = React.useCallback((newValue: FormatType) => {\r\n onChange && onChange(newValue);\r\n }, [onChange]);\r\n\r\n return (\r\n <Select options={formatOptions.current} value={type} onChange={handleOnChange} size=\"small\" {...otherProps} />\r\n );\r\n}\r\n\r\n/** Properties of [[FormatTypeOptionProps]] component.\r\n * @alpha\r\n */\r\nexport interface FormatTypeOptionProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to set the Quantity Format type.\r\n * @alpha\r\n */\r\nexport function FormatTypeOption(props: FormatTypeOptionProps) {\r\n const { formatProps, onChange } = props;\r\n const handleFormatTypeChange = React.useCallback((newType: FormatType) => {\r\n const type = formatTypeToString(newType);\r\n let precision: number | undefined;\r\n let stationOffsetSize: number | undefined;\r\n let scientificType: string | undefined;\r\n switch (newType) { // type must be decimal, fractional, scientific, or station\r\n case FormatType.Scientific:\r\n precision = DecimalPrecision.Six;\r\n scientificType = scientificTypeToString(ScientificType.Normalized);\r\n break;\r\n case FormatType.Decimal:\r\n precision = DecimalPrecision.Four;\r\n break;\r\n case FormatType.Station:\r\n precision = DecimalPrecision.Two;\r\n stationOffsetSize = formatProps.composite?.units[0].name.toLocaleLowerCase().endsWith(\"m\") ? 3 : 2;\r\n break;\r\n case FormatType.Fractional:\r\n precision = FractionalPrecision.Eight;\r\n break;\r\n }\r\n const newFormatProps = { ...formatProps, type, precision, scientificType, stationOffsetSize };\r\n onChange && onChange(newFormatProps);\r\n }, [formatProps, onChange]);\r\n\r\n const formatType = parseFormatType(formatProps.type, \"format\");\r\n const label = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.type\"));\r\n\r\n return (\r\n <>\r\n <span className={\"uicore-label.current\"}>{label.current}</span>\r\n <FormatTypeSelector data-testid=\"format-type-selector\" type={formatType} onChange={handleFormatTypeChange} />\r\n </>\r\n );\r\n}\r\n\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,wDAAyF;AACzF,wDAAsE;AACtE,8DAA2D;AAQ3D,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAyB;QAC7D,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,qBAAqB,CAAC,EAAE;QACz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,IAAA,oBAAU,EAAC,cAAc,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,IAAI,iBAAiB,CAAC,IAAG,cAAc,CAAC,OAAO,CAAQ;QAChJ,oBAAC,oBAAoB,mBAAa,sBAAsB,EAAC,SAAS,EAAE,WAAW,CAAC,YAAY,IAAI,EAAE,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,GAAI,CAClM,CACJ,CAAC;AACJ,CAAC;AAtDD,0CAsDC","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 { CommonProps } from \"@itwin/core-react\";\nimport { Format, FormatProps, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport { Checkbox, Select, SelectOption } from \"@itwin/itwinui-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\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 uomDefaultEntries = React.useRef<SelectOption<string>[]>([\n { value: \"\", label: UiIModelComponents.translate(\"QuantityFormat.none\") },\n { value: \" \", label: UiIModelComponents.translate(\"QuantityFormat.space\") },\n { value: \"-\", label: UiIModelComponents.translate(\"QuantityFormat.dash\") },\n ]);\n\n const handleOnChange = React.useCallback((newValue: string) => {\n onChange && onChange(newValue);\n }, [onChange]);\n\n const separatorOptions = React.useMemo(() => {\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 (undefined === uomDefaultEntries.current.find((option) => option.value === separator)) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries.current);\n return completeListOfEntries;\n }, [separator]);\n\n return (\n <Select options={separatorOptions} value={separator} onChange={handleOnChange} size=\"small\" {...otherProps} />\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\n const handleSetFormatProps = React.useCallback((newProps: FormatProps) => {\n onUnitLabelChange && onUnitLabelChange(newProps);\n }, [onUnitLabelChange]);\n\n const isFormatTraitSet = React.useCallback((trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n }, [formatProps]);\n\n const setFormatTrait = React.useCallback((trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {// setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\n // istanbul ignore else\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {// clearing trait\n // istanbul ignore next\n if (!formatProps.formatTraits)\n return;\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const handleUomSeparatorChange = React.useCallback((newSeparator: string) => {\n const newFormatProps = { ...formatProps, uomSeparator: newSeparator };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const handleShowUnitLabelChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ShowUnitLabel, e.target.checked);\n }, [setFormatTrait]);\n\n const appendUnitLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.appendUnitLabel\"));\n const labelSeparator = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.labelSeparator\"));\n\n return (\n <>\n <span className={\"uicore-label\"}>{appendUnitLabel.current}</span>\n <Checkbox data-testid=\"show-unit-label-checkbox\" checked={isFormatTraitSet(FormatTraits.ShowUnitLabel)} onChange={handleShowUnitLabelChange} />\n <span className={classnames(\"uicore-label\", !isFormatTraitSet(FormatTraits.ShowUnitLabel) && \"uicore-disabled\")}>{labelSeparator.current}</span>\n <UomSeparatorSelector data-testid=\"uom-separator-select\" separator={formatProps.uomSeparator ?? \"\"} onChange={handleUomSeparatorChange} disabled={!isFormatTraitSet(FormatTraits.ShowUnitLabel)} />\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"FormatUnitLabel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnitLabel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,wDAAyF;AACzF,wDAAsE;AACtE,8DAA2D;AAQ3D,SAAS,oBAAoB,CAAC,KAAgC;IAC5D,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAyB;QAC7D,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,qBAAqB,CAAC,EAAE;QACzE,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,sBAAsB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IAAI,iBAAiB,CAAC,IAAG,cAAc,CAAC,OAAO,CAAQ;QAChJ,oBAAC,oBAAoB,mBAAa,sBAAsB,EAAC,SAAS,EAAE,WAAW,CAAC,YAAY,IAAI,EAAE,EAAE,QAAQ,EAAE,wBAAwB,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,aAAa,CAAC,GAAI,CAClM,CACJ,CAAC;AACJ,CAAC;AAtDD,0CAsDC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Format, FormatProps, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\r\nimport { Checkbox, Select, SelectOption } from \"@itwin/itwinui-react\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\ninterface UomSeparatorSelectorProps extends CommonProps {\r\n separator: string;\r\n disabled?: boolean;\r\n onChange: (value: string) => void;\r\n}\r\n\r\nfunction UomSeparatorSelector(props: UomSeparatorSelectorProps) {\r\n const { separator, onChange, ...otherProps } = props;\r\n const uomDefaultEntries = React.useRef<SelectOption<string>[]>([\r\n { value: \"\", label: UiIModelComponents.translate(\"QuantityFormat.none\") },\r\n { value: \" \", label: UiIModelComponents.translate(\"QuantityFormat.space\") },\r\n { value: \"-\", label: UiIModelComponents.translate(\"QuantityFormat.dash\") },\r\n ]);\r\n\r\n const handleOnChange = React.useCallback((newValue: string) => {\r\n onChange && onChange(newValue);\r\n }, [onChange]);\r\n\r\n const separatorOptions = React.useMemo(() => {\r\n const completeListOfEntries: SelectOption<string>[] = [];\r\n // istanbul ignore next (only used if format already has a character that does not match standard options)\r\n if (undefined === uomDefaultEntries.current.find((option) => option.value === separator)) {\r\n completeListOfEntries.push({ value: separator, label: separator });\r\n }\r\n completeListOfEntries.push(...uomDefaultEntries.current);\r\n return completeListOfEntries;\r\n }, [separator]);\r\n\r\n return (\r\n <Select options={separatorOptions} value={separator} onChange={handleOnChange} size=\"small\" {...otherProps} />\r\n );\r\n}\r\n\r\n/** Properties of [[FormatUnitLabel]] component.\r\n * @alpha\r\n */\r\nexport interface FormatUnitLabelProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onUnitLabelChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to set the label separator definition in a Quantity Format and if it the label is to be displayed.\r\n * @alpha\r\n */\r\nexport function FormatUnitLabel(props: FormatUnitLabelProps) {\r\n const { formatProps, onUnitLabelChange } = props;\r\n\r\n const handleSetFormatProps = React.useCallback((newProps: FormatProps) => {\r\n onUnitLabelChange && onUnitLabelChange(newProps);\r\n }, [onUnitLabelChange]);\r\n\r\n const isFormatTraitSet = React.useCallback((trait: FormatTraits) => {\r\n return Format.isFormatTraitSetInProps(formatProps, trait);\r\n }, [formatProps]);\r\n\r\n const setFormatTrait = React.useCallback((trait: FormatTraits, setActive: boolean) => {\r\n const traitStr = getTraitString(trait);\r\n let formatTraits: string[] = [traitStr];\r\n if (setActive) {// setting trait\r\n // istanbul ignore else\r\n if (formatProps.formatTraits) {\r\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\r\n // istanbul ignore else\r\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\r\n formatTraits = [...traits, traitStr];\r\n }\r\n }\r\n } else {// clearing trait\r\n // istanbul ignore next\r\n if (!formatProps.formatTraits)\r\n return;\r\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\r\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\r\n }\r\n const newFormatProps = { ...formatProps, formatTraits };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleUomSeparatorChange = React.useCallback((newSeparator: string) => {\r\n const newFormatProps = { ...formatProps, uomSeparator: newSeparator };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleShowUnitLabelChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.ShowUnitLabel, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const appendUnitLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.appendUnitLabel\"));\r\n const labelSeparator = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.labelSeparator\"));\r\n\r\n return (\r\n <>\r\n <span className={\"uicore-label\"}>{appendUnitLabel.current}</span>\r\n <Checkbox data-testid=\"show-unit-label-checkbox\" checked={isFormatTraitSet(FormatTraits.ShowUnitLabel)} onChange={handleShowUnitLabelChange} />\r\n <span className={classnames(\"uicore-label\", !isFormatTraitSet(FormatTraits.ShowUnitLabel) && \"uicore-disabled\")}>{labelSeparator.current}</span>\r\n <UomSeparatorSelector data-testid=\"uom-separator-select\" separator={formatProps.uomSeparator ?? \"\"} onChange={handleUomSeparatorChange} disabled={!isFormatTraitSet(FormatTraits.ShowUnitLabel)} />\r\n </>\r\n );\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatUnits.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/FormatUnits.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAA6C;AAC7C,gDAA6C;AAC7C,8DAA2D;AAY3D;;GAEG;AACH,SAAgB,WAAW,CAAC,KAAuB;IACjD,MAAM,EAAE,aAAa,EAAE,eAAe,EAAE,aAAa,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC;IAC/E,MAAM,gBAAgB,GAAG,KA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C,WAAW,CAAC,SAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAI,CAAC;YAClE,CAAC;gBACD,eAAe,IAAI,oBAAC,qBAAS,IAAC,GAAG,EAAE,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EACjF,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,GAAI;QAGjJ,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YACvE;gBACE,8BAAM,GAAG,EAAE,wBAAwB,EAAE,SAAS,EAAE,cAAc,IAAG,eAAe,CAAC,OAAO,CAAQ;gBAChG,oBAAC,qBAAK,IAAC,GAAG,EAAE,kBAAkB,iBAAc,kBAAkB,EAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAC,OAAO,GAAG,CACxJ,CAEJ,CACJ,CAAC;AACJ,CAAC;AA1GD,kCA0GC","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 { CommonProps } from \"@itwin/core-react\";\nimport { FormatProps, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport { Input } from \"@itwin/itwinui-react\";\nimport { UnitDescr } from \"./misc/UnitDescr\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\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 } = props;\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((newProps: FormatProps) => {\n setFormatProps(newProps);\n onUnitsChange && onUnitsChange(newProps);\n }, [onUnitsChange]);\n\n const handleUnitLabelChange = React.useCallback((newLabel: string, index: number) => {\n // istanbul ignore else\n if (formatProps.composite && formatProps.composite.units.length > index && index >= 0) {\n const units = formatProps.composite.units.map((entry, ndx) => {\n // istanbul ignore else\n if (index === ndx)\n return { name: entry.name, label: newLabel };\n else\n return entry;\n });\n\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }, [formatProps, handleSetFormatProps]);\n\n const handleUnitChange = React.useCallback((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 = formatProps.composite && formatProps.composite.units.length ?\n [...formatProps.composite.units, { name: unitParts[1], label: unitParts[2] }] :\n /* istanbul ignore next*/[{ name: unitParts[1], label: unitParts[2] }];\n const composite = { ...formatProps.composite, units };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n } else {\n // istanbul ignore else\n if (formatProps.composite && formatProps.composite.units.length > index && index >= 0) {\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\n 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 = { units: [{ name: unitParts[0], label: unitParts[1] }] };\n const newFormatProps = { ...formatProps, composite };\n handleSetFormatProps(newFormatProps);\n }\n }\n }, [formatProps, handleSetFormatProps]);\n\n const handleOnSpacerChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n // istanbul ignore else\n if (formatProps.composite) {\n const spacerValue = e.target.value.length ? e.target.value[0] : /* 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 }, [formatProps, handleSetFormatProps]);\n\n const compositeSpacer = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.compositeSpacer\"));\n\n return (\n <>\n {(formatProps.composite?.units)\n ?\n formatProps.composite.units.map((value, index) => <UnitDescr key={value.name} name={value.name}\n label={value.label ?? \"\"} parentUnitName={index > 0 ? formatProps.composite!.units[index - 1].name :\n undefined} unitsProvider={unitsProvider} index={index} onUnitChange={handleUnitChange} onLabelChange={handleUnitLabelChange}\n readonly={index < (formatProps.composite!.units.length - 1)} />)\n :\n persistenceUnit && <UnitDescr key={persistenceUnit.name} name={persistenceUnit.name}\n label={persistenceUnit.label} unitsProvider={unitsProvider} index={0} onUnitChange={handleUnitChange} onLabelChange={handleUnitLabelChange} />\n }\n\n {(formatProps.composite?.units && formatProps.composite.units.length > 1) &&\n <>\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>{compositeSpacer.current}</span>\n <Input key={\"composite-spacer\"} data-testid=\"composite-spacer\" value={formatProps.composite.spacer ?? \"\"} onChange={handleOnSpacerChange} size=\"small\" />\n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AAG,EAAE,KAAK,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAC5F,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,EAAE,EAAE,cAAc,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAU,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;wBAClG,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,EAC7H,QAAQ,EAAE,KAAK,GAAG,CAAC,WAAW,CAAC,SAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,GAAI,CAAC;YAClE,CAAC;gBACD,eAAe,IAAI,oBAAC,qBAAS,IAAC,GAAG,EAAE,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,eAAe,CAAC,IAAI,EACjF,KAAK,EAAE,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,gBAAgB,EAAE,aAAa,EAAE,qBAAqB,GAAI;QAGjJ,CAAC,WAAW,CAAC,SAAS,EAAE,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;YACvE;gBACE,8BAAM,GAAG,EAAE,wBAAwB,EAAE,SAAS,EAAE,cAAc,IAAG,eAAe,CAAC,OAAO,CAAQ;gBAChG,oBAAC,qBAAK,IAAC,GAAG,EAAE,kBAAkB,iBAAc,kBAAkB,EAAC,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,MAAM,IAAI,EAAE,EAAE,QAAQ,EAAE,oBAAoB,EAAE,IAAI,EAAC,OAAO,GAAG,CACxJ,CAEJ,CACJ,CAAC;AACJ,CAAC;AA1GD,kCA0GC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { FormatProps, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\r\nimport { Input } from \"@itwin/itwinui-react\";\r\nimport { UnitDescr } from \"./misc/UnitDescr\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties of [[FormatUnits]] component.\r\n * @alpha\r\n */\r\nexport interface FormatUnitsProps extends CommonProps {\r\n initialFormat: FormatProps;\r\n persistenceUnit?: UnitProps;\r\n unitsProvider: UnitsProvider;\r\n onUnitsChange?: (format: FormatProps) => void;\r\n}\r\n\r\n/** Component to show/edit Units used for Quantity Formatting.\r\n * @alpha\r\n */\r\nexport function FormatUnits(props: FormatUnitsProps) {\r\n const { initialFormat, persistenceUnit, unitsProvider, onUnitsChange } = props;\r\n const initialFormatRef = React.useRef<FormatProps>(initialFormat);\r\n const [formatProps, setFormatProps] = React.useState(initialFormat);\r\n\r\n React.useEffect(() => {\r\n if (initialFormatRef.current !== initialFormat) {\r\n initialFormatRef.current = initialFormat;\r\n setFormatProps(initialFormat);\r\n }\r\n }, [initialFormat]);\r\n\r\n const handleSetFormatProps = React.useCallback((newProps: FormatProps) => {\r\n setFormatProps(newProps);\r\n onUnitsChange && onUnitsChange(newProps);\r\n }, [onUnitsChange]);\r\n\r\n const handleUnitLabelChange = React.useCallback((newLabel: string, index: number) => {\r\n // istanbul ignore else\r\n if (formatProps.composite && formatProps.composite.units.length > index && index >= 0) {\r\n const units = formatProps.composite.units.map((entry, ndx) => {\r\n // istanbul ignore else\r\n if (index === ndx)\r\n return { name: entry.name, label: newLabel };\r\n else\r\n return entry;\r\n });\r\n\r\n const composite = { ...formatProps.composite, units };\r\n const newFormatProps = { ...formatProps, composite };\r\n handleSetFormatProps(newFormatProps);\r\n }\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleUnitChange = React.useCallback((newUnit: string, index: number) => {\r\n const unitParts = newUnit.split(/:/);\r\n if (unitParts[0] === \"REMOVEUNIT\") {\r\n // istanbul ignore else\r\n if (formatProps.composite && formatProps.composite.units.length > 1) {\r\n const units = [...formatProps.composite.units];\r\n units.pop();\r\n const composite = { ...formatProps.composite, units };\r\n const newFormatProps = { ...formatProps, composite };\r\n handleSetFormatProps(newFormatProps);\r\n }\r\n } else if (unitParts[0] === \"ADDSUBUNIT\") {\r\n const units = formatProps.composite && formatProps.composite.units.length ?\r\n [...formatProps.composite.units, { name: unitParts[1], label: unitParts[2] }] :\r\n /* istanbul ignore next*/[{ name: unitParts[1], label: unitParts[2] }];\r\n const composite = { ...formatProps.composite, units };\r\n const newFormatProps = { ...formatProps, composite };\r\n handleSetFormatProps(newFormatProps);\r\n } else {\r\n // istanbul ignore else\r\n if (formatProps.composite && formatProps.composite.units.length > index && index >= 0) {\r\n const units = formatProps.composite.units.map((entry, ndx) => {\r\n // istanbul ignore else\r\n if (index === ndx)\r\n return { name: unitParts[0], label: unitParts[1] };\r\n else\r\n return entry;\r\n });\r\n const composite = { ...formatProps.composite, units };\r\n const newFormatProps = { ...formatProps, composite };\r\n handleSetFormatProps(newFormatProps);\r\n } else if (!formatProps.composite) {\r\n const composite = { units: [{ name: unitParts[0], label: unitParts[1] }] };\r\n const newFormatProps = { ...formatProps, composite };\r\n handleSetFormatProps(newFormatProps);\r\n }\r\n }\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleOnSpacerChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n // istanbul ignore else\r\n if (formatProps.composite) {\r\n const spacerValue = e.target.value.length ? e.target.value[0] : /* istanbul ignore next */ \"\"; // spacer can only be empty or a single character\r\n const composite = { ...formatProps.composite, spacer: spacerValue };\r\n const newFormatProps = { ...formatProps, composite };\r\n handleSetFormatProps(newFormatProps);\r\n }\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const compositeSpacer = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.compositeSpacer\"));\r\n\r\n return (\r\n <>\r\n {(formatProps.composite?.units)\r\n ?\r\n formatProps.composite.units.map((value, index) => <UnitDescr key={value.name} name={value.name}\r\n label={value.label ?? \"\"} parentUnitName={index > 0 ? formatProps.composite!.units[index - 1].name :\r\n undefined} unitsProvider={unitsProvider} index={index} onUnitChange={handleUnitChange} onLabelChange={handleUnitLabelChange}\r\n readonly={index < (formatProps.composite!.units.length - 1)} />)\r\n :\r\n persistenceUnit && <UnitDescr key={persistenceUnit.name} name={persistenceUnit.name}\r\n label={persistenceUnit.label} unitsProvider={unitsProvider} index={0} onUnitChange={handleUnitChange} onLabelChange={handleUnitLabelChange} />\r\n }\r\n\r\n {(formatProps.composite?.units && formatProps.composite.units.length > 1) &&\r\n <>\r\n <span key={\"composite-spacer-label\"} className={\"uicore-label\"}>{compositeSpacer.current}</span>\r\n <Input key={\"composite-spacer\"} data-testid=\"composite-spacer\" value={formatProps.composite.spacer ?? \"\"} onChange={handleOnSpacerChange} size=\"small\" />\r\n </>\r\n }\r\n </>\r\n );\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAmD;AAEnD,wDAAgD;AAChD,wDAE8B;AAC9B,kDAAuD;AACvD,kEAA+D;AAC/D,8DAAmE;AACnE,0DAA+D;AAC/D,8EAA2E;AAC3E,oEAAiE;AACjE,8DAA2D;AAc3D;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,iBAAiB,EAAE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UAAU,KAAK,0BAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,0BAA0B,GAAI;gBAEzF,KAAK,CAAC,QAAQ;gBAGb,uBAAuB,IAAI,WAAW,IAAI,2BAAG,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,iBAAiB,EACvG,SAAS,EAAE,qCAAqC,EAAE,IAAI,EAAC,MAAM,iBAAa,qBAAqB,EAAC,QAAQ,EAAE,CAAC,IAAG,SAAS,CAAC,OAAO,CAAK,CACvI,CAEJ,CACJ,CAAC;AACJ,CAAC;AAjLD,8CAiLC","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 { SpecialKey } from \"@itwin/appui-abstract\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport { Checkbox } from \"@itwin/itwinui-react\";\nimport { Format, FormatProps, FormatTraits, FormatType, getTraitString, parseFormatType, parseScientificType,\n parseShowSignOption, ScientificType, scientificTypeToString, ShowSignOption, 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 { UiIModelComponents } from \"../UiIModelComponents\";\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 { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties } = props;\n\n const handleSetFormatProps = React.useCallback((newFormatProps: FormatProps) => {\n onChange && onChange(newFormatProps);\n }, [onChange]);\n\n const isFormatTraitSet = React.useCallback((trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n }, [formatProps]);\n\n const handleShowSignChange = React.useCallback((option: ShowSignOption) => {\n const newShowSignOption = showSignOptionToString(option);\n const newFormatProps = { ...formatProps, showSignOption: newShowSignOption };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const setFormatTrait = React.useCallback((trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {// setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\n // istanbul ignore else\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\n formatTraits = [...traits, traitStr];\n }\n }\n } else {// clearing trait\n // istanbul ignore next\n if (!formatProps.formatTraits)\n return;\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const handleShowTrailingZeroesChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\n }, [setFormatTrait]);\n\n const handleKeepDecimalPointChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\n }, [setFormatTrait]);\n\n const handleKeepSingleZeroChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\n }, [setFormatTrait]);\n\n const handleZeroEmptyChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\n }, [setFormatTrait]);\n\n const handleUseFractionDashChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\n }, [setFormatTrait]);\n\n const handleDecimalSeparatorChange = React.useCallback((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 = { ...formatProps, thousandSeparator, decimalSeparator };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, isFormatTraitSet, handleSetFormatProps]);\n\n const handleScientificTypeChange = React.useCallback((type: ScientificType) => {\n const newFormatProps = { ...formatProps, scientificType: scientificTypeToString(type) };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const handleFormatChange = React.useCallback((newFormatProps: FormatProps) => {\n handleSetFormatProps(newFormatProps);\n }, [handleSetFormatProps]);\n\n const formatType = React.useMemo(() => parseFormatType(formatProps.type, \"format\"), [formatProps.type]);\n const showSignOption = React.useMemo(() => parseShowSignOption(formatProps.showSignOption ?? \"onlyNegative\", \"format\"), [formatProps.showSignOption]);\n\n const handleToggleButtonClick = React.useCallback(() => {\n onShowHideOptions(!showOptions);\n }, [onShowHideOptions, showOptions]);\n\n const handleKeyUpOnLink = React.useCallback((e: React.KeyboardEvent<HTMLAnchorElement>) => {\n // istanbul ignore else\n if (e.key === SpecialKey.Enter || e.key === SpecialKey.Space) {\n onShowHideOptions(!showOptions);\n e.preventDefault();\n }\n }, [onShowHideOptions, showOptions]);\n\n const handleStationSeparatorChange = React.useCallback((value: string) => {\n const newFormatProps = { ...formatProps, stationSeparator: value };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const handleStationOffsetChange = React.useCallback((value: number) => {\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const signOptionLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.signOptionLabel\"));\n const stationOffsetLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationOffsetLabel\"));\n const stationSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationSeparatorLabel\"));\n const decimalSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.decimalSeparatorLabel\"));\n const showTrailZerosLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.showTrailZerosLabel\"));\n const keepSingleZeroLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepSingleZeroLabel\"));\n const zeroEmptyLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.zeroEmptyLabel\"));\n const moreLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.moreLabel\"));\n const lessLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.lessLabel\"));\n const keepDecimalPointLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepDecimalPointLabel\"));\n const fractionDashLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.fractionDashLabel\"));\n const scientificTypeLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.scientificTypeLabel\"));\n\n return (\n <>\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\n enableMinimumProperties && !showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-more\" tabIndex={0} >{moreLabel.current}</a>}\n {\n (!enableMinimumProperties || showOptions) &&\n <>\n <span className={\"uicore-label\"}>{signOptionLabel.current}</span>\n <SignOptionSelector data-testid=\"sign-option-selector\" signOption={showSignOption} onChange={handleShowSignChange} />\n\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationOffsetLabel.current}</span>\n <StationSizeSelector data-testid=\"station-size-selector\" value={(formatProps.stationOffsetSize ?? 2)}\n disabled={formatType !== FormatType.Station} onChange={handleStationOffsetChange} />\n\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationSeparatorLabel.current}</span>\n <StationSeparatorSelector data-testid=\"station-separator-selector\" separator={(undefined !== formatProps.stationSeparator ? formatProps.stationSeparator : \"+\")}\n disabled={formatType !== FormatType.Station} onChange={handleStationSeparatorChange} />\n\n <ThousandsSeparator formatProps={formatProps} onChange={handleFormatChange} />\n\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{decimalSeparatorLabel.current}</span>\n <DecimalSeparatorSelector data-testid=\"decimal-separator-selector\" separator={formatProps.decimalSeparator ?? \".\"} onChange={handleDecimalSeparatorChange} disabled={formatType === FormatType.Fractional} />\n\n <span className={\"uicore-label\"}>{showTrailZerosLabel.current}</span>\n <Checkbox data-testid=\"show-trail-zeros\" checked={isFormatTraitSet(FormatTraits.TrailZeroes)} onChange={handleShowTrailingZeroesChange} />\n\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{keepDecimalPointLabel.current}</span>\n <Checkbox data-testid=\"keep-decimal-point\" checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)} onChange={handleKeepDecimalPointChange} />\n\n <span className={\"uicore-label\"}>{keepSingleZeroLabel.current}</span>\n <Checkbox data-testid=\"keep-single-zero\" checked={isFormatTraitSet(FormatTraits.KeepSingleZero)} onChange={handleKeepSingleZeroChange} />\n\n <span className={\"uicore-label\"}>{zeroEmptyLabel.current}</span>\n <Checkbox data-testid=\"zero-empty\" checked={isFormatTraitSet(FormatTraits.ZeroEmpty)} onChange={handleZeroEmptyChange} />\n\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Fractional && \"uicore-disabled\")}>{fractionDashLabel.current}</span>\n <Checkbox data-testid=\"fraction-dash\" checked={isFormatTraitSet(FormatTraits.FractionDash)} onChange={handleUseFractionDashChange} disabled={formatType !== FormatType.Fractional} />\n\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Scientific && \"uicore-disabled\")}>{scientificTypeLabel.current}</span>\n <ScientificTypeSelector data-testid=\"scientific-type-selector\" type={(formatProps.scientificType && formatProps.scientificType.length > 0) ? parseScientificType(formatProps.scientificType, \"custom\") : ScientificType.Normalized}\n disabled={formatType !== FormatType.Scientific} onChange={handleScientificTypeChange} />\n\n {props.children}\n\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\n enableMinimumProperties && showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-less\" tabIndex={0}>{lessLabel.current}</a>}\n </>\n }\n </>\n );\n}\n"]}
1
+ {"version":3,"file":"MiscFormatOptions.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/MiscFormatOptions.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAC/B,0DAAmD;AAEnD,wDAAgD;AAChD,wDAE8B;AAC9B,kDAAuD;AACvD,kEAA+D;AAC/D,8DAAmE;AACnE,0DAA+D;AAC/D,8EAA2E;AAC3E,oEAAiE;AACjE,8DAA2D;AAc3D;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,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QAAQ,EAAE,UAAU,KAAK,0BAAU,CAAC,UAAU,EAAE,QAAQ,EAAE,0BAA0B,GAAI;gBAEzF,KAAK,CAAC,QAAQ;gBAGb,uBAAuB,IAAI,WAAW,IAAI,2BAAG,OAAO,EAAE,uBAAuB,EAAE,OAAO,EAAE,iBAAiB,EACvG,SAAS,EAAE,qCAAqC,EAAE,IAAI,EAAC,MAAM,iBAAa,qBAAqB,EAAC,QAAQ,EAAE,CAAC,IAAG,SAAS,CAAC,OAAO,CAAK,CACvI,CAEJ,CACJ,CAAC;AACJ,CAAC;AAjLD,8CAiLC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport classnames from \"classnames\";\r\nimport * as React from \"react\";\r\nimport { SpecialKey } from \"@itwin/appui-abstract\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Checkbox } from \"@itwin/itwinui-react\";\r\nimport { Format, FormatProps, FormatTraits, FormatType, getTraitString, parseFormatType, parseScientificType,\r\n parseShowSignOption, ScientificType, scientificTypeToString, ShowSignOption, showSignOptionToString,\r\n} from \"@itwin/core-quantity\";\r\nimport { SignOptionSelector } from \"./misc/SignOption\";\r\nimport { ThousandsSeparator } from \"./misc/ThousandsSeparator\";\r\nimport { DecimalSeparatorSelector } from \"./misc/DecimalSeparator\";\r\nimport { ScientificTypeSelector } from \"./misc/ScientificType\";\r\nimport { StationSeparatorSelector } from \"./misc/StationSeparatorSelector\";\r\nimport { StationSizeSelector } from \"./misc/StationSizeSelector\";\r\nimport { UiIModelComponents } from \"../UiIModelComponents\";\r\n\r\n/** Properties of [[MiscFormatOptions]] component.\r\n * @alpha\r\n */\r\nexport interface MiscFormatOptionsProps extends CommonProps {\r\n formatProps: FormatProps;\r\n onChange?: (format: FormatProps) => void;\r\n enableMinimumProperties?: boolean;\r\n showOptions: boolean;\r\n onShowHideOptions: (show: boolean) => void;\r\n children?: React.ReactNode;\r\n}\r\n\r\n/** Component use to set miscellaneous properties is a Formatted Quantity.\r\n * @alpha\r\n */\r\nexport function MiscFormatOptions(props: MiscFormatOptionsProps) {\r\n const { formatProps, onChange, showOptions, onShowHideOptions, enableMinimumProperties } = props;\r\n\r\n const handleSetFormatProps = React.useCallback((newFormatProps: FormatProps) => {\r\n onChange && onChange(newFormatProps);\r\n }, [onChange]);\r\n\r\n const isFormatTraitSet = React.useCallback((trait: FormatTraits) => {\r\n return Format.isFormatTraitSetInProps(formatProps, trait);\r\n }, [formatProps]);\r\n\r\n const handleShowSignChange = React.useCallback((option: ShowSignOption) => {\r\n const newShowSignOption = showSignOptionToString(option);\r\n const newFormatProps = { ...formatProps, showSignOption: newShowSignOption };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const setFormatTrait = React.useCallback((trait: FormatTraits, setActive: boolean) => {\r\n const traitStr = getTraitString(trait);\r\n let formatTraits: string[] = [traitStr];\r\n if (setActive) {// setting trait\r\n // istanbul ignore else\r\n if (formatProps.formatTraits) {\r\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\r\n // istanbul ignore else\r\n if (!traits.find((traitEntry) => traitStr === traitEntry)) {\r\n formatTraits = [...traits, traitStr];\r\n }\r\n }\r\n } else {// clearing trait\r\n // istanbul ignore next\r\n if (!formatProps.formatTraits)\r\n return;\r\n const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\\|/);\r\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\r\n }\r\n const newFormatProps = { ...formatProps, formatTraits };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleShowTrailingZeroesChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.TrailZeroes, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleKeepDecimalPointChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.KeepDecimalPoint, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleKeepSingleZeroChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.KeepSingleZero, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleZeroEmptyChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.ZeroEmpty, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleUseFractionDashChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n setFormatTrait(FormatTraits.FractionDash, e.target.checked);\r\n }, [setFormatTrait]);\r\n\r\n const handleDecimalSeparatorChange = React.useCallback((decimalSeparator: string) => {\r\n let thousandSeparator = formatProps.thousandSeparator;\r\n // make sure 1000 and decimal separator do not match\r\n // istanbul ignore else\r\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\r\n switch (decimalSeparator) {\r\n case \".\":\r\n thousandSeparator = \",\";\r\n break;\r\n case \",\":\r\n thousandSeparator = \".\";\r\n break;\r\n }\r\n }\r\n const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, isFormatTraitSet, handleSetFormatProps]);\r\n\r\n const handleScientificTypeChange = React.useCallback((type: ScientificType) => {\r\n const newFormatProps = { ...formatProps, scientificType: scientificTypeToString(type) };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleFormatChange = React.useCallback((newFormatProps: FormatProps) => {\r\n handleSetFormatProps(newFormatProps);\r\n }, [handleSetFormatProps]);\r\n\r\n const formatType = React.useMemo(() => parseFormatType(formatProps.type, \"format\"), [formatProps.type]);\r\n const showSignOption = React.useMemo(() => parseShowSignOption(formatProps.showSignOption ?? \"onlyNegative\", \"format\"), [formatProps.showSignOption]);\r\n\r\n const handleToggleButtonClick = React.useCallback(() => {\r\n onShowHideOptions(!showOptions);\r\n }, [onShowHideOptions, showOptions]);\r\n\r\n const handleKeyUpOnLink = React.useCallback((e: React.KeyboardEvent<HTMLAnchorElement>) => {\r\n // istanbul ignore else\r\n if (e.key === SpecialKey.Enter || e.key === SpecialKey.Space) {\r\n onShowHideOptions(!showOptions);\r\n e.preventDefault();\r\n }\r\n }, [onShowHideOptions, showOptions]);\r\n\r\n const handleStationSeparatorChange = React.useCallback((value: string) => {\r\n const newFormatProps = { ...formatProps, stationSeparator: value };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const handleStationOffsetChange = React.useCallback((value: number) => {\r\n const newFormatProps = { ...formatProps, stationOffsetSize: value };\r\n handleSetFormatProps(newFormatProps);\r\n }, [formatProps, handleSetFormatProps]);\r\n\r\n const signOptionLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.signOptionLabel\"));\r\n const stationOffsetLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationOffsetLabel\"));\r\n const stationSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.stationSeparatorLabel\"));\r\n const decimalSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.decimalSeparatorLabel\"));\r\n const showTrailZerosLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.showTrailZerosLabel\"));\r\n const keepSingleZeroLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepSingleZeroLabel\"));\r\n const zeroEmptyLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.zeroEmptyLabel\"));\r\n const moreLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.moreLabel\"));\r\n const lessLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.lessLabel\"));\r\n const keepDecimalPointLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.keepDecimalPointLabel\"));\r\n const fractionDashLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.fractionDashLabel\"));\r\n const scientificTypeLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.scientificTypeLabel\"));\r\n\r\n return (\r\n <>\r\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\r\n enableMinimumProperties && !showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\r\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-more\" tabIndex={0} >{moreLabel.current}</a>}\r\n {\r\n (!enableMinimumProperties || showOptions) &&\r\n <>\r\n <span className={\"uicore-label\"}>{signOptionLabel.current}</span>\r\n <SignOptionSelector data-testid=\"sign-option-selector\" signOption={showSignOption} onChange={handleShowSignChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationOffsetLabel.current}</span>\r\n <StationSizeSelector data-testid=\"station-size-selector\" value={(formatProps.stationOffsetSize ?? 2)}\r\n disabled={formatType !== FormatType.Station} onChange={handleStationOffsetChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Station && \"uicore-disabled\")}>{stationSeparatorLabel.current}</span>\r\n <StationSeparatorSelector data-testid=\"station-separator-selector\" separator={(undefined !== formatProps.stationSeparator ? formatProps.stationSeparator : \"+\")}\r\n disabled={formatType !== FormatType.Station} onChange={handleStationSeparatorChange} />\r\n\r\n <ThousandsSeparator formatProps={formatProps} onChange={handleFormatChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{decimalSeparatorLabel.current}</span>\r\n <DecimalSeparatorSelector data-testid=\"decimal-separator-selector\" separator={formatProps.decimalSeparator ?? \".\"} onChange={handleDecimalSeparatorChange} disabled={formatType === FormatType.Fractional} />\r\n\r\n <span className={\"uicore-label\"}>{showTrailZerosLabel.current}</span>\r\n <Checkbox data-testid=\"show-trail-zeros\" checked={isFormatTraitSet(FormatTraits.TrailZeroes)} onChange={handleShowTrailingZeroesChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType === FormatType.Fractional && \"uicore-disabled\")}>{keepDecimalPointLabel.current}</span>\r\n <Checkbox data-testid=\"keep-decimal-point\" checked={isFormatTraitSet(FormatTraits.KeepDecimalPoint)} onChange={handleKeepDecimalPointChange} />\r\n\r\n <span className={\"uicore-label\"}>{keepSingleZeroLabel.current}</span>\r\n <Checkbox data-testid=\"keep-single-zero\" checked={isFormatTraitSet(FormatTraits.KeepSingleZero)} onChange={handleKeepSingleZeroChange} />\r\n\r\n <span className={\"uicore-label\"}>{zeroEmptyLabel.current}</span>\r\n <Checkbox data-testid=\"zero-empty\" checked={isFormatTraitSet(FormatTraits.ZeroEmpty)} onChange={handleZeroEmptyChange} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Fractional && \"uicore-disabled\")}>{fractionDashLabel.current}</span>\r\n <Checkbox data-testid=\"fraction-dash\" checked={isFormatTraitSet(FormatTraits.FractionDash)} onChange={handleUseFractionDashChange} disabled={formatType !== FormatType.Fractional} />\r\n\r\n <span className={classnames(\"uicore-label\", formatType !== FormatType.Scientific && \"uicore-disabled\")}>{scientificTypeLabel.current}</span>\r\n <ScientificTypeSelector data-testid=\"scientific-type-selector\" type={(formatProps.scientificType && formatProps.scientificType.length > 0) ? parseScientificType(formatProps.scientificType, \"custom\") : ScientificType.Normalized}\r\n disabled={formatType !== FormatType.Scientific} onChange={handleScientificTypeChange} />\r\n\r\n {props.children}\r\n\r\n { // eslint-disable-next-line jsx-a11y/anchor-is-valid\r\n enableMinimumProperties && showOptions && <a onClick={handleToggleButtonClick} onKeyUp={handleKeyUpOnLink}\r\n className={\"components-quantityFormat-more-less\"} role=\"link\" data-testid=\"quantityFormat-less\" tabIndex={0}>{lessLabel.current}</a>}\r\n </>\r\n }\r\n </>\r\n );\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,wDAG8B;AAG9B,wDAA+D;AAC/D,+CAA4C;AAC5C,wDAAmD;AAEnD,SAAS,+BAA+B,CAAC,GAAW,EAAE,KAAa,EAAE,OAAoB,EACvF,SAAyC,EAAE,SAA6D,EAAE,gBAAiD;IAC3J,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,IAAG,KAAK,CAAQ;QACpE,oBAAC,qBAAK,mBAAc,GAAG,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,SAAS,EACvD,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,CAAC,GAAW,EAAE,KAAa,EAAE,OAA2C,EAAE,OAAoB,EACjI,SAAyC,EAAE,SAA6D,EAAE,gBAAiD;IAC3J,MAAM,KAAK,GAAG,SAAS,CAAC,OAAO,CAAC,CAAC;IACjC,OAAO,CACL,oBAAC,KAAK,CAAC,QAAQ,IAAC,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BAAuB;YACvB,IAAI,sBAAsB,CAAC,wBAAwB;gBACjD,OAAO,uBAAuB,CAAC,sBAAsB,CAAC,wBAAwB,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAC9G;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9C,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,KAAK,EAAE,OAAoB,EAAE,gBAA2B,EAAE,cAA6B,EAAE,EAAE;QACzF,OAAO,yBAAS,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAErB,OAAO,CACL,6BAAK,SAAS,EAAC,yCAAyC,IACrD,eAAe,IAAI,WAAW;QAC7B,oBAAC,yBAAW,IAAC,cAAc,EAAE,qBAAqB,KAAM,UAAU,EAChE,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,CACA,CACP,CAAC;AACJ,CAAC;AAlGD,kDAkGC","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 {\n CustomFormatPropEditorSpec, getQuantityTypeKey, IModelApp, isCheckboxFormatPropEditorSpec, isCustomQuantityTypeDefinition,\n isTextInputFormatPropEditorSpec, isTextSelectFormatPropEditorSpec, QuantityTypeArg,\n} from \"@itwin/core-frontend\";\nimport { FormatProps, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport { 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(key: string, label: string, inProps: FormatProps,\n getString: (props: FormatProps) => string, setString: (props: FormatProps, value: string) => FormatProps, fireFormatChange: (newProps: FormatProps) => void) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>{label}</span>\n <Input data-testid={`${key}-editor`} 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(key: string, label: string, options: { label: string, value: string }[], inProps: FormatProps,\n getString: (props: FormatProps) => string, setString: (props: FormatProps, value: string) => FormatProps, fireFormatChange: (newProps: FormatProps) => void) {\n const value = getString(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>{label}</span>\n <Select data-testid={`${key}-editor`} 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(key: string, label: string, inProps: FormatProps,\n getBool: (props: FormatProps) => boolean, setBool: (props: FormatProps, isChecked: boolean) => FormatProps, fireFormatChange: (newProps: FormatProps) => void) {\n const isChecked = getBool(inProps);\n return (\n <React.Fragment key={`${key}`}>\n <span key={`${key}-label`} className={\"uicore-label\"}>{label}</span>\n <Checkbox data-testid={`${key}-editor`} key={`${key}-editor`}\n checked={isChecked}\n onChange={(e) => {\n const newProps = setBool(inProps, e.target.checked);\n fireFormatChange(newProps);\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 = 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 = 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 = 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(async (newProps: FormatProps) => {\n setFormatProps(newProps);\n onFormatChange && onFormatChange(newProps);\n }, [onFormatChange]);\n\n const createCustomPropEditors = React.useCallback((specs: CustomFormatPropEditorSpec[], inProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => {\n return specs.map((spec, index) => {\n if (isCheckboxFormatPropEditorSpec(spec))\n return createCheckboxFormatPropEditor(`${spec.editorType}-${index}`, spec.label, inProps, spec.getBool, spec.setBool, fireFormatChange);\n if (isTextSelectFormatPropEditorSpec(spec))\n return createSelectFormatPropEditor(`${spec.editorType}-${index}`, spec.label, spec.selectOptions, inProps, spec.getString, spec.setString, fireFormatChange);\n /* istanbul ignore else */\n if (isTextInputFormatPropEditorSpec(spec))\n return createTextInputFormatPropEditor(`${spec.editorType}-${index}`, spec.label, inProps, spec.getString, spec.setString, fireFormatChange);\n /* istanbul ignore next */\n return <div key={index} />;\n });\n }, []);\n\n const providePrimaryChildren = React.useCallback(\n (inProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition = IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition && isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)) {\n // istanbul ignore else\n if (quantityTypeDefinition.primaryPropEditorSpecs)\n return createCustomPropEditors(quantityTypeDefinition.primaryPropEditorSpecs, inProps, fireFormatChange);\n }\n return null;\n }, [createCustomPropEditors, quantityType]);\n\n const provideSecondaryChildren = React.useCallback(\n (inProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => {\n const quantityTypeKey = getQuantityTypeKey(quantityType);\n const quantityTypeDefinition = IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\n if (quantityTypeDefinition && isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\n quantityTypeDefinition.isCompatibleFormatProps(inProps)) {\n // istanbul ignore else\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\n return createCustomPropEditors(quantityTypeDefinition.secondaryPropEditorSpecs, inProps, fireFormatChange);\n }\n return null;\n }, [createCustomPropEditors, quantityType]);\n\n const provideFormatSpec = React.useCallback(\n async (inProps: FormatProps, _persistenceUnit: UnitProps, _unitsProvider: UnitsProvider) => {\n return IModelApp.quantityFormatter.generateFormatterSpecByType(quantityType, inProps);\n }, [quantityType]);\n\n return (\n <div className=\"components-quantityFormat-quantityPanel\">\n {persistenceUnit && formatProps &&\n <FormatPanel onFormatChange={handleOnFormatChanged} {...otherProps}\n initialFormat={formatProps}\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\n persistenceUnit={persistenceUnit}\n providePrimaryChildren={providePrimaryChildren}\n provideSecondaryChildren={provideSecondaryChildren}\n provideFormatSpec={provideFormatSpec}\n />}\n </div>\n );\n}\n"]}
1
+ {"version":3,"file":"QuantityFormatPanel.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/quantityformat/QuantityFormatPanel.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,wDAG8B;AAG9B,wDAA+D;AAC/D,+CAA4C;AAC5C,wDAAmD;AAEnD,SAAS,+BAA+B,CAAC,GAAW,EAAE,KAAa,EAAE,OAAoB,EACvF,SAAyC,EAAE,SAA6D,EAAE,gBAAiD;IAC3J,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,IAAG,KAAK,CAAQ;QACpE,oBAAC,qBAAK,mBAAc,GAAG,GAAG,SAAS,EAAE,GAAG,EAAE,GAAG,GAAG,SAAS,EACvD,KAAK,EAAE,KAAK,EACZ,IAAI,EAAC,OAAO,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;gBACd,MAAM,QAAQ,GAAG,SAAS,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M,wBAAwB,GAAG,KAAK,CAAC,WAAW,CAChD,CAAC,OAAoB,EAAE,gBAAiD,EAAE,EAAE;QAC1E,MAAM,eAAe,GAAG,IAAA,kCAAkB,EAAC,YAAY,CAAC,CAAC;QACzD,MAAM,sBAAsB,GAAG,yBAAS,CAAC,iBAAiB,CAAC,qBAAqB,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACtG,IAAI,sBAAsB,IAAI,IAAA,8CAA8B,EAAC,sBAAsB,CAAC;YAClF,sBAAsB,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE;YACzD,uBAAuB;YACvB,IAAI,sBAAsB,CAAC,wBAAwB;gBACjD,OAAO,uBAAuB,CAAC,sBAAsB,CAAC,wBAAwB,EAAE,OAAO,EAAE,gBAAgB,CAAC,CAAC;SAC9G;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC,CAAC;IAE9C,MAAM,iBAAiB,GAAG,KAAK,CAAC,WAAW,CACzC,KAAK,EAAE,OAAoB,EAAE,gBAA2B,EAAE,cAA6B,EAAE,EAAE;QACzF,OAAO,yBAAS,CAAC,iBAAiB,CAAC,2BAA2B,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IACxF,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAErB,OAAO,CACL,6BAAK,SAAS,EAAC,yCAAyC,IACrD,eAAe,IAAI,WAAW;QAC7B,oBAAC,yBAAW,IAAC,cAAc,EAAE,qBAAqB,KAAM,UAAU,EAChE,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,CACA,CACP,CAAC;AACJ,CAAC;AAlGD,kDAkGC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport {\r\n CustomFormatPropEditorSpec, getQuantityTypeKey, IModelApp, isCheckboxFormatPropEditorSpec, isCustomQuantityTypeDefinition,\r\n isTextInputFormatPropEditorSpec, isTextSelectFormatPropEditorSpec, QuantityTypeArg,\r\n} from \"@itwin/core-frontend\";\r\nimport { FormatProps, UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Checkbox, Input, Select } from \"@itwin/itwinui-react\";\r\nimport { FormatPanel } from \"./FormatPanel\";\r\nimport { DeepCompare } from \"@itwin/core-geometry\";\r\n\r\nfunction createTextInputFormatPropEditor(key: string, label: string, inProps: FormatProps,\r\n getString: (props: FormatProps) => string, setString: (props: FormatProps, value: string) => FormatProps, fireFormatChange: (newProps: FormatProps) => void) {\r\n const value = getString(inProps);\r\n return (\r\n <React.Fragment key={`${key}`}>\r\n <span key={`${key}-label`} className={\"uicore-label\"}>{label}</span>\r\n <Input data-testid={`${key}-editor`} key={`${key}-editor`}\r\n value={value}\r\n size=\"small\"\r\n onChange={(e) => {\r\n const newProps = setString(inProps, e.currentTarget.value);\r\n fireFormatChange(newProps);\r\n }}\r\n />\r\n </React.Fragment>\r\n );\r\n}\r\nfunction createSelectFormatPropEditor(key: string, label: string, options: { label: string, value: string }[], inProps: FormatProps,\r\n getString: (props: FormatProps) => string, setString: (props: FormatProps, value: string) => FormatProps, fireFormatChange: (newProps: FormatProps) => void) {\r\n const value = getString(inProps);\r\n return (\r\n <React.Fragment key={`${key}`}>\r\n <span key={`${key}-label`} className={\"uicore-label\"}>{label}</span>\r\n <Select data-testid={`${key}-editor`} key={`${key}-editor`}\r\n value={value}\r\n options={options}\r\n size={\"small\"}\r\n onChange={(newValue) => {\r\n const newProps = setString(inProps, newValue);\r\n fireFormatChange(newProps);\r\n }}\r\n />\r\n </React.Fragment>\r\n );\r\n}\r\n\r\nfunction createCheckboxFormatPropEditor(key: string, label: string, inProps: FormatProps,\r\n getBool: (props: FormatProps) => boolean, setBool: (props: FormatProps, isChecked: boolean) => FormatProps, fireFormatChange: (newProps: FormatProps) => void) {\r\n const isChecked = getBool(inProps);\r\n return (\r\n <React.Fragment key={`${key}`}>\r\n <span key={`${key}-label`} className={\"uicore-label\"}>{label}</span>\r\n <Checkbox data-testid={`${key}-editor`} key={`${key}-editor`}\r\n checked={isChecked}\r\n onChange={(e) => {\r\n const newProps = setBool(inProps, e.target.checked);\r\n fireFormatChange(newProps);\r\n }} />\r\n </React.Fragment>\r\n );\r\n}\r\n\r\nfunction formatAreEqual(obj1: FormatProps, obj2: FormatProps) {\r\n const compare = new DeepCompare();\r\n return compare.compare(obj1, obj2);\r\n}\r\n\r\n/** Properties of [[QuantityFormatPanel]] component.\r\n * @alpha\r\n */\r\nexport interface QuantityFormatPanelProps extends CommonProps {\r\n quantityType: QuantityTypeArg;\r\n onFormatChange?: (format: FormatProps) => void;\r\n /** props below are to be passed on to FormatPanel */\r\n showSample?: boolean;\r\n initialMagnitude?: number;\r\n enableMinimumProperties?: boolean;\r\n}\r\n\r\n/** Component to set properties that control Quantity Formatting.\r\n * @alpha\r\n */\r\nexport function QuantityFormatPanel(props: QuantityFormatPanelProps) {\r\n const { quantityType, onFormatChange, ...otherProps } = props;\r\n const [formatProps, setFormatProps] = React.useState<FormatProps>();\r\n const initialFormatProps = React.useRef<FormatProps>();\r\n\r\n const [persistenceUnit, setPersistenceUnit] = React.useState<UnitProps>();\r\n\r\n React.useEffect(() => {\r\n const newFormatProps = IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\r\n // istanbul ignore else\r\n if (!initialFormatProps.current)\r\n initialFormatProps.current = newFormatProps;\r\n setFormatProps(newFormatProps);\r\n const quantityTypeKey = getQuantityTypeKey(quantityType);\r\n const quantityTypeDefinition = IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\r\n // istanbul ignore else\r\n if (quantityTypeDefinition)\r\n setPersistenceUnit(quantityTypeDefinition.persistenceUnit);\r\n else\r\n throw Error(`Unable to locate a quantity type with type ${quantityType}`);\r\n }, [quantityType]); // no dependencies defined as we want this to run on every render\r\n\r\n // handle case where quantityType does not change but the formatProps for that quantity type has (ie after a Set or Clear)\r\n // eslint-disable-next-line react-hooks/exhaustive-deps\r\n React.useEffect(() => {\r\n const newFormatProps = IModelApp.quantityFormatter.getFormatPropsByQuantityType(quantityType);\r\n // istanbul ignore else\r\n if (initialFormatProps.current && newFormatProps) {\r\n if (!formatAreEqual(newFormatProps, initialFormatProps.current)) {\r\n initialFormatProps.current = newFormatProps;\r\n setFormatProps(newFormatProps);\r\n }\r\n }\r\n }); // no dependencies defined as we want this to run on every render\r\n\r\n const handleOnFormatChanged = React.useCallback(async (newProps: FormatProps) => {\r\n setFormatProps(newProps);\r\n onFormatChange && onFormatChange(newProps);\r\n }, [onFormatChange]);\r\n\r\n const createCustomPropEditors = React.useCallback((specs: CustomFormatPropEditorSpec[], inProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => {\r\n return specs.map((spec, index) => {\r\n if (isCheckboxFormatPropEditorSpec(spec))\r\n return createCheckboxFormatPropEditor(`${spec.editorType}-${index}`, spec.label, inProps, spec.getBool, spec.setBool, fireFormatChange);\r\n if (isTextSelectFormatPropEditorSpec(spec))\r\n return createSelectFormatPropEditor(`${spec.editorType}-${index}`, spec.label, spec.selectOptions, inProps, spec.getString, spec.setString, fireFormatChange);\r\n /* istanbul ignore else */\r\n if (isTextInputFormatPropEditorSpec(spec))\r\n return createTextInputFormatPropEditor(`${spec.editorType}-${index}`, spec.label, inProps, spec.getString, spec.setString, fireFormatChange);\r\n /* istanbul ignore next */\r\n return <div key={index} />;\r\n });\r\n }, []);\r\n\r\n const providePrimaryChildren = React.useCallback(\r\n (inProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => {\r\n const quantityTypeKey = getQuantityTypeKey(quantityType);\r\n const quantityTypeDefinition = IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\r\n if (quantityTypeDefinition && isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\r\n quantityTypeDefinition.isCompatibleFormatProps(inProps)) {\r\n // istanbul ignore else\r\n if (quantityTypeDefinition.primaryPropEditorSpecs)\r\n return createCustomPropEditors(quantityTypeDefinition.primaryPropEditorSpecs, inProps, fireFormatChange);\r\n }\r\n return null;\r\n }, [createCustomPropEditors, quantityType]);\r\n\r\n const provideSecondaryChildren = React.useCallback(\r\n (inProps: FormatProps, fireFormatChange: (newProps: FormatProps) => void) => {\r\n const quantityTypeKey = getQuantityTypeKey(quantityType);\r\n const quantityTypeDefinition = IModelApp.quantityFormatter.quantityTypesRegistry.get(quantityTypeKey);\r\n if (quantityTypeDefinition && isCustomQuantityTypeDefinition(quantityTypeDefinition) &&\r\n quantityTypeDefinition.isCompatibleFormatProps(inProps)) {\r\n // istanbul ignore else\r\n if (quantityTypeDefinition.secondaryPropEditorSpecs)\r\n return createCustomPropEditors(quantityTypeDefinition.secondaryPropEditorSpecs, inProps, fireFormatChange);\r\n }\r\n return null;\r\n }, [createCustomPropEditors, quantityType]);\r\n\r\n const provideFormatSpec = React.useCallback(\r\n async (inProps: FormatProps, _persistenceUnit: UnitProps, _unitsProvider: UnitsProvider) => {\r\n return IModelApp.quantityFormatter.generateFormatterSpecByType(quantityType, inProps);\r\n }, [quantityType]);\r\n\r\n return (\r\n <div className=\"components-quantityFormat-quantityPanel\">\r\n {persistenceUnit && formatProps &&\r\n <FormatPanel onFormatChange={handleOnFormatChanged} {...otherProps}\r\n initialFormat={formatProps}\r\n unitsProvider={IModelApp.quantityFormatter.unitsProvider}\r\n persistenceUnit={persistenceUnit}\r\n providePrimaryChildren={providePrimaryChildren}\r\n provideSecondaryChildren={provideSecondaryChildren}\r\n provideFormatSpec={provideFormatSpec}\r\n />}\r\n </div>\r\n );\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"DecimalPrecision.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/DecimalPrecision.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,iEAA8D;AAC9D,wDAA4D;AAU5D;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,KAAoC;IAC3E,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IACrD,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,CAAyB;QACnD,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,uCAAuC,CAAC,EAAE;QAC1F,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,sCAAsC,CAAC,EAAE;QACzF,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,sCAAsC,CAAC,EAAE;QACzF,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,wCAAwC,CAAC,EAAE;QAC3F,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,uCAAuC,CAAC,EAAE;QAC1F,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,uCAAuC,CAAC,EAAE;QAC1F,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,sCAAsC,CAAC,EAAE;QACzF,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,wCAAwC,CAAC,EAAE;QAC3F,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,wCAAwC,CAAC,EAAE;QAC3F,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,uCAAuC,CAAC,EAAE;QAC1F,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,sCAAsC,CAAC,EAAE;QAC1F,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,yCAAyC,CAAC,EAAE;QAC7F,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,yCAAyC,CAAC,EAAE;KAC9F,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAgB,EAAE,EAAE;QAC5D,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,oBAAC,sBAAM,IAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAC,OAAO,KAAK,UAAU,GAAI,CAC9G,CAAC;AACJ,CAAC;AAzBD,4DAyBC","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 { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\n\n/** Properties of [[DecimalPrecisionSelector]] component.\n * @internal\n */\nexport interface DecimalPrecisionSelectorProps extends CommonProps {\n precision: number;\n onChange: (value: number) => void;\n}\n\n/** Component use to set Decimal Precision\n * the unit label.\n * @internal\n */\nexport function DecimalPrecisionSelector(props: DecimalPrecisionSelectorProps) {\n const { precision, onChange, ...otherProps } = props;\n const options = React.useRef<SelectOption<number>[]>([\n { value: 0, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.zero\") },\n { value: 1, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.one\") },\n { value: 2, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.two\") },\n { value: 3, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.three\") },\n { value: 4, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.four\") },\n { value: 5, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.five\") },\n { value: 6, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.six\") },\n { value: 7, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.seven\") },\n { value: 8, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.eight\") },\n { value: 9, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.nine\") },\n { value: 10, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.ten\") },\n { value: 11, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.eleven\") },\n { value: 12, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.twelve\") },\n ]);\n\n const handleOnChange = React.useCallback((newValue: number) => {\n onChange && onChange(newValue);\n }, [onChange]);\n\n return (\n <Select options={options.current} value={precision} onChange={handleOnChange} size=\"small\" {...otherProps} />\n );\n}\n"]}
1
+ {"version":3,"file":"DecimalPrecision.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/DecimalPrecision.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,iEAA8D;AAC9D,wDAA4D;AAU5D;;;GAGG;AACH,SAAgB,wBAAwB,CAAC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AK,EAAE,uCAAkB,CAAC,SAAS,CAAC,yCAAyC,CAAC,EAAE;QAC7F,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,uCAAkB,CAAC,SAAS,CAAC,yCAAyC,CAAC,EAAE;KAC9F,CAAC,CAAC;IAEH,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAgB,EAAE,EAAE;QAC5D,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,OAAO,CACL,oBAAC,sBAAM,IAAC,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAC,OAAO,KAAK,UAAU,GAAI,CAC9G,CAAC;AACJ,CAAC;AAzBD,4DAyBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module QuantityFormat\r\n */\r\n\r\nimport * as React from \"react\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\r\nimport { Select, SelectOption } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties of [[DecimalPrecisionSelector]] component.\r\n * @internal\r\n */\r\nexport interface DecimalPrecisionSelectorProps extends CommonProps {\r\n precision: number;\r\n onChange: (value: number) => void;\r\n}\r\n\r\n/** Component use to set Decimal Precision\r\n * the unit label.\r\n * @internal\r\n */\r\nexport function DecimalPrecisionSelector(props: DecimalPrecisionSelectorProps) {\r\n const { precision, onChange, ...otherProps } = props;\r\n const options = React.useRef<SelectOption<number>[]>([\r\n { value: 0, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.zero\") },\r\n { value: 1, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.one\") },\r\n { value: 2, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.two\") },\r\n { value: 3, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.three\") },\r\n { value: 4, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.four\") },\r\n { value: 5, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.five\") },\r\n { value: 6, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.six\") },\r\n { value: 7, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.seven\") },\r\n { value: 8, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.eight\") },\r\n { value: 9, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.nine\") },\r\n { value: 10, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.ten\") },\r\n { value: 11, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.eleven\") },\r\n { value: 12, label: UiIModelComponents.translate(\"QuantityFormat.decimal_precision.twelve\") },\r\n ]);\r\n\r\n const handleOnChange = React.useCallback((newValue: number) => {\r\n onChange && onChange(newValue);\r\n }, [onChange]);\r\n\r\n return (\r\n <Select options={options.current} value={precision} onChange={handleOnChange} size=\"small\" {...otherProps} />\r\n );\r\n}\r\n"]}