@itwin/imodel-components-react 5.18.0 → 5.20.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 +14 -0
- package/lib/imodel-components-react/UiIModelComponents.js +1 -1
- package/lib/imodel-components-react/UiIModelComponents.js.map +1 -1
- package/lib/imodel-components-react/color/AlphaSlider.js +100 -100
- package/lib/imodel-components-react/color/AlphaSlider.js.map +1 -1
- package/lib/imodel-components-react/editors/ColorEditor.js +20 -23
- package/lib/imodel-components-react/editors/ColorEditor.js.map +1 -1
- package/lib/imodel-components-react/editors/WeightEditor.js +21 -21
- package/lib/imodel-components-react/editors/WeightEditor.js.map +1 -1
- package/lib/imodel-components-react/lineweight/WeightPickerButton.js +53 -53
- package/lib/imodel-components-react/lineweight/WeightPickerButton.js.map +1 -1
- package/lib/imodel-components-react/navigationaids/Cube.js +1 -4
- package/lib/imodel-components-react/navigationaids/Cube.js.map +1 -1
- package/lib/imodel-components-react/navigationaids/CubeNavigationAid.js +296 -302
- package/lib/imodel-components-react/navigationaids/CubeNavigationAid.js.map +1 -1
- package/lib/imodel-components-react/navigationaids/DrawingNavigationAid.js +428 -425
- package/lib/imodel-components-react/navigationaids/DrawingNavigationAid.js.map +1 -1
- package/lib/imodel-components-react/timeline/BaseSolarDataProvider.js +20 -17
- package/lib/imodel-components-react/timeline/BaseSolarDataProvider.js.map +1 -1
- package/lib/imodel-components-react/timeline/BaseTimelineDataProvider.js +13 -10
- package/lib/imodel-components-react/timeline/BaseTimelineDataProvider.js.map +1 -1
- package/lib/imodel-components-react/timeline/InlineEdit.js +20 -20
- package/lib/imodel-components-react/timeline/InlineEdit.js.map +1 -1
- package/lib/imodel-components-react/timeline/SolarTimeline.js +144 -144
- package/lib/imodel-components-react/timeline/SolarTimeline.js.map +1 -1
- package/lib/imodel-components-react/viewport/ViewportComponentEvents.js +16 -15
- package/lib/imodel-components-react/viewport/ViewportComponentEvents.js.map +1 -1
- package/package.json +8 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Change Log - @itwin/imodel-components-react
|
|
2
2
|
|
|
3
|
+
## 5.20.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @itwin/components-react@5.20.0
|
|
8
|
+
- @itwin/core-react@5.20.0
|
|
9
|
+
|
|
10
|
+
## 5.19.0
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- @itwin/components-react@5.19.0
|
|
15
|
+
- @itwin/core-react@5.19.0
|
|
16
|
+
|
|
3
17
|
## 5.18.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -14,6 +14,7 @@ import { EmptyLocalization } from "@itwin/core-common";
|
|
|
14
14
|
* @public
|
|
15
15
|
*/
|
|
16
16
|
export class UiIModelComponents {
|
|
17
|
+
static _initialized = false;
|
|
17
18
|
/**
|
|
18
19
|
* initialize UiIModelComponents.
|
|
19
20
|
*/
|
|
@@ -67,5 +68,4 @@ export class UiIModelComponents {
|
|
|
67
68
|
return `${UiIModelComponents.packageName}.${name}`;
|
|
68
69
|
}
|
|
69
70
|
}
|
|
70
|
-
UiIModelComponents._initialized = false;
|
|
71
71
|
//# sourceMappingURL=UiIModelComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiIModelComponents.js","sourceRoot":"","sources":["../../src/imodel-components-react/UiIModelComponents.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,MAAM,OAAO,kBAAkB;
|
|
1
|
+
{"version":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B,CAAC,YAAY,GAAG,KAAK,CAAC;IAC1C,CAAC;IAED,4DAA4D;IACrD,MAAM,KAAK,WAAW;QAC3B,OAAO,kBAAkB,CAAC,YAAY,CAAC;IACzC,CAAC;IAED,kDAAkD;IAC3C,MAAM,KAAK,qBAAqB;QACrC,OAAO,oBAAoB,CAAC;IAC9B,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,WAAW;QAC3B,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,SAAS,CAAC,GAAsB;QAC5C,IAAI,CAAC,kBAAkB,CAAC,WAAW,IAAI,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC;YAC/D,MAAM,CAAC,QAAQ,CACb,kBAAkB,CAAC,cAAc,CAAC,oBAAoB,CAAC,EACvD,+EAA+E,CAChF,CAAC;YACF,OAAO,EAAE,CAAC;QACZ,CAAC;QACD,OAAO,SAAS,CAAC,YAAY,CAAC,kBAAkB,CAC9C,GAAG,kBAAkB,CAAC,qBAAqB,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAC7D,CAAC;IACJ,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,cAAc,CAAC,IAAY;QACvC,OAAO,GAAG,kBAAkB,CAAC,WAAW,IAAI,IAAI,EAAE,CAAC;IACrD,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 Common\n */\n\nimport { Logger } from \"@itwin/core-bentley\";\nimport { IModelApp } from \"@itwin/core-frontend\";\nimport { UiComponents } from \"@itwin/components-react\";\nimport { EmptyLocalization } from \"@itwin/core-common\";\n\n/**\n * Manages the localization service for the imodel-components-react package.\n * @public\n */\nexport class UiIModelComponents {\n private static _initialized = false;\n\n /**\n * initialize UiIModelComponents.\n */\n public static async initialize(): Promise<void> {\n if (UiIModelComponents._initialized) {\n Logger.logInfo(\n UiIModelComponents.loggerCategory(\"UiIModelComponents\"),\n `UiIModelComponents.initialize already called`\n );\n return;\n }\n\n await IModelApp.localization?.registerNamespace(\n UiIModelComponents.localizationNamespace\n );\n\n if (!IModelApp.localization) {\n // it should only get here in unit test where IModelApp is not setup\n const localization = new EmptyLocalization();\n await localization.initialize();\n await UiComponents.initialize(localization);\n } else {\n await UiComponents.initialize(IModelApp.localization);\n }\n\n UiIModelComponents._initialized = true;\n }\n\n /** Unregisters the UiIModelComponents localization namespace */\n public static terminate() {\n IModelApp.localization?.unregisterNamespace(\n UiIModelComponents.localizationNamespace\n );\n UiComponents.terminate();\n UiIModelComponents._initialized = false;\n }\n\n /** Determines if UiIModelComponents has been initialized */\n public static get initialized(): boolean {\n return UiIModelComponents._initialized;\n }\n\n /** The internationalization service namespace. */\n public static get localizationNamespace(): string {\n return \"UiIModelComponents\";\n }\n\n /** @internal */\n public static get packageName(): string {\n return \"imodel-components-react\";\n }\n\n /** Calls localization.getLocalizedString with the \"UiIModelComponents\" namespace. Do NOT include the namespace in the key.\n * @internal\n */\n public static translate(key: string | string[]): string {\n if (!UiIModelComponents.initialized || !IModelApp.localization) {\n Logger.logError(\n UiIModelComponents.loggerCategory(\"UiIModelComponents\"),\n `translate: IModelApp.localization has not been setup. Returning blank string.`\n );\n return \"\";\n }\n return IModelApp.localization.getLocalizedString(\n `${UiIModelComponents.localizationNamespace}:${String(key)}`\n );\n }\n\n /** @internal */\n public static loggerCategory(name: string): string {\n return `${UiIModelComponents.packageName}.${name}`;\n }\n}\n"]}
|
|
@@ -16,123 +16,123 @@ import { UiIModelComponents } from "../UiIModelComponents.js";
|
|
|
16
16
|
*/
|
|
17
17
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
18
18
|
export class AlphaSlider extends React.PureComponent {
|
|
19
|
+
_container = null;
|
|
19
20
|
/** @internal */
|
|
20
21
|
// eslint-disable-next-line @typescript-eslint/no-deprecated
|
|
21
22
|
constructor(props) {
|
|
22
23
|
super(props);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return undefined;
|
|
34
|
-
x = e.touches[0].pageX;
|
|
35
|
-
}
|
|
36
|
-
if (undefined === x)
|
|
24
|
+
}
|
|
25
|
+
_calculateChange = (e, isHorizontal, alpha, container) => {
|
|
26
|
+
e.preventDefault();
|
|
27
|
+
const { width: containerWidth, height: containerHeight } = container.getBoundingClientRect();
|
|
28
|
+
let x = 0;
|
|
29
|
+
if ("pageX" in e) {
|
|
30
|
+
x = e.pageX;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
if (undefined === e.touches)
|
|
37
34
|
return undefined;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
x = e.touches[0].pageX;
|
|
36
|
+
}
|
|
37
|
+
if (undefined === x)
|
|
38
|
+
return undefined;
|
|
39
|
+
let y = 0;
|
|
40
|
+
if ("pageY" in e) {
|
|
41
|
+
y = e.pageY;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
if (undefined === e.touches)
|
|
45
|
+
return;
|
|
46
|
+
y = e.touches[0].pageY;
|
|
47
|
+
}
|
|
48
|
+
if (undefined === y)
|
|
49
|
+
return undefined;
|
|
50
|
+
const left = x - (container.getBoundingClientRect().left + window.scrollX);
|
|
51
|
+
const top = y - (container.getBoundingClientRect().top + window.scrollY);
|
|
52
|
+
let t = 0;
|
|
53
|
+
if (!isHorizontal) {
|
|
54
|
+
if (top < 0) {
|
|
55
|
+
t = 1;
|
|
46
56
|
}
|
|
47
|
-
if (
|
|
48
|
-
|
|
49
|
-
const left = x - (container.getBoundingClientRect().left + window.scrollX);
|
|
50
|
-
const top = y - (container.getBoundingClientRect().top + window.scrollY);
|
|
51
|
-
let t = 0;
|
|
52
|
-
if (!isHorizontal) {
|
|
53
|
-
if (top < 0) {
|
|
54
|
-
t = 1;
|
|
55
|
-
}
|
|
56
|
-
else if (top > containerHeight) {
|
|
57
|
-
t = 0;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
t = 1 - top / containerHeight;
|
|
61
|
-
}
|
|
57
|
+
else if (top > containerHeight) {
|
|
58
|
+
t = 0;
|
|
62
59
|
}
|
|
63
60
|
else {
|
|
64
|
-
|
|
65
|
-
if (left < 0) {
|
|
66
|
-
t = 0;
|
|
67
|
-
}
|
|
68
|
-
else if (left > containerWidth) {
|
|
69
|
-
t = 1;
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
t = left / containerWidth;
|
|
73
|
-
}
|
|
61
|
+
t = 1 - top / containerHeight;
|
|
74
62
|
}
|
|
75
|
-
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// horizontal
|
|
66
|
+
if (left < 0) {
|
|
76
67
|
t = 0;
|
|
77
|
-
if (t > 1)
|
|
78
|
-
t = 1;
|
|
79
|
-
return alpha !== t ? t : undefined;
|
|
80
|
-
};
|
|
81
|
-
this._onChange = (e) => {
|
|
82
|
-
if (this._container && this.props.onAlphaChange) {
|
|
83
|
-
const change = this._calculateChange(e, this.props.isHorizontal ? this.props.isHorizontal : false, this.props.alpha, this._container);
|
|
84
|
-
undefined !== change &&
|
|
85
|
-
typeof this.props.onAlphaChange === "function" &&
|
|
86
|
-
this.props.onAlphaChange(change);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
this._onMouseDown = (e) => {
|
|
90
|
-
this._onChange(e);
|
|
91
|
-
if (this._container)
|
|
92
|
-
this._container.focus();
|
|
93
|
-
window.addEventListener("mousemove", this._onChange);
|
|
94
|
-
window.addEventListener("mouseup", this._onMouseUp);
|
|
95
|
-
};
|
|
96
|
-
this._onKeyDown = (evt) => {
|
|
97
|
-
let newTransparency;
|
|
98
|
-
if (evt.key === Key.ArrowLeft.valueOf() ||
|
|
99
|
-
evt.key === Key.ArrowDown.valueOf()) {
|
|
100
|
-
newTransparency = this.props.alpha - (evt.ctrlKey ? 0.1 : 0.05);
|
|
101
68
|
}
|
|
102
|
-
else if (
|
|
103
|
-
|
|
104
|
-
newTransparency = this.props.alpha + (evt.ctrlKey ? 0.1 : 0.05);
|
|
105
|
-
}
|
|
106
|
-
else if (evt.key === Key.PageDown.valueOf()) {
|
|
107
|
-
newTransparency = this.props.alpha - (evt.ctrlKey ? 0.5 : 0.25);
|
|
108
|
-
}
|
|
109
|
-
else if (evt.key === Key.PageUp.valueOf()) {
|
|
110
|
-
newTransparency = this.props.alpha + (evt.ctrlKey ? 0.5 : 0.25);
|
|
111
|
-
}
|
|
112
|
-
else if (evt.key === Key.Home.valueOf()) {
|
|
113
|
-
newTransparency = 0;
|
|
69
|
+
else if (left > containerWidth) {
|
|
70
|
+
t = 1;
|
|
114
71
|
}
|
|
115
72
|
else {
|
|
116
|
-
|
|
117
|
-
newTransparency = 1;
|
|
118
|
-
}
|
|
73
|
+
t = left / containerWidth;
|
|
119
74
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
};
|
|
129
|
-
this._onMouseUp = () => {
|
|
130
|
-
this._unbindEventListeners();
|
|
131
|
-
};
|
|
132
|
-
}
|
|
75
|
+
}
|
|
76
|
+
if (t < 0)
|
|
77
|
+
t = 0;
|
|
78
|
+
if (t > 1)
|
|
79
|
+
t = 1;
|
|
80
|
+
return alpha !== t ? t : undefined;
|
|
81
|
+
};
|
|
133
82
|
componentWillUnmount() {
|
|
134
83
|
this._unbindEventListeners();
|
|
135
84
|
}
|
|
85
|
+
_onChange = (e) => {
|
|
86
|
+
if (this._container && this.props.onAlphaChange) {
|
|
87
|
+
const change = this._calculateChange(e, this.props.isHorizontal ? this.props.isHorizontal : false, this.props.alpha, this._container);
|
|
88
|
+
undefined !== change &&
|
|
89
|
+
typeof this.props.onAlphaChange === "function" &&
|
|
90
|
+
this.props.onAlphaChange(change);
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
_onMouseDown = (e) => {
|
|
94
|
+
this._onChange(e);
|
|
95
|
+
if (this._container)
|
|
96
|
+
this._container.focus();
|
|
97
|
+
window.addEventListener("mousemove", this._onChange);
|
|
98
|
+
window.addEventListener("mouseup", this._onMouseUp);
|
|
99
|
+
};
|
|
100
|
+
_onKeyDown = (evt) => {
|
|
101
|
+
let newTransparency;
|
|
102
|
+
if (evt.key === Key.ArrowLeft.valueOf() ||
|
|
103
|
+
evt.key === Key.ArrowDown.valueOf()) {
|
|
104
|
+
newTransparency = this.props.alpha - (evt.ctrlKey ? 0.1 : 0.05);
|
|
105
|
+
}
|
|
106
|
+
else if (evt.key === Key.ArrowRight.valueOf() ||
|
|
107
|
+
evt.key === Key.ArrowUp.valueOf()) {
|
|
108
|
+
newTransparency = this.props.alpha + (evt.ctrlKey ? 0.1 : 0.05);
|
|
109
|
+
}
|
|
110
|
+
else if (evt.key === Key.PageDown.valueOf()) {
|
|
111
|
+
newTransparency = this.props.alpha - (evt.ctrlKey ? 0.5 : 0.25);
|
|
112
|
+
}
|
|
113
|
+
else if (evt.key === Key.PageUp.valueOf()) {
|
|
114
|
+
newTransparency = this.props.alpha + (evt.ctrlKey ? 0.5 : 0.25);
|
|
115
|
+
}
|
|
116
|
+
else if (evt.key === Key.Home.valueOf()) {
|
|
117
|
+
newTransparency = 0;
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
if (evt.key === Key.End.valueOf()) {
|
|
121
|
+
newTransparency = 1;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (undefined !== newTransparency) {
|
|
125
|
+
if (newTransparency > 1)
|
|
126
|
+
newTransparency = 1;
|
|
127
|
+
if (newTransparency < 0)
|
|
128
|
+
newTransparency = 0;
|
|
129
|
+
if (this.props.onAlphaChange)
|
|
130
|
+
this.props.onAlphaChange(newTransparency);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
_onMouseUp = () => {
|
|
134
|
+
this._unbindEventListeners();
|
|
135
|
+
};
|
|
136
136
|
_unbindEventListeners() {
|
|
137
137
|
window.removeEventListener("mousemove", this._onChange);
|
|
138
138
|
window.removeEventListener("mouseup", this._onMouseUp);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlphaSlider.js","sourceRoot":"","sources":["../../../src/imodel-components-react/color/AlphaSlider.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAkB9D;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAA+B;IAGpE,gBAAgB;IAChB,4DAA4D;IAC5D,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;g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CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,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,kBAAkB,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;oBACjB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;gBAC9B,CAAC,EACD,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","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.js\";\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 @typescript-eslint/no-deprecated\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 @typescript-eslint/no-deprecated\nexport class AlphaSlider extends React.PureComponent<AlphaSliderProps> {\n private _container: HTMLDivElement | null = null;\n\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\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 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 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) => {\n this._container = container;\n }}\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,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAkB9D;;;GAGG;AACH,4DAA4D;AAC5D,MAAM,OAAO,WAAY,SAAQ,KAAK,CAAC,aAA+B;IAC5D,UAAU,GAA0B,IAAI,CAAC;IAEjD,gBAAgB;IAChB,4DAA4D;IAC5D,YAAY,KAAuB;QACjC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEO,gBAAgB,GAAG,CACzB,CAAsE,EACtE,YAAqB,EACrB,KAAa,EACb,SAAyB,EACL,EAAE;QACtB,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAM,EAAE,KAAK,EAAE,cAAc,EAAE,MA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I,CAAC,KAAK,CAAC,YAAY;YAC/D,CAAC,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,GAAG,EAAE;YACxC,CAAC,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,GAAG,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,kBAAkB,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;oBACjB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;gBAC9B,CAAC,EACD,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","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.js\";\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 @typescript-eslint/no-deprecated\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 @typescript-eslint/no-deprecated\nexport class AlphaSlider extends React.PureComponent<AlphaSliderProps> {\n private _container: HTMLDivElement | null = null;\n\n /** @internal */\n // eslint-disable-next-line @typescript-eslint/no-deprecated\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 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 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) => {\n this._container = container;\n }}\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"]}
|
|
@@ -16,29 +16,13 @@ import { ColorPickerButton } from "../color/ColorPickerButton.js";
|
|
|
16
16
|
* @beta
|
|
17
17
|
*/
|
|
18
18
|
export class ColorEditor extends React.PureComponent {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
availableColors: [],
|
|
27
|
-
};
|
|
28
|
-
this._onColorPick = (color) => {
|
|
29
|
-
const propertyRecord = this.props.propertyRecord;
|
|
30
|
-
this.setState({
|
|
31
|
-
colorValue: color.tbgr,
|
|
32
|
-
}, async () => {
|
|
33
|
-
if (propertyRecord && this.props.onCommit) {
|
|
34
|
-
const propertyValue = await this.getPropertyValue();
|
|
35
|
-
if (propertyValue !== undefined) {
|
|
36
|
-
this.props.onCommit({ propertyRecord, newValue: propertyValue });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
|
-
}
|
|
19
|
+
_buttonElement = React.createRef();
|
|
20
|
+
state = {
|
|
21
|
+
colorValue: 0,
|
|
22
|
+
readonly: false,
|
|
23
|
+
numColumns: 4,
|
|
24
|
+
availableColors: [],
|
|
25
|
+
};
|
|
42
26
|
async getPropertyValue() {
|
|
43
27
|
const record = this.props.propertyRecord;
|
|
44
28
|
let propertyValue;
|
|
@@ -64,6 +48,19 @@ export class ColorEditor extends React.PureComponent {
|
|
|
64
48
|
this._buttonElement.current.focus();
|
|
65
49
|
}
|
|
66
50
|
}
|
|
51
|
+
_onColorPick = (color) => {
|
|
52
|
+
const propertyRecord = this.props.propertyRecord;
|
|
53
|
+
this.setState({
|
|
54
|
+
colorValue: color.tbgr,
|
|
55
|
+
}, async () => {
|
|
56
|
+
if (propertyRecord && this.props.onCommit) {
|
|
57
|
+
const propertyValue = await this.getPropertyValue();
|
|
58
|
+
if (propertyValue !== undefined) {
|
|
59
|
+
this.props.onCommit({ propertyRecord, newValue: propertyValue });
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
};
|
|
67
64
|
componentDidMount() {
|
|
68
65
|
void this.setStateFromProps();
|
|
69
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/ColorEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,oBAAoB,CAAC;AAC5B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAO9C,OAAO,EACL,wBAAwB,EACxB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,kBAAkB,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E,GAAG,EAAE;gBACH,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;oBACxB,IAAI,CAAC,QAAQ,EAAE,CAAC;gBAClB,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAEe,MAAM;QACpB,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;QACxD,OAAO,CACL,6BACE,SAAS,EAAE,UAAU,CAAC,yBAAyB,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EACtE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;YAEvB,oBAAC,iBAAiB,CAAC,uDAAuD;gBACxE,GAAG,EAAE,IAAI,CAAC,cAAc,EACxB,YAAY,EAAE,QAAQ,EACtB,SAAS,EACP,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;oBACnC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,eAAe;oBAC5B,CAAC,CAAC,CAAC,QAAQ,CAAC,EAEhB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EAC9C,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAC7B,WAAW,EAAE,IAAI,CAAC,YAAY,iBAClB,yBAAyB,GACrC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,mBAAoB,SAAQ,kBAAkB;IACzD,IAAW,SAAS;QAClB,OAAO,oBAAC,WAAW,OAAG,CAAC;IACzB,CAAC;CACF","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 PropertyEditors\n */\n\nimport \"./ColorEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport { ColorDef } from \"@itwin/core-common\";\nimport type {\n ColorEditorParams,\n PropertyEditorParams,\n PropertyRecord,\n PropertyValue,\n} from \"@itwin/appui-abstract\";\nimport {\n PropertyEditorParamTypes,\n PropertyValueFormat,\n} from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { ColorPickerButton } from \"../color/ColorPickerButton.js\";\n\n/** @internal */\ninterface ColorEditorState {\n colorValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n numColumns: number;\n availableColors: ColorDef[];\n}\n\n/** ColorEditor React component that is a property editor with text input\n * @beta\n */\nexport class ColorEditor\n extends React.PureComponent<PropertyEditorProps, ColorEditorState>\n implements TypeEditor\n{\n private _buttonElement: React.RefObject<HTMLButtonElement | null> =\n React.createRef();\n\n public override readonly state: Readonly<ColorEditorState> = {\n colorValue: 0,\n readonly: false,\n numColumns: 4,\n availableColors: [],\n };\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.colorValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._buttonElement.current;\n }\n\n public get hasFocus(): boolean {\n return document.activeElement === this._buttonElement.current;\n }\n\n private setFocus(): void {\n if (\n this._buttonElement &&\n this._buttonElement.current &&\n !this.state.isDisabled\n ) {\n this._buttonElement.current.focus();\n }\n }\n\n private _onColorPick = (color: ColorDef) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n colorValue: color.tbgr,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n };\n\n public override componentDidMount() {\n void this.setStateFromProps();\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n const colorValue = record.value.value as number;\n let numColumns = 4;\n const availableColors = new Array<ColorDef>();\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (record.property.editor && record.property.editor.params) {\n const colorParams = record.property.editor.params.find(\n (param: PropertyEditorParams) =>\n param.type === PropertyEditorParamTypes.ColorData.valueOf()\n ) as ColorEditorParams;\n if (colorParams) {\n colorParams.colorValues.forEach((colorNumber: number) => {\n availableColors.push(ColorDef.create(colorNumber));\n });\n if (colorParams.numColumns) numColumns = colorParams.numColumns;\n }\n }\n this.setState(\n { colorValue, readonly, isDisabled, numColumns, availableColors },\n () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n }\n );\n }\n }\n\n public override render() {\n const colorDef = ColorDef.create(this.state.colorValue);\n return (\n <div\n className={classnames(\"components-color-editor\", this.props.className)}\n style={this.props.style}\n >\n <ColorPickerButton // eslint-disable-line @typescript-eslint/no-deprecated\n ref={this._buttonElement}\n initialColor={colorDef}\n colorDefs={\n this.state.availableColors.length > 0\n ? this.state.availableColors\n : [colorDef]\n }\n numColumns={this.state.numColumns}\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onColorPick={this._onColorPick}\n data-testid=\"components-color-editor\"\n />\n </div>\n );\n }\n}\n\n/** Color Property Editor registered for the \"number\" type name and \"color-picker\" editor name.\n * It uses the [[ColorEditor]] React component.\n * @beta\n */\nexport class ColorPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <ColorEditor />;\n }\n}\n"]}
|
|
@@ -15,29 +15,16 @@ import { WeightPickerButton } from "../lineweight/WeightPickerButton.js";
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
export class WeightEditor extends React.PureComponent {
|
|
18
|
+
_control = null;
|
|
19
|
+
_isMounted = false;
|
|
20
|
+
_availableWeights = [];
|
|
21
|
+
_divElement = React.createRef();
|
|
22
|
+
state = {
|
|
23
|
+
weightValue: 0,
|
|
24
|
+
readonly: false,
|
|
25
|
+
};
|
|
18
26
|
constructor(props) {
|
|
19
27
|
super(props);
|
|
20
|
-
this._control = null;
|
|
21
|
-
this._isMounted = false;
|
|
22
|
-
this._availableWeights = [];
|
|
23
|
-
this._divElement = React.createRef();
|
|
24
|
-
this.state = {
|
|
25
|
-
weightValue: 0,
|
|
26
|
-
readonly: false,
|
|
27
|
-
};
|
|
28
|
-
this._onLineWeightPick = (weight) => {
|
|
29
|
-
const propertyRecord = this.props.propertyRecord;
|
|
30
|
-
this.setState({
|
|
31
|
-
weightValue: weight,
|
|
32
|
-
}, async () => {
|
|
33
|
-
if (propertyRecord && this.props.onCommit) {
|
|
34
|
-
const propertyValue = await this.getPropertyValue();
|
|
35
|
-
if (propertyValue !== undefined) {
|
|
36
|
-
this.props.onCommit({ propertyRecord, newValue: propertyValue });
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
});
|
|
40
|
-
};
|
|
41
28
|
// TODO: add support for following if we need to specify set of weights to display
|
|
42
29
|
// const record = this.props.propertyRecord;
|
|
43
30
|
// if (record && record.property && record.property.editor && record.property.editor.params) {
|
|
@@ -75,6 +62,19 @@ export class WeightEditor extends React.PureComponent {
|
|
|
75
62
|
this._control.setFocus();
|
|
76
63
|
}
|
|
77
64
|
}
|
|
65
|
+
_onLineWeightPick = (weight) => {
|
|
66
|
+
const propertyRecord = this.props.propertyRecord;
|
|
67
|
+
this.setState({
|
|
68
|
+
weightValue: weight,
|
|
69
|
+
}, async () => {
|
|
70
|
+
if (propertyRecord && this.props.onCommit) {
|
|
71
|
+
const propertyValue = await this.getPropertyValue();
|
|
72
|
+
if (propertyValue !== undefined) {
|
|
73
|
+
this.props.onCommit({ propertyRecord, newValue: propertyValue });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
78
|
componentDidMount() {
|
|
79
79
|
this._isMounted = true;
|
|
80
80
|
void this.setStateFromProps();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WeightEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AASzE;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;
|
|
1
|
+
{"version":3,"file":"WeightEditor.js","sourceRoot":"","sources":["../../../src/imodel-components-react/editors/WeightEditor.tsx"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AAEH,OAAO,qBAAqB,CAAC;AAC7B,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AASzE;;GAEG;AACH,MAAM,OAAO,YACX,SAAQ,KAAK,CAAC,aAAqD;IAG3D,QAA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ACtC,CACE,CACP,CAAC;IACJ,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IAC1D,IAAW,SAAS;QAClB,OAAO,oBAAC,YAAY,OAAG,CAAC;IAC1B,CAAC;CACF","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 PropertyEditors\n */\n\nimport \"./WeightEditor.scss\";\nimport classnames from \"classnames\";\nimport * as React from \"react\";\nimport type { PropertyRecord, PropertyValue } from \"@itwin/appui-abstract\";\nimport { PropertyValueFormat } from \"@itwin/appui-abstract\";\nimport type { PropertyEditorProps, TypeEditor } from \"@itwin/components-react\";\nimport { PropertyEditorBase } from \"@itwin/components-react\";\nimport { WeightPickerButton } from \"../lineweight/WeightPickerButton.js\";\n\n/** @internal */\ninterface WeightEditorState {\n weightValue: number;\n readonly: boolean;\n isDisabled?: boolean;\n}\n\n/** WeightEditor React component that is a property editor for picking a weight using a [[WeightPickerButton]] component\n * @public\n */\nexport class WeightEditor\n extends React.PureComponent<PropertyEditorProps, WeightEditorState>\n implements TypeEditor\n{\n private _control: any = null;\n private _isMounted = false;\n private _availableWeights: number[] = [];\n private _divElement = React.createRef<HTMLDivElement>();\n\n public override readonly state: Readonly<WeightEditorState> = {\n weightValue: 0,\n readonly: false,\n };\n\n constructor(props: PropertyEditorProps) {\n super(props);\n\n // TODO: add support for following if we need to specify set of weights to display\n // const record = this.props.propertyRecord;\n // if (record && record.property && record.property.editor && record.property.editor.params) {\n // const weightParams = record.property.editor.params.find((param: PropertyEditorParams) => param.type === PropertyEditorParamTypes.ColorData) as WeightEditorParams;\n // // if (weightParams) {\n // weightParams.weightValues.forEach((weight: number) => {\n // this._availableWeights.push(weight);\n // });\n // }\n // }\n }\n\n public async getPropertyValue(): Promise<PropertyValue | undefined> {\n const record = this.props.propertyRecord;\n let propertyValue: PropertyValue | undefined;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n propertyValue = {\n valueFormat: PropertyValueFormat.Primitive,\n value: this.state.weightValue,\n displayValue: \"\",\n };\n }\n\n return propertyValue;\n }\n\n public get htmlElement(): HTMLElement | null {\n return this._divElement.current;\n }\n\n public get hasFocus(): boolean {\n let containsFocus = false;\n if (this._divElement.current)\n containsFocus = this._divElement.current.contains(document.activeElement);\n return containsFocus;\n }\n\n private setFocus(): void {\n if (this._control && !this.state.isDisabled) {\n this._control.setFocus();\n }\n }\n\n private _onLineWeightPick = (weight: number) => {\n const propertyRecord = this.props.propertyRecord as PropertyRecord;\n\n this.setState(\n {\n weightValue: weight,\n },\n async () => {\n if (propertyRecord && this.props.onCommit) {\n const propertyValue = await this.getPropertyValue();\n if (propertyValue !== undefined) {\n this.props.onCommit({ propertyRecord, newValue: propertyValue });\n }\n }\n }\n );\n };\n\n public override componentDidMount() {\n this._isMounted = true;\n void this.setStateFromProps();\n }\n\n public override componentWillUnmount() {\n this._isMounted = false;\n }\n\n /** @internal */\n public override componentDidUpdate(prevProps: PropertyEditorProps) {\n if (this.props.propertyRecord !== prevProps.propertyRecord) {\n void this.setStateFromProps();\n }\n }\n\n private async setStateFromProps() {\n const record = this.props.propertyRecord;\n let initialValue = 0;\n\n if (record && record.value.valueFormat === PropertyValueFormat.Primitive) {\n initialValue = record.value.value as number;\n }\n\n const readonly =\n record && undefined !== record.isReadonly ? record.isReadonly : false;\n const isDisabled = record ? record.isDisabled : undefined;\n\n if (this._isMounted)\n this.setState({ weightValue: initialValue, readonly, isDisabled }, () => {\n if (this.props.setFocus) {\n this.setFocus();\n }\n });\n }\n\n public override render() {\n return (\n <div\n className={classnames(\"components-weight-editor\", this.props.className)}\n style={this.props.style}\n ref={this._divElement}\n >\n <WeightPickerButton\n ref={(control) => {\n this._control = control;\n }}\n activeWeight={this.state.weightValue}\n weights={\n this._availableWeights.length > 0\n ? this._availableWeights\n : undefined\n }\n disabled={this.state.isDisabled ? true : false}\n readonly={this.state.readonly}\n onLineWeightPick={this._onLineWeightPick}\n data-testid=\"components-weight-editor\"\n />\n </div>\n );\n }\n}\n\n/** Weight Property Editor registered for the \"number\" type name and \"weight-picker\" editor name.\n * It uses the [[WeightEditor]] React component.\n * @public\n */\nexport class WeightPropertyEditor extends PropertyEditorBase {\n public get reactNode(): React.ReactNode {\n return <WeightEditor />;\n }\n}\n"]}
|