@babylonjs/shared-ui-components 8.16.0 → 8.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/fluent/hoc/dropdownPropertyLine.d.ts +0 -1
  2. package/fluent/hoc/dropdownPropertyLine.js +1 -1
  3. package/fluent/hoc/dropdownPropertyLine.js.map +1 -1
  4. package/fluent/hoc/gradientList.d.ts +14 -0
  5. package/fluent/hoc/gradientList.js +76 -0
  6. package/fluent/hoc/gradientList.js.map +1 -0
  7. package/fluent/hoc/inputPropertyLine.d.ts +11 -1
  8. package/fluent/hoc/inputPropertyLine.js +9 -7
  9. package/fluent/hoc/inputPropertyLine.js.map +1 -1
  10. package/fluent/primitives/colorPicker.js +1 -1
  11. package/fluent/primitives/colorPicker.js.map +1 -1
  12. package/fluent/primitives/gradient.d.ts +28 -0
  13. package/fluent/primitives/gradient.js +86 -0
  14. package/fluent/primitives/gradient.js.map +1 -0
  15. package/fluent/primitives/input.d.ts +2 -6
  16. package/fluent/primitives/input.js +10 -7
  17. package/fluent/primitives/input.js.map +1 -1
  18. package/fluent/primitives/list.d.ts +26 -0
  19. package/fluent/primitives/list.js +43 -0
  20. package/fluent/primitives/list.js.map +1 -0
  21. package/fluent/primitives/messageBar.js +2 -2
  22. package/fluent/primitives/messageBar.js.map +1 -1
  23. package/fluent/primitives/syncedSlider.d.ts +6 -1
  24. package/fluent/primitives/syncedSlider.js +28 -11
  25. package/fluent/primitives/syncedSlider.js.map +1 -1
  26. package/lines/optionsLineComponent.d.ts +1 -1
  27. package/lines/optionsLineComponent.js.map +1 -1
  28. package/lines/textInputLineComponent.js +2 -2
  29. package/lines/textInputLineComponent.js.map +1 -1
  30. package/package.json +1 -1
  31. package/components/lines/ColorLineComponent.d.ts +0 -38
  32. package/components/lines/ColorLineComponent.js +0 -147
  33. package/components/lines/ColorLineComponent.js.map +0 -1
  34. package/components/lines/ColorLineComponent.module.scss +0 -67
  35. package/lines/iconButtonLineComponent.d.ts +0 -11
  36. package/lines/iconButtonLineComponent.js +0 -11
  37. package/lines/iconButtonLineComponent.js.map +0 -1
