@itwin/imodel-components-react 4.9.0-dev.1 → 4.10.0-dev.1
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 +23 -1
- package/lib/cjs/imodel-components-react/UiIModelComponents.js +2 -4
- package/lib/cjs/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/editors/ColorEditor.d.ts +1 -1
- package/lib/cjs/imodel-components-react/editors/WeightEditor.d.ts +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts +1 -1
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -11
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js +1 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js +3 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js +6 -10
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js +3 -7
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js +2 -5
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +1 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +2 -2
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.d.ts +1 -1
- package/lib/cjs/imodel-components-react/timeline/PlayerButton.d.ts +2 -2
- package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts +4 -6
- package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js +2 -4
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.scss +3 -2
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.scss +1 -2
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts +2 -2
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js +2 -2
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js +7 -9
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/UiIModelComponents.js +2 -4
- package/lib/esm/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.d.ts +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/editors/ColorEditor.d.ts +1 -1
- package/lib/esm/imodel-components-react/editors/WeightEditor.d.ts +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityNumberInput.js.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts +1 -1
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js +10 -11
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js +1 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js +3 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js +1 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js +6 -10
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js +3 -7
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js +2 -5
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js +1 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts +2 -2
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/UnitDescr.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.d.ts +1 -1
- package/lib/esm/imodel-components-react/timeline/PlayerButton.d.ts +2 -2
- package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts +4 -6
- package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.js +2 -4
- package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.scss +3 -2
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.scss +1 -2
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts +2 -2
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js +2 -2
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js +7 -9
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/package.json +9 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSelector.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":"AAIA;;GAEG
|
|
1
|
+
{"version":3,"file":"ThousandsSelector.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAKrD;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,sBAAsB,qBAsC9D"}
|
|
@@ -38,7 +38,7 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
38
38
|
* @internal
|
|
39
39
|
*/
|
|
40
40
|
function ThousandsSelector(props) {
|
|
41
|
-
const { separator,
|
|
41
|
+
const { separator, ...otherProps } = props;
|
|
42
42
|
const uomDefaultEntries = React.useRef([
|
|
43
43
|
{
|
|
44
44
|
value: ",",
|
|
@@ -49,9 +49,6 @@ function ThousandsSelector(props) {
|
|
|
49
49
|
label: UiIModelComponents_1.UiIModelComponents.translate("QuantityFormat.thousand_separator.point"),
|
|
50
50
|
},
|
|
51
51
|
]);
|
|
52
|
-
const handleOnChange = React.useCallback((newValue) => {
|
|
53
|
-
onChange && onChange(newValue);
|
|
54
|
-
}, [onChange]);
|
|
55
52
|
const separatorOptions = React.useMemo(() => {
|
|
56
53
|
const completeListOfEntries = [];
|
|
57
54
|
// istanbul ignore next (only used if format already has a character that does not match standard options)
|
|
@@ -62,7 +59,7 @@ function ThousandsSelector(props) {
|
|
|
62
59
|
completeListOfEntries.push(...uomDefaultEntries.current);
|
|
63
60
|
return completeListOfEntries;
|
|
64
61
|
}, [separator]);
|
|
65
|
-
return (React.createElement(itwinui_react_1.Select, { options: separatorOptions,
|
|
62
|
+
return (React.createElement(itwinui_react_1.Select, { options: separatorOptions, value: separator, size: "small", ...otherProps }));
|
|
66
63
|
}
|
|
67
64
|
exports.ThousandsSelector = ThousandsSelector;
|
|
68
65
|
//# sourceMappingURL=ThousandsSelector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,iEAA8D;AAE9D,wDAA8C;AAW9C;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"ThousandsSelector.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSelector.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAE/B,iEAA8D;AAE9D,wDAA8C;AAW9C;;GAEG;AACH,SAAgB,iBAAiB,CAAC,KAA6B;IAC7D,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,EAAE,GAAG,KAAK,CAAC;IAC3C,MAAM,iBAAiB,GAAG,KAAK,CAAC,MAAM,CAAyB;QAC7D;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,uCAAkB,CAAC,SAAS,CACjC,yCAAyC,CAC1C;SACF;QACD;YACE,KAAK,EAAE,GAAG;YACV,KAAK,EAAE,uCAAkB,CAAC,SAAS,CACjC,yCAAyC,CAC1C;SACF;KACF,CAAC,CAAC;IAEH,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QAC1C,MAAM,qBAAqB,GAA2B,EAAE,CAAC;QACzD,0GAA0G;QAC1G,IACE,SAAS;YACT,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,KAAK,SAAS,CAAC,EACtE;YACA,qBAAqB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;SACpE;QACD,qBAAqB,CAAC,IAAI,CAAC,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;QACzD,OAAO,qBAAqB,CAAC;IAC/B,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IAEhB,OAAO,CACL,oBAAC,sBAAM,IACL,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,SAAS,EAChB,IAAI,EAAC,OAAO,KACR,UAAU,GACd,CACH,CAAC;AACJ,CAAC;AAtCD,8CAsCC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../../UiIModelComponents\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Select } from \"@itwin/itwinui-react\";\n\n/** Properties of [[ThousandsSelector]] component.\n * @internal\n */\nexport interface ThousandsSelectorProps extends CommonProps {\n separator: string;\n disabled: boolean;\n onChange: (value: string) => void;\n}\n\n/** Component use to set Quantity Format thousand group separator.\n * @internal\n */\nexport function ThousandsSelector(props: ThousandsSelectorProps) {\n const { separator, ...otherProps } = props;\n const uomDefaultEntries = React.useRef<SelectOption<string>[]>([\n {\n value: \",\",\n label: UiIModelComponents.translate(\n \"QuantityFormat.thousand_separator.comma\"\n ),\n },\n {\n value: \".\",\n label: UiIModelComponents.translate(\n \"QuantityFormat.thousand_separator.point\"\n ),\n },\n ]);\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 (\n undefined ===\n uomDefaultEntries.current.find((option) => option.value === separator)\n ) {\n completeListOfEntries.push({ value: separator, label: separator });\n }\n completeListOfEntries.push(...uomDefaultEntries.current);\n return completeListOfEntries;\n }, [separator]);\n\n return (\n <Select\n options={separatorOptions}\n value={separator}\n size=\"small\"\n {...otherProps}\n />\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module QuantityFormat
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
import type { CommonProps } from "@itwin/core-react";
|
|
6
6
|
import type { FormatProps } from "@itwin/core-quantity";
|
|
7
7
|
/** Properties of [[ThousandsSeparator]] component.
|
|
@@ -14,5 +14,5 @@ export interface ThousandsSeparatorProps extends CommonProps {
|
|
|
14
14
|
/** Component use to set Quantity Format thousand group separator.
|
|
15
15
|
* @internal
|
|
16
16
|
*/
|
|
17
|
-
export declare function ThousandsSeparator(props: ThousandsSeparatorProps): JSX.Element;
|
|
17
|
+
export declare function ThousandsSeparator(props: ThousandsSeparatorProps): React.JSX.Element;
|
|
18
18
|
//# sourceMappingURL=ThousandsSeparator.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG
|
|
1
|
+
{"version":3,"file":"ThousandsSeparator.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAMxD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,WAAW;IAC1D,WAAW,EAAE,WAAW,CAAC;IACzB,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;CAC1C;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,qBAgHhE"}
|
|
@@ -44,7 +44,6 @@ const UiIModelComponents_1 = require("../../UiIModelComponents");
|
|
|
44
44
|
* @internal
|
|
45
45
|
*/
|
|
46
46
|
function ThousandsSeparator(props) {
|
|
47
|
-
var _a;
|
|
48
47
|
const { formatProps, onChange } = props;
|
|
49
48
|
const handleSetFormatProps = React.useCallback((newProps) => {
|
|
50
49
|
onChange && onChange(newProps);
|
|
@@ -105,7 +104,7 @@ function ThousandsSeparator(props) {
|
|
|
105
104
|
React.createElement("span", { className: "uicore-label" }, useThousandSeparatorLabel.current),
|
|
106
105
|
React.createElement(itwinui_react_1.Checkbox, { "data-testid": "use-thousands-separator", checked: isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleUseThousandsSeparatorChange }),
|
|
107
106
|
React.createElement("span", { className: (0, classnames_1.default)("uicore-label", !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator) && "uicore-disabled") }, thousandSeparatorLabel.current),
|
|
108
|
-
React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator:
|
|
107
|
+
React.createElement(ThousandsSelector_1.ThousandsSelector, { "data-testid": "thousands-separator-selector", separator: formatProps.thousandSeparator ?? ",", disabled: !isFormatTraitSet(core_quantity_1.FormatTraits.Use1000Separator), onChange: handleThousandSeparatorChange })));
|
|
109
108
|
}
|
|
110
109
|
exports.ThousandsSeparator = ThousandsSeparator;
|
|
111
110
|
//# 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;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAG/B,wDAA4E;AAC5E,wDAAgD;AAChD,2DAAwD;AACxD,iEAA8D;AAU9D;;GAEG;AACH,SAAgB,kBAAkB,CAAC,KAA8B
|
|
1
|
+
{"version":3,"file":"ThousandsSeparator.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/ThousandsSeparator.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4DAAoC;AACpC,6CAA+B;AAG/B,wDAA4E;AAC5E,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,CAC5C,CAAC,QAAqB,EAAE,EAAE;QACxB,QAAQ,IAAI,QAAQ,CAAC,QAAQ,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,QAAQ,CAAC,CACX,CAAC;IAEF,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,CACtC,CAAC,KAAmB,EAAE,SAAkB,EAAE,EAAE;QAC1C,MAAM,QAAQ,GAAG,IAAA,8BAAc,EAAC,KAAK,CAAC,CAAC;QACvC,IAAI,YAAY,GAAa,CAAC,QAAQ,CAAC,CAAC;QACxC,IAAI,SAAS,EAAE;YACb,gBAAgB;YAChB,uBAAuB;YACvB,IAAI,WAAW,CAAC,YAAY,EAAE;gBAC5B,MAAM,MAAM,GAA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CAAC,EAC1D,QAAQ,EAAE,6BAA6B,GACvC,CACD,CACJ,CAAC;AACJ,CAAC;AAhHD,gDAgHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { FormatProps } from \"@itwin/core-quantity\";\nimport { Format, FormatTraits, getTraitString } from \"@itwin/core-quantity\";\nimport { 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(\n (newProps: FormatProps) => {\n onChange && onChange(newProps);\n },\n [onChange]\n );\n\n const setFormatTrait = React.useCallback(\n (trait: FormatTraits, setActive: boolean) => {\n const traitStr = getTraitString(trait);\n let formatTraits: string[] = [traitStr];\n if (setActive) {\n // setting trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = [...traits, traitStr];\n }\n } else {\n // clearing trait\n // istanbul ignore else\n if (formatProps.formatTraits) {\n const traits = Array.isArray(formatProps.formatTraits)\n ? formatProps.formatTraits\n : /* istanbul ignore next */ formatProps.formatTraits.split(\n /,|;|\\|/\n );\n formatTraits = traits.filter((traitEntry) => traitEntry !== traitStr);\n }\n }\n const newFormatProps = { ...formatProps, formatTraits };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, handleSetFormatProps]\n );\n\n const handleUseThousandsSeparatorChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n setFormatTrait(FormatTraits.Use1000Separator, e.target.checked);\n },\n [setFormatTrait]\n );\n\n const isFormatTraitSet = React.useCallback(\n (trait: FormatTraits) => {\n return Format.isFormatTraitSetInProps(formatProps, trait);\n },\n [formatProps]\n );\n\n const handleThousandSeparatorChange = React.useCallback(\n (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 === \".\") decimalSeparator = \",\";\n // thousandSeparator === \",\"\n else decimalSeparator = \".\";\n }\n const newFormatProps = {\n ...formatProps,\n thousandSeparator,\n decimalSeparator,\n };\n handleSetFormatProps(newFormatProps);\n },\n [formatProps, isFormatTraitSet, handleSetFormatProps]\n );\n\n const useThousandSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\n \"QuantityFormat.labels.useThousandSeparatorLabel\"\n )\n );\n const thousandSeparatorLabel = React.useRef(\n UiIModelComponents.translate(\"QuantityFormat.labels.thousandSeparatorLabel\")\n );\n\n return (\n <>\n <span className={\"uicore-label\"}>\n {useThousandSeparatorLabel.current}\n </span>\n <Checkbox\n data-testid=\"use-thousands-separator\"\n checked={isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleUseThousandsSeparatorChange}\n />\n <span\n className={classnames(\n \"uicore-label\",\n !isFormatTraitSet(FormatTraits.Use1000Separator) && \"uicore-disabled\"\n )}\n >\n {thousandSeparatorLabel.current}\n </span>\n <ThousandsSelector\n data-testid=\"thousands-separator-selector\"\n separator={formatProps.thousandSeparator ?? \",\"}\n disabled={!isFormatTraitSet(FormatTraits.Use1000Separator)}\n onChange={handleThousandSeparatorChange}\n />\n </>\n );\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module QuantityFormat
|
|
3
3
|
*/
|
|
4
|
-
|
|
4
|
+
import * as React from "react";
|
|
5
5
|
import type { UnitsProvider } from "@itwin/core-quantity";
|
|
6
6
|
import type { CommonProps } from "@itwin/core-react";
|
|
7
7
|
/** Properties of [[UnitDescr]] component.
|
|
@@ -20,5 +20,5 @@ export interface UnitDescrProps extends CommonProps {
|
|
|
20
20
|
/** Component use to display dropdown list of possible units.
|
|
21
21
|
* @internal
|
|
22
22
|
*/
|
|
23
|
-
export declare function UnitDescr(props: UnitDescrProps): JSX.Element;
|
|
23
|
+
export declare function UnitDescr(props: UnitDescrProps): React.JSX.Element;
|
|
24
24
|
//# sourceMappingURL=UnitDescr.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitDescr.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":"AAIA;;GAEG
|
|
1
|
+
{"version":3,"file":"UnitDescr.d.ts","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAa,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,WAAW;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACrD,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACvD;AAgDD;;GAEG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAuH9C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnitDescr.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAI/B,wDAAqD;AAgBrD,KAAK,UAAU,qBAAqB,CAClC,aAA0B,EAC1B,MAAiB,EACjB,aAA4B;IAE5B,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,UAAU,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;IACH,OAAO,qBAAqB,CAAC;AAC/B,CAAC;AAED,KAAK,UAAU,gBAAgB,CAC7B,UAAqB,EACrB,aAA4B,EAC5B,yBAAkC;IAElC,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC;IACzC,MAAM,aAAa,GAAG,MAAM,aAAa,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,CAAC,yBAAyB;QAAE,OAAO,aAAa,CAAC;IAErD,MAAM,kBAAkB,GAAG,MAAM,qBAAqB,CACpD,aAAa,EACb,UAAU,EACV,aAAa,CACd,CAAC;IACF,MAAM,iBAAiB,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChE,qFAAqF;IACrF,OAAO,iBAAiB;SACrB,MAAM,CACL,CAAC,KAAK,EAAE,EA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K,EAAE,aAAa,CAAC,CACvB,CAAC;IAEF,OAAO,CACL;QACE,oBAAC,sBAAM,IACL,OAAO,EAAE,WAAW,iBACP,QAAQ,WAAW,CAAC,IAAI,EAAE,EACvC,KAAK,EAAE,GAAG,WAAW,CAAC,IAAI,IAAI,WAAW,CAAC,KAAK,EAAE,EACjD,QAAQ,EAAE,kBAAyB,EACnC,QAAQ,EAAE,QAAQ,EAClB,IAAI,EAAC,OAAO,GACZ;QACF,oBAAC,qBAAK,mBACS,cAAc,WAAW,CAAC,IAAI,EAAE,EAC7C,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,mBAAmB,EAC7B,IAAI,EAAC,OAAO,GACZ,CACD,CACJ,CAAC;AACJ,CAAC;AAvHD,8BAuHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Input, Select } 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(\n possibleUnits: UnitProps[],\n toUnit: UnitProps,\n unitsProvider: UnitsProvider\n) {\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(\n parentUnit: UnitProps,\n unitsProvider: UnitsProvider,\n ensureCompatibleComposite: boolean\n) {\n const phenomenon = parentUnit.phenomenon;\n const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);\n if (!ensureCompatibleComposite) return possibleUnits;\n\n const conversionPromises = await getUnitConversionData(\n possibleUnits,\n parentUnit,\n unitsProvider\n );\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\n .filter(\n (entry) =>\n entry.unitProps.system === parentUnit.system &&\n entry.conversion.factor < 1\n )\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) 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 {\n name,\n label,\n parentUnitName,\n index,\n onUnitChange,\n onLabelChange,\n readonly,\n unitsProvider,\n } = props;\n const [unitOptions, setUnitOptions] = React.useState<SelectOption<string>[]>([\n { value: name, label: getUnitName(name) },\n ]);\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(\n parentUnitName ? parentUnitName : name\n );\n // istanbul ignore else\n if (parentUnit && currentUnitProps) {\n let potentialSubUnit: UnitProps | undefined;\n const potentialUnits = await getPossibleUnits(\n parentUnit,\n unitsProvider,\n index !== 0\n );\n // istanbul ignore else\n if (index < 3) {\n const potentialSubUnits = await getPossibleUnits(\n currentUnitProps,\n unitsProvider,\n true\n );\n if (potentialSubUnits.length) potentialSubUnit = potentialSubUnits[0];\n }\n\n const options =\n potentialUnits.length > 0\n ? potentialUnits\n .map((unitValue) => {\n return {\n value: `${unitValue.name}:${unitValue.label}`,\n label: getUnitName(unitValue.name),\n };\n })\n .sort((a, b) => a.label.localeCompare(b.label))\n : /* istanbul ignore next */\n [\n {\n value: `${currentUnitProps.name}:${currentUnitProps.label}`,\n label: getUnitName(name),\n },\n ];\n\n if (potentialSubUnit) {\n // construct an entry that will provide the name and label of the unit to add\n options.push({\n value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`,\n label: \"Add sub-unit\",\n }); // NEEDSWORK - i18n\n }\n\n if (index !== 0) 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 void fetchAllowableUnitSelections();\n }, [index, label, name, parentUnitName, unitsProvider]);\n\n const handleOnUnitChange = React.useCallback(\n (newValue: string) => {\n onUnitChange && onUnitChange(newValue, index);\n },\n [index, onUnitChange]\n );\n\n const handleOnLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n onLabelChange && onLabelChange(e.target.value, index);\n },\n [index, onLabelChange]\n );\n\n return (\n <>\n <Select\n options={unitOptions}\n data-testid={`unit-${currentUnit.name}`}\n value={`${currentUnit.name}:${currentUnit.label}`}\n onChange={handleOnUnitChange as any}\n disabled={readonly}\n size=\"small\"\n />\n <Input\n data-testid={`unit-label-${currentUnit.name}`}\n value={label}\n onChange={handleOnLabelChange}\n size=\"small\"\n />\n </>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"UnitDescr.js","sourceRoot":"","sources":["../../../../../src/imodel-components-react/quantityformat/misc/UnitDescr.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAI/B,wDAAqD;AAgBrD,KAAK,UAAU,qBAAqB,CAClC,aAA0B,EAC1B,MAAiB,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;AAvHD,8BAuHC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module QuantityFormat\n */\n\nimport * as React from \"react\";\nimport type { UnitProps, UnitsProvider } from \"@itwin/core-quantity\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport type { SelectOption } from \"@itwin/itwinui-react\";\nimport { Input, Select } 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(\n possibleUnits: UnitProps[],\n toUnit: UnitProps,\n unitsProvider: UnitsProvider\n) {\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(\n parentUnit: UnitProps,\n unitsProvider: UnitsProvider,\n ensureCompatibleComposite: boolean\n) {\n const phenomenon = parentUnit.phenomenon;\n const possibleUnits = await unitsProvider.getUnitsByFamily(phenomenon);\n if (!ensureCompatibleComposite) return possibleUnits;\n\n const conversionPromises = await getUnitConversionData(\n possibleUnits,\n parentUnit,\n unitsProvider\n );\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\n .filter(\n (entry) =>\n entry.unitProps.system === parentUnit.system &&\n entry.conversion.factor < 1\n )\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) 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 {\n name,\n label,\n parentUnitName,\n index,\n onUnitChange,\n onLabelChange,\n readonly,\n unitsProvider,\n } = props;\n const [unitOptions, setUnitOptions] = React.useState<SelectOption<string>[]>([\n { value: name, label: getUnitName(name) },\n ]);\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(\n parentUnitName ? parentUnitName : name\n );\n // istanbul ignore else\n if (parentUnit && currentUnitProps) {\n let potentialSubUnit: UnitProps | undefined;\n const potentialUnits = await getPossibleUnits(\n parentUnit,\n unitsProvider,\n index !== 0\n );\n // istanbul ignore else\n if (index < 3) {\n const potentialSubUnits = await getPossibleUnits(\n currentUnitProps,\n unitsProvider,\n true\n );\n if (potentialSubUnits.length) potentialSubUnit = potentialSubUnits[0];\n }\n\n const options =\n potentialUnits.length > 0\n ? potentialUnits\n .map((unitValue) => {\n return {\n value: `${unitValue.name}:${unitValue.label}`,\n label: getUnitName(unitValue.name),\n };\n })\n .sort((a, b) => a.label.localeCompare(b.label))\n : /* istanbul ignore next */\n [\n {\n value: `${currentUnitProps.name}:${currentUnitProps.label}`,\n label: getUnitName(name),\n },\n ];\n\n if (potentialSubUnit) {\n // construct an entry that will provide the name and label of the unit to add\n options.push({\n value: `ADDSUBUNIT:${potentialSubUnit.name}:${potentialSubUnit.label}`,\n label: \"Add sub-unit\",\n }); // NEEDSWORK - i18n\n }\n\n if (index !== 0) 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 void fetchAllowableUnitSelections();\n }, [index, label, name, parentUnitName, unitsProvider]);\n\n const handleOnUnitChange = React.useCallback(\n (newValue: string) => {\n onUnitChange && onUnitChange(newValue, index);\n },\n [index, onUnitChange]\n );\n\n const handleOnLabelChange = React.useCallback(\n (e: React.ChangeEvent<HTMLInputElement>) => {\n e.preventDefault();\n onLabelChange && onLabelChange(e.target.value, index);\n },\n [index, onLabelChange]\n );\n\n return (\n <>\n <Select\n options={unitOptions}\n data-testid={`unit-${currentUnit.name}`}\n value={`${currentUnit.name}:${currentUnit.label}`}\n onChange={handleOnUnitChange}\n disabled={readonly}\n size=\"small\"\n />\n <Input\n data-testid={`unit-label-${currentUnit.name}`}\n value={label}\n onChange={handleOnLabelChange}\n size=\"small\"\n />\n </>\n );\n}\n"]}
|
|
@@ -22,7 +22,7 @@ export declare class InlineEdit extends React.Component<InlineEditProps, InlineE
|
|
|
22
22
|
private _onKeyDown;
|
|
23
23
|
private _onChange;
|
|
24
24
|
private _sendChange;
|
|
25
|
-
render(): JSX.Element;
|
|
25
|
+
render(): React.JSX.Element;
|
|
26
26
|
}
|
|
27
27
|
export {};
|
|
28
28
|
//# sourceMappingURL=InlineEdit.d.ts.map
|
|
@@ -6,7 +6,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
6
6
|
*/
|
|
7
7
|
export declare class PlayerButton extends React.PureComponent<any> {
|
|
8
8
|
private _onClick;
|
|
9
|
-
render(): JSX.Element;
|
|
9
|
+
render(): React.JSX.Element;
|
|
10
10
|
}
|
|
11
11
|
/** Properties for Play/Pause button used on timeline control
|
|
12
12
|
* @internal
|
|
@@ -28,7 +28,7 @@ export declare class PlayButton extends React.Component<PlayerButtonProps, PlayB
|
|
|
28
28
|
/** @internal */
|
|
29
29
|
componentDidUpdate(): void;
|
|
30
30
|
private _onClick;
|
|
31
|
-
render(): JSX.Element;
|
|
31
|
+
render(): React.JSX.Element;
|
|
32
32
|
}
|
|
33
33
|
export {};
|
|
34
34
|
//# sourceMappingURL=PlayerButton.d.ts.map
|
|
@@ -6,20 +6,18 @@ import type { TimelineDateMarkerProps } from "./TimelineComponent";
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
export declare function getPercentageOfRectangle(rect: DOMRect, pointer: number): number;
|
|
9
|
-
/**
|
|
10
|
-
* @internal
|
|
11
|
-
*/
|
|
9
|
+
/** @internal */
|
|
12
10
|
export declare function RailMarkers({ showToolTip, percent, tooltipText, markDate, }: {
|
|
13
11
|
showToolTip: boolean;
|
|
14
12
|
percent: number;
|
|
15
13
|
tooltipText: string;
|
|
16
14
|
markDate?: DateMarkerProps;
|
|
17
|
-
}): JSX.Element;
|
|
15
|
+
}): React.JSX.Element;
|
|
18
16
|
/**
|
|
19
17
|
* Custom Timeline Thumb
|
|
20
18
|
* @internal
|
|
21
19
|
*/
|
|
22
|
-
export declare function CustomThumb(): JSX.Element;
|
|
20
|
+
export declare function CustomThumb(): React.JSX.Element;
|
|
23
21
|
/**
|
|
24
22
|
* @internal
|
|
25
23
|
*/
|
|
@@ -50,6 +48,6 @@ interface DateMarkerProps {
|
|
|
50
48
|
/** Scrubber/Slider for timeline control
|
|
51
49
|
* @internal
|
|
52
50
|
*/
|
|
53
|
-
export declare function Scrubber(props: ScrubberProps): JSX.Element;
|
|
51
|
+
export declare function Scrubber(props: ScrubberProps): React.JSX.Element;
|
|
54
52
|
export {};
|
|
55
53
|
//# sourceMappingURL=Scrubber.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scrubber.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":"AAIA,OAAO,iBAAiB,CAAC;AACzB,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qBA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AC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IACnD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,uBAAuB,CAAC;CACpC;AAED;;GAEG;AACH,UAAU,eAAe;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC9B;AACD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,qBAsH5C"}
|
|
@@ -90,9 +90,7 @@ function markDateInTimelineRange(dateMarkerProps, startDate, endDate) {
|
|
|
90
90
|
}
|
|
91
91
|
return false;
|
|
92
92
|
}
|
|
93
|
-
/**
|
|
94
|
-
* @internal
|
|
95
|
-
*/
|
|
93
|
+
/** @internal */
|
|
96
94
|
function RailMarkers({ showToolTip, percent, tooltipText, markDate, }) {
|
|
97
95
|
return (React.createElement("div", { className: "components-timeline-rail-marker-container" },
|
|
98
96
|
showToolTip && (React.createElement("div", { className: "components-timeline-tooltip", style: { left: `${Math.round(percent * 100)}% ` } },
|
|
@@ -159,7 +157,7 @@ function Scrubber(props) {
|
|
|
159
157
|
sliderContainer &&
|
|
160
158
|
setPointerPercent(getPercentageOfRectangle(sliderContainer.getBoundingClientRect(), event.clientX));
|
|
161
159
|
}, [sliderContainer]);
|
|
162
|
-
const thumbHasFocus = useFocusedThumb(sliderContainer
|
|
160
|
+
const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);
|
|
163
161
|
const tickLabel = React.useMemo(() => {
|
|
164
162
|
const showTip = isPlaying || showRailTooltip || thumbHasFocus;
|
|
165
163
|
const percent = isPlaying || thumbHasFocus
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,2BAAyB;AACzB,6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,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,eAAe,CAAC,EACzB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;YACjB,QAAQ,EAAE,oBAAC,WAAW,OAAG;YACzB,SAAS,EAAE,2BAA2B;SACvC,CAAC,EACF,UAAU,EAAE,SAAS,EACrB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,cAAc,EAAE,kBAAkB,GAClC,CACH,CAAC;AACJ,CAAC;AAtHD,4BAsHC","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 *--------------------------------------------------------------------------------------------*/\nimport \"./Scrubber.scss\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { useEventListener } from \"@itwin/core-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport type { TimelineDateMarkerProps } from \"./TimelineComponent\";\n\n/**\n * @internal\n */\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\n return (position - rect.left) / rect.width;\n}\n\n// istanbul ignore next - WIP\nconst formatDuration = (value: number) => {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(value);\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n};\n\nconst formatDate = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return toDateString(date, timeZoneOffset);\n};\n\n// istanbul ignore next - WIP\nconst formatTime = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return ` ${toTimeString(date, timeZoneOffset)}`;\n};\n\nfunction generateToolTipText(\n showTime: boolean,\n percent: number,\n min: number,\n max: number,\n startDate?: Date,\n endDate?: Date,\n timeZoneOffset = 0\n) {\n if (startDate && endDate)\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${\n showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"\n } `;\n\n const val = Math.round(min + (max - min) * percent);\n return formatDuration(val);\n}\n\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\n const newDate = date ? date : new Date();\n const startTime = startDate.getTime();\n const totalDuration = endDate.getTime() - startTime;\n return (newDate.getTime() - startTime) / totalDuration;\n}\n\nfunction getDateMarker(\n dateMarkerPropsIn: TimelineDateMarkerProps,\n startDate: Date,\n endDate: Date\n): DateMarkerProps {\n const percentage = getPercentageFromDate(\n startDate,\n endDate,\n dateMarkerPropsIn.date\n );\n const marker = dateMarkerPropsIn.dateMarker ? (\n dateMarkerPropsIn.dateMarker\n ) : (\n <span className=\"date-marker-default\"></span>\n );\n return { datePercentage: percentage, dateMarker: marker };\n}\n\nfunction markDateInTimelineRange(\n dateMarkerProps?: TimelineDateMarkerProps,\n startDate?: Date,\n endDate?: Date\n): boolean {\n // istanbul ignore else\n if (dateMarkerProps && startDate && endDate) {\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\n // istanbul ignore else\n if (\n inDate.getTime() >= startDate.getTime() &&\n inDate.getTime() <= endDate.getTime()\n )\n return true;\n }\n return false;\n}\n/**\n * @internal\n */\nexport function RailMarkers({\n showToolTip,\n percent,\n tooltipText,\n markDate,\n}: {\n showToolTip: boolean;\n percent: number;\n tooltipText: string;\n markDate?: DateMarkerProps;\n}) {\n return (\n <div className=\"components-timeline-rail-marker-container\">\n {showToolTip && (\n <div\n className=\"components-timeline-tooltip\"\n style={{ left: `${Math.round(percent * 100)}% ` }}\n >\n <span className=\"tooltip-text\">{tooltipText}</span>\n </div>\n )}\n {markDate && (\n <div\n className=\"components-timeline-date-marker\"\n data-testid=\"test-date-marker\"\n style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}\n >\n {markDate.dateMarker}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Custom Timeline Thumb\n * @internal\n */\nexport function CustomThumb() {\n return (\n <div className=\"scrubber-handle\">\n <div />\n <div />\n <div />\n </div>\n );\n}\n\n/**\n * @internal\n */\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\n\n React.useLayoutEffect(() => {\n if (!sliderContainer) return;\n const element = sliderContainer.querySelector(\".components-timeline-thumb\");\n if (!element) return;\n setThumbElement(element as HTMLDivElement);\n }, [sliderContainer, thumbElement]);\n\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\n\n const handleThumbFocus = React.useCallback(() => {\n setThumbHasFocus(true);\n }, []);\n\n const handleThumbBlur = React.useCallback(() => {\n setThumbHasFocus(false);\n }, []);\n\n useEventListener(\"focus\", handleThumbFocus, thumbElement);\n useEventListener(\"blur\", handleThumbBlur, thumbElement);\n return thumbHasFocus;\n}\n\n/** Properties for Scrubber/Slider used on timeline control\n * @internal\n */\nexport interface ScrubberProps extends CommonProps {\n currentDuration: number;\n totalDuration: number;\n isPlaying: boolean;\n inMiniMode: boolean;\n startDate?: Date;\n endDate?: Date;\n showTime?: boolean;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n timeZoneOffset?: number;\n markDate?: TimelineDateMarkerProps;\n}\n\n/** Properties for marking current date in RailMarkers\n * @internal\n */\ninterface DateMarkerProps {\n datePercentage: number;\n dateMarker?: React.ReactNode;\n}\n/** Scrubber/Slider for timeline control\n * @internal\n */\nexport function Scrubber(props: ScrubberProps) {\n const {\n startDate,\n endDate,\n showTime,\n isPlaying,\n totalDuration,\n timeZoneOffset,\n currentDuration,\n className,\n onChange,\n onUpdate,\n } = props;\n\n const [sliderContainer, setSliderContainer] =\n React.useState<HTMLDivElement | null>(null);\n const [pointerPercent, setPointerPercent] = React.useState(0);\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\n\n // istanbul ignore next\n const handlePointerEnter = React.useCallback(() => {\n setShowRailTooltip(true);\n }, []);\n\n // istanbul ignore next\n const handlePointerLeave = React.useCallback(() => {\n setShowRailTooltip(false);\n }, []);\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n sliderContainer &&\n setPointerPercent(\n getPercentageOfRectangle(\n sliderContainer.getBoundingClientRect(),\n event.clientX\n )\n );\n },\n [sliderContainer]\n );\n\n const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);\n\n const tickLabel = React.useMemo(() => {\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\n const percent =\n isPlaying || thumbHasFocus\n ? currentDuration / totalDuration\n : pointerPercent;\n const markDateInRange = markDateInTimelineRange(\n props.markDate,\n startDate,\n endDate\n );\n const currentDateMarker =\n props.markDate && markDateInRange && startDate && endDate\n ? getDateMarker(props.markDate, startDate, endDate)\n : undefined;\n const tooltipText = generateToolTipText(\n !!showTime,\n percent,\n 0,\n totalDuration,\n startDate,\n endDate,\n timeZoneOffset\n );\n return (\n <RailMarkers\n showToolTip={showTip}\n percent={percent}\n tooltipText={tooltipText}\n markDate={currentDateMarker}\n />\n );\n }, [\n isPlaying,\n showRailTooltip,\n currentDuration,\n totalDuration,\n pointerPercent,\n startDate,\n endDate,\n timeZoneOffset,\n showTime,\n thumbHasFocus,\n props.markDate,\n ]);\n\n return (\n <Slider\n ref={setSliderContainer}\n className={className}\n step={1}\n min={0}\n max={totalDuration}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentDuration]}\n tooltipProps={tooltipProps}\n thumbProps={() => ({\n children: <CustomThumb />,\n className: \"components-timeline-thumb\",\n })}\n tickLabels={tickLabel}\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerMove}\n onPointerLeave={handlePointerLeave}\n />\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"Scrubber.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/timeline/Scrubber.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;gGAGgG;AAChG,2BAAyB;AACzB,6CAA+B;AAC/B,wDAA8C;AAE9C,kDAAqD;AACrD,8DAAqE;AAGrE;;GAEG;AACH,SAAgB,wBAAwB,CAAC,IAAa,EAAE,OAAe;IACrE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;IACpE,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC;AAC7C,CAAC;AAHD,4DAGC;AAED,6BAA6B;AAC7B,MAAM,cAAc,GAAG,CAAC,KAAa,EAAE,EAAE;IACvC,MAAM,OAAO,GAAG,CAAC,CAAS,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7B,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,EAAE,CAAC;IACrC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC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AC;QACF,OAAO,CACL,oBAAC,WAAW,IACV,WAAW,EAAE,OAAO,EACpB,OAAO,EAAE,OAAO,EAChB,WAAW,EAAE,WAAW,EACxB,QAAQ,EAAE,iBAAiB,GAC3B,CACH,CAAC;IACJ,CAAC,EAAE;QACD,SAAS;QACT,eAAe;QACf,eAAe;QACf,aAAa;QACb,cAAc;QACd,SAAS;QACT,OAAO;QACP,cAAc;QACd,QAAQ;QACR,aAAa;QACb,KAAK,CAAC,QAAQ;KACf,CAAC,CAAC;IAEH,OAAO,CACL,oBAAC,sBAAM,IACL,GAAG,EAAE,kBAAkB,EACvB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,CAAC,EACP,GAAG,EAAE,CAAC,EACN,GAAG,EAAE,aAAa,EAClB,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAC,EAAE,EACX,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,CAAC,eAAe,CAAC,EACzB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;YACjB,QAAQ,EAAE,oBAAC,WAAW,OAAG;YACzB,SAAS,EAAE,2BAA2B;SACvC,CAAC,EACF,UAAU,EAAE,SAAS,EACrB,cAAc,EAAE,kBAAkB,EAClC,aAAa,EAAE,iBAAiB,EAChC,cAAc,EAAE,kBAAkB,GAClC,CACH,CAAC;AACJ,CAAC;AAtHD,4BAsHC","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 *--------------------------------------------------------------------------------------------*/\nimport \"./Scrubber.scss\";\nimport * as React from \"react\";\nimport { Slider } from \"@itwin/itwinui-react\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { useEventListener } from \"@itwin/core-react\";\nimport { toDateString, toTimeString } from \"@itwin/components-react\";\nimport type { TimelineDateMarkerProps } from \"./TimelineComponent\";\n\n/**\n * @internal\n */\nexport function getPercentageOfRectangle(rect: DOMRect, pointer: number) {\n const position = Math.min(rect.right, Math.max(rect.left, pointer));\n return (position - rect.left) / rect.width;\n}\n\n// istanbul ignore next - WIP\nconst formatDuration = (value: number) => {\n const addZero = (i: number) => {\n return i < 10 ? `0${i}` : i;\n };\n\n const date = new Date(value);\n const minutes = date.getUTCMinutes();\n const seconds = date.getUTCSeconds();\n return `${addZero(minutes)}:${addZero(seconds)}`;\n};\n\nconst formatDate = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return toDateString(date, timeZoneOffset);\n};\n\n// istanbul ignore next - WIP\nconst formatTime = (\n startDate: Date,\n endDate: Date,\n fraction: number,\n timeZoneOffset?: number\n) => {\n const delta = (endDate.getTime() - startDate.getTime()) * fraction;\n const date = new Date(startDate.getTime() + delta);\n return ` ${toTimeString(date, timeZoneOffset)}`;\n};\n\nfunction generateToolTipText(\n showTime: boolean,\n percent: number,\n min: number,\n max: number,\n startDate?: Date,\n endDate?: Date,\n timeZoneOffset = 0\n) {\n if (startDate && endDate)\n return `${formatDate(startDate, endDate, percent, timeZoneOffset)}${\n showTime ? formatTime(startDate, endDate, percent, timeZoneOffset) : \"\"\n } `;\n\n const val = Math.round(min + (max - min) * percent);\n return formatDuration(val);\n}\n\nfunction getPercentageFromDate(startDate: Date, endDate: Date, date?: Date) {\n const newDate = date ? date : new Date();\n const startTime = startDate.getTime();\n const totalDuration = endDate.getTime() - startTime;\n return (newDate.getTime() - startTime) / totalDuration;\n}\n\nfunction getDateMarker(\n dateMarkerPropsIn: TimelineDateMarkerProps,\n startDate: Date,\n endDate: Date\n): DateMarkerProps {\n const percentage = getPercentageFromDate(\n startDate,\n endDate,\n dateMarkerPropsIn.date\n );\n const marker = dateMarkerPropsIn.dateMarker ? (\n dateMarkerPropsIn.dateMarker\n ) : (\n <span className=\"date-marker-default\"></span>\n );\n return { datePercentage: percentage, dateMarker: marker };\n}\n\nfunction markDateInTimelineRange(\n dateMarkerProps?: TimelineDateMarkerProps,\n startDate?: Date,\n endDate?: Date\n): boolean {\n // istanbul ignore else\n if (dateMarkerProps && startDate && endDate) {\n const inDate = dateMarkerProps.date ? dateMarkerProps.date : new Date();\n // istanbul ignore else\n if (\n inDate.getTime() >= startDate.getTime() &&\n inDate.getTime() <= endDate.getTime()\n )\n return true;\n }\n return false;\n}\n\n/** @internal */\nexport function RailMarkers({\n showToolTip,\n percent,\n tooltipText,\n markDate,\n}: {\n showToolTip: boolean;\n percent: number;\n tooltipText: string;\n markDate?: DateMarkerProps;\n}) {\n return (\n <div className=\"components-timeline-rail-marker-container\">\n {showToolTip && (\n <div\n className=\"components-timeline-tooltip\"\n style={{ left: `${Math.round(percent * 100)}% ` }}\n >\n <span className=\"tooltip-text\">{tooltipText}</span>\n </div>\n )}\n {markDate && (\n <div\n className=\"components-timeline-date-marker\"\n data-testid=\"test-date-marker\"\n style={{ left: `${Math.round(markDate.datePercentage * 100)}% ` }}\n >\n {markDate.dateMarker}\n </div>\n )}\n </div>\n );\n}\n\n/**\n * Custom Timeline Thumb\n * @internal\n */\nexport function CustomThumb() {\n return (\n <div className=\"scrubber-handle\">\n <div />\n <div />\n <div />\n </div>\n );\n}\n\n/**\n * @internal\n */\nexport function useFocusedThumb(sliderContainer: HTMLDivElement | undefined) {\n const [thumbElement, setThumbElement] = React.useState<HTMLDivElement>();\n\n React.useLayoutEffect(() => {\n if (!sliderContainer) return;\n const element = sliderContainer.querySelector(\".components-timeline-thumb\");\n if (!element) return;\n setThumbElement(element as HTMLDivElement);\n }, [sliderContainer, thumbElement]);\n\n const [thumbHasFocus, setThumbHasFocus] = React.useState(false);\n\n const handleThumbFocus = React.useCallback(() => {\n setThumbHasFocus(true);\n }, []);\n\n const handleThumbBlur = React.useCallback(() => {\n setThumbHasFocus(false);\n }, []);\n\n useEventListener(\"focus\", handleThumbFocus, thumbElement);\n useEventListener(\"blur\", handleThumbBlur, thumbElement);\n return thumbHasFocus;\n}\n\n/** Properties for Scrubber/Slider used on timeline control\n * @internal\n */\nexport interface ScrubberProps extends CommonProps {\n currentDuration: number;\n totalDuration: number;\n isPlaying: boolean;\n inMiniMode: boolean;\n startDate?: Date;\n endDate?: Date;\n showTime?: boolean;\n onChange?: (values: ReadonlyArray<number>) => void;\n onUpdate?: (values: ReadonlyArray<number>) => void;\n timeZoneOffset?: number;\n markDate?: TimelineDateMarkerProps;\n}\n\n/** Properties for marking current date in RailMarkers\n * @internal\n */\ninterface DateMarkerProps {\n datePercentage: number;\n dateMarker?: React.ReactNode;\n}\n/** Scrubber/Slider for timeline control\n * @internal\n */\nexport function Scrubber(props: ScrubberProps) {\n const {\n startDate,\n endDate,\n showTime,\n isPlaying,\n totalDuration,\n timeZoneOffset,\n currentDuration,\n className,\n onChange,\n onUpdate,\n } = props;\n\n const [sliderContainer, setSliderContainer] =\n React.useState<HTMLDivElement | null>(null);\n const [pointerPercent, setPointerPercent] = React.useState(0);\n\n const tooltipProps = React.useCallback(() => {\n return { visible: false };\n }, []);\n\n const [showRailTooltip, setShowRailTooltip] = React.useState(false);\n\n // istanbul ignore next\n const handlePointerEnter = React.useCallback(() => {\n setShowRailTooltip(true);\n }, []);\n\n // istanbul ignore next\n const handlePointerLeave = React.useCallback(() => {\n setShowRailTooltip(false);\n }, []);\n\n const handlePointerMove = React.useCallback(\n (event: React.PointerEvent) => {\n sliderContainer &&\n setPointerPercent(\n getPercentageOfRectangle(\n sliderContainer.getBoundingClientRect(),\n event.clientX\n )\n );\n },\n [sliderContainer]\n );\n\n const thumbHasFocus = useFocusedThumb(sliderContainer ?? undefined);\n\n const tickLabel = React.useMemo(() => {\n const showTip = isPlaying || showRailTooltip || thumbHasFocus;\n const percent =\n isPlaying || thumbHasFocus\n ? currentDuration / totalDuration\n : pointerPercent;\n const markDateInRange = markDateInTimelineRange(\n props.markDate,\n startDate,\n endDate\n );\n const currentDateMarker =\n props.markDate && markDateInRange && startDate && endDate\n ? getDateMarker(props.markDate, startDate, endDate)\n : undefined;\n const tooltipText = generateToolTipText(\n !!showTime,\n percent,\n 0,\n totalDuration,\n startDate,\n endDate,\n timeZoneOffset\n );\n return (\n <RailMarkers\n showToolTip={showTip}\n percent={percent}\n tooltipText={tooltipText}\n markDate={currentDateMarker}\n />\n );\n }, [\n isPlaying,\n showRailTooltip,\n currentDuration,\n totalDuration,\n pointerPercent,\n startDate,\n endDate,\n timeZoneOffset,\n showTime,\n thumbHasFocus,\n props.markDate,\n ]);\n\n return (\n <Slider\n ref={setSliderContainer}\n className={className}\n step={1}\n min={0}\n max={totalDuration}\n minLabel=\"\"\n maxLabel=\"\"\n onUpdate={onUpdate}\n onChange={onChange}\n values={[currentDuration]}\n tooltipProps={tooltipProps}\n thumbProps={() => ({\n children: <CustomThumb />,\n className: \"components-timeline-thumb\",\n })}\n tickLabels={tickLabel}\n onPointerEnter={handlePointerEnter}\n onPointerMove={handlePointerMove}\n onPointerLeave={handlePointerLeave}\n />\n );\n}\n"]}
|
|
@@ -18,10 +18,11 @@
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
.components-timeline-rail-marker-container {
|
|
21
|
-
width: 100%;
|
|
22
21
|
position: absolute;
|
|
22
|
+
width: 100%;
|
|
23
|
+
top: 0;
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
.components-timeline-tooltip {
|
|
25
26
|
@include uicore-z-index(tooltip);
|
|
26
27
|
position: absolute;
|
|
27
28
|
top: -8px;
|
|
@@ -72,7 +72,7 @@ export declare class SolarTimeline extends React.PureComponent<SolarTimelineComp
|
|
|
72
72
|
private _onPresetColorPick;
|
|
73
73
|
private _handleHueOrSaturationChange;
|
|
74
74
|
getLocalTime(ticks: number): Date;
|
|
75
|
-
render(): JSX.Element;
|
|
75
|
+
render(): React.JSX.Element;
|
|
76
76
|
}
|
|
77
77
|
export {};
|
|
78
78
|
//# sourceMappingURL=SolarTimeline.d.ts.map
|
|
@@ -78,7 +78,7 @@ function Timeline(props) {
|
|
|
78
78
|
setPointerPercent((0, Scrubber_1.getPercentageOfRectangle)(sliderContainer.getBoundingClientRect(), event.clientX));
|
|
79
79
|
}, [sliderContainer]);
|
|
80
80
|
const { formatTick, formatTime, onChange, onUpdate, dayStartMs, sunSetOffsetMs, sunRiseOffsetMs, currentTimeOffsetMs, isPlaying, } = props;
|
|
81
|
-
const thumbHasFocus = (0, Scrubber_1.useFocusedThumb)(sliderContainer
|
|
81
|
+
const thumbHasFocus = (0, Scrubber_1.useFocusedThumb)(sliderContainer ?? undefined);
|
|
82
82
|
const tickLabel = React.useMemo(() => {
|
|
83
83
|
const showTip = isPlaying || showRailTooltip || thumbHasFocus;
|
|
84
84
|
const totalDuration = sunSetOffsetMs - sunRiseOffsetMs;
|