@babylonjs/shared-ui-components 5.28.0 → 5.29.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 -18
- package/colorPicker/colorComponentEntry.js +36 -36
- package/colorPicker/colorPicker.d.ts +43 -43
- package/colorPicker/colorPicker.js +136 -136
- package/colorPicker/hexColor.d.ts +20 -20
- package/colorPicker/hexColor.js +42 -42
- package/components/Button.d.ts +10 -10
- package/components/Button.js +6 -6
- package/components/Icon.d.ts +6 -6
- package/components/Icon.js +6 -6
- package/components/Label.d.ts +7 -7
- package/components/Label.js +6 -6
- package/components/MessageDialog.d.ts +7 -7
- package/components/MessageDialog.js +22 -22
- package/components/Toggle.d.ts +8 -8
- package/components/Toggle.js +15 -15
- package/components/bars/CommandBarComponent.d.ts +16 -16
- package/components/bars/CommandBarComponent.js +68 -68
- package/components/bars/CommandButtonComponent.d.ts +11 -11
- package/components/bars/CommandButtonComponent.js +6 -6
- package/components/bars/CommandDropdownComponent.d.ts +26 -26
- package/components/bars/CommandDropdownComponent.js +48 -48
- package/components/classNames.d.ts +2 -2
- package/components/classNames.js +18 -18
- package/components/colorPicker/ColorComponentEntry.d.ts +18 -18
- package/components/colorPicker/ColorComponentEntry.js +37 -37
- package/components/colorPicker/ColorPicker.d.ts +43 -43
- package/components/colorPicker/ColorPicker.js +137 -137
- package/components/colorPicker/HexColor.d.ts +20 -20
- package/components/colorPicker/HexColor.js +45 -45
- package/components/layout/DraggableIcon.d.ts +23 -0
- package/components/layout/DraggableIcon.js +18 -0
- package/components/layout/DraggableIcon.js.map +1 -0
- package/components/layout/FlexibleColumn.d.ts +17 -0
- package/components/layout/FlexibleColumn.js +12 -0
- package/components/layout/FlexibleColumn.js.map +1 -0
- package/components/layout/FlexibleDragHandler.d.ts +18 -0
- package/components/layout/FlexibleDragHandler.js +88 -0
- package/components/layout/FlexibleDragHandler.js.map +1 -0
- package/components/layout/FlexibleDropZone.d.ts +19 -0
- package/components/layout/FlexibleDropZone.js +12 -0
- package/components/layout/FlexibleDropZone.js.map +1 -0
- package/components/layout/FlexibleGridContainer.d.ts +10 -0
- package/components/layout/FlexibleGridContainer.js +23 -0
- package/components/layout/FlexibleGridContainer.js.map +1 -0
- package/components/layout/FlexibleGridLayout.d.ts +16 -0
- package/components/layout/FlexibleGridLayout.js +24 -0
- package/components/layout/FlexibleGridLayout.js.map +1 -0
- package/components/layout/FlexibleResizeBar.d.ts +40 -0
- package/components/layout/FlexibleResizeBar.js +21 -0
- package/components/layout/FlexibleResizeBar.js.map +1 -0
- package/components/layout/FlexibleTab.d.ts +34 -0
- package/components/layout/FlexibleTab.js +36 -0
- package/components/layout/FlexibleTab.js.map +1 -0
- package/components/layout/FlexibleTabsContainer.d.ts +28 -0
- package/components/layout/FlexibleTabsContainer.js +54 -0
- package/components/layout/FlexibleTabsContainer.js.map +1 -0
- package/components/layout/LayoutContext.d.ts +12 -0
- package/components/layout/LayoutContext.js +3 -0
- package/components/layout/LayoutContext.js.map +1 -0
- package/components/layout/types.d.ts +78 -0
- package/components/layout/types.js +13 -0
- package/components/layout/types.js.map +1 -0
- package/components/layout/utils.d.ts +25 -0
- package/components/layout/utils.js +68 -0
- package/components/layout/utils.js.map +1 -0
- package/components/lines/ColorLineComponent.d.ts +40 -40
- package/components/lines/ColorLineComponent.js +145 -145
- package/components/lines/ColorPickerLineComponent.d.ts +33 -33
- package/components/lines/ColorPickerLineComponent.js +61 -61
- package/components/lines/FileButtonLineComponent.d.ts +16 -16
- package/components/lines/FileButtonLineComponent.js +21 -21
- package/components/lines/NumericInputComponent.d.ts +31 -31
- package/components/lines/NumericInputComponent.js +86 -86
- package/lines/booleanLineComponent.d.ts +11 -11
- package/lines/booleanLineComponent.js +14 -14
- package/lines/buttonLineComponent.d.ts +12 -12
- package/lines/buttonLineComponent.js +10 -10
- package/lines/checkBoxLineComponent.d.ts +36 -36
- package/lines/checkBoxLineComponent.js +88 -88
- package/lines/color3LineComponent.d.ts +18 -18
- package/lines/color3LineComponent.js +9 -9
- package/lines/color4LineComponent.d.ts +18 -18
- package/lines/color4LineComponent.js +9 -9
- package/lines/colorLineComponent.d.ts +40 -40
- package/lines/colorLineComponent.js +144 -144
- package/lines/colorPickerComponent.d.ts +31 -31
- package/lines/colorPickerComponent.js +60 -60
- package/lines/draggableLineComponent.d.ts +9 -9
- package/lines/draggableLineComponent.js +12 -12
- package/lines/fileButtonLineComponent.d.ts +17 -17
- package/lines/fileButtonLineComponent.js +20 -20
- package/lines/fileMultipleButtonLineComponent.d.ts +17 -17
- package/lines/fileMultipleButtonLineComponent.js +20 -20
- package/lines/floatLineComponent.d.ts +50 -50
- package/lines/floatLineComponent.js +175 -175
- package/lines/hexLineComponent.d.ts +40 -40
- package/lines/hexLineComponent.js +121 -121
- package/lines/iSelectedLineContainer.d.ts +4 -4
- package/lines/iSelectedLineContainer.js +1 -1
- package/lines/iconButtonLineComponent.d.ts +11 -11
- package/lines/iconButtonLineComponent.js +10 -10
- package/lines/iconComponent.d.ts +9 -9
- package/lines/iconComponent.js +7 -7
- package/lines/indentedTextLineComponent.d.ts +16 -16
- package/lines/indentedTextLineComponent.js +26 -26
- package/lines/inputArrowsComponent.d.ts +13 -13
- package/lines/inputArrowsComponent.js +37 -37
- package/lines/lineContainerComponent.d.ts +19 -19
- package/lines/lineContainerComponent.js +49 -49
- package/lines/linkButtonComponent.d.ts +16 -16
- package/lines/linkButtonComponent.js +20 -20
- package/lines/matrixLineComponent.d.ts +36 -36
- package/lines/matrixLineComponent.js +102 -102
- package/lines/messageLineComponent.d.ts +12 -12
- package/lines/messageLineComponent.js +14 -14
- package/lines/numericInputComponent.d.ts +31 -31
- package/lines/numericInputComponent.js +85 -85
- package/lines/optionsLineComponent.d.ts +48 -48
- package/lines/optionsLineComponent.js +118 -118
- package/lines/popup.d.ts +4 -4
- package/lines/popup.js +67 -67
- package/lines/radioLineComponent.d.ts +21 -21
- package/lines/radioLineComponent.js +26 -26
- package/lines/sliderLineComponent.d.ts +37 -37
- package/lines/sliderLineComponent.js +89 -89
- package/lines/targetsProxy.d.ts +11 -11
- package/lines/targetsProxy.js +42 -42
- package/lines/textInputLineComponent.d.ts +47 -47
- package/lines/textInputLineComponent.js +154 -154
- package/lines/textLineComponent.d.ts +21 -21
- package/lines/textLineComponent.js +30 -30
- package/lines/unitButton.d.ts +8 -8
- package/lines/unitButton.js +7 -7
- package/lines/valueLineComponent.d.ts +15 -15
- package/lines/valueLineComponent.js +12 -12
- package/lines/vector2LineComponent.d.ts +36 -36
- package/lines/vector2LineComponent.js +63 -63
- package/lines/vector3LineComponent.d.ts +41 -41
- package/lines/vector3LineComponent.js +74 -74
- package/lines/vector4LineComponent.d.ts +42 -42
- package/lines/vector4LineComponent.js +81 -81
- package/nodeGraphSystem/displayLedger.d.ts +5 -5
- package/nodeGraphSystem/displayLedger.js +3 -3
- package/nodeGraphSystem/frameNodePort.d.ts +25 -25
- package/nodeGraphSystem/frameNodePort.js +59 -59
- package/nodeGraphSystem/graphCanvas.d.ts +111 -111
- package/nodeGraphSystem/graphCanvas.js +1131 -1131
- package/nodeGraphSystem/graphFrame.d.ts +153 -153
- package/nodeGraphSystem/graphFrame.js +1328 -1328
- package/nodeGraphSystem/graphNode.d.ts +79 -79
- package/nodeGraphSystem/graphNode.js +459 -459
- package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -13
- package/nodeGraphSystem/interfaces/displayManager.js +1 -1
- package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -6
- package/nodeGraphSystem/interfaces/nodeContainer.js +1 -1
- package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -15
- package/nodeGraphSystem/interfaces/nodeData.js +1 -1
- package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -26
- package/nodeGraphSystem/interfaces/nodeLocationInfo.js +1 -1
- package/nodeGraphSystem/interfaces/portData.d.ts +28 -28
- package/nodeGraphSystem/interfaces/portData.js +7 -7
- package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -6
- package/nodeGraphSystem/interfaces/propertyComponentProps.js +1 -1
- package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -11
- package/nodeGraphSystem/interfaces/selectionChangedOptions.js +1 -1
- package/nodeGraphSystem/nodeLink.d.ts +31 -31
- package/nodeGraphSystem/nodeLink.js +182 -182
- package/nodeGraphSystem/nodePort.d.ts +35 -35
- package/nodeGraphSystem/nodePort.js +128 -128
- package/nodeGraphSystem/propertyLedger.d.ts +8 -8
- package/nodeGraphSystem/propertyLedger.js +3 -3
- package/nodeGraphSystem/stateManager.d.ts +45 -45
- package/nodeGraphSystem/stateManager.js +18 -18
- package/nodeGraphSystem/tools.d.ts +5 -5
- package/nodeGraphSystem/tools.js +36 -36
- package/nodeGraphSystem/typeLedger.d.ts +8 -8
- package/nodeGraphSystem/typeLedger.js +2 -2
- package/nodeGraphSystem/types/framePortData.d.ts +7 -7
- package/nodeGraphSystem/types/framePortData.js +1 -1
- package/package.json +4 -3
- package/propertyChangedEvent.d.ts +7 -7
- package/propertyChangedEvent.js +2 -2
- package/stories/Button.stories.d.ts +10 -10
- package/stories/Button.stories.js +19 -19
- package/stories/Icon.stories.d.ts +9 -9
- package/stories/Icon.stories.js +16 -16
- package/stories/Label.stories.d.ts +8 -8
- package/stories/Label.stories.js +10 -10
- package/stories/MessageDialog.stories.d.ts +9 -9
- package/stories/MessageDialog.stories.js +19 -19
- package/stories/Toggle.stories.d.ts +9 -9
- package/stories/Toggle.stories.js +17 -17
- package/stories/bars/CommandBarComponent.stories.d.ts +11 -11
- package/stories/bars/CommandBarComponent.stories.js +12 -12
- package/stories/bars/CommandButtonComponent.stories.d.ts +6 -6
- package/stories/bars/CommandButtonComponent.stories.js +6 -6
- package/stories/colorPicker/ColorPicker.stories.d.ts +11 -11
- package/stories/colorPicker/ColorPicker.stories.js +4 -4
- package/stories/layout/FlexibleGridLayout.stories.d.ts +46 -0
- package/stories/layout/FlexibleGridLayout.stories.js +48 -0
- package/stories/layout/FlexibleGridLayout.stories.js.map +1 -0
- package/stories/lines/ColorLineComponent.stories.d.ts +21 -21
- package/stories/lines/ColorLineComponent.stories.js +9 -9
- package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -14
- package/stories/lines/ColorPickerLineComponent.stories.js +10 -10
- package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -6
- package/stories/lines/FileButtonLineComponent.stories.js +5 -5
- package/stories/lines/NumericInputComponent.stories.d.ts +11 -11
- package/stories/lines/NumericInputComponent.stories.js +5 -5
- package/stringTools.d.ts +11 -11
- package/stringTools.js +88 -88
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +14 -14
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -17
- package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +55 -55
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +12 -12
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -17
- package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +38 -38
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +16 -16
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +25 -25
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +17 -17
- package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -16
- package/tabs/propertyGrids/gui/linePropertyGridComponent.js +27 -27
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +17 -17
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +15 -15
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +16 -16
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +14 -14
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -15
- package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +34 -34
- package/tabs/propertyGrids/lockObject.d.ts +9 -9
- package/tabs/propertyGrids/lockObject.js +11 -11
@@ -0,0 +1,78 @@
|
|
1
|
+
import type { ComponentType } from "react";
|
2
|
+
export declare type LayoutTab = {
|
3
|
+
/**
|
4
|
+
* Tab id
|
5
|
+
*/
|
6
|
+
id: string;
|
7
|
+
/**
|
8
|
+
* React component rendered by tab
|
9
|
+
*/
|
10
|
+
component: ComponentType;
|
11
|
+
};
|
12
|
+
export declare type LayoutTabsRow = {
|
13
|
+
/**
|
14
|
+
* row id
|
15
|
+
*/
|
16
|
+
id: string;
|
17
|
+
/**
|
18
|
+
* row height in its containing column
|
19
|
+
*/
|
20
|
+
height: string;
|
21
|
+
/**
|
22
|
+
* selected tab in row
|
23
|
+
*/
|
24
|
+
selectedTab: string;
|
25
|
+
/**
|
26
|
+
* list of tabs contained in row
|
27
|
+
*/
|
28
|
+
tabs: LayoutTab[];
|
29
|
+
};
|
30
|
+
export declare type LayoutColumn = {
|
31
|
+
/**
|
32
|
+
* column id
|
33
|
+
*/
|
34
|
+
id: string;
|
35
|
+
/**
|
36
|
+
* column width in the grid
|
37
|
+
*/
|
38
|
+
width: string;
|
39
|
+
/**
|
40
|
+
* column rows
|
41
|
+
*/
|
42
|
+
rows: LayoutTabsRow[];
|
43
|
+
};
|
44
|
+
export declare type Layout = {
|
45
|
+
/**
|
46
|
+
* layout columns
|
47
|
+
*/
|
48
|
+
columns?: LayoutColumn[];
|
49
|
+
};
|
50
|
+
export declare type TabDrag = {
|
51
|
+
/**
|
52
|
+
* row number of the tab being dragged
|
53
|
+
*/
|
54
|
+
rowNumber: number;
|
55
|
+
/**
|
56
|
+
* column number of the tab being dragged
|
57
|
+
*/
|
58
|
+
columnNumber: number;
|
59
|
+
/**
|
60
|
+
* the tabs being dragged
|
61
|
+
*/
|
62
|
+
tabs: {
|
63
|
+
/**
|
64
|
+
* id of tab being dragged
|
65
|
+
*/
|
66
|
+
id: string;
|
67
|
+
}[];
|
68
|
+
};
|
69
|
+
export declare enum ElementTypes {
|
70
|
+
RESIZE_BAR = "0",
|
71
|
+
TAB = "1",
|
72
|
+
TAB_GROUP = "2",
|
73
|
+
NONE = "2"
|
74
|
+
}
|
75
|
+
export declare enum ResizeDirections {
|
76
|
+
ROW = "row",
|
77
|
+
COLUMN = "column"
|
78
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
export var ElementTypes;
|
2
|
+
(function (ElementTypes) {
|
3
|
+
ElementTypes["RESIZE_BAR"] = "0";
|
4
|
+
ElementTypes["TAB"] = "1";
|
5
|
+
ElementTypes["TAB_GROUP"] = "2";
|
6
|
+
ElementTypes["NONE"] = "2";
|
7
|
+
})(ElementTypes || (ElementTypes = {}));
|
8
|
+
export var ResizeDirections;
|
9
|
+
(function (ResizeDirections) {
|
10
|
+
ResizeDirections["ROW"] = "row";
|
11
|
+
ResizeDirections["COLUMN"] = "column";
|
12
|
+
})(ResizeDirections || (ResizeDirections = {}));
|
13
|
+
//# sourceMappingURL=types.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/types.ts"],"names":[],"mappings":"AA4EA,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACpB,gCAAgB,CAAA;IAChB,yBAAS,CAAA;IACT,+BAAe,CAAA;IACf,0BAAU,CAAA;AACd,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,MAAM,CAAN,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IACxB,+BAAW,CAAA;IACX,qCAAiB,CAAA;AACrB,CAAC,EAHW,gBAAgB,KAAhB,gBAAgB,QAG3B","sourcesContent":["import type { ComponentType } from \"react\";\r\n\r\n// Define layout typing\r\n\r\nexport type LayoutTab = {\r\n /**\r\n * Tab id\r\n */\r\n id: string;\r\n /**\r\n * React component rendered by tab\r\n */\r\n component: ComponentType;\r\n};\r\n\r\nexport type LayoutTabsRow = {\r\n /**\r\n * row id\r\n */\r\n id: string;\r\n /**\r\n * row height in its containing column\r\n */\r\n height: string;\r\n /**\r\n * selected tab in row\r\n */\r\n selectedTab: string;\r\n /**\r\n * list of tabs contained in row\r\n */\r\n tabs: LayoutTab[];\r\n};\r\n\r\nexport type LayoutColumn = {\r\n /**\r\n * column id\r\n */\r\n id: string;\r\n /**\r\n * column width in the grid\r\n */\r\n width: string;\r\n /**\r\n * column rows\r\n */\r\n rows: LayoutTabsRow[];\r\n};\r\n\r\nexport type Layout = {\r\n /**\r\n * layout columns\r\n */\r\n columns?: LayoutColumn[];\r\n};\r\n\r\nexport type TabDrag = {\r\n /**\r\n * row number of the tab being dragged\r\n */\r\n rowNumber: number;\r\n /**\r\n * column number of the tab being dragged\r\n */\r\n columnNumber: number;\r\n /**\r\n * the tabs being dragged\r\n */\r\n tabs: {\r\n /**\r\n * id of tab being dragged\r\n */\r\n id: string;\r\n }[];\r\n};\r\n\r\nexport enum ElementTypes {\r\n RESIZE_BAR = \"0\",\r\n TAB = \"1\",\r\n TAB_GROUP = \"2\",\r\n NONE = \"2\",\r\n}\r\n\r\nexport enum ResizeDirections {\r\n ROW = \"row\",\r\n COLUMN = \"column\",\r\n}\r\n"]}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { Layout } from "./types";
|
2
|
+
/**
|
3
|
+
* Given a column and row number in the layout, return the corresponding column/row
|
4
|
+
* @param layout
|
5
|
+
* @param column
|
6
|
+
* @param row
|
7
|
+
* @returns
|
8
|
+
*/
|
9
|
+
export declare const getPosInLayout: (layout: Layout, column: number, row?: number | undefined) => import("./types").LayoutTabsRow | import("./types").LayoutColumn;
|
10
|
+
/**
|
11
|
+
* Remove a row in position row, column from the layout, and redistribute heights of remaining rows
|
12
|
+
* @param layout
|
13
|
+
* @param column
|
14
|
+
* @param row
|
15
|
+
*/
|
16
|
+
export declare const removeLayoutRowAndRedistributePercentages: (layout: Layout, column: number, row: number) => void;
|
17
|
+
/**
|
18
|
+
* Add a percentage string to a number
|
19
|
+
*/
|
20
|
+
export declare const addPercentageStringToNumber: (p1: string, p2: number) => number;
|
21
|
+
/**
|
22
|
+
* Parses a percentage string into a number
|
23
|
+
* @param p the percentage string
|
24
|
+
*/
|
25
|
+
export declare const parsePercentage: (p: string) => number;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
/**
|
2
|
+
* Given a column and row number in the layout, return the corresponding column/row
|
3
|
+
* @param layout
|
4
|
+
* @param column
|
5
|
+
* @param row
|
6
|
+
* @returns
|
7
|
+
*/
|
8
|
+
export const getPosInLayout = (layout, column, row) => {
|
9
|
+
if (!layout.columns) {
|
10
|
+
throw new Error("Attempted to get position on empty layout");
|
11
|
+
}
|
12
|
+
const columnLayout = layout.columns[column];
|
13
|
+
if (!columnLayout) {
|
14
|
+
throw new Error("Attempted to get an invalid layout column");
|
15
|
+
}
|
16
|
+
if (row === undefined) {
|
17
|
+
return columnLayout;
|
18
|
+
}
|
19
|
+
return columnLayout.rows[row];
|
20
|
+
};
|
21
|
+
/**
|
22
|
+
* Remove a row in position row, column from the layout, and redistribute heights of remaining rows
|
23
|
+
* @param layout
|
24
|
+
* @param column
|
25
|
+
* @param row
|
26
|
+
*/
|
27
|
+
export const removeLayoutRowAndRedistributePercentages = (layout, column, row) => {
|
28
|
+
if (!layout.columns) {
|
29
|
+
throw new Error("Attempted to get position on empty layout");
|
30
|
+
}
|
31
|
+
const columnLayout = layout.columns[column];
|
32
|
+
if (!columnLayout) {
|
33
|
+
throw new Error("Attempted to get an invalid layout column");
|
34
|
+
}
|
35
|
+
const rowLayout = columnLayout.rows[row];
|
36
|
+
if (!rowLayout) {
|
37
|
+
throw new Error("Attempted to get an invalid layout row");
|
38
|
+
}
|
39
|
+
const rowHeight = rowLayout.height;
|
40
|
+
if (rowHeight === undefined) {
|
41
|
+
throw new Error("Attempted to remove a row with no height");
|
42
|
+
}
|
43
|
+
// Remove row from layout
|
44
|
+
columnLayout.rows.splice(row, 1);
|
45
|
+
// Redistribute this row's height to the remaining rows
|
46
|
+
const percToAdd = parsePercentage(rowHeight) / columnLayout.rows.length;
|
47
|
+
columnLayout.rows.forEach((row) => {
|
48
|
+
row.height = addPercentageStringToNumber(row.height, percToAdd) + "%";
|
49
|
+
});
|
50
|
+
};
|
51
|
+
/**
|
52
|
+
* Add a percentage string to a number
|
53
|
+
*/
|
54
|
+
export const addPercentageStringToNumber = (p1, p2) => {
|
55
|
+
// Convert both values to numbers
|
56
|
+
const np1 = Number.parseFloat(p1.replace("%", ""));
|
57
|
+
const np2 = p2;
|
58
|
+
const nr = np1 + np2;
|
59
|
+
return nr;
|
60
|
+
};
|
61
|
+
/**
|
62
|
+
* Parses a percentage string into a number
|
63
|
+
* @param p the percentage string
|
64
|
+
*/
|
65
|
+
export const parsePercentage = (p) => {
|
66
|
+
return Number.parseFloat(p.replace("%", ""));
|
67
|
+
};
|
68
|
+
//# sourceMappingURL=utils.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/utils.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,GAAY,EAAE,EAAE;IAC3E,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,YAAY,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,IAAI,GAAG,KAAK,SAAS,EAAE;QACnB,OAAO,YAAY,CAAC;KACvB;IACD,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClC,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,yCAAyC,GAAG,CAAC,MAAc,EAAE,MAAc,EAAE,GAAW,EAAE,EAAE;IACrG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,CAAC,YAAY,EAAE;QACf,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;KAChE;IACD,MAAM,SAAS,GAAG,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,SAAS,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;KAC7D;IACD,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;IACnC,IAAI,SAAS,KAAK,SAAS,EAAE;QACzB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;KAC/D;IACD,yBAAyB;IACzB,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAEjC,uDAAuD;IACvD,MAAM,SAAS,GAAG,eAAe,CAAC,SAAS,CAAC,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC;IACxE,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,GAAQ,EAAE,EAAE;QACnC,GAAG,CAAC,MAAM,GAAG,2BAA2B,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC;IAC1E,CAAC,CAAC,CAAC;AACP,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EAAU,EAAE,EAAU,EAAU,EAAE;IAC1E,iCAAiC;IACjC,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;IACnD,MAAM,GAAG,GAAG,EAAE,CAAC;IAEf,MAAM,EAAE,GAAG,GAAG,GAAG,GAAG,CAAC;IACrB,OAAO,EAAE,CAAC;AACd,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAS,EAAU,EAAE;IACjD,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,CAAC;AACjD,CAAC,CAAC","sourcesContent":["import type { Layout } from \"./types\";\r\n\r\n/**\r\n * Given a column and row number in the layout, return the corresponding column/row\r\n * @param layout\r\n * @param column\r\n * @param row\r\n * @returns\r\n */\r\nexport const getPosInLayout = (layout: Layout, column: number, row?: number) => {\r\n if (!layout.columns) {\r\n throw new Error(\"Attempted to get position on empty layout\");\r\n }\r\n const columnLayout = layout.columns[column];\r\n if (!columnLayout) {\r\n throw new Error(\"Attempted to get an invalid layout column\");\r\n }\r\n if (row === undefined) {\r\n return columnLayout;\r\n }\r\n return columnLayout.rows[row];\r\n};\r\n\r\n/**\r\n * Remove a row in position row, column from the layout, and redistribute heights of remaining rows\r\n * @param layout\r\n * @param column\r\n * @param row\r\n */\r\nexport const removeLayoutRowAndRedistributePercentages = (layout: Layout, column: number, row: number) => {\r\n if (!layout.columns) {\r\n throw new Error(\"Attempted to get position on empty layout\");\r\n }\r\n const columnLayout = layout.columns[column];\r\n if (!columnLayout) {\r\n throw new Error(\"Attempted to get an invalid layout column\");\r\n }\r\n const rowLayout = columnLayout.rows[row];\r\n if (!rowLayout) {\r\n throw new Error(\"Attempted to get an invalid layout row\");\r\n }\r\n const rowHeight = rowLayout.height;\r\n if (rowHeight === undefined) {\r\n throw new Error(\"Attempted to remove a row with no height\");\r\n }\r\n // Remove row from layout\r\n columnLayout.rows.splice(row, 1);\r\n\r\n // Redistribute this row's height to the remaining rows\r\n const percToAdd = parsePercentage(rowHeight) / columnLayout.rows.length;\r\n columnLayout.rows.forEach((row: any) => {\r\n row.height = addPercentageStringToNumber(row.height, percToAdd) + \"%\";\r\n });\r\n};\r\n\r\n/**\r\n * Add a percentage string to a number\r\n */\r\nexport const addPercentageStringToNumber = (p1: string, p2: number): number => {\r\n // Convert both values to numbers\r\n const np1 = Number.parseFloat(p1.replace(\"%\", \"\"));\r\n const np2 = p2;\r\n\r\n const nr = np1 + np2;\r\n return nr;\r\n};\r\n\r\n/**\r\n * Parses a percentage string into a number\r\n * @param p the percentage string\r\n */\r\nexport const parsePercentage = (p: string): number => {\r\n return Number.parseFloat(p.replace(\"%\", \"\"));\r\n};\r\n"]}
|
@@ -1,40 +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 {};
|
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 {};
|
@@ -1,146 +1,146 @@
|
|
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 style from "./ColorLineComponent.modules.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
|
-
if (typeof property === "string") {
|
41
|
-
// if (property === conflictingValuesPlaceholder) {
|
42
|
-
// return emptyColor;
|
43
|
-
// }
|
44
|
-
return this._convertToColor(property);
|
45
|
-
}
|
46
|
-
else {
|
47
|
-
if (props.isLinear) {
|
48
|
-
return property.toGammaSpace();
|
49
|
-
}
|
50
|
-
return property.clone();
|
51
|
-
}
|
52
|
-
}
|
53
|
-
setColorFromString(colorString) {
|
54
|
-
const color = this._convertToColor(colorString);
|
55
|
-
this.setColor(color);
|
56
|
-
}
|
57
|
-
setColor(newColor) {
|
58
|
-
this.setState({ color: newColor.clone() });
|
59
|
-
if (this.props.isLinear) {
|
60
|
-
newColor.toLinearSpaceToRef(newColor);
|
61
|
-
}
|
62
|
-
// whether to set properties to color3 or color4
|
63
|
-
const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;
|
64
|
-
const target = this.props.target;
|
65
|
-
const initialValue = target[this.props.propertyName];
|
66
|
-
const value = typeof target[this.props.propertyName] === "string" ? setColor.toHexString() : setColor;
|
67
|
-
// make the change
|
68
|
-
target[this.props.propertyName] = value;
|
69
|
-
// notify observers
|
70
|
-
if (this.props.onPropertyChangedObservable) {
|
71
|
-
this.props.onPropertyChangedObservable.notifyObservers({
|
72
|
-
object: target,
|
73
|
-
property: this.props.propertyName,
|
74
|
-
value,
|
75
|
-
initialValue,
|
76
|
-
});
|
77
|
-
}
|
78
|
-
if (this.props.onChange) {
|
79
|
-
this.props.onChange();
|
80
|
-
}
|
81
|
-
}
|
82
|
-
switchExpandState() {
|
83
|
-
this.setState({ isExpanded: !this.state.isExpanded });
|
84
|
-
}
|
85
|
-
updateStateR(value) {
|
86
|
-
this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));
|
87
|
-
}
|
88
|
-
updateStateG(value) {
|
89
|
-
this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));
|
90
|
-
}
|
91
|
-
updateStateB(value) {
|
92
|
-
this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));
|
93
|
-
}
|
94
|
-
updateStateA(value) {
|
95
|
-
if (this.props.disableAlpha) {
|
96
|
-
return;
|
97
|
-
}
|
98
|
-
this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
|
99
|
-
}
|
100
|
-
copyToClipboard() {
|
101
|
-
const element = document.createElement("div");
|
102
|
-
element.textContent = this.state.color.toHexString();
|
103
|
-
document.body.appendChild(element);
|
104
|
-
if (window.getSelection) {
|
105
|
-
const range = document.createRange();
|
106
|
-
range.selectNode(element);
|
107
|
-
window.getSelection().removeAllRanges();
|
108
|
-
window.getSelection().addRange(range);
|
109
|
-
}
|
110
|
-
document.execCommand("copy");
|
111
|
-
element.remove();
|
112
|
-
}
|
113
|
-
_convertToColor(color) {
|
114
|
-
if (color === "" || color === "transparent") {
|
115
|
-
return emptyColor;
|
116
|
-
}
|
117
|
-
if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
|
118
|
-
const d = document.createElement("div");
|
119
|
-
d.style.color = color;
|
120
|
-
document.body.append(d);
|
121
|
-
const rgb = window.getComputedStyle(d).color;
|
122
|
-
document.body.removeChild(d);
|
123
|
-
const rgbArray = rgb
|
124
|
-
.substring(4, rgb.length - 1)
|
125
|
-
.replace(/ /g, "")
|
126
|
-
.split(",");
|
127
|
-
const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;
|
128
|
-
return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);
|
129
|
-
}
|
130
|
-
if (this.props.disableAlpha) {
|
131
|
-
const color3 = Color3.FromHexString(color);
|
132
|
-
return new Color4(color3.r, color3.g, color3.b, 1.0);
|
133
|
-
}
|
134
|
-
return Color4.FromHexString(color);
|
135
|
-
}
|
136
|
-
_toColor3(color) {
|
137
|
-
return new Color3(color.r, color.g, color.b);
|
138
|
-
}
|
139
|
-
render() {
|
140
|
-
const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
|
141
|
-
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) => {
|
142
|
-
this.setColorFromString(colorString);
|
143
|
-
} }) }), _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", 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) }))] }))] }));
|
144
|
-
}
|
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 "./ColorPickerLineComponent.js";
|
8
|
+
import style from "./ColorLineComponent.modules.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
|
+
if (typeof property === "string") {
|
41
|
+
// if (property === conflictingValuesPlaceholder) {
|
42
|
+
// return emptyColor;
|
43
|
+
// }
|
44
|
+
return this._convertToColor(property);
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
if (props.isLinear) {
|
48
|
+
return property.toGammaSpace();
|
49
|
+
}
|
50
|
+
return property.clone();
|
51
|
+
}
|
52
|
+
}
|
53
|
+
setColorFromString(colorString) {
|
54
|
+
const color = this._convertToColor(colorString);
|
55
|
+
this.setColor(color);
|
56
|
+
}
|
57
|
+
setColor(newColor) {
|
58
|
+
this.setState({ color: newColor.clone() });
|
59
|
+
if (this.props.isLinear) {
|
60
|
+
newColor.toLinearSpaceToRef(newColor);
|
61
|
+
}
|
62
|
+
// whether to set properties to color3 or color4
|
63
|
+
const setColor = this.props.disableAlpha ? this._toColor3(newColor) : newColor;
|
64
|
+
const target = this.props.target;
|
65
|
+
const initialValue = target[this.props.propertyName];
|
66
|
+
const value = typeof target[this.props.propertyName] === "string" ? setColor.toHexString() : setColor;
|
67
|
+
// make the change
|
68
|
+
target[this.props.propertyName] = value;
|
69
|
+
// notify observers
|
70
|
+
if (this.props.onPropertyChangedObservable) {
|
71
|
+
this.props.onPropertyChangedObservable.notifyObservers({
|
72
|
+
object: target,
|
73
|
+
property: this.props.propertyName,
|
74
|
+
value,
|
75
|
+
initialValue,
|
76
|
+
});
|
77
|
+
}
|
78
|
+
if (this.props.onChange) {
|
79
|
+
this.props.onChange();
|
80
|
+
}
|
81
|
+
}
|
82
|
+
switchExpandState() {
|
83
|
+
this.setState({ isExpanded: !this.state.isExpanded });
|
84
|
+
}
|
85
|
+
updateStateR(value) {
|
86
|
+
this.setColor(new Color4(value, this.state.color.g, this.state.color.b, this.state.color.a));
|
87
|
+
}
|
88
|
+
updateStateG(value) {
|
89
|
+
this.setColor(new Color4(this.state.color.r, value, this.state.color.b, this.state.color.a));
|
90
|
+
}
|
91
|
+
updateStateB(value) {
|
92
|
+
this.setColor(new Color4(this.state.color.r, this.state.color.g, value, this.state.color.a));
|
93
|
+
}
|
94
|
+
updateStateA(value) {
|
95
|
+
if (this.props.disableAlpha) {
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
this.setColor(new Color4(this.state.color.r, this.state.color.g, this.state.color.b, value));
|
99
|
+
}
|
100
|
+
copyToClipboard() {
|
101
|
+
const element = document.createElement("div");
|
102
|
+
element.textContent = this.state.color.toHexString();
|
103
|
+
document.body.appendChild(element);
|
104
|
+
if (window.getSelection) {
|
105
|
+
const range = document.createRange();
|
106
|
+
range.selectNode(element);
|
107
|
+
window.getSelection().removeAllRanges();
|
108
|
+
window.getSelection().addRange(range);
|
109
|
+
}
|
110
|
+
document.execCommand("copy");
|
111
|
+
element.remove();
|
112
|
+
}
|
113
|
+
_convertToColor(color) {
|
114
|
+
if (color === "" || color === "transparent") {
|
115
|
+
return emptyColor;
|
116
|
+
}
|
117
|
+
if (color.substring(0, 1) !== "#" || (color.length !== 7 && color.length !== 9)) {
|
118
|
+
const d = document.createElement("div");
|
119
|
+
d.style.color = color;
|
120
|
+
document.body.append(d);
|
121
|
+
const rgb = window.getComputedStyle(d).color;
|
122
|
+
document.body.removeChild(d);
|
123
|
+
const rgbArray = rgb
|
124
|
+
.substring(4, rgb.length - 1)
|
125
|
+
.replace(/ /g, "")
|
126
|
+
.split(",");
|
127
|
+
const alpha = rgbArray.length > 3 ? parseInt(rgbArray[3]) / 255 : 1.0;
|
128
|
+
return new Color4(parseInt(rgbArray[0]) / 255, parseInt(rgbArray[1]) / 255, parseInt(rgbArray[2]) / 255, alpha);
|
129
|
+
}
|
130
|
+
if (this.props.disableAlpha) {
|
131
|
+
const color3 = Color3.FromHexString(color);
|
132
|
+
return new Color4(color3.r, color3.g, color3.b, 1.0);
|
133
|
+
}
|
134
|
+
return Color4.FromHexString(color);
|
135
|
+
}
|
136
|
+
_toColor3(color) {
|
137
|
+
return new Color3(color.r, color.g, color.b);
|
138
|
+
}
|
139
|
+
render() {
|
140
|
+
const chevron = this.state.isExpanded ? _jsx(FontAwesomeIcon, { icon: faMinus }) : _jsx(FontAwesomeIcon, { icon: faPlus });
|
141
|
+
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) => {
|
142
|
+
this.setColorFromString(colorString);
|
143
|
+
} }) }), _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", 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) }))] }))] }));
|
144
|
+
}
|
145
|
+
}
|
146
146
|
//# sourceMappingURL=ColorLineComponent.js.map
|
@@ -1,33 +1,33 @@
|
|
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
|
-
backgroundColor?: string;
|
13
|
-
}
|
14
|
-
interface IColorPickerComponentState {
|
15
|
-
pickerEnabled: boolean;
|
16
|
-
color: Color3 | Color4;
|
17
|
-
hex: string;
|
18
|
-
}
|
19
|
-
export declare class ColorPickerLineComponent extends React.Component<IColorPickerComponentProps, IColorPickerComponentState> {
|
20
|
-
private _floatRef;
|
21
|
-
private _floatHostRef;
|
22
|
-
private _coverRef;
|
23
|
-
constructor(props: IColorPickerComponentProps);
|
24
|
-
syncPositions(): void;
|
25
|
-
shouldComponentUpdate(nextProps: IColorPickerComponentProps, nextState: IColorPickerComponentState): boolean;
|
26
|
-
getHexString(props?: Readonly<IColorPickerComponentProps> & Readonly<{
|
27
|
-
children?: React.ReactNode;
|
28
|
-
}>): string;
|
29
|
-
componentDidUpdate(): void;
|
30
|
-
componentDidMount(): void;
|
31
|
-
render(): JSX.Element;
|
32
|
-
}
|
33
|
-
export {};
|
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
|
+
backgroundColor?: string;
|
13
|
+
}
|
14
|
+
interface IColorPickerComponentState {
|
15
|
+
pickerEnabled: boolean;
|
16
|
+
color: Color3 | Color4;
|
17
|
+
hex: string;
|
18
|
+
}
|
19
|
+
export declare class ColorPickerLineComponent extends React.Component<IColorPickerComponentProps, IColorPickerComponentState> {
|
20
|
+
private _floatRef;
|
21
|
+
private _floatHostRef;
|
22
|
+
private _coverRef;
|
23
|
+
constructor(props: IColorPickerComponentProps);
|
24
|
+
syncPositions(): void;
|
25
|
+
shouldComponentUpdate(nextProps: IColorPickerComponentProps, nextState: IColorPickerComponentState): boolean;
|
26
|
+
getHexString(props?: Readonly<IColorPickerComponentProps> & Readonly<{
|
27
|
+
children?: React.ReactNode;
|
28
|
+
}>): string;
|
29
|
+
componentDidUpdate(): void;
|
30
|
+
componentDidMount(): void;
|
31
|
+
render(): JSX.Element;
|
32
|
+
}
|
33
|
+
export {};
|