@babylonjs/shared-ui-components 5.28.0 → 5.30.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/CommandBarComponent.js.map +1 -1
- 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 +82 -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 +117 -111
- package/nodeGraphSystem/graphCanvas.js +1137 -1131
- package/nodeGraphSystem/graphCanvas.js.map +1 -1
- package/nodeGraphSystem/graphFrame.d.ts +153 -153
- package/nodeGraphSystem/graphFrame.js +1328 -1328
- package/nodeGraphSystem/graphNode.d.ts +81 -79
- package/nodeGraphSystem/graphNode.js +465 -459
- package/nodeGraphSystem/graphNode.js.map +1 -1
- 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,54 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useContext } from "react";
|
3
|
+
import { FlexibleTab } from "./FlexibleTab.js";
|
4
|
+
import { LayoutContext } from "./LayoutContext.js";
|
5
|
+
import style from "./FlexibleTabsContainer.modules.scss";
|
6
|
+
import dragIcon from "../../imgs/dragDotsIcon_white.svg";
|
7
|
+
import { getPosInLayout, removeLayoutRowAndRedistributePercentages } from "./utils.js";
|
8
|
+
import { DraggableIcon } from "./DraggableIcon.js";
|
9
|
+
import { ElementTypes } from "./types.js";
|
10
|
+
/**
|
11
|
+
* This component contains a set of tabs of which only one is visible at a time.
|
12
|
+
* The tabs can also be dragged from and to different containers.
|
13
|
+
*/
|
14
|
+
export const FlexibleTabsContainer = (props) => {
|
15
|
+
const { layout, setLayout } = useContext(LayoutContext);
|
16
|
+
const { tabs, selectedTab } = props;
|
17
|
+
const selectedTabId = props.selectedTab !== undefined ? props.selectedTab : tabs[0].id;
|
18
|
+
const selectedTabArray = tabs.filter((tab) => tab.id === selectedTabId);
|
19
|
+
const selectedTabObject = selectedTabArray.length > 0 ? selectedTabArray[0] : null;
|
20
|
+
const selectTab = (tabId) => {
|
21
|
+
const layoutPos = getPosInLayout(layout, props.columnIndex, props.rowIndex);
|
22
|
+
layoutPos.selectedTab = tabId;
|
23
|
+
setLayout({ ...layout });
|
24
|
+
};
|
25
|
+
const addTabAfter = (droppedTabItem, dropZoneTabId) => {
|
26
|
+
// Get layout element corresponding to dropped tabs
|
27
|
+
const layoutDropped = getPosInLayout(layout, droppedTabItem.columnNumber, droppedTabItem.rowNumber);
|
28
|
+
// Get layout element corresponding to dropzone
|
29
|
+
const layoutDropZone = getPosInLayout(layout, props.columnIndex, props.rowIndex);
|
30
|
+
for (const { id } of droppedTabItem.tabs) {
|
31
|
+
const droppedTabIndex = layoutDropped.tabs.findIndex((tab) => tab.id === id);
|
32
|
+
const droppedTab = layoutDropped.tabs[droppedTabIndex];
|
33
|
+
// Add dropped tab after dropZoneTabId
|
34
|
+
const dropZoneIndex = layoutDropZone.tabs.findIndex((tab) => tab.id === dropZoneTabId);
|
35
|
+
layoutDropZone.tabs.splice(dropZoneIndex + 1, 0, droppedTab);
|
36
|
+
// Remove dropped tab from its original position
|
37
|
+
layoutDropped.tabs.splice(droppedTabIndex, 1);
|
38
|
+
}
|
39
|
+
if (layoutDropped.tabs.length === 0) {
|
40
|
+
// Check if the layout that was dropped from is empty now
|
41
|
+
removeLayoutRowAndRedistributePercentages(layout, droppedTabItem.columnNumber, droppedTabItem.rowNumber);
|
42
|
+
}
|
43
|
+
else if (droppedTabItem.tabs.map((tab) => tab.id).includes(layoutDropped.selectedTab)) {
|
44
|
+
//Check if the layout that was dropped from's active tab is still in the layout
|
45
|
+
layoutDropped.selectedTab = layoutDropped.tabs[0].id;
|
46
|
+
}
|
47
|
+
// Update layout
|
48
|
+
setLayout({ ...layout });
|
49
|
+
};
|
50
|
+
return (_jsxs("div", { className: style.rootContainer, children: [_jsxs("div", { draggable: false, className: style.tabsLineContainer, children: [_jsx("div", { className: style.tabsContainer, children: tabs.map((tab) => {
|
51
|
+
return (_jsx(FlexibleTab, { title: tab.title, selected: tab.id === selectedTab, onClick: () => selectTab(tab.id), item: { rowNumber: props.rowIndex, columnNumber: props.columnIndex, tabs: [{ id: tab.id }] }, onTabDroppedAction: (item) => addTabAfter(item, tab.id) }, tab.id));
|
52
|
+
}) }), _jsx(DraggableIcon, { src: dragIcon, item: { rowNumber: props.rowIndex, columnNumber: props.columnIndex, tabs: tabs.map((t) => ({ id: t.id })) }, type: ElementTypes.TAB_GROUP })] }), _jsx("div", { className: style.contentContainer, children: selectedTabObject === null || selectedTabObject === void 0 ? void 0 : selectedTabObject.component })] }));
|
53
|
+
};
|
54
|
+
//# sourceMappingURL=FlexibleTabsContainer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleTabsContainer.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleTabsContainer.tsx"],"names":[],"mappings":"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","sourcesContent":["import type { FC } from \"react\";\r\nimport { useContext } from \"react\";\r\nimport { FlexibleTab } from \"./FlexibleTab\";\r\nimport { LayoutContext } from \"./LayoutContext\";\r\nimport style from \"./FlexibleTabsContainer.modules.scss\";\r\n\r\nimport dragIcon from \"../../imgs/dragDotsIcon_white.svg\";\r\nimport { getPosInLayout, removeLayoutRowAndRedistributePercentages } from \"./utils\";\r\nimport { DraggableIcon } from \"./DraggableIcon\";\r\nimport type { LayoutTab, LayoutTabsRow, TabDrag } from \"./types\";\r\nimport { ElementTypes } from \"./types\";\r\n\r\n/**\r\n * Arguments for the TabsContainer component.\r\n */\r\nexport interface IFlexibleTabsContainerProps {\r\n /**\r\n * The tabs to display\r\n */\r\n tabs: LayoutTab[];\r\n /**\r\n * Row index of component in layout\r\n */\r\n rowIndex: number;\r\n /**\r\n * Column index of component in layout\r\n */\r\n columnIndex: number;\r\n /**\r\n * Which tab is selected in the layout\r\n */\r\n selectedTab?: string;\r\n}\r\n\r\n/**\r\n * This component contains a set of tabs of which only one is visible at a time.\r\n * The tabs can also be dragged from and to different containers.\r\n */\r\nexport const FlexibleTabsContainer: FC<IFlexibleTabsContainerProps> = (props) => {\r\n const { layout, setLayout } = useContext(LayoutContext);\r\n const { tabs, selectedTab } = props;\r\n const selectedTabId = props.selectedTab !== undefined ? props.selectedTab : tabs[0].id;\r\n const selectedTabArray = tabs.filter((tab) => tab.id === selectedTabId);\r\n const selectedTabObject = selectedTabArray.length > 0 ? selectedTabArray[0] : null;\r\n\r\n const selectTab = (tabId: string) => {\r\n const layoutPos = getPosInLayout(layout, props.columnIndex, props.rowIndex) as LayoutTabsRow;\r\n layoutPos.selectedTab = tabId;\r\n setLayout({ ...layout });\r\n };\r\n\r\n const addTabAfter = (droppedTabItem: TabDrag, dropZoneTabId: string) => {\r\n // Get layout element corresponding to dropped tabs\r\n const layoutDropped = getPosInLayout(layout, droppedTabItem.columnNumber, droppedTabItem.rowNumber) as LayoutTabsRow;\r\n // Get layout element corresponding to dropzone\r\n const layoutDropZone = getPosInLayout(layout, props.columnIndex, props.rowIndex) as LayoutTabsRow;\r\n\r\n for (const { id } of droppedTabItem.tabs) {\r\n const droppedTabIndex = layoutDropped.tabs.findIndex((tab: any) => tab.id === id);\r\n const droppedTab = layoutDropped.tabs[droppedTabIndex];\r\n // Add dropped tab after dropZoneTabId\r\n const dropZoneIndex = layoutDropZone.tabs.findIndex((tab: any) => tab.id === dropZoneTabId);\r\n layoutDropZone.tabs.splice(dropZoneIndex + 1, 0, droppedTab);\r\n // Remove dropped tab from its original position\r\n layoutDropped.tabs.splice(droppedTabIndex, 1);\r\n }\r\n\r\n if (layoutDropped.tabs.length === 0) {\r\n // Check if the layout that was dropped from is empty now\r\n removeLayoutRowAndRedistributePercentages(layout, droppedTabItem.columnNumber, droppedTabItem.rowNumber);\r\n } else if (droppedTabItem.tabs.map((tab: any) => tab.id).includes(layoutDropped.selectedTab)) {\r\n //Check if the layout that was dropped from's active tab is still in the layout\r\n layoutDropped.selectedTab = layoutDropped.tabs[0].id;\r\n }\r\n\r\n // Update layout\r\n setLayout({ ...layout });\r\n };\r\n\r\n return (\r\n <div className={style.rootContainer}>\r\n <div draggable={false} className={style.tabsLineContainer}>\r\n <div className={style.tabsContainer}>\r\n {tabs.map((tab) => {\r\n return (\r\n <FlexibleTab\r\n key={tab.id}\r\n title={tab.title}\r\n selected={tab.id === selectedTab}\r\n onClick={() => selectTab(tab.id)}\r\n item={{ rowNumber: props.rowIndex, columnNumber: props.columnIndex, tabs: [{ id: tab.id }] }}\r\n onTabDroppedAction={(item) => addTabAfter(item, tab.id)}\r\n />\r\n );\r\n })}\r\n </div>\r\n <DraggableIcon\r\n src={dragIcon}\r\n item={{ rowNumber: props.rowIndex, columnNumber: props.columnIndex, tabs: tabs.map((t) => ({ id: t.id })) }}\r\n type={ElementTypes.TAB_GROUP}\r\n />\r\n </div>\r\n <div className={style.contentContainer}>{selectedTabObject?.component}</div>\r\n </div>\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
/// <reference types="react" />
|
2
|
+
import type { Layout } from "./types";
|
3
|
+
export declare const LayoutContext: import("react").Context<{
|
4
|
+
/**
|
5
|
+
* The layout object
|
6
|
+
*/
|
7
|
+
layout: Layout;
|
8
|
+
/**
|
9
|
+
* Function to set the layout object in the context
|
10
|
+
*/
|
11
|
+
setLayout: (layout: Layout) => void;
|
12
|
+
}>;
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"LayoutContext.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/LayoutContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,CAAC,MAAM,aAAa,GAAG,aAAa,CASvC,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,GAAE,CAAC,EAAE,CAAC,CAAC","sourcesContent":["import { createContext } from \"react\";\r\nimport type { Layout } from \"./types\";\r\n\r\nexport const LayoutContext = createContext<{\r\n /**\r\n * The layout object\r\n */\r\n layout: Layout;\r\n /**\r\n * Function to set the layout object in the context\r\n */\r\n setLayout: (layout: Layout) => void;\r\n}>({ layout: {}, setLayout: () => {} });\r\n"]}
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import type { ReactElement } 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: ReactElement;
|
11
|
+
/**
|
12
|
+
* Tab title
|
13
|
+
*/
|
14
|
+
title: string;
|
15
|
+
};
|
16
|
+
export declare type LayoutTabsRow = {
|
17
|
+
/**
|
18
|
+
* row id
|
19
|
+
*/
|
20
|
+
id: string;
|
21
|
+
/**
|
22
|
+
* row height in its containing column
|
23
|
+
*/
|
24
|
+
height: string;
|
25
|
+
/**
|
26
|
+
* selected tab in row
|
27
|
+
*/
|
28
|
+
selectedTab: string;
|
29
|
+
/**
|
30
|
+
* list of tabs contained in row
|
31
|
+
*/
|
32
|
+
tabs: LayoutTab[];
|
33
|
+
};
|
34
|
+
export declare type LayoutColumn = {
|
35
|
+
/**
|
36
|
+
* column id
|
37
|
+
*/
|
38
|
+
id: string;
|
39
|
+
/**
|
40
|
+
* column width in the grid
|
41
|
+
*/
|
42
|
+
width: string;
|
43
|
+
/**
|
44
|
+
* column rows
|
45
|
+
*/
|
46
|
+
rows: LayoutTabsRow[];
|
47
|
+
};
|
48
|
+
export declare type Layout = {
|
49
|
+
/**
|
50
|
+
* layout columns
|
51
|
+
*/
|
52
|
+
columns?: LayoutColumn[];
|
53
|
+
};
|
54
|
+
export declare type TabDrag = {
|
55
|
+
/**
|
56
|
+
* row number of the tab being dragged
|
57
|
+
*/
|
58
|
+
rowNumber: number;
|
59
|
+
/**
|
60
|
+
* column number of the tab being dragged
|
61
|
+
*/
|
62
|
+
columnNumber: number;
|
63
|
+
/**
|
64
|
+
* the tabs being dragged
|
65
|
+
*/
|
66
|
+
tabs: {
|
67
|
+
/**
|
68
|
+
* id of tab being dragged
|
69
|
+
*/
|
70
|
+
id: string;
|
71
|
+
}[];
|
72
|
+
};
|
73
|
+
export declare enum ElementTypes {
|
74
|
+
RESIZE_BAR = "0",
|
75
|
+
TAB = "1",
|
76
|
+
TAB_GROUP = "2",
|
77
|
+
NONE = "2"
|
78
|
+
}
|
79
|
+
export declare enum ResizeDirections {
|
80
|
+
ROW = "row",
|
81
|
+
COLUMN = "column"
|
82
|
+
}
|
@@ -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":"AAgFA,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 { ReactElement } 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: ReactElement;\r\n /**\r\n * Tab title\r\n */\r\n title: string;\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 {};
|