@itwin/imodel-components-react 4.14.0 → 4.15.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 +21 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.js +1 -1
- package/lib/cjs/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/ColorPickerButton.d.ts.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.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js +1 -1
- package/lib/cjs/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/HueSlider.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.js +1 -1
- package/lib/cjs/imodel-components-react/color/HueSlider.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.js +1 -1
- package/lib/cjs/imodel-components-react/color/SaturationPicker.js.map +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts +2 -2
- package/lib/cjs/imodel-components-react/color/Swatch.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.js +1 -1
- package/lib/cjs/imodel-components-react/color/Swatch.js.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/inputs/QuantityInput.js.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/Swatch.js.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js +3 -1
- package/lib/cjs/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/Cube.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- 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.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.d.ts +4 -4
- package/lib/cjs/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.d.ts +12 -12
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js +6 -6
- package/lib/cjs/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/cjs/imodel-components-react.d.ts +0 -1
- package/lib/cjs/imodel-components-react.d.ts.map +1 -1
- package/lib/cjs/imodel-components-react.js +0 -1
- package/lib/cjs/imodel-components-react.js.map +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/AlphaSlider.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.js +1 -1
- package/lib/esm/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/ColorPickerButton.d.ts.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.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerDialog.js.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js +1 -1
- package/lib/esm/imodel-components-react/color/ColorPickerPopup.js.map +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/HueSlider.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.js +1 -1
- package/lib/esm/imodel-components-react/color/HueSlider.js.map +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/SaturationPicker.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.js +1 -1
- package/lib/esm/imodel-components-react/color/SaturationPicker.js.map +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.d.ts +2 -2
- package/lib/esm/imodel-components-react/color/Swatch.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.js +1 -1
- package/lib/esm/imodel-components-react/color/Swatch.js.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityInput.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/inputs/QuantityInput.js.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/Swatch.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/Swatch.js.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js +3 -1
- package/lib/esm/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/Cube.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/Cube.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatSample.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnitLabel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/FormatUnits.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/MiscFormatOptions.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/QuantityFormatPanel.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/DecimalSeparator.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/FractionPrecision.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ScientificType.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/SignOption.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSeparatorSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/StationSizeSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSelector.js.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/quantityformat/misc/ThousandsSeparator.js.map +1 -1
- 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.map +1 -1
- package/lib/esm/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/Scrubber.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/timeline/SpeedTimeline.js.map +1 -1
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.d.ts +4 -4
- package/lib/esm/imodel-components-react/timeline/TimelineComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.d.ts.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponent.js.map +1 -1
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.d.ts +12 -12
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js +6 -6
- package/lib/esm/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/lib/esm/imodel-components-react.d.ts +0 -1
- package/lib/esm/imodel-components-react.d.ts.map +1 -1
- package/lib/esm/imodel-components-react.js +0 -1
- package/lib/esm/imodel-components-react.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,30 @@
|
|
|
1
1
|
# Change Log - @itwin/imodel-components-react
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Fri, 28 Jun 2024 09:09:37 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.15.0
|
|
6
|
+
Fri, 28 Jun 2024 09:09:37 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.14.1
|
|
11
|
+
Tue, 11 Jun 2024 15:58:29 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
4
14
|
|
|
5
15
|
## 4.14.0
|
|
6
16
|
Thu, 06 Jun 2024 08:24:21 GMT
|
|
7
17
|
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.13.4
|
|
21
|
+
Tue, 21 May 2024 08:21:34 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 4.13.3
|
|
26
|
+
Fri, 17 May 2024 09:43:31 GMT
|
|
27
|
+
|
|
8
28
|
### Updates
|
|
9
29
|
|
|
10
30
|
- timeline.settings added to UiIModelComponents.json
|
|
@@ -6,7 +6,7 @@ import * as React from "react";
|
|
|
6
6
|
import type { CommonProps } from "@itwin/core-react";
|
|
7
7
|
/** Properties for the [[AlphaSlider]] React component
|
|
8
8
|
* @public
|
|
9
|
-
* @deprecated in 4.11.
|
|
9
|
+
* @deprecated in 4.11.0. Props of deprecated component {@link AlphaSlider}.
|
|
10
10
|
*/
|
|
11
11
|
export interface AlphaSliderProps extends React.HTMLAttributes<HTMLDivElement>, CommonProps {
|
|
12
12
|
/** true if slider is oriented horizontal, else vertical orientation is assumed */
|
|
@@ -18,7 +18,7 @@ export interface AlphaSliderProps extends React.HTMLAttributes<HTMLDivElement>,
|
|
|
18
18
|
}
|
|
19
19
|
/** AlphaSlider component used to set the alpha value.
|
|
20
20
|
* @public
|
|
21
|
-
* @deprecated in 4.11.
|
|
21
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
22
22
|
*/
|
|
23
23
|
export declare class AlphaSlider extends React.PureComponent<AlphaSliderProps> {
|
|
24
24
|
private _container;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlphaSlider.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"AlphaSlider.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAE5B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAE1C,WAAW;IACb,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,qDAAqD;IACrD,aAAa,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtD,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AAEH,qBAAa,WAAY,SAAQ,KAAK,CAAC,aAAa,CAAC,gBAAgB,CAAC;IACpE,OAAO,CAAC,UAAU,CAA+B;IAEjD,gBAAgB;gBAEJ,KAAK,EAAE,gBAAgB;IAInC,OAAO,CAAC,gBAAgB,CAuDtB;IAEF,gBAAgB;IACA,oBAAoB;IAIpC,OAAO,CAAC,SAAS,CAcf;IAEF,OAAO,CAAC,YAAY,CAKlB;IAEF,OAAO,CAAC,UAAU,CA6BhB;IAEF,OAAO,CAAC,UAAU,CAEhB;IAEF,OAAO,CAAC,qBAAqB;IAK7B,gBAAgB;IACA,MAAM,IAAI,KAAK,CAAC,SAAS;CA0C1C"}
|
|
@@ -41,7 +41,7 @@ const ts_key_enum_1 = require("ts-key-enum");
|
|
|
41
41
|
const UiIModelComponents_1 = require("../UiIModelComponents");
|
|
42
42
|
/** AlphaSlider component used to set the alpha value.
|
|
43
43
|
* @public
|
|
44
|
-
* @deprecated in 4.11.
|
|
44
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
45
45
|
*/
|
|
46
46
|
// eslint-disable-next-line deprecation/deprecation
|
|
47
47
|
class AlphaSlider extends React.PureComponent {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlphaSlider.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAA4B;AAC5B,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAElC,8DAA2D;AAiB3D;;;GAGG;AACH,mDAAmD;AACnD,MAAa,WAAY,SAAQ,KAAK,CAAC,aAA+B;IAGpE,gBAAgB;IAChB,mDAAmD;IACnD,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QALP,eAAU,GAA0B,IAAI,CAAC;QAQzC,qBAAgB,GAAG,CACzB,CAAsE,EACtE,YAAqB,EACrB,KAAa,EACb,SAAyB,EACL,EAAE;YACtB,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,GACtD,SAAS,CAAC,qBAAqB,EAAE,CAAC;YAEpC,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;gBACjB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,IAAI,SAAS,KAAK,CAAC,CAAC,OAAO;oBAAE,OAAO,SAAS,CAAC;gBAC9C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACzB,CAAC;YACD,IAAI,SAAS,KAAK,CAAC;gBAAE,OAAO,SAAS,CAAC;YAEtC,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;gBACjB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;YACd,CAAC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BACD,uCAAkB,CAAC,SAAS,CAAC,oBAAoB,CAAC,mBAC/C,CAAC,mBACD,CAAC,mBACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAC/B,SAAS,EAAC,yBAAyB,EACnC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,EACjD,WAAW,EAAE,IAAI,CAAC,YAAY,EAC9B,WAAW,EAAE,IAAI,CAAC,SAAS,EAC3B,YAAY,EAAE,IAAI,CAAC,SAAS,EAC5B,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,IAAI,CAAC,UAAU;gBAE1B,6BACE,KAAK,EAAE,YAAY,EACnB,SAAS,EAAC,0BAA0B,iBACxB,eAAe,GAC3B,CACE,CACF,CACP,CAAC;IACJ,CAAC;CACF;AAjLD,kCAiLC","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 Color\n */\n\nimport \"./AlphaSlider.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties for the [[AlphaSlider]] React component\n * @public\n * @deprecated in 4.11.x. Props of deprecated component {@link AlphaSlider}.\n */\nexport interface AlphaSliderProps\n extends React.HTMLAttributes<HTMLDivElement>,\n CommonProps {\n /** true if slider is oriented horizontal, else vertical orientation is assumed */\n isHorizontal?: boolean;\n /** function to run when user selects color swatch */\n onAlphaChange?: ((alpha: number) => void) | undefined;\n /** Alpha value between 0 (transparent) and 1 (opaque) */\n alpha: number;\n}\n\n/** AlphaSlider component used to set the alpha value.\n * @public\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class AlphaSlider extends React.PureComponent<AlphaSliderProps> {\n private _container: HTMLDivElement | null = null;\n\n /** @internal */\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: AlphaSliderProps) {\n super(props);\n }\n\n private _calculateChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n isHorizontal: boolean,\n alpha: number,\n container: HTMLDivElement\n ): number | undefined => {\n e.preventDefault();\n const { width: containerWidth, height: containerHeight } =\n container.getBoundingClientRect();\n\n let x = 0;\n if (\"pageX\" in e) {\n x = e.pageX;\n } else {\n if (undefined === e.touches) return undefined;\n x = e.touches[0].pageX;\n }\n if (undefined === x) return undefined;\n\n let y = 0;\n if (\"pageY\" in e) {\n y = e.pageY;\n } else {\n if (undefined === e.touches) return;\n y = e.touches[0].pageY;\n }\n if (undefined === y) return undefined;\n\n const left = x - (container.getBoundingClientRect().left + window.scrollX);\n const top = y - (container.getBoundingClientRect().top + window.scrollY);\n\n let t = 0;\n\n if (!isHorizontal) {\n if (top < 0) {\n t = 1;\n } else if (top > containerHeight) {\n t = 0;\n } else {\n t = 1 - top / containerHeight;\n }\n } else {\n // horizontal\n if (left < 0) {\n t = 0;\n } else if (left > containerWidth) {\n t = 1;\n } else {\n t = left / containerWidth;\n }\n }\n\n if (t < 0) t = 0;\n if (t > 1) t = 1;\n return alpha !== t ? t : undefined;\n };\n\n /** @internal */\n public override componentWillUnmount() {\n this._unbindEventListeners();\n }\n\n private _onChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (this._container && this.props.onAlphaChange) {\n const change = this._calculateChange(\n e,\n this.props.isHorizontal ? this.props.isHorizontal : false,\n this.props.alpha,\n this._container\n );\n undefined !== change &&\n typeof this.props.onAlphaChange === \"function\" &&\n this.props.onAlphaChange(change);\n }\n };\n\n private _onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {\n this._onChange(e);\n if (this._container) this._container.focus();\n window.addEventListener(\"mousemove\", this._onChange as any);\n window.addEventListener(\"mouseup\", this._onMouseUp);\n };\n\n private _onKeyDown = (evt: React.KeyboardEvent<HTMLDivElement>) => {\n let newTransparency: number | undefined;\n if (\n evt.key === Key.ArrowLeft.valueOf() ||\n evt.key === Key.ArrowDown.valueOf()\n ) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.1 : 0.05);\n } else if (\n evt.key === Key.ArrowRight.valueOf() ||\n evt.key === Key.ArrowUp.valueOf()\n ) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.1 : 0.05);\n } else if (evt.key === Key.PageDown.valueOf()) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.PageUp.valueOf()) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.Home.valueOf()) {\n newTransparency = 0;\n } else {\n if (evt.key === Key.End.valueOf()) {\n newTransparency = 1;\n }\n }\n\n if (undefined !== newTransparency) {\n if (newTransparency > 1) newTransparency = 1;\n if (newTransparency < 0) newTransparency = 0;\n if (this.props.onAlphaChange) this.props.onAlphaChange(newTransparency);\n }\n };\n\n private _onMouseUp = () => {\n this._unbindEventListeners();\n };\n\n private _unbindEventListeners() {\n window.removeEventListener(\"mousemove\", this._onChange as any);\n window.removeEventListener(\"mouseup\", this._onMouseUp);\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const containerClasses = classnames(\n this.props.isHorizontal\n ? \"components-alpha-container-horizontal\"\n : \"components-alpha-container-vertical\",\n this.props.className\n );\n\n const pointerStyle: React.CSSProperties = this.props.isHorizontal\n ? { left: `${this.props.alpha * 100}%` }\n : { left: `0px`, top: `${-(this.props.alpha * 100) + 100}%` };\n\n return (\n <div\n className={containerClasses}\n style={this.props.style}\n data-testid=\"alpha-container\"\n >\n <div\n data-testid=\"alpha-slider\"\n role=\"slider\"\n aria-label={UiIModelComponents.translate(\"color.transparency\")}\n aria-valuemin={0}\n aria-valuemax={1}\n aria-valuenow={this.props.alpha}\n className=\"components-alpha-slider\"\n ref={(container) => (this._container = container)}\n onMouseDown={this._onMouseDown}\n onTouchMove={this._onChange}\n onTouchStart={this._onChange}\n tabIndex={0}\n onKeyDown={this._onKeyDown}\n >\n <div\n style={pointerStyle}\n className=\"components-alpha-pointer\"\n data-testid=\"alpha-pointer\"\n />\n </div>\n </div>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AlphaSlider.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,8BAA4B;AAC5B,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAElC,8DAA2D;AAkB3D;;;GAGG;AACH,mDAAmD;AACnD,MAAa,WAAY,SAAQ,KAAK,CAAC,aAA+B;IAGpE,gBAAgB;IAChB,mDAAmD;IACnD,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;QALP,eAAU,GAA0B,IAAI,CAAC;QAQzC,qBAAgB,GAAG,CACzB,CAAsE,EACtE,YAAqB,EACrB,KAAa,EACb,SAAyB,EACL,EAAE;YACtB,CAAC,CAAC,cAAc,EAAE,CAAC;YACnB,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,EAAE,GACtD,SAAS,CAAC,qBAAqB,EAAE,CAAC;YAEpC,IAAI,CAAC,GAAG,CAAC,CAAC;YACV,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;gBACjB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC;YACd,CAAC;iBAAM,CAAC;gBACN,IAAI,SAAS,KAAK,CAAC,CAAC,OAAO;oBAAE,OAAO,SAAS,CAAC;gBAC9C,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YACzB,CAAC;YACD,IAAI,SAAS,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,EAAE,CAAC;QAEhE,OAAO,CACL,6BACE,SAAS,EAAE,gBAAgB,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,iBACX,iBAAiB;YAE7B,4CACc,cAAc,EAC1B,IAAI,EAAC,QAAQ,gBACD,uCAAkB,CAAC,SAAS,CAAC,oBAAoB,CAAC,mBAC/C,CAAC,mBACD,CAAC,mBACD,IAAI,CAAC,KAAK,CAAC,KAAK,EAC/B,SAAS,EAAC,yBAAyB,EACnC,GAAG,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,EACjD,WAAW,EAAE,IAAI,CAAC,YAAY,EAC9B,WAAW,EAAE,IAAI,CAAC,SAAS,EAC3B,YAAY,EAAE,IAAI,CAAC,SAAS,EAC5B,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,IAAI,CAAC,UAAU;gBAE1B,6BACE,KAAK,EAAE,YAAY,EACnB,SAAS,EAAC,0BAA0B,iBACxB,eAAe,GAC3B,CACE,CACF,CACP,CAAC;IACJ,CAAC;CACF;AAjLD,kCAiLC","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 Color\n */\n\nimport \"./AlphaSlider.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { UiIModelComponents } from \"../UiIModelComponents\";\n\n/** Properties for the [[AlphaSlider]] React component\n * @public\n * @deprecated in 4.11.0. Props of deprecated component {@link AlphaSlider}.\n */\nexport interface AlphaSliderProps\n extends React.HTMLAttributes<HTMLDivElement>,\n // eslint-disable-next-line deprecation/deprecation\n CommonProps {\n /** true if slider is oriented horizontal, else vertical orientation is assumed */\n isHorizontal?: boolean;\n /** function to run when user selects color swatch */\n onAlphaChange?: ((alpha: number) => void) | undefined;\n /** Alpha value between 0 (transparent) and 1 (opaque) */\n alpha: number;\n}\n\n/** AlphaSlider component used to set the alpha value.\n * @public\n * @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\n// eslint-disable-next-line deprecation/deprecation\nexport class AlphaSlider extends React.PureComponent<AlphaSliderProps> {\n private _container: HTMLDivElement | null = null;\n\n /** @internal */\n // eslint-disable-next-line deprecation/deprecation\n constructor(props: AlphaSliderProps) {\n super(props);\n }\n\n private _calculateChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n isHorizontal: boolean,\n alpha: number,\n container: HTMLDivElement\n ): number | undefined => {\n e.preventDefault();\n const { width: containerWidth, height: containerHeight } =\n container.getBoundingClientRect();\n\n let x = 0;\n if (\"pageX\" in e) {\n x = e.pageX;\n } else {\n if (undefined === e.touches) return undefined;\n x = e.touches[0].pageX;\n }\n if (undefined === x) return undefined;\n\n let y = 0;\n if (\"pageY\" in e) {\n y = e.pageY;\n } else {\n if (undefined === e.touches) return;\n y = e.touches[0].pageY;\n }\n if (undefined === y) return undefined;\n\n const left = x - (container.getBoundingClientRect().left + window.scrollX);\n const top = y - (container.getBoundingClientRect().top + window.scrollY);\n\n let t = 0;\n\n if (!isHorizontal) {\n if (top < 0) {\n t = 1;\n } else if (top > containerHeight) {\n t = 0;\n } else {\n t = 1 - top / containerHeight;\n }\n } else {\n // horizontal\n if (left < 0) {\n t = 0;\n } else if (left > containerWidth) {\n t = 1;\n } else {\n t = left / containerWidth;\n }\n }\n\n if (t < 0) t = 0;\n if (t > 1) t = 1;\n return alpha !== t ? t : undefined;\n };\n\n /** @internal */\n public override componentWillUnmount() {\n this._unbindEventListeners();\n }\n\n private _onChange = (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (this._container && this.props.onAlphaChange) {\n const change = this._calculateChange(\n e,\n this.props.isHorizontal ? this.props.isHorizontal : false,\n this.props.alpha,\n this._container\n );\n undefined !== change &&\n typeof this.props.onAlphaChange === \"function\" &&\n this.props.onAlphaChange(change);\n }\n };\n\n private _onMouseDown = (e: React.MouseEvent<HTMLDivElement>) => {\n this._onChange(e);\n if (this._container) this._container.focus();\n window.addEventListener(\"mousemove\", this._onChange as any);\n window.addEventListener(\"mouseup\", this._onMouseUp);\n };\n\n private _onKeyDown = (evt: React.KeyboardEvent<HTMLDivElement>) => {\n let newTransparency: number | undefined;\n if (\n evt.key === Key.ArrowLeft.valueOf() ||\n evt.key === Key.ArrowDown.valueOf()\n ) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.1 : 0.05);\n } else if (\n evt.key === Key.ArrowRight.valueOf() ||\n evt.key === Key.ArrowUp.valueOf()\n ) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.1 : 0.05);\n } else if (evt.key === Key.PageDown.valueOf()) {\n newTransparency = this.props.alpha - (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.PageUp.valueOf()) {\n newTransparency = this.props.alpha + (evt.ctrlKey ? 0.5 : 0.25);\n } else if (evt.key === Key.Home.valueOf()) {\n newTransparency = 0;\n } else {\n if (evt.key === Key.End.valueOf()) {\n newTransparency = 1;\n }\n }\n\n if (undefined !== newTransparency) {\n if (newTransparency > 1) newTransparency = 1;\n if (newTransparency < 0) newTransparency = 0;\n if (this.props.onAlphaChange) this.props.onAlphaChange(newTransparency);\n }\n };\n\n private _onMouseUp = () => {\n this._unbindEventListeners();\n };\n\n private _unbindEventListeners() {\n window.removeEventListener(\"mousemove\", this._onChange as any);\n window.removeEventListener(\"mouseup\", this._onMouseUp);\n }\n\n /** @internal */\n public override render(): React.ReactNode {\n const containerClasses = classnames(\n this.props.isHorizontal\n ? \"components-alpha-container-horizontal\"\n : \"components-alpha-container-vertical\",\n this.props.className\n );\n\n const pointerStyle: React.CSSProperties = this.props.isHorizontal\n ? { left: `${this.props.alpha * 100}%` }\n : { left: `0px`, top: `${-(this.props.alpha * 100) + 100}%` };\n\n return (\n <div\n className={containerClasses}\n style={this.props.style}\n data-testid=\"alpha-container\"\n >\n <div\n data-testid=\"alpha-slider\"\n role=\"slider\"\n aria-label={UiIModelComponents.translate(\"color.transparency\")}\n aria-valuemin={0}\n aria-valuemax={1}\n aria-valuenow={this.props.alpha}\n className=\"components-alpha-slider\"\n ref={(container) => (this._container = container)}\n onMouseDown={this._onMouseDown}\n onTouchMove={this._onChange}\n onTouchStart={this._onChange}\n tabIndex={0}\n onKeyDown={this._onKeyDown}\n >\n <div\n style={pointerStyle}\n className=\"components-alpha-pointer\"\n data-testid=\"alpha-pointer\"\n />\n </div>\n </div>\n );\n }\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { ColorDef } from "@itwin/core-common";
|
|
|
7
7
|
import type { CommonProps } from "@itwin/core-react";
|
|
8
8
|
/** Properties for the [[ColorPickerButton]] React component
|
|
9
9
|
* @beta
|
|
10
|
-
* @deprecated in 4.11.
|
|
10
|
+
* @deprecated in 4.11.0. Props of deprecated component {@link ColorPickerButton}.
|
|
11
11
|
*/
|
|
12
12
|
export interface ColorPickerProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {
|
|
13
13
|
/** Active color */
|
|
@@ -34,7 +34,7 @@ export interface ColorPickerProps extends React.ButtonHTMLAttributes<HTMLButtonE
|
|
|
34
34
|
/** ColorPickerButton component
|
|
35
35
|
* @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.
|
|
36
36
|
* @beta
|
|
37
|
-
* @deprecated in 4.11.
|
|
37
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
38
38
|
*/
|
|
39
39
|
export declare const ColorPickerButton: (props: ColorPickerProps) => React.ReactNode;
|
|
40
40
|
//# sourceMappingURL=ColorPickerButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerButton.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA+CrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,
|
|
1
|
+
{"version":3,"file":"ColorPickerButton.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAe,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA+CrD;;;GAGG;AACH,MAAM,WAAW,gBACf,SAAQ,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAEnD,WAAW;IACb,mBAAmB;IACnB,YAAY,EAAE,QAAQ,CAAC;IACvB,uBAAuB;IACvB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;IACvB,qDAAqD;IACrD,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACtD,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,sBAAsB;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,uCAAuC;IACvC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,wBAAwB;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gEAAgE;IAChE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAoID;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,CAE9B,KAAK,EAAE,gBAAgB,KACpB,KAAK,CAAC,SAAuC,CAAC"}
|
|
@@ -111,7 +111,7 @@ const ForwardRefColorPickerButton = React.forwardRef(function ForwardRefColorPic
|
|
|
111
111
|
/** ColorPickerButton component
|
|
112
112
|
* @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.
|
|
113
113
|
* @beta
|
|
114
|
-
* @deprecated in 4.11.
|
|
114
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
115
115
|
*/
|
|
116
116
|
exports.ColorPickerButton = ForwardRefColorPickerButton;
|
|
117
117
|
//# sourceMappingURL=ColorPickerButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oCAAkC;AAClC,4DAAoC;AACpC,6CAA+B;AAC/B,oDAA2D;AAC3D,0DAAyD;AAEzD,kDAAyD;AACzD,qCAAuC;AACvC,6DAA0D;AAC1D,oEAAgF;AAEhF,4BAA4B;AAE5B,SAAS,YAAY,CAAC,EACpB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,KAAK,EACL,KAAK,GAON;IACC,MAAM,cAAc,GAAwB;QAC1C,mBAAmB,EAAE,UAAU,UAAU,QAAQ;KAClD,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,wCAAwC;QACpD,KAAK,IAAI,gCAAK,KAAK,CAAM;QAC1B,4CACc,qCAAqC,EACjD,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gB,CAAC,UAAU,EACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,EACtB,8BAA8B;YAE9B,oBAAC,YAAY,IACX,iBAAiB,EAAE,iBAAiB,EACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,UAAU,IAAI,CAAC,EAC3B,KAAK,EAAE,CAAC,CAAC,KAAK,EACd,KAAK,EAAE,aAAa,GACpB,CACI,CACP,CACJ,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;GAIG;AACU,QAAA,iBAAiB,GAGP,2BAA2B,CAAC","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 Color\n */\n\nimport \"./ColorPickerButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup, useRefs } from \"@itwin/core-react\";\nimport { ColorSwatch } from \"./Swatch\";\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\n\n// cSpell:ignore colorpicker\n\nfunction ColorOptions({\n handleColorPicked,\n options,\n numColumns,\n round,\n title,\n}: {\n handleColorPicked: (color: ColorDef) => void;\n options: ColorDef[];\n numColumns: number;\n round: boolean;\n title?: string;\n}) {\n const containerStyle: React.CSSProperties = {\n gridTemplateColumns: `repeat(${numColumns}, 1fr)`,\n };\n return (\n <div className=\"components-colorpicker-popup-container\">\n {title && <h4>{title}</h4>}\n <div\n data-testid=\"components-colorpicker-popup-colors\"\n className=\"components-colorpicker-popup-colors\"\n style={containerStyle}\n >\n {options.map((color, index) => (\n // eslint-disable-next-line deprecation/deprecation\n <ColorSwatch\n className=\"components-colorpicker-swatch\"\n key={index}\n colorDef={color}\n onColorPick={handleColorPicked}\n round={round}\n />\n ))}\n </div>\n </div>\n );\n}\n\n/** Properties for the [[ColorPickerButton]] React component\n * @beta\n * @deprecated in 4.11.x. Props of deprecated component {@link ColorPickerButton}.\n */\nexport interface ColorPickerProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n CommonProps {\n /** Active color */\n initialColor: ColorDef;\n /** Available colors */\n colorDefs?: ColorDef[];\n /** Function to run when user selects color swatch */\n onColorPick?: ((color: ColorDef) => void) | undefined;\n /** Show swatches as squares unless round is set to true */\n round?: boolean;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** Title to show at top of DropDown */\n dropDownTitle?: string;\n /** Number of columns */\n numColumns?: number;\n /** Provides ability to return reference to HTMLButtonElement */\n ref?: React.Ref<HTMLButtonElement>;\n /** If true show up/down caret next to color */\n showCaret?: boolean;\n}\n\n// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted\nconst ForwardRefColorPickerButton = React.forwardRef<\n HTMLButtonElement,\n // eslint-disable-next-line deprecation/deprecation\n ColorPickerProps\n>(function ForwardRefColorPickerButton(\n {\n className,\n colorDefs,\n disabled,\n dropDownTitle,\n initialColor,\n numColumns,\n onColorPick,\n readonly,\n round,\n showCaret,\n style,\n },\n ref\n) {\n const target = React.useRef<HTMLButtonElement>(null);\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\n const [showPopup, setShowPopup] = React.useState(false);\n const [colorDef, setColorDef] = React.useState(initialColor);\n\n // See if new initialColor props have changed since component mounted\n React.useEffect(() => {\n setColorDef(initialColor);\n }, [initialColor]);\n\n const defaultColors = React.useRef([\n ColorDef.create(ColorByName.red),\n ColorDef.create(ColorByName.orange),\n ColorDef.create(ColorByName.yellow),\n ColorDef.create(ColorByName.green),\n ColorDef.create(ColorByName.blue),\n ColorDef.create(ColorByName.indigo),\n ColorDef.create(ColorByName.violet),\n ColorDef.create(ColorByName.black),\n ColorDef.create(ColorByName.white),\n ColorDef.create(ColorByName.cyan),\n ColorDef.create(ColorByName.fuchsia),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.gray),\n ColorDef.create(ColorByName.brown),\n ColorDef.create(ColorByName.purple),\n ColorDef.create(ColorByName.olive),\n ]);\n\n const closePopup = React.useCallback(() => {\n setShowPopup(false);\n }, []);\n\n const togglePopup = React.useCallback(() => {\n setShowPopup(!showPopup);\n }, [showPopup]);\n\n const handleColorPicked = React.useCallback(\n (color: ColorDef) => {\n closePopup();\n\n if (!color.equals(colorDef)) {\n setColorDef(color);\n onColorPick && onColorPick(color);\n }\n },\n [closePopup, colorDef, onColorPick]\n );\n\n const rgbaString = getCSSColorFromDef(colorDef);\n\n const buttonStyle = { ...style } as React.CSSProperties;\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\n\n const buttonClassNames = classnames(\n \"components-colorpicker-button\",\n round && \"round\",\n readonly && \"readonly\",\n className\n );\n\n const colorOptions =\n colorDefs && colorDefs.length ? colorDefs : defaultColors.current;\n return (\n <>\n <button\n data-testid=\"components-colorpicker-button\"\n data-value={rgbaString}\n onClick={togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={disabled}\n ref={refs}\n >\n <div className=\"components-colorpicker-button-container\">\n <div\n className=\"components-colorpicker-button-color-swatch\"\n style={swatchStyle}\n data-testid={showPopup ? \"caret-up\" : \"caret-down\"}\n />\n {showCaret && (\n <Icon\n className=\"components-caret\"\n iconSpec={showPopup ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}\n />\n )}\n </div>\n </button>\n <Popup\n className=\"components-colorpicker-popup\"\n isOpen={showPopup}\n position={RelativePosition.BottomLeft}\n onClose={closePopup}\n target={target.current}\n closeOnNestedPopupOutsideClick\n >\n <ColorOptions\n handleColorPicked={handleColorPicked}\n options={colorOptions}\n numColumns={numColumns ?? 4}\n round={!!round}\n title={dropDownTitle}\n />\n </Popup>\n </>\n );\n});\n\n/** ColorPickerButton component\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\n * @beta\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport const ColorPickerButton: (\n // eslint-disable-next-line deprecation/deprecation\n props: ColorPickerProps\n) => React.ReactNode = ForwardRefColorPickerButton;\n"]}
|
|
1
|
+
{"version":3,"file":"ColorPickerButton.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerButton.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,oCAAkC;AAClC,4DAAoC;AACpC,6CAA+B;AAC/B,oDAA2D;AAC3D,0DAAyD;AAEzD,kDAAyD;AACzD,qCAAuC;AACvC,6DAA0D;AAC1D,oEAAgF;AAEhF,4BAA4B;AAE5B,SAAS,YAAY,CAAC,EACpB,iBAAiB,EACjB,OAAO,EACP,UAAU,EACV,KAAK,EACL,KAAK,GAON;IACC,MAAM,cAAc,GAAwB;QAC1C,mBAAmB,EAAE,UAAU,UAAU,QAAQ;KAClD,CAAC;IACF,OAAO,CACL,6BAAK,SAAS,EAAC,wCAAwC;QACpD,KAAK,IAAI,gCAAK,KAAK,CAAM;QAC1B,4CACc,qCAAqC,EACjD,SAAS,EAAC,qCAAqC,EAC/C,KAAK,EAAE,cAAc,IAEpB,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7B,mDAAmD;QACnD,oBAAC,oBAAW,IACV,SAAS,EAAC,+BAA+B,EACzC,GAAG,EAAE,KAAK,EACV,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,iBAAiB,EAC9B,KAAK,EAAE,KAAK,GACZ,CACH,CAAC,CACE,CACF,CACP,CAAC;AACJ,CAAC;AAgCD,sHAAsH;AACtH,MAAM,2BAA2B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C","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 Color\n */\n\nimport \"./ColorPickerButton.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup, useRefs } from \"@itwin/core-react\";\nimport { ColorSwatch } from \"./Swatch\";\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\nimport { SvgCaretDownSmall, SvgCaretUpSmall } from \"@itwin/itwinui-icons-react\";\n\n// cSpell:ignore colorpicker\n\nfunction ColorOptions({\n handleColorPicked,\n options,\n numColumns,\n round,\n title,\n}: {\n handleColorPicked: (color: ColorDef) => void;\n options: ColorDef[];\n numColumns: number;\n round: boolean;\n title?: string;\n}) {\n const containerStyle: React.CSSProperties = {\n gridTemplateColumns: `repeat(${numColumns}, 1fr)`,\n };\n return (\n <div className=\"components-colorpicker-popup-container\">\n {title && <h4>{title}</h4>}\n <div\n data-testid=\"components-colorpicker-popup-colors\"\n className=\"components-colorpicker-popup-colors\"\n style={containerStyle}\n >\n {options.map((color, index) => (\n // eslint-disable-next-line deprecation/deprecation\n <ColorSwatch\n className=\"components-colorpicker-swatch\"\n key={index}\n colorDef={color}\n onColorPick={handleColorPicked}\n round={round}\n />\n ))}\n </div>\n </div>\n );\n}\n\n/** Properties for the [[ColorPickerButton]] React component\n * @beta\n * @deprecated in 4.11.0. Props of deprecated component {@link ColorPickerButton}.\n */\nexport interface ColorPickerProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n // eslint-disable-next-line deprecation/deprecation\n CommonProps {\n /** Active color */\n initialColor: ColorDef;\n /** Available colors */\n colorDefs?: ColorDef[];\n /** Function to run when user selects color swatch */\n onColorPick?: ((color: ColorDef) => void) | undefined;\n /** Show swatches as squares unless round is set to true */\n round?: boolean;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not */\n readonly?: boolean;\n /** Title to show at top of DropDown */\n dropDownTitle?: string;\n /** Number of columns */\n numColumns?: number;\n /** Provides ability to return reference to HTMLButtonElement */\n ref?: React.Ref<HTMLButtonElement>;\n /** If true show up/down caret next to color */\n showCaret?: boolean;\n}\n\n// Defined using following pattern (const ColorPickerButton at bottom) to ensure useful API documentation is extracted\nconst ForwardRefColorPickerButton = React.forwardRef<\n HTMLButtonElement,\n // eslint-disable-next-line deprecation/deprecation\n ColorPickerProps\n>(function ForwardRefColorPickerButton(\n {\n className,\n colorDefs,\n disabled,\n dropDownTitle,\n initialColor,\n numColumns,\n onColorPick,\n readonly,\n round,\n showCaret,\n style,\n },\n ref\n) {\n const target = React.useRef<HTMLButtonElement>(null);\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\n const [showPopup, setShowPopup] = React.useState(false);\n const [colorDef, setColorDef] = React.useState(initialColor);\n\n // See if new initialColor props have changed since component mounted\n React.useEffect(() => {\n setColorDef(initialColor);\n }, [initialColor]);\n\n const defaultColors = React.useRef([\n ColorDef.create(ColorByName.red),\n ColorDef.create(ColorByName.orange),\n ColorDef.create(ColorByName.yellow),\n ColorDef.create(ColorByName.green),\n ColorDef.create(ColorByName.blue),\n ColorDef.create(ColorByName.indigo),\n ColorDef.create(ColorByName.violet),\n ColorDef.create(ColorByName.black),\n ColorDef.create(ColorByName.white),\n ColorDef.create(ColorByName.cyan),\n ColorDef.create(ColorByName.fuchsia),\n ColorDef.create(ColorByName.tan),\n ColorDef.create(ColorByName.gray),\n ColorDef.create(ColorByName.brown),\n ColorDef.create(ColorByName.purple),\n ColorDef.create(ColorByName.olive),\n ]);\n\n const closePopup = React.useCallback(() => {\n setShowPopup(false);\n }, []);\n\n const togglePopup = React.useCallback(() => {\n setShowPopup(!showPopup);\n }, [showPopup]);\n\n const handleColorPicked = React.useCallback(\n (color: ColorDef) => {\n closePopup();\n\n if (!color.equals(colorDef)) {\n setColorDef(color);\n onColorPick && onColorPick(color);\n }\n },\n [closePopup, colorDef, onColorPick]\n );\n\n const rgbaString = getCSSColorFromDef(colorDef);\n\n const buttonStyle = { ...style } as React.CSSProperties;\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\n\n const buttonClassNames = classnames(\n \"components-colorpicker-button\",\n round && \"round\",\n readonly && \"readonly\",\n className\n );\n\n const colorOptions =\n colorDefs && colorDefs.length ? colorDefs : defaultColors.current;\n return (\n <>\n <button\n data-testid=\"components-colorpicker-button\"\n data-value={rgbaString}\n onClick={togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={disabled}\n ref={refs}\n >\n <div className=\"components-colorpicker-button-container\">\n <div\n className=\"components-colorpicker-button-color-swatch\"\n style={swatchStyle}\n data-testid={showPopup ? \"caret-up\" : \"caret-down\"}\n />\n {showCaret && (\n <Icon\n className=\"components-caret\"\n iconSpec={showPopup ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}\n />\n )}\n </div>\n </button>\n {/* eslint-disable-next-line deprecation/deprecation */}\n <Popup\n className=\"components-colorpicker-popup\"\n isOpen={showPopup}\n position={RelativePosition.BottomLeft}\n onClose={closePopup}\n target={target.current}\n closeOnNestedPopupOutsideClick\n >\n <ColorOptions\n handleColorPicked={handleColorPicked}\n options={colorOptions}\n numColumns={numColumns ?? 4}\n round={!!round}\n title={dropDownTitle}\n />\n </Popup>\n </>\n );\n});\n\n/** ColorPickerButton component\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\n * @beta\n * @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport const ColorPickerButton: (\n // eslint-disable-next-line deprecation/deprecation\n props: ColorPickerProps\n) => React.ReactNode = ForwardRefColorPickerButton;\n"]}
|
|
@@ -5,7 +5,7 @@ import * as React from "react";
|
|
|
5
5
|
import { ColorDef } from "@itwin/core-common";
|
|
6
6
|
/** Properties for the [[ColorPickerDialog]] React component
|
|
7
7
|
* @beta
|
|
8
|
-
* @deprecated in 4.11.
|
|
8
|
+
* @deprecated in 4.11.0. Props of deprecated component {@link ColorPickerDialog}.
|
|
9
9
|
*/
|
|
10
10
|
export interface ColorPickerDialogProps {
|
|
11
11
|
dialogTitle: string;
|
|
@@ -20,7 +20,7 @@ export interface ColorPickerDialogProps {
|
|
|
20
20
|
/**
|
|
21
21
|
* Color Picker Dialog to use as modal dialog.
|
|
22
22
|
* @beta
|
|
23
|
-
* @deprecated in 4.11.
|
|
23
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
24
24
|
*/
|
|
25
25
|
export declare function ColorPickerDialog({ dialogTitle, color, onOkResult, onCancelResult, colorPresets, colorInputType, }: ColorPickerDialogProps): React.JSX.Element;
|
|
26
26
|
//# sourceMappingURL=ColorPickerDialog.d.ts.map
|
|
@@ -39,7 +39,7 @@ const itwinui_react_1 = require("@itwin/itwinui-react");
|
|
|
39
39
|
/**
|
|
40
40
|
* Color Picker Dialog to use as modal dialog.
|
|
41
41
|
* @beta
|
|
42
|
-
* @deprecated in 4.11.
|
|
42
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
43
43
|
*/
|
|
44
44
|
function ColorPickerDialog({ dialogTitle, color, onOkResult, onCancelResult, colorPresets, colorInputType, }) {
|
|
45
45
|
const [activeColor, setActiveColor] = React.useState(color);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerDialog.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerDialog.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,0DAAyD;AACzD,kDAA2C;A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YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,0BAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,6BAAK,GAAG,EAAE,eAAe;QAEvB,oBAAC,mBAAM,IACL,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,EACb,KAAK,EAAE,IAAI,EACX,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,GAAG;YAEb,oBAAC,2BAAW,IACV,aAAa,EAAE,0BAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EACpD,gBAAgB,EAAE,kBAAkB;gBAEpC,oBAAC,4BAAY,OAAG;gBACf,cAAc,IAAI,CACjB,oBAAC,+BAAe,IAAC,kBAAkB,EAAE,cAAc,GAAI,CACxD;gBACA,YAAY,IAAI,oBAAC,4BAAY,IAAC,MAAM,EAAE,YAAY,GAAI,CAC3C,CACP,CACL,CACP,CAAC;AACJ,CAAC;AAlED,8CAkEC","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 Color\n */\n\nimport * as React from \"react\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { Dialog } from \"@itwin/core-react\";\nimport { ColorDef } from \"@itwin/core-common\";\nimport {\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n ColorValue,\n} from \"@itwin/itwinui-react\";\n\n/** Properties for the [[ColorPickerDialog]] React component\n * @beta\n * @deprecated in 4.11.
|
|
1
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AgB,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,EAAE;KACzD,EACD,CAAC,YAAY,EAAE,QAAQ,CAAC,CACzB,CAAC;IAEF,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACtC,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,0BAAU,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;QAClE,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACL,6BAAK,GAAG,EAAE,eAAe;QAEvB,oBAAC,mBAAM,IACL,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,IAAI,EACZ,SAAS,EAAE,KAAK,EAChB,OAAO,EAAE,IAAI,EACb,KAAK,EAAE,IAAI,EACX,aAAa,EAAE,aAAa,EAC5B,OAAO,EAAE,YAAY,EACrB,QAAQ,EAAE,YAAY,EACtB,QAAQ,EAAE,GAAG;YAEb,oBAAC,2BAAW,IACV,aAAa,EAAE,0BAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,CAAC,EACpD,gBAAgB,EAAE,kBAAkB;gBAEpC,oBAAC,4BAAY,OAAG;gBACf,cAAc,IAAI,CACjB,oBAAC,+BAAe,IAAC,kBAAkB,EAAE,cAAc,GAAI,CACxD;gBACA,YAAY,IAAI,oBAAC,4BAAY,IAAC,MAAM,EAAE,YAAY,GAAI,CAC3C,CACP,CACL,CACP,CAAC;AACJ,CAAC;AAlED,8CAkEC","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 Color\n */\n\nimport * as React from \"react\";\nimport { DialogButtonType } from \"@itwin/appui-abstract\";\nimport { Dialog } from \"@itwin/core-react\";\nimport { ColorDef } from \"@itwin/core-common\";\nimport {\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n ColorValue,\n} from \"@itwin/itwinui-react\";\n\n/** Properties for the [[ColorPickerDialog]] React component\n * @beta\n * @deprecated in 4.11.0. Props of deprecated component {@link ColorPickerDialog}.\n */\nexport interface ColorPickerDialogProps {\n dialogTitle: string;\n color: ColorDef;\n onOkResult: (selectedColor: ColorDef) => void;\n onCancelResult: () => void;\n /** displayed in rows of 9 items */\n colorPresets?: ColorDef[];\n /** If set show either HSL, RGB, or HEX input values. If undefined no input value is shown */\n colorInputType?: \"hsl\" | \"rgb\" | \"hex\";\n}\n\n/**\n * Color Picker Dialog to use as modal dialog.\n * @beta\n * @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport function ColorPickerDialog({\n dialogTitle,\n color,\n onOkResult,\n onCancelResult,\n colorPresets,\n colorInputType,\n}: // eslint-disable-next-line deprecation/deprecation\nColorPickerDialogProps) {\n const [activeColor, setActiveColor] = React.useState(color);\n const dialogContainer = React.useRef<HTMLDivElement>(null);\n\n const handleOk = React.useCallback(() => {\n onOkResult(activeColor);\n }, [onOkResult, activeColor]);\n const handleCancel = React.useCallback(() => {\n if (onCancelResult) onCancelResult();\n }, [onCancelResult]);\n\n const handleColorChanged = React.useCallback((newColorValue: ColorValue) => {\n const newColorDef = ColorDef.fromTbgr(newColorValue.toTbgr());\n setActiveColor(newColorDef);\n }, []);\n\n const buttonCluster = React.useMemo(\n () => [\n { type: DialogButtonType.OK, onClick: handleOk },\n { type: DialogButtonType.Cancel, onClick: handleCancel },\n ],\n [handleCancel, handleOk]\n );\n\n const colorOptions = React.useMemo(() => {\n if (colorPresets) {\n return colorPresets.map((def) => ColorValue.fromTbgr(def.tbgr));\n }\n return undefined;\n }, [colorPresets]);\n\n return (\n <div ref={dialogContainer}>\n {/* eslint-disable-next-line deprecation/deprecation */}\n <Dialog\n title={dialogTitle}\n opened={true}\n resizable={false}\n movable={true}\n modal={true}\n buttonCluster={buttonCluster}\n onClose={handleCancel}\n onEscape={handleCancel}\n maxWidth={320}\n >\n <ColorPicker\n selectedColor={ColorValue.fromTbgr(activeColor.tbgr)}\n onChangeComplete={handleColorChanged}\n >\n <ColorBuilder />\n {colorInputType && (\n <ColorInputPanel defaultColorFormat={colorInputType} />\n )}\n {colorOptions && <ColorPalette colors={colorOptions} />}\n </ColorPicker>\n </Dialog>\n </div>\n );\n}\n"]}
|
|
@@ -8,7 +8,7 @@ import type { CommonProps } from "@itwin/core-react";
|
|
|
8
8
|
import "./ColorPickerPopup.scss";
|
|
9
9
|
/** Properties for the [[ColorPickerPopup]] React component
|
|
10
10
|
* @public
|
|
11
|
-
* @deprecated in 4.11.
|
|
11
|
+
* @deprecated in 4.11.0. Props of deprecated component {@link ColorPickerPopup}.
|
|
12
12
|
*/
|
|
13
13
|
export interface ColorPickerPopupProps extends React.ButtonHTMLAttributes<HTMLButtonElement>, CommonProps {
|
|
14
14
|
/** Current color */
|
|
@@ -41,7 +41,7 @@ export interface ColorPickerPopupProps extends React.ButtonHTMLAttributes<HTMLBu
|
|
|
41
41
|
* ColorPickerButton component that allows user to select a color from a set of color swatches or to define a new color.
|
|
42
42
|
* @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.
|
|
43
43
|
* @public
|
|
44
|
-
* @deprecated in 4.11.
|
|
44
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
45
45
|
*/
|
|
46
46
|
export declare const ColorPickerPopup: (props: ColorPickerPopupProps) => React.ReactNode;
|
|
47
47
|
//# sourceMappingURL=ColorPickerPopup.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPopup.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerPopup.tsx"],"names":[],"mappings":"AAI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EAAE,gBAAgB,CAAC;IACjC,gEAAgE;IAChE,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IACnC,gDAAgD;IAChD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,8CAA8C;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,+BAA+B;IAC/B,cAAc,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAC;CACxC;AA8JD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAE,CAE7B,KAAK,EAAE,qBAAqB,KACzB,KAAK,CAAC,SAAsC,CAAC"}
|
|
@@ -133,7 +133,7 @@ const ForwardRefColorPickerPopup = React.forwardRef(function ForwardRefColorPick
|
|
|
133
133
|
* ColorPickerButton component that allows user to select a color from a set of color swatches or to define a new color.
|
|
134
134
|
* @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.
|
|
135
135
|
* @public
|
|
136
|
-
* @deprecated in 4.11.
|
|
136
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
137
137
|
*/
|
|
138
138
|
exports.ColorPickerPopup = ForwardRefColorPickerPopup;
|
|
139
139
|
//# sourceMappingURL=ColorPickerPopup.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorPickerPopup.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerPopup.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,6CAA+B;AAC/B,4DAAoC;AACpC,oDAA2D;AAC3D,0DAAyD;AAEzD,kDAAyD;AACzD,wDAM8B;AAC9B,mCAAiC;AACjC,6DAA0D;AAC1D,oEAIoC;AACpC,sDAAmD;AAoCnD,qHAAqH;AAErH,MAAM,0B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BAAI,IAAC,QAAQ,EAAE,oBAAC,8BAAQ,OAAG,GAAI,CACzB,CACV;gBACD,oBAAC,2BAAW,IACV,aAAa,EAAE,0BAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EACjD,gBAAgB,EAAE,kBAAkB;oBAEpC,oBAAC,4BAAY,OAAG;oBACf,KAAK,CAAC,cAAc,IAAI,CACvB,oBAAC,+BAAe,IAAC,kBAAkB,EAAE,KAAK,CAAC,cAAc,GAAI,CAC9D;oBACA,YAAY,IAAI,oBAAC,4BAAY,IAAC,MAAM,EAAE,YAAY,GAAI,CAC3C,CACV,CACA,CACJ,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,gBAAgB,GAGN,0BAA0B,CAAC","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 Color\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup, useRefs } from \"@itwin/core-react\";\nimport {\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n ColorValue,\n} from \"@itwin/itwinui-react\";\nimport \"./ColorPickerPopup.scss\";\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\nimport {\n SvgCaretDownSmall,\n SvgCaretUpSmall,\n SvgClose,\n} from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties for the [[ColorPickerPopup]] React component\n * @public\n * @deprecated in 4.11.x. Props of deprecated component {@link ColorPickerPopup}.\n */\nexport interface ColorPickerPopupProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n CommonProps {\n /** Current color */\n initialColor: ColorDef;\n /** Preset colors. Pass undefined to show default preset colors. Pass empty array to show no presets.\n * Displayed in rows of 9 items */\n colorDefs?: ColorDef[];\n /** Function to call when the color value is changed */\n onColorChange?: ((newColor: ColorDef) => void) | undefined;\n /** Function to call when the popup is closed */\n onClose?: ((colorValue: ColorDef) => void) | undefined;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not, color displayed on button but button will not trigger pop-up */\n readonly?: boolean;\n /** popup position. If not set RelativePosition.BottomLeft is used */\n popupPosition?: RelativePosition;\n /** Provides ability to return reference to HTMLButtonElement */\n ref?: React.Ref<HTMLButtonElement>;\n /** If true show up/down caret next to color */\n showCaret?: boolean;\n /** If true, don't propagate clicks out of the ColorPicker */\n captureClicks?: boolean;\n /** If true, don't show close button at top */\n hideCloseButton?: boolean;\n /** If set show input values */\n colorInputType?: \"hsl\" | \"rgb\" | \"hex\";\n}\n\n// Defined using following pattern (const ColorPickerPopup at bottom) to ensure useful API documentation is extracted\n\nconst ForwardRefColorPickerPopup = React.forwardRef<\n HTMLButtonElement,\n // eslint-disable-next-line deprecation/deprecation\n ColorPickerPopupProps\n>(function ForwardRefColorPickerPopup(props, ref) {\n const { translate } = useTranslation();\n const target = React.useRef<HTMLButtonElement>(null);\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\n const [showPopup, setShowPopup] = React.useState(false);\n const [colorDef, setColorDef] = React.useState(props.initialColor);\n const initialColorRef = React.useRef(props.initialColor);\n\n React.useEffect(() => {\n if (props.initialColor !== initialColorRef.current) {\n initialColorRef.current = props.initialColor;\n setColorDef(props.initialColor);\n }\n }, [props.initialColor]);\n\n const defaultColors = React.useRef([\n ColorValue.fromTbgr(ColorByName.red),\n ColorValue.fromTbgr(ColorByName.orange),\n ColorValue.fromTbgr(ColorByName.yellow),\n ColorValue.fromTbgr(ColorByName.green),\n ColorValue.fromTbgr(ColorByName.blue),\n ColorValue.fromTbgr(ColorByName.mediumBlue),\n ColorValue.fromTbgr(ColorByName.indigo),\n ColorValue.fromTbgr(ColorByName.violet),\n ColorValue.fromTbgr(ColorByName.black),\n ColorValue.fromTbgr(ColorByName.white),\n ColorValue.fromTbgr(ColorByName.cyan),\n ColorValue.fromTbgr(ColorByName.fuchsia),\n ColorValue.fromTbgr(ColorByName.tan),\n ColorValue.fromTbgr(ColorByName.gray),\n ColorValue.fromTbgr(ColorByName.brown),\n ColorValue.fromTbgr(ColorByName.purple),\n ColorValue.fromTbgr(ColorByName.olive),\n ColorValue.fromTbgr(ColorByName.darkGreen),\n ]);\n\n const closePopup = React.useCallback(() => {\n props.onClose && props.onClose(colorDef);\n setShowPopup(false);\n }, [colorDef, props]);\n\n const togglePopup = React.useCallback(() => {\n setShowPopup(!showPopup);\n }, [showPopup]);\n\n const handleColorChanged = React.useCallback(\n (newColorValue: ColorValue) => {\n const newColor = ColorDef.fromTbgr(newColorValue.toTbgr());\n if (!newColor.equals(colorDef)) {\n setColorDef(newColor);\n\n props.onColorChange && props.onColorChange(newColor);\n }\n },\n [colorDef, props]\n );\n\n const rgbaString = getCSSColorFromDef(colorDef);\n\n const buttonStyle = { ...props.style } as React.CSSProperties;\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\n const buttonClassNames = classnames(\n \"components-colorpicker-popup-button\",\n props.readonly && \"readonly\",\n props.className\n );\n\n const clickHandler = (event: React.MouseEvent) => {\n if (props.captureClicks) event.stopPropagation();\n };\n\n const colorOptions = React.useMemo(() => {\n if (props.colorDefs && props.colorDefs.length) {\n return props.colorDefs.map((def) => ColorValue.fromTbgr(def.tbgr));\n }\n if (props.colorDefs && 0 === props.colorDefs.length) return undefined;\n return defaultColors.current;\n }, [props.colorDefs]);\n const popupPosition =\n undefined !== props.popupPosition\n ? props.popupPosition\n : RelativePosition.BottomLeft;\n\n const closeLabel = translate(\"color.close\");\n const togglePopupLabel = translate(\"color.toggleColorPopup\");\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n <div onClick={clickHandler}>\n <button\n data-testid=\"components-colorpicker-popup-button\"\n onClick={togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={props.disabled}\n ref={refs}\n title={togglePopupLabel}\n >\n <div className=\"components-colorpicker-button-container\">\n <div\n className=\"components-colorpicker-button-color-swatch\"\n style={swatchStyle}\n data-testid={showPopup ? \"caret-up\" : \"caret-down\"}\n />\n {props.showCaret && (\n <Icon\n className=\"components-caret\"\n iconSpec={showPopup ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}\n />\n )}\n </div>\n </button>\n <Popup\n className=\"components-colorpicker-popup\"\n isOpen={showPopup}\n position={popupPosition}\n onClose={closePopup}\n target={target.current}\n closeOnNestedPopupOutsideClick\n >\n <div className=\"components-colorpicker-popup-panel-padding\">\n {!props.hideCloseButton && (\n <button\n title={closeLabel}\n className={\n \"core-focus-trap-ignore-initial core-dialog-close icon\"\n }\n data-testid=\"core-dialog-close\"\n onClick={togglePopup}\n >\n <Icon iconSpec={<SvgClose />} />\n </button>\n )}\n <ColorPicker\n selectedColor={ColorValue.fromTbgr(colorDef.tbgr)}\n onChangeComplete={handleColorChanged}\n >\n <ColorBuilder />\n {props.colorInputType && (\n <ColorInputPanel defaultColorFormat={props.colorInputType} />\n )}\n {colorOptions && <ColorPalette colors={colorOptions} />}\n </ColorPicker>\n </div>\n </Popup>\n </div>\n );\n});\n\n/**\n * ColorPickerButton component that allows user to select a color from a set of color swatches or to define a new color.\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\n * @public\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport const ColorPickerPopup: (\n // eslint-disable-next-line deprecation/deprecation\n props: ColorPickerPopupProps\n) => React.ReactNode = ForwardRefColorPickerPopup;\n"]}
|
|
1
|
+
{"version":3,"file":"ColorPickerPopup.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/ColorPickerP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,aAAa,EACvB,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,CAAC,OAAO,EACtB,8BAA8B;YAE9B,6BAAK,SAAS,EAAC,4CAA4C;gBACxD,CAAC,KAAK,CAAC,eAAe,IAAI,CACzB,gCACE,KAAK,EAAE,UAAU,EACjB,SAAS,EACP,uDAAuD,iBAE7C,mBAAmB,EAC/B,OAAO,EAAE,WAAW;oBAEpB,oBAAC,iBAAI,IAAC,QAAQ,EAAE,oBAAC,8BAAQ,OAAG,GAAI,CACzB,CACV;gBACD,oBAAC,2BAAW,IACV,aAAa,EAAE,0BAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EACjD,gBAAgB,EAAE,kBAAkB;oBAEpC,oBAAC,4BAAY,OAAG;oBACf,KAAK,CAAC,cAAc,IAAI,CACvB,oBAAC,+BAAe,IAAC,kBAAkB,EAAE,KAAK,CAAC,cAAc,GAAI,CAC9D;oBACA,YAAY,IAAI,oBAAC,4BAAY,IAAC,MAAM,EAAE,YAAY,GAAI,CAC3C,CACV,CACA,CACJ,CACP,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH;;;;;GAKG;AACU,QAAA,gBAAgB,GAGN,0BAA0B,CAAC","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 Color\n */\n\nimport * as React from \"react\";\nimport classnames from \"classnames\";\nimport { ColorByName, ColorDef } from \"@itwin/core-common\";\nimport { RelativePosition } from \"@itwin/appui-abstract\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { Icon, Popup, useRefs } from \"@itwin/core-react\";\nimport {\n ColorBuilder,\n ColorInputPanel,\n ColorPalette,\n ColorPicker,\n ColorValue,\n} from \"@itwin/itwinui-react\";\nimport \"./ColorPickerPopup.scss\";\nimport { getCSSColorFromDef } from \"./getCSSColorFromDef\";\nimport {\n SvgCaretDownSmall,\n SvgCaretUpSmall,\n SvgClose,\n} from \"@itwin/itwinui-icons-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n/** Properties for the [[ColorPickerPopup]] React component\n * @public\n * @deprecated in 4.11.0. Props of deprecated component {@link ColorPickerPopup}.\n */\nexport interface ColorPickerPopupProps\n extends React.ButtonHTMLAttributes<HTMLButtonElement>,\n // eslint-disable-next-line deprecation/deprecation\n CommonProps {\n /** Current color */\n initialColor: ColorDef;\n /** Preset colors. Pass undefined to show default preset colors. Pass empty array to show no presets.\n * Displayed in rows of 9 items */\n colorDefs?: ColorDef[];\n /** Function to call when the color value is changed */\n onColorChange?: ((newColor: ColorDef) => void) | undefined;\n /** Function to call when the popup is closed */\n onClose?: ((colorValue: ColorDef) => void) | undefined;\n /** Disabled or not */\n disabled?: boolean;\n /** Readonly or not, color displayed on button but button will not trigger pop-up */\n readonly?: boolean;\n /** popup position. If not set RelativePosition.BottomLeft is used */\n popupPosition?: RelativePosition;\n /** Provides ability to return reference to HTMLButtonElement */\n ref?: React.Ref<HTMLButtonElement>;\n /** If true show up/down caret next to color */\n showCaret?: boolean;\n /** If true, don't propagate clicks out of the ColorPicker */\n captureClicks?: boolean;\n /** If true, don't show close button at top */\n hideCloseButton?: boolean;\n /** If set show input values */\n colorInputType?: \"hsl\" | \"rgb\" | \"hex\";\n}\n\n// Defined using following pattern (const ColorPickerPopup at bottom) to ensure useful API documentation is extracted\n\nconst ForwardRefColorPickerPopup = React.forwardRef<\n HTMLButtonElement,\n // eslint-disable-next-line deprecation/deprecation\n ColorPickerPopupProps\n>(function ForwardRefColorPickerPopup(props, ref) {\n const { translate } = useTranslation();\n const target = React.useRef<HTMLButtonElement>(null);\n const refs = useRefs(target, ref); // combine ref needed for target with the forwardRef needed by the Parent when parent is a Type Editor.\n const [showPopup, setShowPopup] = React.useState(false);\n const [colorDef, setColorDef] = React.useState(props.initialColor);\n const initialColorRef = React.useRef(props.initialColor);\n\n React.useEffect(() => {\n if (props.initialColor !== initialColorRef.current) {\n initialColorRef.current = props.initialColor;\n setColorDef(props.initialColor);\n }\n }, [props.initialColor]);\n\n const defaultColors = React.useRef([\n ColorValue.fromTbgr(ColorByName.red),\n ColorValue.fromTbgr(ColorByName.orange),\n ColorValue.fromTbgr(ColorByName.yellow),\n ColorValue.fromTbgr(ColorByName.green),\n ColorValue.fromTbgr(ColorByName.blue),\n ColorValue.fromTbgr(ColorByName.mediumBlue),\n ColorValue.fromTbgr(ColorByName.indigo),\n ColorValue.fromTbgr(ColorByName.violet),\n ColorValue.fromTbgr(ColorByName.black),\n ColorValue.fromTbgr(ColorByName.white),\n ColorValue.fromTbgr(ColorByName.cyan),\n ColorValue.fromTbgr(ColorByName.fuchsia),\n ColorValue.fromTbgr(ColorByName.tan),\n ColorValue.fromTbgr(ColorByName.gray),\n ColorValue.fromTbgr(ColorByName.brown),\n ColorValue.fromTbgr(ColorByName.purple),\n ColorValue.fromTbgr(ColorByName.olive),\n ColorValue.fromTbgr(ColorByName.darkGreen),\n ]);\n\n const closePopup = React.useCallback(() => {\n props.onClose && props.onClose(colorDef);\n setShowPopup(false);\n }, [colorDef, props]);\n\n const togglePopup = React.useCallback(() => {\n setShowPopup(!showPopup);\n }, [showPopup]);\n\n const handleColorChanged = React.useCallback(\n (newColorValue: ColorValue) => {\n const newColor = ColorDef.fromTbgr(newColorValue.toTbgr());\n if (!newColor.equals(colorDef)) {\n setColorDef(newColor);\n\n props.onColorChange && props.onColorChange(newColor);\n }\n },\n [colorDef, props]\n );\n\n const rgbaString = getCSSColorFromDef(colorDef);\n\n const buttonStyle = { ...props.style } as React.CSSProperties;\n const swatchStyle = { backgroundColor: rgbaString } as React.CSSProperties;\n const buttonClassNames = classnames(\n \"components-colorpicker-popup-button\",\n props.readonly && \"readonly\",\n props.className\n );\n\n const clickHandler = (event: React.MouseEvent) => {\n if (props.captureClicks) event.stopPropagation();\n };\n\n const colorOptions = React.useMemo(() => {\n if (props.colorDefs && props.colorDefs.length) {\n return props.colorDefs.map((def) => ColorValue.fromTbgr(def.tbgr));\n }\n if (props.colorDefs && 0 === props.colorDefs.length) return undefined;\n return defaultColors.current;\n }, [props.colorDefs]);\n const popupPosition =\n undefined !== props.popupPosition\n ? props.popupPosition\n : RelativePosition.BottomLeft;\n\n const closeLabel = translate(\"color.close\");\n const togglePopupLabel = translate(\"color.toggleColorPopup\");\n\n return (\n /* eslint-disable-next-line jsx-a11y/no-static-element-interactions, jsx-a11y/click-events-have-key-events */\n <div onClick={clickHandler}>\n <button\n data-testid=\"components-colorpicker-popup-button\"\n onClick={togglePopup}\n className={buttonClassNames}\n style={buttonStyle}\n disabled={props.disabled}\n ref={refs}\n title={togglePopupLabel}\n >\n <div className=\"components-colorpicker-button-container\">\n <div\n className=\"components-colorpicker-button-color-swatch\"\n style={swatchStyle}\n data-testid={showPopup ? \"caret-up\" : \"caret-down\"}\n />\n {props.showCaret && (\n <Icon\n className=\"components-caret\"\n iconSpec={showPopup ? <SvgCaretUpSmall /> : <SvgCaretDownSmall />}\n />\n )}\n </div>\n </button>\n {/* eslint-disable-next-line deprecation/deprecation */}\n <Popup\n className=\"components-colorpicker-popup\"\n isOpen={showPopup}\n position={popupPosition}\n onClose={closePopup}\n target={target.current}\n closeOnNestedPopupOutsideClick\n >\n <div className=\"components-colorpicker-popup-panel-padding\">\n {!props.hideCloseButton && (\n <button\n title={closeLabel}\n className={\n \"core-focus-trap-ignore-initial core-dialog-close icon\"\n }\n data-testid=\"core-dialog-close\"\n onClick={togglePopup}\n >\n <Icon iconSpec={<SvgClose />} />\n </button>\n )}\n <ColorPicker\n selectedColor={ColorValue.fromTbgr(colorDef.tbgr)}\n onChangeComplete={handleColorChanged}\n >\n <ColorBuilder />\n {props.colorInputType && (\n <ColorInputPanel defaultColorFormat={props.colorInputType} />\n )}\n {colorOptions && <ColorPalette colors={colorOptions} />}\n </ColorPicker>\n </div>\n </Popup>\n </div>\n );\n});\n\n/**\n * ColorPickerButton component that allows user to select a color from a set of color swatches or to define a new color.\n * @note Using forwardRef so the ColorEditor (Type Editor) can access the ref of the button element inside this component.\n * @public\n * @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport const ColorPickerPopup: (\n // eslint-disable-next-line deprecation/deprecation\n props: ColorPickerPopupProps\n) => React.ReactNode = ForwardRefColorPickerPopup;\n"]}
|
|
@@ -7,7 +7,7 @@ import type { HSVColor } from "@itwin/core-common";
|
|
|
7
7
|
import type { CommonProps } from "@itwin/core-react";
|
|
8
8
|
/** Properties for the [[HueSlider]] React component
|
|
9
9
|
* @beta
|
|
10
|
-
* @deprecated in 4.11.
|
|
10
|
+
* @deprecated in 4.11.0. Props of deprecated component {@link HueSlider}.
|
|
11
11
|
*/
|
|
12
12
|
export interface HueSliderProps extends React.HTMLAttributes<HTMLDivElement>, CommonProps {
|
|
13
13
|
/** true if slider is oriented horizontal, else vertical orientation is assumed */
|
|
@@ -19,7 +19,7 @@ export interface HueSliderProps extends React.HTMLAttributes<HTMLDivElement>, Co
|
|
|
19
19
|
}
|
|
20
20
|
/** HueSlider component used to set the hue value.
|
|
21
21
|
* @beta
|
|
22
|
-
* @deprecated in 4.11.
|
|
22
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
23
23
|
*/
|
|
24
24
|
export declare function HueSlider({ isHorizontal, onHueChange, hsv, className, style, }: HueSliderProps): React.JSX.Element;
|
|
25
25
|
//# sourceMappingURL=HueSlider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HueSlider.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/HueSlider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA2DrD;;;GAGG;AACH,MAAM,WAAW,cACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"HueSlider.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/HueSlider.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,kBAAkB,CAAC;AAE1B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA2DrD;;;GAGG;AACH,MAAM,WAAW,cACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAE1C,WAAW;IACb,kFAAkF;IAClF,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IACpD,sBAAsB;IACtB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,EACxB,YAAY,EACZ,WAAW,EACX,GAAG,EACH,SAAS,EACT,KAAK,GACN,EACD,cAAc,qBAwKb"}
|
|
@@ -91,7 +91,7 @@ function calculateChange(currentHue, e, isHorizontal, container) {
|
|
|
91
91
|
}
|
|
92
92
|
/** HueSlider component used to set the hue value.
|
|
93
93
|
* @beta
|
|
94
|
-
* @deprecated in 4.11.
|
|
94
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
95
95
|
*/
|
|
96
96
|
function HueSlider({ isHorizontal, onHueChange, hsv, className, style, }) {
|
|
97
97
|
const { translate } = (0, useTranslation_1.useTranslation)();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Hue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AY,EACnB,SAAS,EAAC,wBAAwB,iBACtB,aAAa,GACzB,CACE,CACF,CACP,CAAC;AACJ,CAAC;AA/KD,8BA+KC","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 Color\n */\n\nimport \"./HueSlider.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { HSVColor } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n// hue is a value from 0 to 360\nfunction calculateHue(currentPos: number, high: number, isVertical: boolean) {\n if (currentPos <= 0) {\n return isVertical ? 359 : 0;\n } else if (currentPos >= high) {\n return isVertical ? 0 : 359;\n } else {\n let percent = (currentPos * 100) / high;\n if (isVertical) percent = 100 - percent;\n return Math.round((359 * percent) / 100);\n }\n}\n\nfunction calculateChange(\n currentHue: number,\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n isHorizontal: boolean,\n container: HTMLDivElement\n) {\n const {\n width: containerWidth,\n height: containerHeight,\n top: containerTop,\n left: containerLeft,\n } = container.getBoundingClientRect();\n\n let x: number | undefined;\n if (\"pageX\" in e) {\n x = e.pageX;\n } else {\n if (undefined === e.touches || 0 === e.touches.length) return currentHue;\n x = e.touches[0].pageX;\n }\n if (undefined === x) return currentHue;\n\n let y: number | undefined;\n if (\"pageY\" in e) {\n y = e.pageY;\n } else {\n if (undefined === e.touches || 0 === e.touches.length) return currentHue;\n y = e.touches[0].pageY;\n }\n if (undefined === y) return currentHue;\n\n const pointerX = x - (containerLeft + window.scrollX);\n const pointerY = y - (containerTop + window.scrollY);\n\n if (!isHorizontal) {\n // vertical\n return calculateHue(pointerY, containerHeight, true);\n } else {\n // horizontal\n return calculateHue(pointerX, containerWidth, false);\n }\n}\n\n/** Properties for the [[HueSlider]] React component\n * @beta\n * @deprecated in 4.11.x. Props of deprecated component {@link HueSlider}.\n */\nexport interface HueSliderProps\n extends React.HTMLAttributes<HTMLDivElement>,\n CommonProps {\n /** true if slider is oriented horizontal, else vertical orientation is assumed */\n isHorizontal?: boolean;\n /** function to run when user hue is changed */\n onHueChange?: ((hue: HSVColor) => void) | undefined;\n /** HSV Color Value */\n hsv: HSVColor;\n}\n\n/** HueSlider component used to set the hue value.\n * @beta\n * @deprecated in 4.11.x. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport function HueSlider({\n isHorizontal,\n onHueChange,\n hsv,\n className,\n style,\n}: // eslint-disable-next-line deprecation/deprecation\nHueSliderProps) {\n const { translate } = useTranslation();\n const container = React.useRef<HTMLDivElement>(null);\n const isDragging = React.useRef(false);\n\n const onChange = React.useCallback(\n (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (container.current) {\n const newHue = calculateChange(\n hsv.h,\n e,\n !!isHorizontal,\n container.current\n );\n const newColor = hsv.clone(newHue);\n if (onHueChange) onHueChange(newColor);\n }\n },\n [isHorizontal, hsv, onHueChange]\n );\n\n const onDragging = React.useCallback(\n (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (isDragging.current) {\n onChange(e);\n }\n },\n [onChange]\n );\n\n const onMouseUp = React.useCallback(() => {\n if (isDragging.current) {\n isDragging.current = false;\n }\n }, []);\n\n const onTouchEnd = React.useCallback(\n (event: React.TouchEvent<HTMLDivElement>) => {\n event.preventDefault();\n\n if (isDragging.current) {\n onChange(event);\n isDragging.current = false;\n }\n },\n [onChange]\n );\n\n const onMouseDown = React.useCallback(\n (e: React.MouseEvent<HTMLDivElement>) => {\n e.preventDefault();\n\n if (e.target !== e.currentTarget) {\n if (!isDragging.current) {\n document.addEventListener(\"mouseup\", onMouseUp, {\n capture: true,\n once: true,\n });\n isDragging.current = true;\n }\n }\n\n onChange(e);\n\n if (container.current) container.current.focus();\n },\n [onChange, onMouseUp]\n );\n\n const onTouchStart = React.useCallback(\n (e: React.TouchEvent<HTMLDivElement>) => {\n if (e.target !== e.currentTarget) isDragging.current = true;\n\n onChange(e);\n\n if (container.current) container.current.focus();\n },\n [onChange]\n );\n\n const onKeyDown = React.useCallback(\n (evt: React.KeyboardEvent<HTMLDivElement>) => {\n let newHue: number | undefined;\n const hueValue = hsv.h;\n if (\n evt.key === Key.ArrowLeft.valueOf() ||\n evt.key === Key.ArrowDown.valueOf()\n ) {\n newHue = hueValue - (evt.ctrlKey ? 10 : 1);\n } else if (\n evt.key === Key.ArrowRight.valueOf() ||\n evt.key === Key.ArrowUp.valueOf()\n ) {\n newHue = hueValue + (evt.ctrlKey ? 10 : 1);\n } else if (evt.key === Key.PageDown.valueOf()) {\n newHue = hueValue - (evt.ctrlKey ? 180 : 60);\n } else if (evt.key === Key.PageUp.valueOf()) {\n newHue = hueValue + (evt.ctrlKey ? 180 : 60);\n } else if (evt.key === Key.Home.valueOf()) {\n newHue = 0;\n } else {\n if (evt.key === Key.End.valueOf()) {\n newHue = 359;\n }\n }\n\n if (undefined !== newHue) {\n if (newHue > 359) newHue = 359; // 360 is same as zero\n if (newHue < 0) newHue = 0;\n\n const newColor = hsv.clone(newHue);\n if (onHueChange) onHueChange(newColor);\n evt.preventDefault();\n }\n },\n [hsv, onHueChange]\n );\n\n const containerClasses = classnames(\n isHorizontal\n ? \"components-hue-container-horizontal\"\n : \"components-hue-container-vertical\",\n className\n );\n\n const pointerStyle: React.CSSProperties = isHorizontal\n ? {\n left: `${(hsv.h * 100) / 360}%`,\n backgroundColor: `hsl(${hsv.h} ,100%, 50%)`,\n }\n : {\n left: `0px`,\n top: `${-((hsv.h * 100) / 360) + 100}%`,\n backgroundColor: `hsl(${hsv.h} ,100%, 50%)`,\n };\n\n return (\n <div className={containerClasses} style={style} data-testid=\"hue-container\">\n <div\n data-testid=\"hue-slider\"\n role=\"slider\"\n aria-label={translate(\"color.hue\")}\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={hsv.h}\n className=\"components-hue-slider\"\n ref={container}\n onMouseDown={onMouseDown}\n onMouseMove={onDragging}\n onTouchMove={onDragging}\n onMouseUp={onMouseUp}\n onTouchStart={onTouchStart}\n onTouchEnd={onTouchEnd}\n tabIndex={0}\n onKeyDown={onKeyDown}\n >\n <div\n style={pointerStyle}\n className=\"components-hue-pointer\"\n data-testid=\"hue-pointer\"\n />\n </div>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"HueSlider.js","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/HueSlider.tsx"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,4BAA0B;AAC1B,4DAAoC;AACpC,6CAA+B;AAC/B,6CAAkC;AAGlC,sDAAmD;AAEnD,+BAA+B;AAC/B,SAAS,YAAY,CAAC,UAAkB,EAAE,IAAY,EAAE,UAAmB;IACzE,IAAI,UAAU,IAAI,CAAC,EAAE,CAAC;QACpB,OAAO,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC9B,CAAC;SAAM,IAAI,UAAU,IAAI,IAAI,EAAE,CAAC;QAC9B,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC9B,CAAC;SAAM,CAAC;QACN,IAAI,OAAO,GAAG,CAAC,UAAU,GAAG,GAAG,CAAC,GAAG,IAAI,CAAC;QACxC,IAAI,UAAU;YAAE,OAAO,GAAG,GAAG,GAAG,OAAO,CAAC;QACxC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,GAAG,CAAC,CAAC;IAC3C,CAAC;AACH,CAAC;AAED,SAAS,eAAe,CACtB,UAAkB,EAClB,CAAsE,EACtE,YAAqB,EACrB,SAAyB;IA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,EAAC,QAAQ,gBACD,SAAS,CAAC,WAAW,CAAC,mBACnB,CAAC,mBACD,GAAG,mBACH,GAAG,CAAC,CAAC,EACpB,SAAS,EAAC,uBAAuB,EACjC,GAAG,EAAE,SAAS,EACd,WAAW,EAAE,WAAW,EACxB,WAAW,EAAE,UAAU,EACvB,WAAW,EAAE,UAAU,EACvB,SAAS,EAAE,SAAS,EACpB,YAAY,EAAE,YAAY,EAC1B,UAAU,EAAE,UAAU,EACtB,QAAQ,EAAE,CAAC,EACX,SAAS,EAAE,SAAS;YAEpB,6BACE,KAAK,EAAE,YAAY,EACnB,SAAS,EAAC,wBAAwB,iBACtB,aAAa,GACzB,CACE,CACF,CACP,CAAC;AACJ,CAAC;AA/KD,8BA+KC","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 Color\n */\n\nimport \"./HueSlider.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { Key } from \"ts-key-enum\";\nimport type { HSVColor } from \"@itwin/core-common\";\nimport type { CommonProps } from \"@itwin/core-react\";\nimport { useTranslation } from \"../useTranslation\";\n\n// hue is a value from 0 to 360\nfunction calculateHue(currentPos: number, high: number, isVertical: boolean) {\n if (currentPos <= 0) {\n return isVertical ? 359 : 0;\n } else if (currentPos >= high) {\n return isVertical ? 0 : 359;\n } else {\n let percent = (currentPos * 100) / high;\n if (isVertical) percent = 100 - percent;\n return Math.round((359 * percent) / 100);\n }\n}\n\nfunction calculateChange(\n currentHue: number,\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>,\n isHorizontal: boolean,\n container: HTMLDivElement\n) {\n const {\n width: containerWidth,\n height: containerHeight,\n top: containerTop,\n left: containerLeft,\n } = container.getBoundingClientRect();\n\n let x: number | undefined;\n if (\"pageX\" in e) {\n x = e.pageX;\n } else {\n if (undefined === e.touches || 0 === e.touches.length) return currentHue;\n x = e.touches[0].pageX;\n }\n if (undefined === x) return currentHue;\n\n let y: number | undefined;\n if (\"pageY\" in e) {\n y = e.pageY;\n } else {\n if (undefined === e.touches || 0 === e.touches.length) return currentHue;\n y = e.touches[0].pageY;\n }\n if (undefined === y) return currentHue;\n\n const pointerX = x - (containerLeft + window.scrollX);\n const pointerY = y - (containerTop + window.scrollY);\n\n if (!isHorizontal) {\n // vertical\n return calculateHue(pointerY, containerHeight, true);\n } else {\n // horizontal\n return calculateHue(pointerX, containerWidth, false);\n }\n}\n\n/** Properties for the [[HueSlider]] React component\n * @beta\n * @deprecated in 4.11.0. Props of deprecated component {@link HueSlider}.\n */\nexport interface HueSliderProps\n extends React.HTMLAttributes<HTMLDivElement>,\n // eslint-disable-next-line deprecation/deprecation\n CommonProps {\n /** true if slider is oriented horizontal, else vertical orientation is assumed */\n isHorizontal?: boolean;\n /** function to run when user hue is changed */\n onHueChange?: ((hue: HSVColor) => void) | undefined;\n /** HSV Color Value */\n hsv: HSVColor;\n}\n\n/** HueSlider component used to set the hue value.\n * @beta\n * @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.\n */\nexport function HueSlider({\n isHorizontal,\n onHueChange,\n hsv,\n className,\n style,\n}: // eslint-disable-next-line deprecation/deprecation\nHueSliderProps) {\n const { translate } = useTranslation();\n const container = React.useRef<HTMLDivElement>(null);\n const isDragging = React.useRef(false);\n\n const onChange = React.useCallback(\n (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (container.current) {\n const newHue = calculateChange(\n hsv.h,\n e,\n !!isHorizontal,\n container.current\n );\n const newColor = hsv.clone(newHue);\n if (onHueChange) onHueChange(newColor);\n }\n },\n [isHorizontal, hsv, onHueChange]\n );\n\n const onDragging = React.useCallback(\n (\n e: React.MouseEvent<HTMLDivElement> | React.TouchEvent<HTMLDivElement>\n ) => {\n if (isDragging.current) {\n onChange(e);\n }\n },\n [onChange]\n );\n\n const onMouseUp = React.useCallback(() => {\n if (isDragging.current) {\n isDragging.current = false;\n }\n }, []);\n\n const onTouchEnd = React.useCallback(\n (event: React.TouchEvent<HTMLDivElement>) => {\n event.preventDefault();\n\n if (isDragging.current) {\n onChange(event);\n isDragging.current = false;\n }\n },\n [onChange]\n );\n\n const onMouseDown = React.useCallback(\n (e: React.MouseEvent<HTMLDivElement>) => {\n e.preventDefault();\n\n if (e.target !== e.currentTarget) {\n if (!isDragging.current) {\n document.addEventListener(\"mouseup\", onMouseUp, {\n capture: true,\n once: true,\n });\n isDragging.current = true;\n }\n }\n\n onChange(e);\n\n if (container.current) container.current.focus();\n },\n [onChange, onMouseUp]\n );\n\n const onTouchStart = React.useCallback(\n (e: React.TouchEvent<HTMLDivElement>) => {\n if (e.target !== e.currentTarget) isDragging.current = true;\n\n onChange(e);\n\n if (container.current) container.current.focus();\n },\n [onChange]\n );\n\n const onKeyDown = React.useCallback(\n (evt: React.KeyboardEvent<HTMLDivElement>) => {\n let newHue: number | undefined;\n const hueValue = hsv.h;\n if (\n evt.key === Key.ArrowLeft.valueOf() ||\n evt.key === Key.ArrowDown.valueOf()\n ) {\n newHue = hueValue - (evt.ctrlKey ? 10 : 1);\n } else if (\n evt.key === Key.ArrowRight.valueOf() ||\n evt.key === Key.ArrowUp.valueOf()\n ) {\n newHue = hueValue + (evt.ctrlKey ? 10 : 1);\n } else if (evt.key === Key.PageDown.valueOf()) {\n newHue = hueValue - (evt.ctrlKey ? 180 : 60);\n } else if (evt.key === Key.PageUp.valueOf()) {\n newHue = hueValue + (evt.ctrlKey ? 180 : 60);\n } else if (evt.key === Key.Home.valueOf()) {\n newHue = 0;\n } else {\n if (evt.key === Key.End.valueOf()) {\n newHue = 359;\n }\n }\n\n if (undefined !== newHue) {\n if (newHue > 359) newHue = 359; // 360 is same as zero\n if (newHue < 0) newHue = 0;\n\n const newColor = hsv.clone(newHue);\n if (onHueChange) onHueChange(newColor);\n evt.preventDefault();\n }\n },\n [hsv, onHueChange]\n );\n\n const containerClasses = classnames(\n isHorizontal\n ? \"components-hue-container-horizontal\"\n : \"components-hue-container-vertical\",\n className\n );\n\n const pointerStyle: React.CSSProperties = isHorizontal\n ? {\n left: `${(hsv.h * 100) / 360}%`,\n backgroundColor: `hsl(${hsv.h} ,100%, 50%)`,\n }\n : {\n left: `0px`,\n top: `${-((hsv.h * 100) / 360) + 100}%`,\n backgroundColor: `hsl(${hsv.h} ,100%, 50%)`,\n };\n\n return (\n <div className={containerClasses} style={style} data-testid=\"hue-container\">\n <div\n data-testid=\"hue-slider\"\n role=\"slider\"\n aria-label={translate(\"color.hue\")}\n aria-valuemin={0}\n aria-valuemax={360}\n aria-valuenow={hsv.h}\n className=\"components-hue-slider\"\n ref={container}\n onMouseDown={onMouseDown}\n onMouseMove={onDragging}\n onTouchMove={onDragging}\n onMouseUp={onMouseUp}\n onTouchStart={onTouchStart}\n onTouchEnd={onTouchEnd}\n tabIndex={0}\n onKeyDown={onKeyDown}\n >\n <div\n style={pointerStyle}\n className=\"components-hue-pointer\"\n data-testid=\"hue-pointer\"\n />\n </div>\n </div>\n );\n}\n"]}
|
|
@@ -7,7 +7,7 @@ import { HSVColor } from "@itwin/core-common";
|
|
|
7
7
|
import type { CommonProps } from "@itwin/core-react";
|
|
8
8
|
/** Properties for the [[SaturationPicker]] React component
|
|
9
9
|
* @beta
|
|
10
|
-
* @deprecated in 4.11.
|
|
10
|
+
* @deprecated in 4.11.0. Props of deprecated component {@link SaturationPicker}.
|
|
11
11
|
*/
|
|
12
12
|
export interface SaturationPickerProps extends React.HTMLAttributes<HTMLDivElement>, CommonProps {
|
|
13
13
|
/** function to run when user selects location in saturation region */
|
|
@@ -17,7 +17,7 @@ export interface SaturationPickerProps extends React.HTMLAttributes<HTMLDivEleme
|
|
|
17
17
|
}
|
|
18
18
|
/** SaturationPicker component used to set the saturation value.
|
|
19
19
|
* @beta
|
|
20
|
-
* @deprecated in 4.11.
|
|
20
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
21
21
|
*/
|
|
22
22
|
export declare function SaturationPicker({ onSaturationChange, hsv, className, style, }: SaturationPickerProps): React.JSX.Element;
|
|
23
23
|
//# sourceMappingURL=SaturationPicker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SaturationPicker.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/SaturationPicker.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAY,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuDrD;;;GAGG;AACH,MAAM,WAAW,qBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"SaturationPicker.d.ts","sourceRoot":"","sources":["../../../../src/imodel-components-react/color/SaturationPicker.tsx"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,yBAAyB,CAAC;AAEjC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAY,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAuDrD;;;GAGG;AACH,MAAM,WAAW,qBACf,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAE1C,WAAW;IACb,sEAAsE;IACtE,kBAAkB,CAAC,EAAE,CAAC,CAAC,UAAU,EAAE,QAAQ,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAClE,sBAAsB;IACtB,GAAG,EAAE,QAAQ,CAAC;CACf;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,kBAAkB,EAClB,GAAG,EACH,SAAS,EACT,KAAK,GACN,EACD,qBAAqB,qBA6JpB"}
|
|
@@ -90,7 +90,7 @@ function calculateChange(e, hsv, container) {
|
|
|
90
90
|
}
|
|
91
91
|
/** SaturationPicker component used to set the saturation value.
|
|
92
92
|
* @beta
|
|
93
|
-
* @deprecated in 4.11.
|
|
93
|
+
* @deprecated in 4.11.0. Use {@link https://itwinui.bentley.com/docs/colorpicker iTwinUI color picker} instead.
|
|
94
94
|
*/
|
|
95
95
|
function SaturationPicker({ onSaturationChange, hsv, className, style, }) {
|
|
96
96
|
const { translate } = (0, useTranslation_1.useTranslation)();
|