@itwin/imodel-components-react 3.6.0-dev.7 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -1
- package/LICENSE.md +1 -1
- package/lib/cjs/imodel-components-react/UiIModelComponents.d.ts +28 -28
- package/lib/cjs/imodel-components-react/UiIModelComponents.js +79 -79
- package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +36 -36
- package/lib/cjs/imodel-components-react/color/AlphaSlider.js +186 -186
- package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.scss +63 -63
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +107 -107
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.scss +91 -91
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js +74 -74
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js +145 -145
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPanel.scss +93 -93
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +137 -137
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.scss +64 -64
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +22 -22
- package/lib/cjs/imodel-components-react/color/HueSlider.js +199 -199
- package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.scss +61 -61
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +20 -20
- package/lib/cjs/imodel-components-react/color/SaturationPicker.js +213 -213
- package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.scss +35 -35
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts +22 -22
- package/lib/cjs/imodel-components-react/color/Swatch.js +60 -60
- package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.scss +23 -23
- package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
- package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js +23 -23
- package/lib/cjs/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
- package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +44 -44
- package/lib/cjs/imodel-components-react/editors/ColorEditor.js +151 -151
- package/lib/cjs/imodel-components-react/editors/ColorEditor.js.map +1 -1
- package/lib/cjs/imodel-components-react/editors/ColorEditor.scss +18 -18
- package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +47 -47
- package/lib/cjs/imodel-components-react/editors/WeightEditor.js +160 -160
- package/lib/cjs/imodel-components-react/editors/WeightEditor.js.map +1 -1
- package/lib/cjs/imodel-components-react/editors/WeightEditor.scss +16 -16
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.js +96 -96
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +265 -265
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.scss +107 -107
- package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +33 -33
- package/lib/cjs/imodel-components-react/lineweight/Swatch.js +85 -85
- package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/Swatch.scss +48 -48
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +159 -159
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.scss +52 -52
- package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts +45 -45
- package/lib/cjs/imodel-components-react/navigationaids/Cube.js +127 -127
- package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/Cube.scss +19 -19
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +174 -174
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +634 -634
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.scss +180 -180
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js +647 -647
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.scss +133 -133
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +99 -99
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.scss +64 -64
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +53 -53
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +83 -83
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +86 -86
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +109 -109
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +133 -133
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +184 -184
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js +154 -154
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js +59 -59
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js +47 -47
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js +54 -54
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js +48 -48
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js +50 -50
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +58 -58
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js +47 -47
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +56 -56
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +95 -95
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js +119 -119
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
- package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js +143 -143
- package/lib/cjs/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
- package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js +69 -69
- package/lib/cjs/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.js +81 -81
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.scss +26 -26
- package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
- package/lib/cjs/imodel-components-react/timeline/PlayerButton.js +91 -91
- package/lib/cjs/imodel-components-react/timeline/PlayerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/PlayerButton.scss +25 -25
- package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +54 -54
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js +191 -191
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +106 -106
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +424 -424
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +357 -357
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js +54 -54
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
- package/lib/cjs/imodel-components-react/timeline/Timeline.scss +164 -164
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +133 -133
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +358 -358
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.scss +163 -163
- package/lib/cjs/imodel-components-react/timeline/interfaces.d.ts +174 -174
- package/lib/cjs/imodel-components-react/timeline/interfaces.js +45 -45
- package/lib/cjs/imodel-components-react/timeline/interfaces.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +274 -274
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +105 -105
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/cjs/imodel-components-react.d.ts +82 -82
- package/lib/cjs/imodel-components-react.js +101 -101
- package/lib/cjs/imodel-components-react.js.map +1 -1
- package/lib/esm/imodel-components-react/UiIModelComponents.d.ts +28 -28
- package/lib/esm/imodel-components-react/UiIModelComponents.js +75 -75
- package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +36 -36
- package/lib/esm/imodel-components-react/color/AlphaSlider.js +160 -160
- package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.scss +63 -63
- package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +37 -37
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js +82 -82
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.scss +91 -91
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +23 -23
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js +51 -51
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.d.ts +21 -21
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.js +122 -122
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPanel.scss +93 -93
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +44 -44
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +112 -112
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.scss +64 -64
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts +22 -22
- package/lib/esm/imodel-components-react/color/HueSlider.js +173 -173
- package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.scss +61 -61
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +20 -20
- package/lib/esm/imodel-components-react/color/SaturationPicker.js +187 -187
- package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.scss +35 -35
- package/lib/esm/imodel-components-react/color/Swatch.d.ts +22 -22
- package/lib/esm/imodel-components-react/color/Swatch.js +34 -34
- package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.scss +23 -23
- package/lib/esm/imodel-components-react/color/getCSSColorFromDef.d.ts +6 -6
- package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js +19 -19
- package/lib/esm/imodel-components-react/color/getCSSColorFromDef.js.map +1 -1
- package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +44 -44
- package/lib/esm/imodel-components-react/editors/ColorEditor.js +124 -124
- package/lib/esm/imodel-components-react/editors/ColorEditor.js.map +1 -1
- package/lib/esm/imodel-components-react/editors/ColorEditor.scss +18 -18
- package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +47 -47
- package/lib/esm/imodel-components-react/editors/WeightEditor.js +133 -133
- package/lib/esm/imodel-components-react/editors/WeightEditor.js.map +1 -1
- package/lib/esm/imodel-components-react/editors/WeightEditor.scss +16 -16
- package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +25 -25
- package/lib/esm/imodel-components-react/inputs/QuantityInput.js +70 -70
- package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.d.ts +44 -44
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +240 -240
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.scss +107 -107
- package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +33 -33
- package/lib/esm/imodel-components-react/lineweight/Swatch.js +59 -59
- package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/Swatch.scss +48 -48
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +60 -60
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +133 -133
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.scss +52 -52
- package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts +45 -45
- package/lib/esm/imodel-components-react/navigationaids/Cube.js +100 -100
- package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/Cube.scss +19 -19
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts +174 -174
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +606 -606
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.scss +180 -180
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts +145 -145
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js +620 -620
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.scss +133 -133
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +26 -26
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +76 -76
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.scss +64 -64
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +30 -30
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +18 -18
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +60 -60
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +63 -63
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +83 -83
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +19 -19
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +110 -110
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +21 -21
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +158 -158
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +22 -22
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js +131 -131
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js +36 -36
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js +24 -24
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +16 -16
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js +31 -31
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +18 -18
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js +25 -25
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js +27 -27
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js +35 -35
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js +24 -24
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +33 -33
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +17 -17
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +69 -69
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +23 -23
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js +96 -96
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.d.ts +52 -52
- package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js +139 -139
- package/lib/esm/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.d.ts +31 -31
- package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js +65 -65
- package/lib/esm/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +27 -27
- package/lib/esm/imodel-components-react/timeline/InlineEdit.js +55 -55
- package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.scss +26 -26
- package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +33 -33
- package/lib/esm/imodel-components-react/timeline/PlayerButton.js +64 -64
- package/lib/esm/imodel-components-react/timeline/PlayerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/PlayerButton.scss +25 -25
- package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +54 -54
- package/lib/esm/imodel-components-react/timeline/Scrubber.js +164 -164
- package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.scss +106 -106
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +77 -77
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +398 -398
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +357 -357
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +15 -15
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js +28 -28
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.scss +39 -39
- package/lib/esm/imodel-components-react/timeline/Timeline.scss +164 -164
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +133 -133
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +332 -332
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.scss +163 -163
- package/lib/esm/imodel-components-react/timeline/interfaces.d.ts +174 -174
- package/lib/esm/imodel-components-react/timeline/interfaces.js +42 -42
- package/lib/esm/imodel-components-react/timeline/interfaces.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +42 -42
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +251 -251
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +106 -106
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +95 -95
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/esm/imodel-components-react.d.ts +82 -82
- package/lib/esm/imodel-components-react.js +87 -87
- package/lib/esm/imodel-components-react.js.map +1 -1
- package/lib/public/locales/en/UiIModelComponents.json +139 -139
- package/package.json +20 -20
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module QuantityFormat
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
-
};
|
|
31
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
-
exports.ThousandsSeparator = void 0;
|
|
33
|
-
const classnames_1 = __importDefault(require("classnames"));
|
|
34
|
-
const React = __importStar(require("react"));
|
|
35
|
-
const core_quantity_1 = require("@itwin/core-quantity");
|
|
36
|
-
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
37
|
-
const ThousandsSelector_1 = require("./ThousandsSelector");
|
|
38
|
-
const UiIModelComponents_1 = require("../../UiIModelComponents");
|
|
39
|
-
/** Component use to set Quantity Format thousand group separator.
|
|
40
|
-
* @internal
|
|
41
|
-
*/
|
|
42
|
-
function ThousandsSeparator(props) {
|
|
43
|
-
var _a;
|
|
44
|
-
const { formatProps, onChange } = props;
|
|
45
|
-
const handleSetFormatProps = React.useCallback((newProps) => {
|
|
46
|
-
onChange && onChange(newProps);
|
|
47
|
-
}, [onChange]);
|
|
48
|
-
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
49
|
-
const traitStr = (0, core_quantity_1.getTraitString)(trait);
|
|
50
|
-
let formatTraits = [traitStr];
|
|
51
|
-
if (setActive) { // setting trait
|
|
52
|
-
// istanbul ignore else
|
|
53
|
-
if (formatProps.formatTraits) {
|
|
54
|
-
const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
|
|
55
|
-
formatTraits = [...traits, traitStr];
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else { // clearing trait
|
|
59
|
-
// istanbul ignore else
|
|
60
|
-
if (formatProps.formatTraits) {
|
|
61
|
-
const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
|
|
62
|
-
formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
const newFormatProps = { ...formatProps, formatTraits };
|
|
66
|
-
handleSetFormatProps(newFormatProps);
|
|
67
|
-
}, [formatProps, handleSetFormatProps]);
|
|
68
|
-
const handleUseThousandsSeparatorChange = React.useCallback((e) => {
|
|
69
|
-
setFormatTrait(core_quantity_1.FormatTraits.Use1000Separator, e.target.checked);
|
|
70
|
-
}, [setFormatTrait]);
|
|
71
|
-
const isFormatTraitSet = React.useCallback((trait) => {
|
|
72
|
-
return core_quantity_1.Format.isFormatTraitSetInProps(formatProps, trait);
|
|
73
|
-
}, [formatProps]);
|
|
74
|
-
const handleThousandSeparatorChange = React.useCallback((thousandSeparator) => {
|
|
75
|
-
let decimalSeparator = formatProps.decimalSeparator;
|
|
76
|
-
// make sure 1000 and decimal separator do not match
|
|
77
|
-
// istanbul ignore else
|
|
78
|
-
if (isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator)) {
|
|
79
|
-
if (thousandSeparator === ".")
|
|
80
|
-
decimalSeparator = ",";
|
|
81
|
-
else // thousandSeparator === ","
|
|
82
|
-
decimalSeparator = ".";
|
|
83
|
-
}
|
|
84
|
-
const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };
|
|
85
|
-
handleSetFormatProps(newFormatProps);
|
|
86
|
-
}, [formatProps, isFormatTraitSet, handleSetFormatProps]);
|
|
87
|
-
const useThousandSeparatorLabel = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.useThousandSeparatorLabel"));
|
|
88
|
-
const thousandSeparatorLabel = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.thousandSeparatorLabel"));
|
|
89
|
-
return (React.createElement(React.Fragment, null,
|
|
90
|
-
React.createElement("span", { className: "uicore-label" }, useThousandSeparatorLabel.current),
|
|
91
|
-
React.createElement(itwinui_react_1.Checkbox, { "data-testid": "use-thousands-separator", checked: isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleUseThousandsSeparatorChange }),
|
|
92
|
-
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", !(isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator)) && "uicore-disabled") }, thousandSeparatorLabel.current),
|
|
93
|
-
React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: (_a = formatProps.thousandSeparator) !== null && _a !== void 0 ? _a : ",", disabled: !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleThousandSeparatorChange })));
|
|
94
|
-
}
|
|
95
|
-
exports.ThousandsSeparator = ThousandsSeparator;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module QuantityFormat
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
29
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.ThousandsSeparator = void 0;
|
|
33
|
+
const classnames_1 = __importDefault(require("classnames"));
|
|
34
|
+
const React = __importStar(require("react"));
|
|
35
|
+
const core_quantity_1 = require("@itwin/core-quantity");
|
|
36
|
+
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
37
|
+
const ThousandsSelector_1 = require("./ThousandsSelector");
|
|
38
|
+
const UiIModelComponents_1 = require("../../UiIModelComponents");
|
|
39
|
+
/** Component use to set Quantity Format thousand group separator.
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
function ThousandsSeparator(props) {
|
|
43
|
+
var _a;
|
|
44
|
+
const { formatProps, onChange } = props;
|
|
45
|
+
const handleSetFormatProps = React.useCallback((newProps) => {
|
|
46
|
+
onChange && onChange(newProps);
|
|
47
|
+
}, [onChange]);
|
|
48
|
+
const setFormatTrait = React.useCallback((trait, setActive) => {
|
|
49
|
+
const traitStr = (0, core_quantity_1.getTraitString)(trait);
|
|
50
|
+
let formatTraits = [traitStr];
|
|
51
|
+
if (setActive) { // setting trait
|
|
52
|
+
// istanbul ignore else
|
|
53
|
+
if (formatProps.formatTraits) {
|
|
54
|
+
const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
|
|
55
|
+
formatTraits = [...traits, traitStr];
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else { // clearing trait
|
|
59
|
+
// istanbul ignore else
|
|
60
|
+
if (formatProps.formatTraits) {
|
|
61
|
+
const traits = Array.isArray(formatProps.formatTraits) ? formatProps.formatTraits : /* istanbul ignore next */ formatProps.formatTraits.split(/,|;|\|/);
|
|
62
|
+
formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
const newFormatProps = { ...formatProps, formatTraits };
|
|
66
|
+
handleSetFormatProps(newFormatProps);
|
|
67
|
+
}, [formatProps, handleSetFormatProps]);
|
|
68
|
+
const handleUseThousandsSeparatorChange = React.useCallback((e) => {
|
|
69
|
+
setFormatTrait(core_quantity_1.FormatTraits.Use1000Separator, e.target.checked);
|
|
70
|
+
}, [setFormatTrait]);
|
|
71
|
+
const isFormatTraitSet = React.useCallback((trait) => {
|
|
72
|
+
return core_quantity_1.Format.isFormatTraitSetInProps(formatProps, trait);
|
|
73
|
+
}, [formatProps]);
|
|
74
|
+
const handleThousandSeparatorChange = React.useCallback((thousandSeparator) => {
|
|
75
|
+
let decimalSeparator = formatProps.decimalSeparator;
|
|
76
|
+
// make sure 1000 and decimal separator do not match
|
|
77
|
+
// istanbul ignore else
|
|
78
|
+
if (isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator)) {
|
|
79
|
+
if (thousandSeparator === ".")
|
|
80
|
+
decimalSeparator = ",";
|
|
81
|
+
else // thousandSeparator === ","
|
|
82
|
+
decimalSeparator = ".";
|
|
83
|
+
}
|
|
84
|
+
const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };
|
|
85
|
+
handleSetFormatProps(newFormatProps);
|
|
86
|
+
}, [formatProps, isFormatTraitSet, handleSetFormatProps]);
|
|
87
|
+
const useThousandSeparatorLabel = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.useThousandSeparatorLabel"));
|
|
88
|
+
const thousandSeparatorLabel = React.useRef(UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.labels.thousandSeparatorLabel"));
|
|
89
|
+
return (React.createElement(React.Fragment, null,
|
|
90
|
+
React.createElement("span", { className: "uicore-label" }, useThousandSeparatorLabel.current),
|
|
91
|
+
React.createElement(itwinui_react_1.Checkbox, { "data-testid": "use-thousands-separator", checked: isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleUseThousandsSeparatorChange }),
|
|
92
|
+
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", !(isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator)) && "uicore-disabled") }, thousandSeparatorLabel.current),
|
|
93
|
+
React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: (_a = formatProps.thousandSeparator) !== null && _a !== void 0 ? _a : ",", disabled: !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleThousandSeparatorChange })));
|
|
94
|
+
}
|
|
95
|
+
exports.ThousandsSeparator = ThousandsSeparator;
|
|
96
96
|
//# sourceMappingURL=ThousandsSeparator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,wDAAyF;AACzF,wDAAgD;AAChD,2DAAwD;AACxD,iEAA8D;AAU9D;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAA8B;;IAC/D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAqB,EAAE,EAAE;QACvE,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAmB,EAAE,SAAkB,EAAE,EAAE;QACnF,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,YAAY,GAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE,EAAC,gBAAgB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C,SAAS,EAAE,MAAA,WAAW,CAAC,iBAAiB,mCAAI,GAAG,EAAE,QAAQ,EAAE,CAAC,gBAAgB,CAAC,4BAAY,CAAC,gBAAgB,CAAC,EAAE,QAAQ,EAAE,6BAA6B,GAAI,CACrN,CACJ,CAAC;AACJ,CAAC;AA5DD,gDA4DC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAE/B,wDAAyF;AACzF,wDAAgD;AAChD,2DAAwD;AACxD,iEAA8D;AAU9D;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAA8B;;IAC/D,MAAM,EAAE,WAAW,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;IAExC,MAAM,oBAAoB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAqB,EAAE,EAAE;QACvE,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,KAAmB,EAAE,SAAkB,EAAE,EAAE;QACnF,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,YAAY,GAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE,EAAC,gBAAgB;YAC9B,uBAAuB;YACvB,IAAI,WAAW,CAAC,YAAY,EAAE;gBAC5B,MAAM,MAAM,GAAG,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC,0BAA0B,CAAC,WAAW,CAAC,YA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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 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 } from \"@itwin/itwinui-react\";\nimport { ThousandsSelector } from \"./ThousandsSelector\";\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\n\n/** Properties of [[ThousandsSeparator]] component.\n * @internal\n */\nexport interface ThousandsSeparatorProps extends CommonProps {\n formatProps: FormatProps;\n onChange?: (format: FormatProps) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSeparator(props: ThousandsSeparatorProps) {\n const { formatProps, onChange } = props;\n\n const handleSetFormatProps = React.useCallback((newProps: FormatProps) => {\n onChange && onChange(newProps);\n }, [onChange]);\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 formatTraits = [...traits, traitStr];\n }\n } else { // clearing 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 formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, handleSetFormatProps]);\n\n const handleUseThousandsSeparatorChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.Use1000Separator, e.target.checked);\n }, [setFormatTrait]);\n\n const isFormatTraitSet = React.useCallback((trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n }, [formatProps]);\n\n const handleThousandSeparatorChange = React.useCallback((thousandSeparator: string) => {\n let decimalSeparator = formatProps.decimalSeparator;\n // make sure 1000 and decimal separator do not match\n // istanbul ignore else\n if (isFormatTraitSet(FormatTraits.Use1000Separator)) {\n if (thousandSeparator === \".\")\n decimalSeparator = \",\";\n else // thousandSeparator === \",\"\n decimalSeparator = \".\";\n }\n const newFormatProps = { ...formatProps, thousandSeparator, decimalSeparator };\n handleSetFormatProps(newFormatProps);\n }, [formatProps, isFormatTraitSet, handleSetFormatProps]);\n\n const useThousandSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.useThousandSeparatorLabel\"));\n const thousandSeparatorLabel = React.useRef(UiIModelComponents.translate(\"QuantityFormat.labels.thousandSeparatorLabel\"));\n\n return (\n <>\n <span className={\"uicore-label\"}>{useThousandSeparatorLabel.current}</span>\n <Checkbox data-testid=\"use-thousands-separator\" checked={isFormatTraitSet(FormatTraits.Use1000Separator)} onChange={handleUseThousandsSeparatorChange} />\n <span className={classnames(\"uicore-label\", !(isFormatTraitSet(FormatTraits.Use1000Separator)) && \"uicore-disabled\")}>{thousandSeparatorLabel.current}</span>\n <ThousandsSelector data-testid=\"thousands-separator-selector\" separator={formatProps.thousandSeparator ?? \",\"} disabled={!isFormatTraitSet(FormatTraits.Use1000Separator)} onChange={handleThousandSeparatorChange} />\n </>\n );\n}\n"]}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module QuantityFormat
|
|
3
|
-
*/
|
|
4
|
-
/// <reference types="react" />
|
|
5
|
-
import { UnitsProvider } from "@itwin/core-quantity";
|
|
6
|
-
import { CommonProps } from "@itwin/core-react";
|
|
7
|
-
/** Properties of [[UnitDescr]] component.
|
|
8
|
-
* @internal
|
|
9
|
-
*/
|
|
10
|
-
export interface UnitDescrProps extends CommonProps {
|
|
11
|
-
name: string;
|
|
12
|
-
parentUnitName?: string;
|
|
13
|
-
label: string;
|
|
14
|
-
index: number;
|
|
15
|
-
unitsProvider: UnitsProvider;
|
|
16
|
-
readonly?: boolean;
|
|
17
|
-
onUnitChange: (value: string, index: number) => void;
|
|
18
|
-
onLabelChange: (value: string, index: number) => void;
|
|
19
|
-
}
|
|
20
|
-
/** Component use to display dropdown list of possible units.
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
export declare function UnitDescr(props: UnitDescrProps): JSX.Element;
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module QuantityFormat
|
|
3
|
+
*/
|
|
4
|
+
/// <reference types="react" />
|
|
5
|
+
import { UnitsProvider } from "@itwin/core-quantity";
|
|
6
|
+
import { CommonProps } from "@itwin/core-react";
|
|
7
|
+
/** Properties of [[UnitDescr]] component.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
export interface UnitDescrProps extends CommonProps {
|
|
11
|
+
name: string;
|
|
12
|
+
parentUnitName?: string;
|
|
13
|
+
label: string;
|
|
14
|
+
index: number;
|
|
15
|
+
unitsProvider: UnitsProvider;
|
|
16
|
+
readonly?: boolean;
|
|
17
|
+
onUnitChange: (value: string, index: number) => void;
|
|
18
|
+
onLabelChange: (value: string, index: number) => void;
|
|
19
|
+
}
|
|
20
|
+
/** Component use to display dropdown list of possible units.
|
|
21
|
+
* @internal
|
|
22
|
+
*/
|
|
23
|
+
export declare function UnitDescr(props: UnitDescrProps): JSX.Element;
|
|
24
24
|
//# sourceMappingURL=UnitDescr.d.ts.map
|
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module QuantityFormat
|
|
8
|
-
*/
|
|
9
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
-
}) : (function(o, m, k, k2) {
|
|
13
|
-
if (k2 === undefined) k2 = k;
|
|
14
|
-
o[k2] = m[k];
|
|
15
|
-
}));
|
|
16
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
-
}) : function(o, v) {
|
|
19
|
-
o["default"] = v;
|
|
20
|
-
});
|
|
21
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
-
if (mod && mod.__esModule) return mod;
|
|
23
|
-
var result = {};
|
|
24
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
-
__setModuleDefault(result, mod);
|
|
26
|
-
return result;
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.UnitDescr = void 0;
|
|
30
|
-
const React = __importStar(require("react"));
|
|
31
|
-
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
32
|
-
async function getUnitConversionData(possibleUnits, toUnit, unitsProvider) {
|
|
33
|
-
const unitConversionEntries = possibleUnits.map(async (unit) => {
|
|
34
|
-
const conversion = await unitsProvider.getConversion(unit, toUnit);
|
|
35
|
-
return { conversion, unitProps: unit };
|
|
36
|
-
});
|
|
37
|
-
return unitConversionEntries;
|
|
38
|
-
}
|
|
39
|
-
async function getPossibleUnits(parentUnit, unitsProvider, ensureCompatibleComposite) {
|
|
40
|
-
const phenomenon = parentUnit.phenomenon;
|
|
41
|
-
const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);
|
|
42
|
-
if (!ensureCompatibleComposite)
|
|
43
|
-
return possibleUnits;
|
|
44
|
-
const conversionPromises = await getUnitConversionData(possibleUnits, parentUnit, unitsProvider);
|
|
45
|
-
const conversionEntries = await Promise.all(conversionPromises);
|
|
46
|
-
// sort the entries so the best potential sub unit will be the first one in the array
|
|
47
|
-
return conversionEntries.filter((entry) => ((entry.unitProps.system === parentUnit.system) && (entry.conversion.factor < 1)))
|
|
48
|
-
.sort((a, b) => b.conversion.factor - a.conversion.factor)
|
|
49
|
-
.map((value) => value.unitProps);
|
|
50
|
-
}
|
|
51
|
-
function getUnitName(fullUnitName) {
|
|
52
|
-
const nameParts = fullUnitName.split(/[.:]/);
|
|
53
|
-
// istanbul ignore else
|
|
54
|
-
if (nameParts.length > 0)
|
|
55
|
-
return nameParts[nameParts.length - 1];
|
|
56
|
-
// istanbul ignore next
|
|
57
|
-
throw Error("Bad unit name encountered");
|
|
58
|
-
}
|
|
59
|
-
/** Component use to display dropdown list of possible units.
|
|
60
|
-
* @internal
|
|
61
|
-
*/
|
|
62
|
-
function UnitDescr(props) {
|
|
63
|
-
const { name, label, parentUnitName, index, onUnitChange, onLabelChange, readonly, unitsProvider } = props;
|
|
64
|
-
const [unitOptions, setUnitOptions] = React.useState([{ value: name, label: getUnitName(name) }]);
|
|
65
|
-
const [currentUnit, setCurrentUnit] = React.useState({ name, label });
|
|
66
|
-
const isMounted = React.useRef(false);
|
|
67
|
-
React.useEffect(() => {
|
|
68
|
-
isMounted.current = true;
|
|
69
|
-
return () => {
|
|
70
|
-
isMounted.current = false;
|
|
71
|
-
};
|
|
72
|
-
});
|
|
73
|
-
React.useEffect(() => {
|
|
74
|
-
async function fetchAllowableUnitSelections() {
|
|
75
|
-
const currentUnitProps = await unitsProvider.findUnitByName(name);
|
|
76
|
-
const parentUnit = await unitsProvider.findUnitByName(parentUnitName ? parentUnitName : name);
|
|
77
|
-
// istanbul ignore else
|
|
78
|
-
if (parentUnit && currentUnitProps) {
|
|
79
|
-
let potentialSubUnit;
|
|
80
|
-
const potentialUnits = await getPossibleUnits(parentUnit, unitsProvider, index !== 0);
|
|
81
|
-
// istanbul ignore else
|
|
82
|
-
if (index < 3) {
|
|
83
|
-
const potentialSubUnits = await getPossibleUnits(currentUnitProps, unitsProvider, true);
|
|
84
|
-
if (potentialSubUnits.length)
|
|
85
|
-
potentialSubUnit = potentialSubUnits[0];
|
|
86
|
-
}
|
|
87
|
-
const options = (potentialUnits.length > 0) ?
|
|
88
|
-
potentialUnits.map((unitValue) => {
|
|
89
|
-
return { value: `${unitValue.name}:${unitValue.label}`, label: getUnitName(unitValue.name) };
|
|
90
|
-
}).sort((a, b) => a.label.localeCompare(b.label))
|
|
91
|
-
: /* istanbul ignore next */
|
|
92
|
-
[{ value: `${currentUnitProps.name}:${currentUnitProps.label}`, label: getUnitName(name) }];
|
|
93
|
-
if (potentialSubUnit) {
|
|
94
|
-
// construct an entry that will provide the name and label of the unit to add
|
|
95
|
-
options.push({ value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`, label: "Add sub-unit" }); // NEEDSWORK - i18n
|
|
96
|
-
}
|
|
97
|
-
if (index !== 0)
|
|
98
|
-
options.push({ value: "REMOVEUNIT", label: "Remove" }); // NEEDSWORK - i18n
|
|
99
|
-
// istanbul ignore else
|
|
100
|
-
if (isMounted.current) {
|
|
101
|
-
setUnitOptions(options);
|
|
102
|
-
setCurrentUnit(currentUnitProps);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
fetchAllowableUnitSelections(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
107
|
-
}, [index, label, name, parentUnitName, unitsProvider]);
|
|
108
|
-
const handleOnUnitChange = React.useCallback((newValue) => {
|
|
109
|
-
onUnitChange && onUnitChange(newValue, index);
|
|
110
|
-
}, [index, onUnitChange]);
|
|
111
|
-
const handleOnLabelChange = React.useCallback((e) => {
|
|
112
|
-
e.preventDefault();
|
|
113
|
-
onLabelChange && onLabelChange(e.target.value, index);
|
|
114
|
-
}, [index, onLabelChange]);
|
|
115
|
-
return (React.createElement(React.Fragment, null,
|
|
116
|
-
React.createElement(itwinui_react_1.Select, { options: unitOptions, "data-testid": `unit-${currentUnit.name}`, value: `${currentUnit.name}:${currentUnit.label}`, onChange: handleOnUnitChange, disabled: readonly, size: "small" }),
|
|
117
|
-
React.createElement(itwinui_react_1.Input, { "data-testid": `unit-label-${currentUnit.name}`, value: label, onChange: handleOnLabelChange, size: "small" })));
|
|
118
|
-
}
|
|
119
|
-
exports.UnitDescr = UnitDescr;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module QuantityFormat
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
25
|
+
__setModuleDefault(result, mod);
|
|
26
|
+
return result;
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.UnitDescr = void 0;
|
|
30
|
+
const React = __importStar(require("react"));
|
|
31
|
+
const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
32
|
+
async function getUnitConversionData(possibleUnits, toUnit, unitsProvider) {
|
|
33
|
+
const unitConversionEntries = possibleUnits.map(async (unit) => {
|
|
34
|
+
const conversion = await unitsProvider.getConversion(unit, toUnit);
|
|
35
|
+
return { conversion, unitProps: unit };
|
|
36
|
+
});
|
|
37
|
+
return unitConversionEntries;
|
|
38
|
+
}
|
|
39
|
+
async function getPossibleUnits(parentUnit, unitsProvider, ensureCompatibleComposite) {
|
|
40
|
+
const phenomenon = parentUnit.phenomenon;
|
|
41
|
+
const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);
|
|
42
|
+
if (!ensureCompatibleComposite)
|
|
43
|
+
return possibleUnits;
|
|
44
|
+
const conversionPromises = await getUnitConversionData(possibleUnits, parentUnit, unitsProvider);
|
|
45
|
+
const conversionEntries = await Promise.all(conversionPromises);
|
|
46
|
+
// sort the entries so the best potential sub unit will be the first one in the array
|
|
47
|
+
return conversionEntries.filter((entry) => ((entry.unitProps.system === parentUnit.system) && (entry.conversion.factor < 1)))
|
|
48
|
+
.sort((a, b) => b.conversion.factor - a.conversion.factor)
|
|
49
|
+
.map((value) => value.unitProps);
|
|
50
|
+
}
|
|
51
|
+
function getUnitName(fullUnitName) {
|
|
52
|
+
const nameParts = fullUnitName.split(/[.:]/);
|
|
53
|
+
// istanbul ignore else
|
|
54
|
+
if (nameParts.length > 0)
|
|
55
|
+
return nameParts[nameParts.length - 1];
|
|
56
|
+
// istanbul ignore next
|
|
57
|
+
throw Error("Bad unit name encountered");
|
|
58
|
+
}
|
|
59
|
+
/** Component use to display dropdown list of possible units.
|
|
60
|
+
* @internal
|
|
61
|
+
*/
|
|
62
|
+
function UnitDescr(props) {
|
|
63
|
+
const { name, label, parentUnitName, index, onUnitChange, onLabelChange, readonly, unitsProvider } = props;
|
|
64
|
+
const [unitOptions, setUnitOptions] = React.useState([{ value: name, label: getUnitName(name) }]);
|
|
65
|
+
const [currentUnit, setCurrentUnit] = React.useState({ name, label });
|
|
66
|
+
const isMounted = React.useRef(false);
|
|
67
|
+
React.useEffect(() => {
|
|
68
|
+
isMounted.current = true;
|
|
69
|
+
return () => {
|
|
70
|
+
isMounted.current = false;
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
React.useEffect(() => {
|
|
74
|
+
async function fetchAllowableUnitSelections() {
|
|
75
|
+
const currentUnitProps = await unitsProvider.findUnitByName(name);
|
|
76
|
+
const parentUnit = await unitsProvider.findUnitByName(parentUnitName ? parentUnitName : name);
|
|
77
|
+
// istanbul ignore else
|
|
78
|
+
if (parentUnit && currentUnitProps) {
|
|
79
|
+
let potentialSubUnit;
|
|
80
|
+
const potentialUnits = await getPossibleUnits(parentUnit, unitsProvider, index !== 0);
|
|
81
|
+
// istanbul ignore else
|
|
82
|
+
if (index < 3) {
|
|
83
|
+
const potentialSubUnits = await getPossibleUnits(currentUnitProps, unitsProvider, true);
|
|
84
|
+
if (potentialSubUnits.length)
|
|
85
|
+
potentialSubUnit = potentialSubUnits[0];
|
|
86
|
+
}
|
|
87
|
+
const options = (potentialUnits.length > 0) ?
|
|
88
|
+
potentialUnits.map((unitValue) => {
|
|
89
|
+
return { value: `${unitValue.name}:${unitValue.label}`, label: getUnitName(unitValue.name) };
|
|
90
|
+
}).sort((a, b) => a.label.localeCompare(b.label))
|
|
91
|
+
: /* istanbul ignore next */
|
|
92
|
+
[{ value: `${currentUnitProps.name}:${currentUnitProps.label}`, label: getUnitName(name) }];
|
|
93
|
+
if (potentialSubUnit) {
|
|
94
|
+
// construct an entry that will provide the name and label of the unit to add
|
|
95
|
+
options.push({ value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`, label: "Add sub-unit" }); // NEEDSWORK - i18n
|
|
96
|
+
}
|
|
97
|
+
if (index !== 0)
|
|
98
|
+
options.push({ value: "REMOVEUNIT", label: "Remove" }); // NEEDSWORK - i18n
|
|
99
|
+
// istanbul ignore else
|
|
100
|
+
if (isMounted.current) {
|
|
101
|
+
setUnitOptions(options);
|
|
102
|
+
setCurrentUnit(currentUnitProps);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
fetchAllowableUnitSelections(); // eslint-disable-line @typescript-eslint/no-floating-promises
|
|
107
|
+
}, [index, label, name, parentUnitName, unitsProvider]);
|
|
108
|
+
const handleOnUnitChange = React.useCallback((newValue) => {
|
|
109
|
+
onUnitChange && onUnitChange(newValue, index);
|
|
110
|
+
}, [index, onUnitChange]);
|
|
111
|
+
const handleOnLabelChange = React.useCallback((e) => {
|
|
112
|
+
e.preventDefault();
|
|
113
|
+
onLabelChange && onLabelChange(e.target.value, index);
|
|
114
|
+
}, [index, onLabelChange]);
|
|
115
|
+
return (React.createElement(React.Fragment, null,
|
|
116
|
+
React.createElement(itwinui_react_1.Select, { options: unitOptions, "data-testid": `unit-${currentUnit.name}`, value: `${currentUnit.name}:${currentUnit.label}`, onChange: handleOnUnitChange, disabled: readonly, size: "small" }),
|
|
117
|
+
React.createElement(itwinui_react_1.Input, { "data-testid": `unit-label-${currentUnit.name}`, value: label, onChange: handleOnLabelChange, size: "small" })));
|
|
118
|
+
}
|
|
119
|
+
exports.UnitDescr = UnitDescr;
|
|
120
120
|
//# sourceMappingURL=UnitDescr.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitDescr.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAAmE;AAgBnE,KAAK,UAAU,qBAAqB,CAAC,aAA0B,E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AE,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAC,OAAO,GAAG,CACjH,CACJ,CAAC;AACJ,CAAC;AArED,8BAqEC","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 { UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\r\nimport { CommonProps } from \"@itwin/core-react\";\r\nimport { Input, Select, SelectOption } from \"@itwin/itwinui-react\";\r\n\r\n/** Properties of [[UnitDescr]] component.\r\n * @internal\r\n */\r\nexport interface UnitDescrProps extends CommonProps {\r\n name: string;\r\n parentUnitName?: string;\r\n label: string;\r\n index: number;\r\n unitsProvider: UnitsProvider;\r\n readonly?: boolean;\r\n onUnitChange: (value: string, index: number) => void;\r\n onLabelChange: (value: string, index: number) => void;\r\n}\r\n\r\nasync function getUnitConversionData(possibleUnits: UnitProps[], toUnit: UnitProps, unitsProvider: UnitsProvider) {\r\n const unitConversionEntries = possibleUnits.map(async (unit) => {\r\n const conversion = await unitsProvider.getConversion(unit, toUnit);\r\n return { conversion, unitProps: unit };\r\n });\r\n return unitConversionEntries;\r\n}\r\n\r\nasync function getPossibleUnits(parentUnit: UnitProps, unitsProvider: UnitsProvider, ensureCompatibleComposite: boolean) {\r\n const phenomenon = parentUnit.phenomenon;\r\n const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);\r\n if (!ensureCompatibleComposite)\r\n return possibleUnits;\r\n\r\n const conversionPromises = await getUnitConversionData(possibleUnits, parentUnit, unitsProvider);\r\n const conversionEntries = await Promise.all(conversionPromises);\r\n // sort the entries so the best potential sub unit will be the first one in the array\r\n return conversionEntries.filter((entry) => ((entry.unitProps.system === parentUnit.system) && (entry.conversion.factor < 1)))\r\n .sort((a, b) => b.conversion.factor - a.conversion.factor)\r\n .map((value) => value.unitProps);\r\n}\r\n\r\nfunction getUnitName(fullUnitName: string) {\r\n const nameParts = fullUnitName.split(/[.:]/);\r\n // istanbul ignore else\r\n if (nameParts.length > 0)\r\n return nameParts[nameParts.length - 1];\r\n // istanbul ignore next\r\n throw Error(\"Bad unit name encountered\");\r\n}\r\n\r\n/** Component use to display dropdown list of possible units.\r\n * @internal\r\n */\r\nexport function UnitDescr(props: UnitDescrProps) {\r\n const { name, label, parentUnitName, index, onUnitChange, onLabelChange, readonly, unitsProvider } = props;\r\n const [unitOptions, setUnitOptions] = React.useState<SelectOption<string>[]>([{ value: name, label: getUnitName(name) }]);\r\n const [currentUnit, setCurrentUnit] = React.useState({ name, label });\r\n const isMounted = React.useRef(false);\r\n\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 fetchAllowableUnitSelections() {\r\n const currentUnitProps = await unitsProvider.findUnitByName(name);\r\n const parentUnit = await unitsProvider.findUnitByName(parentUnitName ? parentUnitName : name);\r\n // istanbul ignore else\r\n if (parentUnit && currentUnitProps) {\r\n let potentialSubUnit: UnitProps | undefined;\r\n const potentialUnits = await getPossibleUnits(parentUnit, unitsProvider, index !== 0);\r\n // istanbul ignore else\r\n if (index < 3) {\r\n const potentialSubUnits = await getPossibleUnits(currentUnitProps, unitsProvider, true);\r\n if (potentialSubUnits.length)\r\n potentialSubUnit = potentialSubUnits[0];\r\n }\r\n\r\n const options = (potentialUnits.length > 0) ?\r\n potentialUnits.map((unitValue) => {\r\n return { value: `${unitValue.name}:${unitValue.label}`, label: getUnitName(unitValue.name) };\r\n }).sort((a, b) => a.label.localeCompare(b.label))\r\n : /* istanbul ignore next */\r\n [{ value: `${currentUnitProps.name}:${currentUnitProps.label}`, label: getUnitName(name) }];\r\n\r\n if (potentialSubUnit) {\r\n // construct an entry that will provide the name and label of the unit to add\r\n options.push({ value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`, label: \"Add sub-unit\" }); // NEEDSWORK - i18n\r\n }\r\n\r\n if (index !== 0)\r\n options.push({ value: \"REMOVEUNIT\", label: \"Remove\" }); // NEEDSWORK - i18n\r\n\r\n // istanbul ignore else\r\n if (isMounted.current) {\r\n setUnitOptions(options);\r\n setCurrentUnit(currentUnitProps);\r\n }\r\n }\r\n }\r\n fetchAllowableUnitSelections(); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n }, [index, label, name, parentUnitName, unitsProvider]);\r\n\r\n const handleOnUnitChange = React.useCallback((newValue: string) => {\r\n onUnitChange && onUnitChange(newValue, index);\r\n }, [index, onUnitChange]);\r\n\r\n const handleOnLabelChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\r\n e.preventDefault();\r\n onLabelChange && onLabelChange(e.target.value, index);\r\n }, [index, onLabelChange]);\r\n\r\n return (\r\n <>\r\n <Select options={unitOptions} data-testid={`unit-${currentUnit.name}`} value={`${currentUnit.name}:${currentUnit.label}`}\r\n onChange={handleOnUnitChange} disabled={readonly} size=\"small\" />\r\n <Input data-testid={`unit-label-${currentUnit.name}`} value={label} onChange={handleOnLabelChange} size=\"small\" />\r\n </>\r\n );\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"UnitDescr.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAG/B,wDAAmE;AAgBnE,KAAK,UAAU,qBAAqB,CAAC,aAA0B,EAAE,MAAiB,EAAE,aAA4B;IAC9G,MAAM,qBAAqB,GAAG,aAAa,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;QAC7D,MAAM,UAAU,GAAG,MAAM,aAAa,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnE,OAAO,EAAE,UA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oBACrB,cAAc,CAAC,OAAO,CAAC,CAAC;oBACxB,cAAc,CAAC,gBAAgB,CAAC,CAAC;iBAClC;aACF;QACH,CAAC;QACD,4BAA4B,EAAE,CAAC,CAAC,8DAA8D;IAChG,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;IAExD,MAAM,kBAAkB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,QAAgB,EAAE,EAAE;QAChE,YAAY,IAAI,YAAY,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;IAE1B,MAAM,mBAAmB,GAAG,KAAK,CAAC,WAAW,CAAC,CAAC,CAAsC,EAAE,EAAE;QACvF,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,aAAa,IAAI,aAAa,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC,CAAC;IAE3B,OAAO,CACL;QACE,oBAAC,sBAAM,IAAC,OAAO,EAAE,WAAW,iBAAe,QAAQ,WAAW,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EACtH,QAAQ,EAAE,kBAAkB,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAC,OAAO,GAAG;QACnE,oBAAC,qBAAK,mBAAc,cAAc,WAAW,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAC,OAAO,GAAG,CACjH,CACJ,CAAC;AACJ,CAAC;AArED,8BAqEC","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 { UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport { CommonProps } from \"@itwin/core-react\";\nimport { Input, Select, SelectOption } from \"@itwin/itwinui-react\";\n\n/** Properties of [[UnitDescr]] component.\n * @internal\n */\nexport interface UnitDescrProps extends CommonProps {\n name: string;\n parentUnitName?: string;\n label: string;\n index: number;\n unitsProvider: UnitsProvider;\n readonly?: boolean;\n onUnitChange: (value: string, index: number) => void;\n onLabelChange: (value: string, index: number) => void;\n}\n\nasync function getUnitConversionData(possibleUnits: UnitProps[], toUnit: UnitProps, unitsProvider: UnitsProvider) {\n const unitConversionEntries = possibleUnits.map(async (unit) => {\n const conversion = await unitsProvider.getConversion(unit, toUnit);\n return { conversion, unitProps: unit };\n });\n return unitConversionEntries;\n}\n\nasync function getPossibleUnits(parentUnit: UnitProps, unitsProvider: UnitsProvider, ensureCompatibleComposite: boolean) {\n const phenomenon = parentUnit.phenomenon;\n const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);\n if (!ensureCompatibleComposite)\n return possibleUnits;\n\n const conversionPromises = await getUnitConversionData(possibleUnits, parentUnit, unitsProvider);\n const conversionEntries = await Promise.all(conversionPromises);\n // sort the entries so the best potential sub unit will be the first one in the array\n return conversionEntries.filter((entry) => ((entry.unitProps.system === parentUnit.system) && (entry.conversion.factor < 1)))\n .sort((a, b) => b.conversion.factor - a.conversion.factor)\n .map((value) => value.unitProps);\n}\n\nfunction getUnitName(fullUnitName: string) {\n const nameParts = fullUnitName.split(/[.:]/);\n // istanbul ignore else\n if (nameParts.length > 0)\n return nameParts[nameParts.length - 1];\n // istanbul ignore next\n throw Error(\"Bad unit name encountered\");\n}\n\n/** Component use to display dropdown list of possible units.\n * @internal\n */\nexport function UnitDescr(props: UnitDescrProps) {\n const { name, label, parentUnitName, index, onUnitChange, onLabelChange, readonly, unitsProvider } = props;\n const [unitOptions, setUnitOptions] = React.useState<SelectOption<string>[]>([{ value: name, label: getUnitName(name) }]);\n const [currentUnit, setCurrentUnit] = React.useState({ name, label });\n const isMounted = React.useRef(false);\n\n React.useEffect(() => {\n isMounted.current = true;\n return () => {\n isMounted.current = false;\n };\n });\n\n React.useEffect(() => {\n async function fetchAllowableUnitSelections() {\n const currentUnitProps = await unitsProvider.findUnitByName(name);\n const parentUnit = await unitsProvider.findUnitByName(parentUnitName ? parentUnitName : name);\n // istanbul ignore else\n if (parentUnit && currentUnitProps) {\n let potentialSubUnit: UnitProps | undefined;\n const potentialUnits = await getPossibleUnits(parentUnit, unitsProvider, index !== 0);\n // istanbul ignore else\n if (index < 3) {\n const potentialSubUnits = await getPossibleUnits(currentUnitProps, unitsProvider, true);\n if (potentialSubUnits.length)\n potentialSubUnit = potentialSubUnits[0];\n }\n\n const options = (potentialUnits.length > 0) ?\n potentialUnits.map((unitValue) => {\n return { value: `${unitValue.name}:${unitValue.label}`, label: getUnitName(unitValue.name) };\n }).sort((a, b) => a.label.localeCompare(b.label))\n : /* istanbul ignore next */\n [{ value: `${currentUnitProps.name}:${currentUnitProps.label}`, label: getUnitName(name) }];\n\n if (potentialSubUnit) {\n // construct an entry that will provide the name and label of the unit to add\n options.push({ value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`, label: \"Add sub-unit\" }); // NEEDSWORK - i18n\n }\n\n if (index !== 0)\n options.push({ value: \"REMOVEUNIT\", label: \"Remove\" }); // NEEDSWORK - i18n\n\n // istanbul ignore else\n if (isMounted.current) {\n setUnitOptions(options);\n setCurrentUnit(currentUnitProps);\n }\n }\n }\n fetchAllowableUnitSelections(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }, [index, label, name, parentUnitName, unitsProvider]);\n\n const handleOnUnitChange = React.useCallback((newValue: string) => {\n onUnitChange && onUnitChange(newValue, index);\n }, [index, onUnitChange]);\n\n const handleOnLabelChange = React.useCallback((e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n onLabelChange && onLabelChange(e.target.value, index);\n }, [index, onLabelChange]);\n\n return (\n <>\n <Select options={unitOptions} data-testid={`unit-${currentUnit.name}`} value={`${currentUnit.name}:${currentUnit.label}`}\n onChange={handleOnUnitChange} disabled={readonly} size=\"small\" />\n <Input data-testid={`unit-label-${currentUnit.name}`} value={label} onChange={handleOnLabelChange} size=\"small\" />\n </>\n );\n}\n"]}
|