@babylonjs/shared-ui-components 5.28.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/colorPicker/colorComponentEntry.d.ts +18 -0
- package/colorPicker/colorComponentEntry.js +37 -0
- package/colorPicker/colorComponentEntry.js.map +1 -0
- package/colorPicker/colorPicker.d.ts +43 -0
- package/colorPicker/colorPicker.js +137 -0
- package/colorPicker/colorPicker.js.map +1 -0
- package/colorPicker/hexColor.d.ts +20 -0
- package/colorPicker/hexColor.js +43 -0
- package/colorPicker/hexColor.js.map +1 -0
- package/components/Button.d.ts +10 -0
- package/components/Button.js +7 -0
- package/components/Button.js.map +1 -0
- package/components/Icon.d.ts +6 -0
- package/components/Icon.js +7 -0
- package/components/Icon.js.map +1 -0
- package/components/Label.d.ts +7 -0
- package/components/Label.js +7 -0
- package/components/Label.js.map +1 -0
- package/components/MessageDialog.d.ts +7 -0
- package/components/MessageDialog.js +23 -0
- package/components/MessageDialog.js.map +1 -0
- package/components/Toggle.d.ts +8 -0
- package/components/Toggle.js +16 -0
- package/components/Toggle.js.map +1 -0
- package/components/bars/CommandBarComponent.d.ts +16 -0
- package/components/bars/CommandBarComponent.js +69 -0
- package/components/bars/CommandBarComponent.js.map +1 -0
- package/components/bars/CommandButtonComponent.d.ts +11 -0
- package/components/bars/CommandButtonComponent.js +7 -0
- package/components/bars/CommandButtonComponent.js.map +1 -0
- package/components/bars/CommandDropdownComponent.d.ts +26 -0
- package/components/bars/CommandDropdownComponent.js +49 -0
- package/components/bars/CommandDropdownComponent.js.map +1 -0
- package/components/classNames.d.ts +2 -0
- package/components/classNames.js +19 -0
- package/components/classNames.js.map +1 -0
- package/components/colorPicker/ColorComponentEntry.d.ts +18 -0
- package/components/colorPicker/ColorComponentEntry.js +38 -0
- package/components/colorPicker/ColorComponentEntry.js.map +1 -0
- package/components/colorPicker/ColorPicker.d.ts +43 -0
- package/components/colorPicker/ColorPicker.js +138 -0
- package/components/colorPicker/ColorPicker.js.map +1 -0
- package/components/colorPicker/HexColor.d.ts +20 -0
- package/components/colorPicker/HexColor.js +46 -0
- package/components/colorPicker/HexColor.js.map +1 -0
- package/components/lines/ColorLineComponent.d.ts +40 -0
- package/components/lines/ColorLineComponent.js +146 -0
- package/components/lines/ColorLineComponent.js.map +1 -0
- package/components/lines/ColorPickerLineComponent.d.ts +33 -0
- package/components/lines/ColorPickerLineComponent.js +62 -0
- package/components/lines/ColorPickerLineComponent.js.map +1 -0
- package/components/lines/FileButtonLineComponent.d.ts +16 -0
- package/components/lines/FileButtonLineComponent.js +22 -0
- package/components/lines/FileButtonLineComponent.js.map +1 -0
- package/components/lines/NumericInputComponent.d.ts +31 -0
- package/components/lines/NumericInputComponent.js +87 -0
- package/components/lines/NumericInputComponent.js.map +1 -0
- package/license.md +71 -0
- package/lines/booleanLineComponent.d.ts +11 -0
- package/lines/booleanLineComponent.js +15 -0
- package/lines/booleanLineComponent.js.map +1 -0
- package/lines/buttonLineComponent.d.ts +12 -0
- package/lines/buttonLineComponent.js +11 -0
- package/lines/buttonLineComponent.js.map +1 -0
- package/lines/checkBoxLineComponent.d.ts +36 -0
- package/lines/checkBoxLineComponent.js +89 -0
- package/lines/checkBoxLineComponent.js.map +1 -0
- package/lines/color3LineComponent.d.ts +18 -0
- package/lines/color3LineComponent.js +10 -0
- package/lines/color3LineComponent.js.map +1 -0
- package/lines/color4LineComponent.d.ts +18 -0
- package/lines/color4LineComponent.js +10 -0
- package/lines/color4LineComponent.js.map +1 -0
- package/lines/colorLineComponent.d.ts +40 -0
- package/lines/colorLineComponent.js +145 -0
- package/lines/colorLineComponent.js.map +1 -0
- package/lines/colorPickerComponent.d.ts +31 -0
- package/lines/colorPickerComponent.js +61 -0
- package/lines/colorPickerComponent.js.map +1 -0
- package/lines/draggableLineComponent.d.ts +9 -0
- package/lines/draggableLineComponent.js +13 -0
- package/lines/draggableLineComponent.js.map +1 -0
- package/lines/fileButtonLineComponent.d.ts +17 -0
- package/lines/fileButtonLineComponent.js +21 -0
- package/lines/fileButtonLineComponent.js.map +1 -0
- package/lines/fileMultipleButtonLineComponent.d.ts +17 -0
- package/lines/fileMultipleButtonLineComponent.js +21 -0
- package/lines/fileMultipleButtonLineComponent.js.map +1 -0
- package/lines/floatLineComponent.d.ts +50 -0
- package/lines/floatLineComponent.js +176 -0
- package/lines/floatLineComponent.js.map +1 -0
- package/lines/hexLineComponent.d.ts +40 -0
- package/lines/hexLineComponent.js +122 -0
- package/lines/hexLineComponent.js.map +1 -0
- package/lines/iSelectedLineContainer.d.ts +4 -0
- package/lines/iSelectedLineContainer.js +2 -0
- package/lines/iSelectedLineContainer.js.map +1 -0
- package/lines/iconButtonLineComponent.d.ts +11 -0
- package/lines/iconButtonLineComponent.js +11 -0
- package/lines/iconButtonLineComponent.js.map +1 -0
- package/lines/iconComponent.d.ts +9 -0
- package/lines/iconComponent.js +8 -0
- package/lines/iconComponent.js.map +1 -0
- package/lines/indentedTextLineComponent.d.ts +16 -0
- package/lines/indentedTextLineComponent.js +27 -0
- package/lines/indentedTextLineComponent.js.map +1 -0
- package/lines/inputArrowsComponent.d.ts +13 -0
- package/lines/inputArrowsComponent.js +38 -0
- package/lines/inputArrowsComponent.js.map +1 -0
- package/lines/lineContainerComponent.d.ts +19 -0
- package/lines/lineContainerComponent.js +50 -0
- package/lines/lineContainerComponent.js.map +1 -0
- package/lines/linkButtonComponent.d.ts +16 -0
- package/lines/linkButtonComponent.js +21 -0
- package/lines/linkButtonComponent.js.map +1 -0
- package/lines/matrixLineComponent.d.ts +36 -0
- package/lines/matrixLineComponent.js +103 -0
- package/lines/matrixLineComponent.js.map +1 -0
- package/lines/messageLineComponent.d.ts +12 -0
- package/lines/messageLineComponent.js +15 -0
- package/lines/messageLineComponent.js.map +1 -0
- package/lines/numericInputComponent.d.ts +31 -0
- package/lines/numericInputComponent.js +86 -0
- package/lines/numericInputComponent.js.map +1 -0
- package/lines/optionsLineComponent.d.ts +48 -0
- package/lines/optionsLineComponent.js +119 -0
- package/lines/optionsLineComponent.js.map +1 -0
- package/lines/popup.d.ts +4 -0
- package/lines/popup.js +68 -0
- package/lines/popup.js.map +1 -0
- package/lines/radioLineComponent.d.ts +21 -0
- package/lines/radioLineComponent.js +27 -0
- package/lines/radioLineComponent.js.map +1 -0
- package/lines/sliderLineComponent.d.ts +37 -0
- package/lines/sliderLineComponent.js +90 -0
- package/lines/sliderLineComponent.js.map +1 -0
- package/lines/targetsProxy.d.ts +11 -0
- package/lines/targetsProxy.js +43 -0
- package/lines/targetsProxy.js.map +1 -0
- package/lines/textInputLineComponent.d.ts +47 -0
- package/lines/textInputLineComponent.js +155 -0
- package/lines/textInputLineComponent.js.map +1 -0
- package/lines/textLineComponent.d.ts +21 -0
- package/lines/textLineComponent.js +31 -0
- package/lines/textLineComponent.js.map +1 -0
- package/lines/unitButton.d.ts +8 -0
- package/lines/unitButton.js +8 -0
- package/lines/unitButton.js.map +1 -0
- package/lines/valueLineComponent.d.ts +15 -0
- package/lines/valueLineComponent.js +13 -0
- package/lines/valueLineComponent.js.map +1 -0
- package/lines/vector2LineComponent.d.ts +36 -0
- package/lines/vector2LineComponent.js +64 -0
- package/lines/vector2LineComponent.js.map +1 -0
- package/lines/vector3LineComponent.d.ts +41 -0
- package/lines/vector3LineComponent.js +75 -0
- package/lines/vector3LineComponent.js.map +1 -0
- package/lines/vector4LineComponent.d.ts +42 -0
- package/lines/vector4LineComponent.js +82 -0
- package/lines/vector4LineComponent.js.map +1 -0
- package/nodeGraphSystem/displayLedger.d.ts +5 -0
- package/nodeGraphSystem/displayLedger.js +4 -0
- package/nodeGraphSystem/displayLedger.js.map +1 -0
- package/nodeGraphSystem/frameNodePort.d.ts +25 -0
- package/nodeGraphSystem/frameNodePort.js +60 -0
- package/nodeGraphSystem/frameNodePort.js.map +1 -0
- package/nodeGraphSystem/graphCanvas.d.ts +111 -0
- package/nodeGraphSystem/graphCanvas.js +1132 -0
- package/nodeGraphSystem/graphCanvas.js.map +1 -0
- package/nodeGraphSystem/graphFrame.d.ts +153 -0
- package/nodeGraphSystem/graphFrame.js +1329 -0
- package/nodeGraphSystem/graphFrame.js.map +1 -0
- package/nodeGraphSystem/graphNode.d.ts +79 -0
- package/nodeGraphSystem/graphNode.js +460 -0
- package/nodeGraphSystem/graphNode.js.map +1 -0
- package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -0
- package/nodeGraphSystem/interfaces/displayManager.js +2 -0
- package/nodeGraphSystem/interfaces/displayManager.js.map +1 -0
- package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -0
- package/nodeGraphSystem/interfaces/nodeContainer.js +2 -0
- package/nodeGraphSystem/interfaces/nodeContainer.js.map +1 -0
- package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -0
- package/nodeGraphSystem/interfaces/nodeData.js +2 -0
- package/nodeGraphSystem/interfaces/nodeData.js.map +1 -0
- package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -0
- package/nodeGraphSystem/interfaces/nodeLocationInfo.js +2 -0
- package/nodeGraphSystem/interfaces/nodeLocationInfo.js.map +1 -0
- package/nodeGraphSystem/interfaces/portData.d.ts +28 -0
- package/nodeGraphSystem/interfaces/portData.js +8 -0
- package/nodeGraphSystem/interfaces/portData.js.map +1 -0
- package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -0
- package/nodeGraphSystem/interfaces/propertyComponentProps.js +2 -0
- package/nodeGraphSystem/interfaces/propertyComponentProps.js.map +1 -0
- package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -0
- package/nodeGraphSystem/interfaces/selectionChangedOptions.js +2 -0
- package/nodeGraphSystem/interfaces/selectionChangedOptions.js.map +1 -0
- package/nodeGraphSystem/nodeLink.d.ts +31 -0
- package/nodeGraphSystem/nodeLink.js +183 -0
- package/nodeGraphSystem/nodeLink.js.map +1 -0
- package/nodeGraphSystem/nodePort.d.ts +35 -0
- package/nodeGraphSystem/nodePort.js +129 -0
- package/nodeGraphSystem/nodePort.js.map +1 -0
- package/nodeGraphSystem/propertyLedger.d.ts +8 -0
- package/nodeGraphSystem/propertyLedger.js +4 -0
- package/nodeGraphSystem/propertyLedger.js.map +1 -0
- package/nodeGraphSystem/stateManager.d.ts +45 -0
- package/nodeGraphSystem/stateManager.js +19 -0
- package/nodeGraphSystem/stateManager.js.map +1 -0
- package/nodeGraphSystem/tools.d.ts +5 -0
- package/nodeGraphSystem/tools.js +37 -0
- package/nodeGraphSystem/tools.js.map +1 -0
- package/nodeGraphSystem/typeLedger.d.ts +8 -0
- package/nodeGraphSystem/typeLedger.js +3 -0
- package/nodeGraphSystem/typeLedger.js.map +1 -0
- package/nodeGraphSystem/types/framePortData.d.ts +7 -0
- package/nodeGraphSystem/types/framePortData.js +2 -0
- package/nodeGraphSystem/types/framePortData.js.map +1 -0
- package/package.json +55 -0
- package/propertyChangedEvent.d.ts +7 -0
- package/propertyChangedEvent.js +3 -0
- package/propertyChangedEvent.js.map +1 -0
- package/readme.md +6 -0
- package/stories/Button.stories.d.ts +10 -0
- package/stories/Button.stories.js +20 -0
- package/stories/Button.stories.js.map +1 -0
- package/stories/Icon.stories.d.ts +9 -0
- package/stories/Icon.stories.js +17 -0
- package/stories/Icon.stories.js.map +1 -0
- package/stories/Label.stories.d.ts +8 -0
- package/stories/Label.stories.js +11 -0
- package/stories/Label.stories.js.map +1 -0
- package/stories/MessageDialog.stories.d.ts +9 -0
- package/stories/MessageDialog.stories.js +20 -0
- package/stories/MessageDialog.stories.js.map +1 -0
- package/stories/Toggle.stories.d.ts +9 -0
- package/stories/Toggle.stories.js +18 -0
- package/stories/Toggle.stories.js.map +1 -0
- package/stories/bars/CommandBarComponent.stories.d.ts +11 -0
- package/stories/bars/CommandBarComponent.stories.js +13 -0
- package/stories/bars/CommandBarComponent.stories.js.map +1 -0
- package/stories/bars/CommandButtonComponent.stories.d.ts +6 -0
- package/stories/bars/CommandButtonComponent.stories.js +7 -0
- package/stories/bars/CommandButtonComponent.stories.js.map +1 -0
- package/stories/colorPicker/ColorPicker.stories.d.ts +11 -0
- package/stories/colorPicker/ColorPicker.stories.js +5 -0
- package/stories/colorPicker/ColorPicker.stories.js.map +1 -0
- package/stories/lines/ColorLineComponent.stories.d.ts +21 -0
- package/stories/lines/ColorLineComponent.stories.js +10 -0
- package/stories/lines/ColorLineComponent.stories.js.map +1 -0
- package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -0
- package/stories/lines/ColorPickerLineComponent.stories.js +11 -0
- package/stories/lines/ColorPickerLineComponent.stories.js.map +1 -0
- package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -0
- package/stories/lines/FileButtonLineComponent.stories.js +6 -0
- package/stories/lines/FileButtonLineComponent.stories.js.map +1 -0
- package/stories/lines/NumericInputComponent.stories.d.ts +11 -0
- package/stories/lines/NumericInputComponent.stories.js +6 -0
- package/stories/lines/NumericInputComponent.stories.js.map +1 -0
- package/stringTools.d.ts +11 -0
- package/stringTools.js +89 -0
- package/stringTools.js.map +1 -0
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +16 -0
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +15 -0
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -0
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +56 -0
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +13 -0
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +16 -0
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -0
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +39 -0
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +17 -0
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +26 -0
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +18 -0
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -0
- package/tabs/propertyGrids/gui/linePropertyGridComponent.js +28 -0
- package/tabs/propertyGrids/gui/linePropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +18 -0
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +16 -0
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +16 -0
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +17 -0
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +15 -0
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -0
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +35 -0
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js.map +1 -0
- package/tabs/propertyGrids/lockObject.d.ts +9 -0
- package/tabs/propertyGrids/lockObject.js +12 -0
- package/tabs/propertyGrids/lockObject.js.map +1 -0
@@ -0,0 +1,11 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
export class ButtonLineComponent extends React.Component {
|
4
|
+
constructor(props) {
|
5
|
+
super(props);
|
6
|
+
}
|
7
|
+
render() {
|
8
|
+
return (_jsxs("div", { className: "buttonLine" + (this.props.isDisabled ? " disabled" : ""), children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("button", { onClick: () => this.props.onClick(), children: this.props.label })] }));
|
9
|
+
}
|
10
|
+
}
|
11
|
+
//# sourceMappingURL=buttonLineComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"buttonLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/buttonLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAU/B,MAAM,OAAO,mBAAoB,SAAQ,KAAK,CAAC,SAAoC;IAC/E,YAAY,KAAgC;QACxC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,OAAO,CACH,eAAK,SAAS,EAAE,YAAY,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,aACpE,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,cAAK,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,SAAS,EAAE,SAAS,EAAC,MAAM,GAAG,EAC1H,iBAAQ,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,YAAG,IAAI,CAAC,KAAK,CAAC,KAAK,GAAU,IACtE,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\nexport interface IButtonLineComponentProps {\r\n label: string;\r\n onClick: () => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n isDisabled?: boolean;\r\n}\r\n\r\nexport class ButtonLineComponent extends React.Component<IButtonLineComponentProps> {\r\n constructor(props: IButtonLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n return (\r\n <div className={\"buttonLine\" + (this.props.isDisabled ? \" disabled\" : \"\")}>\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <button onClick={() => this.props.onClick()}>{this.props.label}</button>\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
3
|
+
import type { PropertyChangedEvent } from "./../propertyChangedEvent";
|
4
|
+
import type { IconDefinition } from "@fortawesome/fontawesome-common-types";
|
5
|
+
export interface ICheckBoxLineComponentProps {
|
6
|
+
label?: string;
|
7
|
+
target?: any;
|
8
|
+
propertyName?: string;
|
9
|
+
isSelected?: () => boolean;
|
10
|
+
onSelect?: (value: boolean) => void;
|
11
|
+
onValueChanged?: () => void;
|
12
|
+
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
13
|
+
disabled?: boolean;
|
14
|
+
icon?: string;
|
15
|
+
iconLabel?: string;
|
16
|
+
faIcons?: {
|
17
|
+
enabled: IconDefinition;
|
18
|
+
disabled: IconDefinition;
|
19
|
+
};
|
20
|
+
large?: boolean;
|
21
|
+
}
|
22
|
+
export declare class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, {
|
23
|
+
isSelected: boolean;
|
24
|
+
isDisabled?: boolean;
|
25
|
+
isConflict: boolean;
|
26
|
+
}> {
|
27
|
+
private _localChange;
|
28
|
+
constructor(props: ICheckBoxLineComponentProps);
|
29
|
+
shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: {
|
30
|
+
isSelected: boolean;
|
31
|
+
isDisabled: boolean;
|
32
|
+
isConflict: boolean;
|
33
|
+
}): boolean;
|
34
|
+
onChange(): void;
|
35
|
+
render(): JSX.Element;
|
36
|
+
}
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
4
|
+
import { conflictingValuesPlaceholder } from "./targetsProxy.js";
|
5
|
+
import toggleOnIcon_40px from "../imgs/toggleOnIcon_40px.svg";
|
6
|
+
import toggleOffIcon_40px from "../imgs/toggleOffIcon_40px.svg";
|
7
|
+
import toggleOnIcon_30px from "../imgs/toggleOnIcon_30px.svg";
|
8
|
+
import toggleMixedIcon_30px from "../imgs/toggleMixedIcon_30px.svg";
|
9
|
+
import toggleOffIcon_30px from "../imgs/toggleOffIcon_30px.svg";
|
10
|
+
const Icons = {
|
11
|
+
size30: {
|
12
|
+
on: toggleOnIcon_30px,
|
13
|
+
mixed: toggleMixedIcon_30px,
|
14
|
+
off: toggleOffIcon_30px,
|
15
|
+
},
|
16
|
+
size40: {
|
17
|
+
on: toggleOnIcon_40px,
|
18
|
+
mixed: "",
|
19
|
+
off: toggleOffIcon_40px,
|
20
|
+
},
|
21
|
+
};
|
22
|
+
export class CheckBoxLineComponent extends React.Component {
|
23
|
+
constructor(props) {
|
24
|
+
super(props);
|
25
|
+
this._localChange = false;
|
26
|
+
if (this.props.isSelected) {
|
27
|
+
this.state = { isSelected: this.props.isSelected(), isConflict: false };
|
28
|
+
}
|
29
|
+
else {
|
30
|
+
this.state = {
|
31
|
+
isSelected: this.props.target[this.props.propertyName] === true,
|
32
|
+
isConflict: this.props.target[this.props.propertyName] === conflictingValuesPlaceholder,
|
33
|
+
};
|
34
|
+
}
|
35
|
+
if (this.props.disabled) {
|
36
|
+
this.state = { ...this.state, isDisabled: this.props.disabled };
|
37
|
+
}
|
38
|
+
}
|
39
|
+
shouldComponentUpdate(nextProps, nextState) {
|
40
|
+
let selected;
|
41
|
+
if (nextProps.isSelected) {
|
42
|
+
selected = nextProps.isSelected();
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
selected = nextProps.target[nextProps.propertyName] === true;
|
46
|
+
if (nextProps.target[nextProps.propertyName] === conflictingValuesPlaceholder) {
|
47
|
+
nextState.isConflict = true;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
if (selected !== nextState.isSelected || this._localChange) {
|
51
|
+
nextState.isSelected = selected;
|
52
|
+
this._localChange = false;
|
53
|
+
return true;
|
54
|
+
}
|
55
|
+
if (nextProps.disabled !== nextState.isDisabled) {
|
56
|
+
return true;
|
57
|
+
}
|
58
|
+
return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;
|
59
|
+
}
|
60
|
+
onChange() {
|
61
|
+
this._localChange = true;
|
62
|
+
if (this.props.onSelect) {
|
63
|
+
this.props.onSelect(!this.state.isSelected);
|
64
|
+
}
|
65
|
+
else {
|
66
|
+
if (this.props.onPropertyChangedObservable) {
|
67
|
+
this.props.onPropertyChangedObservable.notifyObservers({
|
68
|
+
object: this.props.target,
|
69
|
+
property: this.props.propertyName,
|
70
|
+
value: !this.state.isSelected,
|
71
|
+
initialValue: this.state.isSelected,
|
72
|
+
});
|
73
|
+
}
|
74
|
+
if (this.props.target && this.props.propertyName) {
|
75
|
+
this.props.target[this.props.propertyName] = !this.state.isSelected;
|
76
|
+
}
|
77
|
+
}
|
78
|
+
if (this.props.onValueChanged) {
|
79
|
+
this.props.onValueChanged();
|
80
|
+
}
|
81
|
+
this.setState({ isSelected: !this.state.isSelected, isConflict: false });
|
82
|
+
}
|
83
|
+
render() {
|
84
|
+
const icons = this.props.large ? Icons.size40 : Icons.size30;
|
85
|
+
const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;
|
86
|
+
return (_jsxs("div", { className: "checkBoxLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), this.props.label && (_jsx("div", { className: "label", title: this.props.iconLabel, children: this.props.label })), this.props.faIcons && (_jsx(FontAwesomeIcon, { className: `cbx ${this.props.disabled ? "disabled" : ""}`, icon: this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled, onClick: () => !this.props.disabled && this.onChange() })), !this.props.faIcons && (_jsx("div", { className: "checkBox", children: _jsxs("label", { className: `container lbl${this.props.disabled ? " disabled" : ""} ${this.state.isSelected ? "checked" : ""}`, children: [_jsx("input", { type: "checkbox", className: `cbx hidden ${this.state.isConflict ? "conflict" : ""}`, checked: this.state.isSelected, onChange: () => this.onChange(), disabled: !!this.props.disabled }), _jsx("img", { className: "icon", src: icon, alt: this.props.label })] }) }))] }));
|
87
|
+
}
|
88
|
+
}
|
89
|
+
//# sourceMappingURL=checkBoxLineComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"checkBoxLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/checkBox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,EAClE,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,QAAQ,EAAE,EAC/B,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,QAAQ,GACjC,EACF,cAAK,SAAS,EAAC,MAAM,EAAC,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,GAAI,IACtD,GACN,CACT,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"./../propertyChangedEvent\";\r\nimport type { IconDefinition } from \"@fortawesome/fontawesome-common-types\";\r\nimport { FontAwesomeIcon } from \"@fortawesome/react-fontawesome\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\n\r\nexport interface ICheckBoxLineComponentProps {\r\n label?: string;\r\n target?: any;\r\n propertyName?: string;\r\n isSelected?: () => boolean;\r\n onSelect?: (value: boolean) => void;\r\n onValueChanged?: () => void;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n disabled?: boolean;\r\n icon?: string;\r\n iconLabel?: string;\r\n faIcons?: { enabled: IconDefinition; disabled: IconDefinition };\r\n large?: boolean;\r\n}\r\n\r\nimport toggleOnIcon_40px from \"../imgs/toggleOnIcon_40px.svg\";\r\nimport toggleOffIcon_40px from \"../imgs/toggleOffIcon_40px.svg\";\r\nimport toggleOnIcon_30px from \"../imgs/toggleOnIcon_30px.svg\";\r\nimport toggleMixedIcon_30px from \"../imgs/toggleMixedIcon_30px.svg\";\r\nimport toggleOffIcon_30px from \"../imgs/toggleOffIcon_30px.svg\";\r\n\r\nconst Icons = {\r\n size30: {\r\n on: toggleOnIcon_30px,\r\n mixed: toggleMixedIcon_30px,\r\n off: toggleOffIcon_30px,\r\n },\r\n size40: {\r\n on: toggleOnIcon_40px,\r\n mixed: \"\", // unneeded\r\n off: toggleOffIcon_40px,\r\n },\r\n};\r\n\r\nexport class CheckBoxLineComponent extends React.Component<ICheckBoxLineComponentProps, { isSelected: boolean; isDisabled?: boolean; isConflict: boolean }> {\r\n private _localChange = false;\r\n constructor(props: ICheckBoxLineComponentProps) {\r\n super(props);\r\n\r\n if (this.props.isSelected) {\r\n this.state = { isSelected: this.props.isSelected(), isConflict: false };\r\n } else {\r\n this.state = {\r\n isSelected: this.props.target[this.props.propertyName!] === true,\r\n isConflict: this.props.target[this.props.propertyName!] === conflictingValuesPlaceholder,\r\n };\r\n }\r\n\r\n if (this.props.disabled) {\r\n this.state = { ...this.state, isDisabled: this.props.disabled };\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: ICheckBoxLineComponentProps, nextState: { isSelected: boolean; isDisabled: boolean; isConflict: boolean }) {\r\n let selected: boolean;\r\n\r\n if (nextProps.isSelected) {\r\n selected = nextProps.isSelected!();\r\n } else {\r\n selected = nextProps.target[nextProps.propertyName!] === true;\r\n if (nextProps.target[nextProps.propertyName!] === conflictingValuesPlaceholder) {\r\n nextState.isConflict = true;\r\n }\r\n }\r\n\r\n if (selected !== nextState.isSelected || this._localChange) {\r\n nextState.isSelected = selected;\r\n this._localChange = false;\r\n return true;\r\n }\r\n\r\n if (nextProps.disabled !== nextState.isDisabled) {\r\n return true;\r\n }\r\n\r\n return nextProps.label !== this.props.label || nextProps.target !== this.props.target || nextState.isConflict !== this.state.isConflict;\r\n }\r\n\r\n onChange() {\r\n this._localChange = true;\r\n if (this.props.onSelect) {\r\n this.props.onSelect(!this.state.isSelected);\r\n } else {\r\n if (this.props.onPropertyChangedObservable) {\r\n this.props.onPropertyChangedObservable.notifyObservers({\r\n object: this.props.target,\r\n property: this.props.propertyName!,\r\n value: !this.state.isSelected,\r\n initialValue: this.state.isSelected,\r\n });\r\n }\r\n\r\n if (this.props.target && this.props.propertyName) {\r\n this.props.target[this.props.propertyName!] = !this.state.isSelected;\r\n }\r\n }\r\n\r\n if (this.props.onValueChanged) {\r\n this.props.onValueChanged();\r\n }\r\n\r\n this.setState({ isSelected: !this.state.isSelected, isConflict: false });\r\n }\r\n\r\n render() {\r\n const icons = this.props.large ? Icons.size40 : Icons.size30;\r\n const icon = this.state.isConflict ? icons.mixed : this.state.isSelected ? icons.on : icons.off;\r\n return (\r\n <div className=\"checkBoxLine\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n {this.props.label && (\r\n <div className=\"label\" title={this.props.iconLabel}>\r\n {this.props.label}\r\n </div>\r\n )}\r\n {this.props.faIcons && (\r\n <FontAwesomeIcon\r\n className={`cbx ${this.props.disabled ? \"disabled\" : \"\"}`}\r\n icon={this.state.isSelected ? this.props.faIcons.enabled : this.props.faIcons.disabled}\r\n onClick={() => !this.props.disabled && this.onChange()}\r\n />\r\n )}\r\n {!this.props.faIcons && (\r\n <div className=\"checkBox\">\r\n <label className={`container lbl${this.props.disabled ? \" disabled\" : \"\"} ${this.state.isSelected ? \"checked\" : \"\"}`}>\r\n <input\r\n type=\"checkbox\"\r\n className={`cbx hidden ${this.state.isConflict ? \"conflict\" : \"\"}`}\r\n checked={this.state.isSelected}\r\n onChange={() => this.onChange()}\r\n disabled={!!this.props.disabled}\r\n />\r\n <img className=\"icon\" src={icon} alt={this.props.label} />\r\n </label>\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
3
|
+
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
4
|
+
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
5
|
+
export interface IColor3LineComponentProps {
|
6
|
+
label: string;
|
7
|
+
target: any;
|
8
|
+
propertyName: string;
|
9
|
+
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
10
|
+
isLinear?: boolean;
|
11
|
+
icon?: string;
|
12
|
+
lockObject: LockObject;
|
13
|
+
iconLabel?: string;
|
14
|
+
onChange?: () => void;
|
15
|
+
}
|
16
|
+
export declare class Color3LineComponent extends React.Component<IColor3LineComponentProps> {
|
17
|
+
render(): JSX.Element;
|
18
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
import { ColorLineComponent } from "./colorLineComponent.js";
|
4
|
+
export class Color3LineComponent extends React.Component {
|
5
|
+
render() {
|
6
|
+
const props = this.props;
|
7
|
+
return _jsx(ColorLineComponent, { disableAlpha: true, ...props });
|
8
|
+
}
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=color3LineComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"color3LineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/color3LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAc1D,MAAM,OAAO,mBAAoB,SAAQ,KAAK,CAAC,SAAoC;IAC/E,MAAM;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,OAAO,KAAC,kBAAkB,IAAC,YAAY,EAAE,IAAI,KAAM,KAAK,GAAI,CAAC;IACjE,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { ColorLineComponent } from \"./colorLineComponent\";\r\n\r\nexport interface IColor3LineComponentProps {\r\n label: string;\r\n target: any;\r\n propertyName: string;\r\n onPropertyChangedObservable?: Observable<PropertyChangedEvent>;\r\n isLinear?: boolean;\r\n icon?: string;\r\n lockObject: LockObject;\r\n iconLabel?: string;\r\n onChange?: () => void;\r\n}\r\n\r\nexport class Color3LineComponent extends React.Component<IColor3LineComponentProps> {\r\n render() {\r\n const props = this.props;\r\n return <ColorLineComponent disableAlpha={true} {...props} />;\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
3
|
+
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
4
|
+
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
5
|
+
export interface IColor4LineComponentProps {
|
6
|
+
label: string;
|
7
|
+
target?: any;
|
8
|
+
propertyName: string;
|
9
|
+
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
10
|
+
onChange?: () => void;
|
11
|
+
isLinear?: boolean;
|
12
|
+
icon?: string;
|
13
|
+
iconLabel?: string;
|
14
|
+
lockObject: LockObject;
|
15
|
+
}
|
16
|
+
export declare class Color4LineComponent extends React.Component<IColor4LineComponentProps> {
|
17
|
+
render(): JSX.Element;
|
18
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
import { ColorLineComponent } from "./colorLineComponent.js";
|
4
|
+
export class Color4LineComponent extends React.Component {
|
5
|
+
render() {
|
6
|
+
const props = this.props;
|
7
|
+
return _jsx(ColorLineComponent, { ...props });
|
8
|
+
}
|
9
|
+
}
|
10
|
+
//# sourceMappingURL=color4LineComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"color4LineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/color4LineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAc1D,MAAM,OAAO,mBAAoB,SAAQ,KAAK,CAAC,SAAoC;IAC/E,MAAM;QACF,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACzB,OAAO,KAAC,kBAAkB,OAAK,KAAK,GAAI,CAAC;IAC7C,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Observable } from \"core/Misc/observable\";\r\nimport type { PropertyChangedEvent } from \"../propertyChangedEvent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { ColorLineComponent } from \"./colorLineComponent\";\r\n\r\nexport interface IColor4LineComponentProps {\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 lockObject: LockObject;\r\n}\r\n\r\nexport class Color4LineComponent extends React.Component<IColor4LineComponentProps> {\r\n render() {\r\n const props = this.props;\r\n return <ColorLineComponent {...props} />;\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import type { Observable } from "@babylonjs/core/Misc/observable.js";
|
3
|
+
import { Color4 } from "@babylonjs/core/Maths/math.color.js";
|
4
|
+
import type { PropertyChangedEvent } from "../propertyChangedEvent";
|
5
|
+
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
6
|
+
export interface IColorLineComponentProps {
|
7
|
+
label: string;
|
8
|
+
target?: any;
|
9
|
+
propertyName: string;
|
10
|
+
onPropertyChangedObservable?: Observable<PropertyChangedEvent>;
|
11
|
+
onChange?: () => void;
|
12
|
+
isLinear?: boolean;
|
13
|
+
icon?: string;
|
14
|
+
iconLabel?: string;
|
15
|
+
disableAlpha?: boolean;
|
16
|
+
lockObject: LockObject;
|
17
|
+
}
|
18
|
+
interface IColorLineComponentState {
|
19
|
+
isExpanded: boolean;
|
20
|
+
color: Color4;
|
21
|
+
}
|
22
|
+
export declare class ColorLineComponent extends React.Component<IColorLineComponentProps, IColorLineComponentState> {
|
23
|
+
constructor(props: IColorLineComponentProps);
|
24
|
+
shouldComponentUpdate(nextProps: IColorLineComponentProps, nextState: IColorLineComponentState): boolean;
|
25
|
+
getValue(props?: Readonly<IColorLineComponentProps> & Readonly<{
|
26
|
+
children?: React.ReactNode;
|
27
|
+
}>): Color4;
|
28
|
+
setColorFromString(colorString: string): void;
|
29
|
+
setColor(newColor: Color4): void;
|
30
|
+
switchExpandState(): void;
|
31
|
+
updateStateR(value: number): void;
|
32
|
+
updateStateG(value: number): void;
|
33
|
+
updateStateB(value: number): void;
|
34
|
+
updateStateA(value: number): void;
|
35
|
+
copyToClipboard(): void;
|
36
|
+
private _convertToColor;
|
37
|
+
private _toColor3;
|
38
|
+
render(): JSX.Element;
|
39
|
+
}
|
40
|
+
export {};
|
@@ -0,0 +1,145 @@
|
|
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 "./colorPickerComponent.js";
|
8
|
+
import { conflictingValuesPlaceholder } from "./targetsProxy.js";
|
9
|
+
import copyIcon from "./copy.svg";
|
10
|
+
const emptyColor = new Color4(0, 0, 0, 0);
|
11
|
+
export class ColorLineComponent extends React.Component {
|
12
|
+
constructor(props) {
|
13
|
+
super(props);
|
14
|
+
this.state = { isExpanded: false, color: this.getValue() };
|
15
|
+
const target = this.props.target;
|
16
|
+
target._isLinearColor = props.isLinear; // so that replayRecorder can append toLinearSpace() as appropriate
|
17
|
+
}
|
18
|
+
shouldComponentUpdate(nextProps, nextState) {
|
19
|
+
const stateColor = nextState.color;
|
20
|
+
const propsColor = this.getValue(nextProps);
|
21
|
+
if (stateColor !== this.state.color) {
|
22
|
+
nextState.color = stateColor;
|
23
|
+
return true;
|
24
|
+
}
|
25
|
+
if (propsColor !== this.state.color) {
|
26
|
+
nextState.color = propsColor;
|
27
|
+
return true;
|
28
|
+
}
|
29
|
+
if (nextState.isExpanded !== this.state.isExpanded) {
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
getValue(props = this.props) {
|
35
|
+
const target = props.target;
|
36
|
+
const property = target[props.propertyName];
|
37
|
+
if (!property)
|
38
|
+
return emptyColor;
|
39
|
+
if (typeof property === "string") {
|
40
|
+
if (property === conflictingValuesPlaceholder) {
|
41
|
+
return emptyColor;
|
42
|
+
}
|
43
|
+
return this._convertToColor(property);
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
if (props.isLinear) {
|
47
|
+
return property.toGammaSpace();
|
48
|
+
}
|
49
|
+
return property.clone();
|
50
|
+
}
|
51
|
+
}
|
52
|
+
setColorFromString(colorString) {
|
53
|
+
const color = this._convertToColor(colorString);
|
54
|
+
this.setColor(color);
|
55
|
+
}
|
56
|
+
setColor(newColor) {
|
57
|
+
this.setState({ color: newColor.clone() });
|
58
|
+
if (this.props.isLinear) {
|
59
|
+
newColor.toLinearSpaceToRef(newColor);
|
60
|
+
}
|
61
|
+
// whether to set properties to color3 or color4
|
62
|
+
const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;
|
63
|
+
const target = this.props.target;
|
64
|
+
const initialValue = target[this.props.propertyName];
|
65
|
+
const value = typeof target[this.props.propertyName] === "string" ? setColor.toHexString() : setColor;
|
66
|
+
// make the change
|
67
|
+
target[this.props.propertyName] = value;
|
68
|
+
// notify observers
|
69
|
+
if (this.props.onPropertyChangedObservable) {
|
70
|
+
this.props.onPropertyChangedObservable.notifyObservers({
|
71
|
+
object: target,
|
72
|
+
property: this.props.propertyName,
|
73
|
+
value,
|
74
|
+
initialValue,
|
75
|
+
});
|
76
|
+
}
|
77
|
+
if (this.props.onChange) {
|
78
|
+
this.props.onChange();
|
79
|
+
}
|
80
|
+
}
|
81
|
+
switchExpandState() {
|
82
|
+
this.setState({ isExpanded: !this.state.isExpanded });
|
83
|
+
}
|
84
|
+
updateStateR(value) {
|
85
|
+
this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));
|
86
|
+
}
|
87
|
+
updateStateG(value) {
|
88
|
+
this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));
|
89
|
+
}
|
90
|
+
updateStateB(value) {
|
91
|
+
this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));
|
92
|
+
}
|
93
|
+
updateStateA(value) {
|
94
|
+
if (this.props.disableAlpha) {
|
95
|
+
return;
|
96
|
+
}
|
97
|
+
this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
|
98
|
+
}
|
99
|
+
copyToClipboard() {
|
100
|
+
const element = document.createElement("div");
|
101
|
+
element.textContent = this.state.color.toHexString();
|
102
|
+
document.body.appendChild(element);
|
103
|
+
if (window.getSelection) {
|
104
|
+
const range = document.createRange();
|
105
|
+
range.selectNode(element);
|
106
|
+
window.getSelection().removeAllRanges();
|
107
|
+
window.getSelection().addRange(range);
|
108
|
+
}
|
109
|
+
document.execCommand("copy");
|
110
|
+
element.remove();
|
111
|
+
}
|
112
|
+
_convertToColor(color) {
|
113
|
+
if (color === "" || color === "transparent") {
|
114
|
+
return emptyColor;
|
115
|
+
}
|
116
|
+
if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
|
117
|
+
const d = document.createElement("div");
|
118
|
+
d.style.color = color;
|
119
|
+
document.body.append(d);
|
120
|
+
const rgb = window.getComputedStyle(d).color;
|
121
|
+
document.body.removeChild(d);
|
122
|
+
const rgbArray = rgb
|
123
|
+
.substring(4, rgb.length - 1)
|
124
|
+
.replace(/ /g, "")
|
125
|
+
.split(",");
|
126
|
+
const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;
|
127
|
+
return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);
|
128
|
+
}
|
129
|
+
if (this.props.disableAlpha) {
|
130
|
+
const color3 = Color3.FromHexString(color);
|
131
|
+
return new Color4(color3.r, color3.g, color3.b, 1.0);
|
132
|
+
}
|
133
|
+
return Color4.FromHexString(color);
|
134
|
+
}
|
135
|
+
_toColor3(color) {
|
136
|
+
return new Color3(color.r, color.g, color.b);
|
137
|
+
}
|
138
|
+
render() {
|
139
|
+
const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
|
140
|
+
return (_jsxs("div", { className: "color3Line", children: [_jsxs("div", { className: "firstLine", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "label", title: this.props.label, children: this.props.label }), _jsx("div", { className: "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) => {
|
141
|
+
this.setColorFromString(colorString);
|
142
|
+
} }) }), _jsx("div", { className: "copy hoverIcon", onClick: () => this.copyToClipboard(), title: "Copy to clipboard", children: _jsx("img", { src: copyIcon, alt: "Copy" }) }), _jsx("div", { className: "expand hoverIcon", onClick: () => this.switchExpandState(), title: "Expand", children: chevron })] }), this.state.isExpanded && (_jsxs("div", { className: "secondLine", children: [_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "r", value: this.state.color.r, onChange: (value) => this.updateStateR(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "g", value: this.state.color.g, onChange: (value) => this.updateStateG(value) }), _jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "b", value: this.state.color.b, onChange: (value) => this.updateStateB(value) }), this.props.disableAlpha || (_jsx(NumericInputComponent, { lockObject: this.props.lockObject, label: "a", value: this.state.color.a, onChange: (value) => this.updateStateA(value) }))] }))] }));
|
143
|
+
}
|
144
|
+
}
|
145
|
+
//# sourceMappingURL=colorLineComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"colorLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/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,wBAAwB,CAAC;AAElE,OAAO,EAAE,4BAA4B,EAAE,MAAM,gBAAgB,CAAC;AAE9D,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,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,CAAC;IAED,qBAAqB,CAAC,SAAmC,EAAE,SAAmC;QAC1F,MAAM,UAAU,GAAG,SAAS,CAAC,KAAK,CAAC;QACnC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,UAAU,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AC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EAChJ,KAAC,qBAAqB,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,EAC/I,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,CACxB,KAAC,qBAAqB,IAAC,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,EAAC,GAAG,EAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,GAAI,CACnJ,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 \"./colorPickerComponent\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\nimport { conflictingValuesPlaceholder } from \"./targetsProxy\";\r\n\r\nimport copyIcon from \"./copy.svg\";\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 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) return emptyColor;\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 render() {\r\n const chevron = this.state.isExpanded ? <FontAwesomeIcon icon={faMinus} /> : <FontAwesomeIcon icon={faPlus} />;\r\n\r\n return (\r\n <div className=\"color3Line\">\r\n <div className=\"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=\"label\" title={this.props.label}>\r\n {this.props.label}\r\n </div>\r\n <div className=\"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=\"copy hoverIcon\" onClick={() => this.copyToClipboard()} title=\"Copy to clipboard\">\r\n <img src={copyIcon} alt=\"Copy\" />\r\n </div>\r\n <div className=\"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=\"secondLine\">\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"r\" value={this.state.color.r} onChange={(value) => this.updateStateR(value)} />\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"g\" value={this.state.color.g} onChange={(value) => this.updateStateG(value)} />\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"b\" value={this.state.color.b} onChange={(value) => this.updateStateB(value)} />\r\n {this.props.disableAlpha || (\r\n <NumericInputComponent lockObject={this.props.lockObject} label=\"a\" value={this.state.color.a} onChange={(value) => this.updateStateA(value)} />\r\n )}\r\n </div>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
import type { Color4, Color3 } from "@babylonjs/core/Maths/math.color.js";
|
3
|
+
import type { LockObject } from "../tabs/propertyGrids/lockObject";
|
4
|
+
export interface IColorPickerComponentProps {
|
5
|
+
value: Color4 | Color3;
|
6
|
+
linearHint?: boolean;
|
7
|
+
onColorChanged: (newOne: string) => void;
|
8
|
+
icon?: string;
|
9
|
+
iconLabel?: string;
|
10
|
+
shouldPopRight?: boolean;
|
11
|
+
lockObject?: LockObject;
|
12
|
+
}
|
13
|
+
interface IColorPickerComponentState {
|
14
|
+
pickerEnabled: boolean;
|
15
|
+
color: Color3 | Color4;
|
16
|
+
hex: string;
|
17
|
+
}
|
18
|
+
export declare class ColorPickerLineComponent extends React.Component<IColorPickerComponentProps, IColorPickerComponentState> {
|
19
|
+
private _floatRef;
|
20
|
+
private _floatHostRef;
|
21
|
+
constructor(props: IColorPickerComponentProps);
|
22
|
+
syncPositions(): void;
|
23
|
+
shouldComponentUpdate(nextProps: IColorPickerComponentProps, nextState: IColorPickerComponentState): boolean;
|
24
|
+
getHexString(props?: Readonly<IColorPickerComponentProps> & Readonly<{
|
25
|
+
children?: React.ReactNode;
|
26
|
+
}>): string;
|
27
|
+
componentDidUpdate(): void;
|
28
|
+
componentDidMount(): void;
|
29
|
+
render(): JSX.Element;
|
30
|
+
}
|
31
|
+
export {};
|
@@ -0,0 +1,61 @@
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
import { ColorPicker } from "../colorPicker/colorPicker.js";
|
4
|
+
export class ColorPickerLineComponent extends React.Component {
|
5
|
+
constructor(props) {
|
6
|
+
super(props);
|
7
|
+
this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };
|
8
|
+
this._floatRef = React.createRef();
|
9
|
+
this._floatHostRef = React.createRef();
|
10
|
+
}
|
11
|
+
syncPositions() {
|
12
|
+
const div = this._floatRef.current;
|
13
|
+
const host = this._floatHostRef.current;
|
14
|
+
if (!div || !host) {
|
15
|
+
return;
|
16
|
+
}
|
17
|
+
let top = host.getBoundingClientRect().top;
|
18
|
+
const height = div.getBoundingClientRect().height;
|
19
|
+
if (top + height + 10 > window.innerHeight) {
|
20
|
+
top = window.innerHeight - height - 10;
|
21
|
+
}
|
22
|
+
div.style.top = top + "px";
|
23
|
+
if (!this.props.shouldPopRight) {
|
24
|
+
div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + "px";
|
25
|
+
}
|
26
|
+
else {
|
27
|
+
div.style.left = host.getBoundingClientRect().left + "px";
|
28
|
+
}
|
29
|
+
}
|
30
|
+
shouldComponentUpdate(nextProps, nextState) {
|
31
|
+
const diffProps = this.getHexString(nextProps) !== this.getHexString();
|
32
|
+
if (diffProps) {
|
33
|
+
nextState.color = nextProps.value;
|
34
|
+
nextState.hex = this.getHexString(nextProps);
|
35
|
+
}
|
36
|
+
return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;
|
37
|
+
}
|
38
|
+
getHexString(props = this.props) {
|
39
|
+
return props.value.toHexString();
|
40
|
+
}
|
41
|
+
componentDidUpdate() {
|
42
|
+
this.syncPositions();
|
43
|
+
}
|
44
|
+
componentDidMount() {
|
45
|
+
this.syncPositions();
|
46
|
+
}
|
47
|
+
render() {
|
48
|
+
return (_jsxs("div", { className: "color-picker", children: [this.props.icon && _jsx("img", { src: this.props.icon, title: this.props.iconLabel, alt: this.props.iconLabel, className: "icon" }), _jsx("div", { className: "color-rect-background", ref: this._floatHostRef, onClick: () => this.setState({ pickerEnabled: true }), children: _jsx("div", { className: "color-rect", style: { background: this.state.hex } }) }), this.state.pickerEnabled && (_jsx(_Fragment, { children: _jsx("div", { className: "color-picker-cover", onClick: (evt) => {
|
49
|
+
var _a, _b;
|
50
|
+
if (evt.target !== ((_b = (_a = this._floatRef.current) === null || _a === void 0 ? void 0 : _a.ownerDocument) === null || _b === void 0 ? void 0 : _b.querySelector(".color-picker-cover"))) {
|
51
|
+
return;
|
52
|
+
}
|
53
|
+
this.setState({ pickerEnabled: false });
|
54
|
+
}, children: _jsx("div", { className: "color-picker-float", ref: this._floatRef, children: _jsx(ColorPicker, { lockObject: this.props.lockObject || {}, color: this.state.color, linearhint: this.props.linearHint, onColorChanged: (color) => {
|
55
|
+
const hex = color.toHexString();
|
56
|
+
this.setState({ hex, color });
|
57
|
+
this.props.onColorChanged(hex);
|
58
|
+
} }) }) }) }))] }));
|
59
|
+
}
|
60
|
+
}
|
61
|
+
//# sourceMappingURL=colorPickerComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"colorPickerComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/colorPickerComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAmBzD,MAAM,OAAO,wBAAyB,SAAQ,KAAK,CAAC,SAAiE;IAIjH,YAAY,KAAiC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC;QAEb,IAAI,CAAC,KAAK,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;QAE9F,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;IAC3C,CAAC;IAED,aAAa;QACT,MAAM,GAAG,GAAG,IAAI,C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EAAC,GAAG,EAAE,IAAI,CAAC,SAAS,YACnD,KAAC,WAAW,IACR,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,IAAK,EAAU,EAChD,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,EACvB,UAAU,EAAE,IAAI,CAAC,KAAK,CAAC,UAAU,EACjC,cAAc,EAAE,CAAC,KAAsB,EAAE,EAAE;oCACvC,MAAM,GAAG,GAAW,KAAK,CAAC,WAAW,EAAE,CAAC;oCACxC,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC;oCAC9B,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;gCACnC,CAAC,GACH,GACA,GACJ,GACP,CACN,IACC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\nimport type { Color4, Color3 } from \"core/Maths/math.color\";\r\nimport { ColorPicker } from \"../colorPicker/colorPicker\";\r\nimport type { LockObject } from \"../tabs/propertyGrids/lockObject\";\r\n\r\nexport interface IColorPickerComponentProps {\r\n value: Color4 | Color3;\r\n linearHint?: boolean;\r\n onColorChanged: (newOne: string) => void;\r\n icon?: string;\r\n iconLabel?: string;\r\n shouldPopRight?: boolean;\r\n lockObject?: LockObject;\r\n}\r\n\r\ninterface IColorPickerComponentState {\r\n pickerEnabled: boolean;\r\n color: Color3 | Color4;\r\n hex: string;\r\n}\r\n\r\nexport class ColorPickerLineComponent extends React.Component<IColorPickerComponentProps, IColorPickerComponentState> {\r\n private _floatRef: React.RefObject<HTMLDivElement>;\r\n private _floatHostRef: React.RefObject<HTMLDivElement>;\r\n\r\n constructor(props: IColorPickerComponentProps) {\r\n super(props);\r\n\r\n this.state = { pickerEnabled: false, color: this.props.value, hex: this.getHexString(props) };\r\n\r\n this._floatRef = React.createRef();\r\n this._floatHostRef = React.createRef();\r\n }\r\n\r\n syncPositions() {\r\n const div = this._floatRef.current as HTMLDivElement;\r\n const host = this._floatHostRef.current as HTMLDivElement;\r\n\r\n if (!div || !host) {\r\n return;\r\n }\r\n\r\n let top = host.getBoundingClientRect().top;\r\n const height = div.getBoundingClientRect().height;\r\n\r\n if (top + height + 10 > window.innerHeight) {\r\n top = window.innerHeight - height - 10;\r\n }\r\n\r\n div.style.top = top + \"px\";\r\n if (!this.props.shouldPopRight) {\r\n div.style.left = host.getBoundingClientRect().left - div.getBoundingClientRect().width + \"px\";\r\n } else {\r\n div.style.left = host.getBoundingClientRect().left + \"px\";\r\n }\r\n }\r\n\r\n shouldComponentUpdate(nextProps: IColorPickerComponentProps, nextState: IColorPickerComponentState) {\r\n const diffProps = this.getHexString(nextProps) !== this.getHexString();\r\n\r\n if (diffProps) {\r\n nextState.color = nextProps.value;\r\n nextState.hex = this.getHexString(nextProps);\r\n }\r\n\r\n return diffProps || nextState.hex !== this.state.hex || nextState.pickerEnabled !== this.state.pickerEnabled;\r\n }\r\n\r\n getHexString(props = this.props) {\r\n return props.value.toHexString();\r\n }\r\n\r\n componentDidUpdate() {\r\n this.syncPositions();\r\n }\r\n\r\n componentDidMount() {\r\n this.syncPositions();\r\n }\r\n\r\n render() {\r\n return (\r\n <div className=\"color-picker\">\r\n {this.props.icon && <img src={this.props.icon} title={this.props.iconLabel} alt={this.props.iconLabel} className=\"icon\" />}\r\n <div className=\"color-rect-background\" ref={this._floatHostRef} onClick={() => this.setState({ pickerEnabled: true })}>\r\n <div className=\"color-rect\" style={{ background: this.state.hex }}></div>\r\n </div>\r\n {this.state.pickerEnabled && (\r\n <>\r\n <div\r\n className=\"color-picker-cover\"\r\n onClick={(evt) => {\r\n if (evt.target !== this._floatRef.current?.ownerDocument?.querySelector(\".color-picker-cover\")) {\r\n return;\r\n }\r\n this.setState({ pickerEnabled: false });\r\n }}\r\n >\r\n <div className=\"color-picker-float\" ref={this._floatRef}>\r\n <ColorPicker\r\n lockObject={this.props.lockObject || ({} as any)}\r\n color={this.state.color}\r\n linearhint={this.props.linearHint}\r\n onColorChanged={(color: Color3 | Color4) => {\r\n const hex: string = color.toHexString();\r\n this.setState({ hex, color });\r\n this.props.onColorChanged(hex);\r\n }}\r\n />\r\n </div>\r\n </div>\r\n </>\r\n )}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|
@@ -0,0 +1,9 @@
|
|
1
|
+
import * as React from "react";
|
2
|
+
export interface IButtonLineComponentProps {
|
3
|
+
data: string;
|
4
|
+
tooltip: string;
|
5
|
+
}
|
6
|
+
export declare class DraggableLineComponent extends React.Component<IButtonLineComponentProps> {
|
7
|
+
constructor(props: IButtonLineComponentProps);
|
8
|
+
render(): JSX.Element;
|
9
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
export class DraggableLineComponent extends React.Component {
|
4
|
+
constructor(props) {
|
5
|
+
super(props);
|
6
|
+
}
|
7
|
+
render() {
|
8
|
+
return (_jsx("div", { className: "draggableLine", title: this.props.tooltip, draggable: true, onDragStart: (event) => {
|
9
|
+
event.dataTransfer.setData("babylonjs-gui-node", this.props.data);
|
10
|
+
}, children: this.props.data.replace("Block", "") }));
|
11
|
+
}
|
12
|
+
}
|
13
|
+
//# sourceMappingURL=draggableLineComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"draggableLineComponent.js","sourceRoot":"","sources":["../../../../../dev/sharedUiComponents/src/lines/draggableLineComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,MAAM,OAAO,sBAAuB,SAAQ,KAAK,CAAC,SAAoC;IAClF,YAAY,KAAgC;QACxC,KAAK,CAAC,KAAK,CAAC,CAAC;IACjB,CAAC;IAED,MAAM;QACF,OAAO,CACH,cACI,SAAS,EAAC,eAAe,EACzB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO,EACzB,SAAS,EAAE,IAAI,EACf,WAAW,EAAE,CAAC,KAAK,EAAE,EAAE;gBACnB,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,oBAAoB,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACtE,CAAC,YAEA,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,GACnC,CACT,CAAC;IACN,CAAC;CACJ","sourcesContent":["import * as React from \"react\";\r\n\r\nexport interface IButtonLineComponentProps {\r\n data: string;\r\n tooltip: string;\r\n}\r\n\r\nexport class DraggableLineComponent extends React.Component<IButtonLineComponentProps> {\r\n constructor(props: IButtonLineComponentProps) {\r\n super(props);\r\n }\r\n\r\n render() {\r\n return (\r\n <div\r\n className=\"draggableLine\"\r\n title={this.props.tooltip}\r\n draggable={true}\r\n onDragStart={(event) => {\r\n event.dataTransfer.setData(\"babylonjs-gui-node\", this.props.data);\r\n }}\r\n >\r\n {this.props.data.replace(\"Block\", \"\")}\r\n </div>\r\n );\r\n }\r\n}\r\n"]}
|