@@ -1,147 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { Color3, Color4 } from "@babylonjs/core/Maths/math.color.js";
4
- import { NumericInputComponent } from "./NumericInputComponent.js";
5
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
6
- import { faMinus, faPlus } from "@fortawesome/free-solid-svg-icons";
7
- import { ColorPickerLineComponent } from "./ColorPickerLineComponent.js";
8
- import * as style from "./ColorLineComponent.module.scss";
9
- import copyIcon from "../../imgs/copy.svg";
10
- import { JoinClassNames } from "../classNames.js";
11
- const EmptyColor = new Color4(0, 0, 0, 0);
12
- export class ColorLineComponent extends React.Component {
13
- constructor(props) {
14
- super(props);
15
- this.state = { isExpanded: false, color: this.getValue() };
16
- const target = this.props.target;
17
- target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate
18
- }
19
- shouldComponentUpdate(nextProps, nextState) {
20
- const stateColor = nextState.color;
21
- const propsColor = this.getValue(nextProps);
22
- if (stateColor !== this.state.color) {
23
- nextState.color = stateColor;
24
- return true;
25
- }
26
- if (propsColor !== this.state.color) {
27
- nextState.color = propsColor;
28
- return true;
29
- }
30
- if (nextState.isExpanded !== this.state.isExpanded) {
31
- return true;
32
- }
33
- return false;
34
- }
35
- getValue(props = this.props) {
36
- const target = props.target;
37
- const property = target[props.propertyName];
38
- if (!property) {
39
- return EmptyColor;
40
- }
41
- if (typeof property === "string") {
42
- // if (property === conflictingValuesPlaceholder) {
43
- // return emptyColor;
44
- // }
45
- return this._convertToColor(property);
46
- }
47
- else {
48
- if (props.isLinear) {
49
- return property.toGammaSpace();
50
- }
51
- return property.clone();
52
- }
53
- }
54
- setColorFromString(colorString) {
55
- const color = this._convertToColor(colorString);
56
- this.setColor(color);
57
- }
58
- setColor(newColor) {
59
- this.setState({ color: newColor.clone() });
60
- if (this.props.isLinear) {
61
- newColor.toLinearSpaceToRef(newColor);
62
- }
63
- // whether to set properties to color3 or color4
64
- const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;
65
- const target = this.props.target;
66
- const initialValue = target[this.props.propertyName];
67
- const value = typeof target[this.props.propertyName] === "string" ? setColor.toHexString() : setColor;
68
- // make the change
69
- target[this.props.propertyName] = value;
70
- // notify observers
71
- if (this.props.onPropertyChangedObservable) {
72
- this.props.onPropertyChangedObservable.notifyObservers({
73
- object: target,
74
- property: this.props.propertyName,
75
- value,
76
- initialValue,
77
- });
78
- }
79
- if (this.props.onChange) {
80
- this.props.onChange();
81
- }
82
- }
83
- switchExpandState() {
84
- this.setState({ isExpanded: !this.state.isExpanded });
85
- }
86
- updateStateR(value) {
87
- this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));
88
- }
89
- updateStateG(value) {
90
- this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));
91
- }
92
- updateStateB(value) {
93
- this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));
94
- }
95
- updateStateA(value) {
96
- if (this.props.disableAlpha) {
97
- return;
98
- }
99
- this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
100
- }
101
- copyToClipboard() {
102
- const element = document.createElement("div");
103
- element.textContent = this.state.color.toHexString();
104
- document.body.appendChild(element);
105
- if (window.getSelection) {
106
- const range = document.createRange();
107
- range.selectNode(element);
108
- window.getSelection().removeAllRanges();
109
- window.getSelection().addRange(range);
110
- }
111
- document.execCommand("copy");
112
- element.remove();
113
- }
114
- _convertToColor(color) {
115
- if (color === "" || color === "transparent") {
116
- return EmptyColor;
117
- }
118
- if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
119
- const d = document.createElement("div");
120
- d.style.color = color;
121
- document.body.append(d);
122
- const rgb = window.getComputedStyle(d).color;
123
- document.body.removeChild(d);
124
- const rgbArray = rgb
125
- .substring(4, rgb.length - 1)
126
- .replace(/ /g, "")
127
- .split(",");
128
- const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;
129
- return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);
130
- }
131
- if (this.props.disableAlpha) {
132
- const color3 = Color3.FromHexString(color);
133
- return new Color4(color3.r, color3.g, color3.b, 1.0);
134
- }
135
- return Color4.FromHexString(color);
136
- }
137
- _toColor3(color) {
138
- return new Color3(color.r, color.g, color.b);
139
- }
140
- render() {
141
- const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
142
- return (_jsxs("div", { className: style.color3Line, children: [_jsxs("div", { className: style.firstLine, children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: style.label, title: this.props.label, children: this.props.label }), _jsx("div", { className: style.color3, children: _jsx(ColorPickerLineComponent, { lockObject: this.props.lockObject, linearHint: this.props.isLinear, value: this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color, onColorChanged: (colorString) => {
143
- this.setColorFromString(colorString);
144
- } }) }), _jsx("div", { className: JoinClassNames(style, "copy", "hoverIcon"), onClick: () => this.copyToClipboard(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) }), _jsx("div", { className: JoinClassNames("expand", "hoverIcon"), onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && (_jsxs("div", { className: style.secondLine, children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "r", labelTooltip: "Red", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "g", labelTooltip: "Green", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "b", labelTooltip: "Blue", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "a", labelTooltip: "Alpha", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
145
- }
146
- }
147
- //# sourceMappingURL=ColorLineComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ColorLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/components/lines/ColorLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,4CAA8B;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAEpE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,OAAO,KAAK,KAAK,MAAM,kCAAkC,CAAC;AAE1D,OAAO,QAAQ,MAAM,qBAAqB,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,MAAM,UAAU,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAoB1C,MAAM,OAAO,kBAAmB,SAAQ,KAAK,CAAC,SAA6D;IACvG,YAAY,KAA+B;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC;QAE3D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACjC,MAAM,CAAC,cAAc,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,mEAAmE;IAC/G,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AK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAC/C,CACL,IACC,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport { Color3, Color4 } from \"core/Maths/math.color\";\r\nimport { NumericInputComponent } from \"./NumericInputComponent\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { faMinus, faPlus } from \"@fortawesome/free-solid-svg-icons\";\r\nimport type { PropertyChangedEvent } from \"../../propertyChangedEvent\";\r\nimport { ColorPickerLineComponent } from \"./ColorPickerLineComponent\";\r\nimport type { LockObject } from \"../../tabs/propertyGrids/lockObject\";\r\nimport * as style from \"./ColorLineComponent.module.scss\";\r\n\r\nimport copyIcon from \"../../imgs/copy.svg\";\r\nimport { JoinClassNames } from \"../classNames\";\r\nconst EmptyColor = new Color4(0, 0, 0, 0);\r\n\r\nexport interface IColorLineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n onPropertyChangedObservable: Observable<PropertyChangedEvent>;\r\n onChange?: () => void;\r\n isLinear?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n disableAlpha?: boolean;\r\n lockObject: LockObject;\r\n}\r\n\r\ninterface IColorLineComponentState {\r\n isExpanded: boolean;\r\n color: Color4;\r\n}\r\n\r\nexport class ColorLineComponent extends React.Component<IColorLineComponentProps, IColorLineComponentState> {\r\n constructor(props: IColorLineComponentProps) {\r\n super(props);\r\n\r\n this.state = { isExpanded: false, color: this.getValue() };\r\n\r\n const target = this.props.target;\r\n target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate\r\n }\r\n\r\n override shouldComponentUpdate(nextProps: IColorLineComponentProps, nextState: IColorLineComponentState) {\r\n const stateColor = nextState.color;\r\n const propsColor = this.getValue(nextProps);\r\n if (stateColor !== this.state.color) {\r\n nextState.color = stateColor;\r\n return true;\r\n }\r\n if (propsColor !== this.state.color) {\r\n nextState.color = propsColor;\r\n return true;\r\n }\r\n if (nextState.isExpanded !== this.state.isExpanded) {\r\n return true;\r\n }\r\n return false;\r\n }\r\n\r\n getValue(props = this.props): Color4 {\r\n const target = props.target;\r\n const property = target[props.propertyName];\r\n if (!property) {\r\n return EmptyColor;\r\n }\r\n if (typeof property === \"string\") {\r\n // if (property === conflictingValuesPlaceholder) {\r\n // return emptyColor;\r\n // }\r\n return this._convertToColor(property);\r\n } else {\r\n if (props.isLinear) {\r\n return property.toGammaSpace();\r\n }\r\n return property.clone();\r\n }\r\n }\r\n\r\n setColorFromString(colorString: string) {\r\n const color = this._convertToColor(colorString);\r\n this.setColor(color);\r\n }\r\n\r\n setColor(newColor: Color4) {\r\n this.setState({ color: newColor.clone() });\r\n if (this.props.isLinear) {\r\n newColor.toLinearSpaceToRef(newColor);\r\n }\r\n // whether to set properties to color3 or color4\r\n const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;\r\n\r\n const target = this.props.target;\r\n const initialValue = target[this.props.propertyName];\r\n const value = typeof target[this.props.propertyName] === \"string\" ? setColor.toHexString() : setColor;\r\n // make the change\r\n target[this.props.propertyName] = value;\r\n // notify observers\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: target,\r\n property: this.props.propertyName,\r\n value,\r\n initialValue,\r\n });\r\n }\r\n\r\n if (this.props.onChange) {\r\n this.props.onChange();\r\n }\r\n }\r\n\r\n switchExpandState() {\r\n this.setState({ isExpanded: !this.state.isExpanded });\r\n }\r\n\r\n updateStateR(value: number) {\r\n this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateG(value: number) {\r\n this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));\r\n }\r\n\r\n updateStateB(value: number) {\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));\r\n }\r\n\r\n updateStateA(value: number) {\r\n if (this.props.disableAlpha) {\r\n return;\r\n }\r\n this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));\r\n }\r\n\r\n copyToClipboard() {\r\n const element = document.createElement(\"div\");\r\n element.textContent = this.state.color.toHexString();\r\n document.body.appendChild(element);\r\n\r\n if (window.getSelection) {\r\n const range = document.createRange();\r\n range.selectNode(element);\r\n window.getSelection()!.removeAllRanges();\r\n window.getSelection()!.addRange(range);\r\n }\r\n\r\n document.execCommand(\"copy\");\r\n element.remove();\r\n }\r\n\r\n private _convertToColor(color: string): Color4 {\r\n if (color === \"\" || color === \"transparent\") {\r\n return EmptyColor;\r\n }\r\n\r\n if (color.substring(0, 1) !== \"#\" || (color.length !== 7 && color.length !== 9)) {\r\n const d = document.createElement(\"div\");\r\n d.style.color = color;\r\n document.body.append(d);\r\n const rgb = window.getComputedStyle(d).color;\r\n document.body.removeChild(d);\r\n\r\n const rgbArray = rgb\r\n .substring(4, rgb.length - 1)\r\n .replace(/ /g, \"\")\r\n .split(\",\");\r\n\r\n const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;\r\n\r\n return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);\r\n }\r\n\r\n if (this.props.disableAlpha) {\r\n const color3 = Color3.FromHexString(color);\r\n return new Color4(color3.r, color3.g, color3.b, 1.0);\r\n }\r\n\r\n return Color4.FromHexString(color);\r\n }\r\n\r\n private _toColor3(color: Color4) {\r\n return new Color3(color.r, color.g, color.b);\r\n }\r\n\r\n override render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className={style.color3Line}>\r\n <div className={style.firstLine}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className={style.label} title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className={style.color3}>\r\n <ColorPickerLineComponent\r\n lockObject={this.props.lockObject}\r\n linearHint={this.props.isLinear}\r\n value={this.props.disableAlpha ? this._toColor3(this.state.color) : this.state.color}\r\n onColorChanged={(colorString) => {\r\n this.setColorFromString(colorString);\r\n }}\r\n />\r\n </div>\r\n <div className={JoinClassNames(style, \"copy\", \"hoverIcon\")} onClick={() => this.copyToClipboard()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n <div className={JoinClassNames(\"expand\", \"hoverIcon\")} onClick={() => this.switchExpandState()} title=\"Expand\">\r\n {chevron}\r\n </div>\r\n </div>\r\n {this.state.isExpanded && (\r\n <div className={style.secondLine}>\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"r\"\r\n labelTooltip=\"Red\"\r\n value={this.state.color.r}\r\n onChange={(value) => this.updateStateR(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"g\"\r\n labelTooltip=\"Green\"\r\n value={this.state.color.g}\r\n onChange={(value) => this.updateStateG(value)}\r\n />\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"b\"\r\n labelTooltip=\"Blue\"\r\n value={this.state.color.b}\r\n onChange={(value) => this.updateStateB(value)}\r\n />\r\n {this.props.disableAlpha || (\r\n <NumericInputComponent\r\n lockObject={this.props.lockObject}\r\n label=\"a\"\r\n labelTooltip=\"Alpha\"\r\n value={this.state.color.a}\r\n onChange={(value) => this.updateStateA(value)}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
@@ -1,67 +0,0 @@
1
- .color3Line {
2
- display: grid;
3
- }
4
-
5
- .firstLine {
6
- display: flex;
7
- align-items: center;
8
- }
9
-
10
- .color3 {
11
- display: flex;
12
- align-items: center;
13
-
14
- input {
15
- margin-right: 5px;
16
- }
17
- }
18
-
19
- .label {
20
- padding-right: 5px;
21
- }
22
-
23
- .floatLine {
24
- .value {
25
- padding-left: 2px;
26
- }
27
- }
28
-
29
- .hoverIcon:hover {
30
- opacity: 0.8;
31
- }
32
-
33
- .copy {
34
- display: none;
35
- }
36
-
37
- .expand {
38
- display: none;
39
- }
40
-
41
- .secondLine {
42
- display: grid;
43
- padding-right: 5px;
44
- border-left: 1px solid rgb(51, 122, 183);
45
- }
46
-
47
- .numeric {
48
- display: grid;
49
- grid-template-columns: 1fr auto;
50
- }
51
-
52
- .numeric-label {
53
- text-align: right;
54
- grid-column: 1;
55
- display: flex;
56
- align-items: center;
57
- justify-self: right;
58
- margin-right: 10px;
59
- }
60
-
61
- .numeric-value {
62
- width: 120px;
63
- grid-column: 2;
64
- display: flex;
65
- align-items: center;
66
- border: 1px solid rgb(51, 122, 183);
67
- }
@@ -1,11 +0,0 @@
1
- import * as React from "react";
2
- export interface IIconButtonLineComponentProps {
3
- icon: string;
4
- onClick: () => void;
5
- tooltip: string;
6
- active?: boolean;
7
- }
8
- export declare class IconButtonLineComponent extends React.Component<IIconButtonLineComponentProps> {
9
- constructor(props: IIconButtonLineComponentProps);
10
- render(): import("react/jsx-runtime").JSX.Element;
11
- }
@@ -1,11 +0,0 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import * as React from "react";
3
- export class IconButtonLineComponent extends React.Component {
4
- constructor(props) {
5
- super(props);
6
- }
7
- render() {
8
- return (_jsx("div", { style: { backgroundColor: this.props.active ? "#111111" : "" }, title: this.props.tooltip, className: `icon ${this.props.icon}`, onClick: () => this.props.onClick() }));
9
- }
10
- }
11
- //# sourceMappingURL=iconButtonLineComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"iconButtonLineComponent.js","sourceRoot":"","sources":["../../../../dev/sharedUiComponents/src/lines/iconButtonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,MAAM,OAAO,uBAAwB,SAAQ,KAAK,CAAC,SAAwC;IACvF,YAAY,KAAoC;QAC5C,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAEQ,MAAM;QACX,OAAO,CACH,cACI,KAAK,EAAE,EAAE,eAAe,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,EAC9D,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EACzB,SAAS,EAAE,QAAQ,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EACpC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GACrC,CACL,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\nexport interface IIconButtonLineComponentProps {\r\n icon: string;\r\n onClick: () => void;\r\n tooltip: string;\r\n active?: boolean;\r\n}\r\n\r\nexport class IconButtonLineComponent extends React.Component<IIconButtonLineComponentProps> {\r\n constructor(props: IIconButtonLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n override render() {\r\n return (\r\n <div\r\n style={{ backgroundColor: this.props.active ? \"#111111\" : \"\" }}\r\n title={this.props.tooltip}\r\n className={`icon ${this.props.icon}`}\r\n onClick={() => this.props.onClick()}\r\n />\r\n );\r\n }\r\n}\r\n"]}