@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
@@ -1,46 +1,46 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import * as React from "react";
|
3
|
-
import style from "./HexColor.modules.scss";
|
4
|
-
export class HexColor extends React.Component {
|
5
|
-
constructor(props) {
|
6
|
-
super(props);
|
7
|
-
this.state = { hex: this.props.value.replace("#", "") };
|
8
|
-
}
|
9
|
-
shouldComponentUpdate(nextProps, nextState) {
|
10
|
-
if (nextProps.value !== this.props.value) {
|
11
|
-
nextState.hex = nextProps.value.replace("#", "");
|
12
|
-
}
|
13
|
-
return true;
|
14
|
-
}
|
15
|
-
lock() {
|
16
|
-
if (this.props.lockObject) {
|
17
|
-
this.props.lockObject.lock = true;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
unlock() {
|
21
|
-
if (this.props.lockObject) {
|
22
|
-
this.props.lockObject.lock = false;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
updateHexValue(valueString) {
|
26
|
-
if (valueString != "" && /^[0-9A-Fa-f]+$/g.test(valueString) == false) {
|
27
|
-
return;
|
28
|
-
}
|
29
|
-
this.setState({ hex: valueString });
|
30
|
-
if (valueString.length !== this.props.expectedLength) {
|
31
|
-
if (this.props.expectedLength === 8 && valueString.length === 6) {
|
32
|
-
valueString = valueString + "FF";
|
33
|
-
}
|
34
|
-
else {
|
35
|
-
return;
|
36
|
-
}
|
37
|
-
}
|
38
|
-
this.props.onChange("#" + valueString);
|
39
|
-
}
|
40
|
-
render() {
|
41
|
-
return (_jsxs("div", { className: style.colorPickerHex, children: [_jsx("div", { className: style.colorPickerHexLabel, children: "Hex" }), _jsx("div", { className: style.colorPickerHexValue, children: _jsx("input", { type: "string",
|
42
|
-
// className="hex-input"
|
43
|
-
className: style.colorPickerHex, value: this.state.hex, onBlur: () => this.unlock(), onFocus: () => this.lock(), onChange: (evt) => this.updateHexValue(evt.target.value) }) })] }));
|
44
|
-
}
|
45
|
-
}
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import * as React from "react";
|
3
|
+
import style from "./HexColor.modules.scss";
|
4
|
+
export class HexColor extends React.Component {
|
5
|
+
constructor(props) {
|
6
|
+
super(props);
|
7
|
+
this.state = { hex: this.props.value.replace("#", "") };
|
8
|
+
}
|
9
|
+
shouldComponentUpdate(nextProps, nextState) {
|
10
|
+
if (nextProps.value !== this.props.value) {
|
11
|
+
nextState.hex = nextProps.value.replace("#", "");
|
12
|
+
}
|
13
|
+
return true;
|
14
|
+
}
|
15
|
+
lock() {
|
16
|
+
if (this.props.lockObject) {
|
17
|
+
this.props.lockObject.lock = true;
|
18
|
+
}
|
19
|
+
}
|
20
|
+
unlock() {
|
21
|
+
if (this.props.lockObject) {
|
22
|
+
this.props.lockObject.lock = false;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
updateHexValue(valueString) {
|
26
|
+
if (valueString != "" && /^[0-9A-Fa-f]+$/g.test(valueString) == false) {
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
this.setState({ hex: valueString });
|
30
|
+
if (valueString.length !== this.props.expectedLength) {
|
31
|
+
if (this.props.expectedLength === 8 && valueString.length === 6) {
|
32
|
+
valueString = valueString + "FF";
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
return;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
this.props.onChange("#" + valueString);
|
39
|
+
}
|
40
|
+
render() {
|
41
|
+
return (_jsxs("div", { className: style.colorPickerHex, children: [_jsx("div", { className: style.colorPickerHexLabel, children: "Hex" }), _jsx("div", { className: style.colorPickerHexValue, children: _jsx("input", { type: "string",
|
42
|
+
// className="hex-input"
|
43
|
+
className: style.colorPickerHex, value: this.state.hex, onBlur: () => this.unlock(), onFocus: () => this.lock(), onChange: (evt) => this.updateHexValue(evt.target.value) }) })] }));
|
44
|
+
}
|
45
|
+
}
|
46
46
|
//# sourceMappingURL=HexColor.js.map
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
import type { ElementTypes, TabDrag } from "./types";
|
3
|
+
/**
|
4
|
+
* Arguments for the DraggableIcon component.
|
5
|
+
*/
|
6
|
+
export interface IDraggableIconProps {
|
7
|
+
/**
|
8
|
+
* Icon source
|
9
|
+
*/
|
10
|
+
src: string;
|
11
|
+
/**
|
12
|
+
* Object that will be passed to the drag event
|
13
|
+
*/
|
14
|
+
item: TabDrag;
|
15
|
+
/**
|
16
|
+
* Type of drag event
|
17
|
+
*/
|
18
|
+
type: ElementTypes;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* An icon that can be dragged by the user
|
22
|
+
*/
|
23
|
+
export declare const DraggableIcon: FC<IDraggableIconProps>;
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useDrag } from "react-dnd";
|
3
|
+
/**
|
4
|
+
* An icon that can be dragged by the user
|
5
|
+
*/
|
6
|
+
export const DraggableIcon = (props) => {
|
7
|
+
const [, drag] = useDrag(() => ({
|
8
|
+
type: props.type,
|
9
|
+
item: props.item,
|
10
|
+
collect(monitor) {
|
11
|
+
return {
|
12
|
+
isDragging: !!monitor.isDragging(),
|
13
|
+
};
|
14
|
+
},
|
15
|
+
}));
|
16
|
+
return _jsx("img", { ref: drag, src: props.src });
|
17
|
+
};
|
18
|
+
//# sourceMappingURL=DraggableIcon.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"DraggableIcon.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/DraggableIcon.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAA4B,CAAC,KAAK,EAAE,EAAE;IAC5D,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5B,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,CAAC,OAAO;YACX,OAAO;gBACH,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE;aACrC,CAAC;QACN,CAAC;KACJ,CAAC,CAAC,CAAC;IACJ,OAAO,cAAK,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,GAAI,CAAC;AAC9C,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport { useDrag } from \"react-dnd\";\r\nimport type { ElementTypes, TabDrag } from \"./types\";\r\n\r\n/**\r\n * Arguments for the DraggableIcon component.\r\n */\r\nexport interface IDraggableIconProps {\r\n /**\r\n * Icon source\r\n */\r\n src: string;\r\n /**\r\n * Object that will be passed to the drag event\r\n */\r\n item: TabDrag;\r\n /**\r\n * Type of drag event\r\n */\r\n type: ElementTypes;\r\n}\r\n\r\n/**\r\n * An icon that can be dragged by the user\r\n */\r\nexport const DraggableIcon: FC<IDraggableIconProps> = (props) => {\r\n const [, drag] = useDrag(() => ({\r\n type: props.type,\r\n item: props.item,\r\n collect(monitor) {\r\n return {\r\n isDragging: !!monitor.isDragging(),\r\n };\r\n },\r\n }));\r\n return <img ref={drag} src={props.src} />;\r\n};\r\n"]}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
/**
|
3
|
+
* Arguments for the Column component.
|
4
|
+
*/
|
5
|
+
export interface IFlexibleColumnProps {
|
6
|
+
/**
|
7
|
+
* Width of column
|
8
|
+
*/
|
9
|
+
width: string;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* This component represents a single column in the layout. It receives a width
|
13
|
+
* that it occupies and the content to display
|
14
|
+
* @param props
|
15
|
+
* @returns
|
16
|
+
*/
|
17
|
+
export declare const FlexibleColumn: FC<IFlexibleColumnProps>;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import style from "./FlexibleColumn.modules.scss";
|
3
|
+
/**
|
4
|
+
* This component represents a single column in the layout. It receives a width
|
5
|
+
* that it occupies and the content to display
|
6
|
+
* @param props
|
7
|
+
* @returns
|
8
|
+
*/
|
9
|
+
export const FlexibleColumn = (props) => {
|
10
|
+
return (_jsx("div", { style: { width: props.width }, className: style.flexibleColumn, children: props.children }));
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=FlexibleColumn.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleColumn.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleColumn.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,+BAA+B,CAAC;AAYlD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAA6B,CAAC,KAAK,EAAE,EAAE;IAC9D,OAAO,CACH,cAAK,KAAK,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,cAAc,YAC9D,KAAK,CAAC,QAAQ,GACb,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport style from \"./FlexibleColumn.modules.scss\";\r\n\r\n/**\r\n * Arguments for the Column component.\r\n */\r\nexport interface IFlexibleColumnProps {\r\n /**\r\n * Width of column\r\n */\r\n width: string;\r\n}\r\n\r\n/**\r\n * This component represents a single column in the layout. It receives a width\r\n * that it occupies and the content to display\r\n * @param props\r\n * @returns\r\n */\r\nexport const FlexibleColumn: FC<IFlexibleColumnProps> = (props) => {\r\n return (\r\n <div style={{ width: props.width }} className={style.flexibleColumn}>\r\n {props.children}\r\n </div>\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
/**
|
3
|
+
* Arguments for the DragHandler component.
|
4
|
+
*/
|
5
|
+
export interface IFlexibleDragHandlerProps {
|
6
|
+
/**
|
7
|
+
* The size of the containing element. Used to calculate the percentage of
|
8
|
+
* space occupied by the component
|
9
|
+
*/
|
10
|
+
containerSize: {
|
11
|
+
width: number;
|
12
|
+
height: number;
|
13
|
+
};
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* This component receives the drop events and updates the layout accordingly
|
17
|
+
*/
|
18
|
+
export declare const FlexibleDragHandler: FC<IFlexibleDragHandlerProps>;
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useContext, useRef } from "react";
|
3
|
+
import { Vector2 } from "@babylonjs/core/Maths/math.js";
|
4
|
+
import { useDrop } from "react-dnd";
|
5
|
+
import { ElementTypes } from "./types.js";
|
6
|
+
import { addPercentageStringToNumber, getPosInLayout } from "./utils.js";
|
7
|
+
import { LayoutContext } from "./LayoutContext.js";
|
8
|
+
/**
|
9
|
+
* This component receives the drop events and updates the layout accordingly
|
10
|
+
*/
|
11
|
+
export const FlexibleDragHandler = (props) => {
|
12
|
+
const { layout, setLayout } = useContext(LayoutContext);
|
13
|
+
// CLICK/DRAG INFORMATION
|
14
|
+
const pointerPos = useRef(null);
|
15
|
+
const [_, drop] = useDrop(() => ({
|
16
|
+
accept: [ElementTypes.RESIZE_BAR],
|
17
|
+
hover(item, monitor) {
|
18
|
+
const anyitem = item;
|
19
|
+
const xy = monitor.getClientOffset();
|
20
|
+
const pos = new Vector2(xy.x, xy.y);
|
21
|
+
if (pointerPos.current) {
|
22
|
+
if (monitor.getItemType() === ElementTypes.RESIZE_BAR) {
|
23
|
+
onResize(anyitem.rowNumber, anyitem.columnNumber, pos, pointerPos.current, anyitem.direction);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
pointerPos.current = pos;
|
27
|
+
},
|
28
|
+
drop(item, monitor) {
|
29
|
+
pointerPos.current = null;
|
30
|
+
},
|
31
|
+
}));
|
32
|
+
const getLayoutProperty = (layout, property) => {
|
33
|
+
if (property === "width") {
|
34
|
+
return layout[property];
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
return layout[property];
|
38
|
+
}
|
39
|
+
};
|
40
|
+
const setLayoutProperty = (layout, property, value) => {
|
41
|
+
if (property === "width") {
|
42
|
+
layout[property] = value;
|
43
|
+
}
|
44
|
+
else {
|
45
|
+
layout[property] = value;
|
46
|
+
}
|
47
|
+
};
|
48
|
+
const processResize = (pos, prevPos, row0, column0, row1, column1, axis, maxAxisValue, property, minFinalValue) => {
|
49
|
+
// Check axis difference
|
50
|
+
const axisDiff = pos[axis] - prevPos[axis];
|
51
|
+
try {
|
52
|
+
// Get layout rows
|
53
|
+
const layoutElement0 = getPosInLayout(layout, column0, row0);
|
54
|
+
const layoutElement1 = getPosInLayout(layout, column1, row1);
|
55
|
+
if (layoutElement0 && layoutElement1) {
|
56
|
+
const percDiff = (axisDiff / maxAxisValue) * 100;
|
57
|
+
const newValue0 = addPercentageStringToNumber(getLayoutProperty(layoutElement0, property), percDiff);
|
58
|
+
const newValue1 = addPercentageStringToNumber(getLayoutProperty(layoutElement1, property), -percDiff);
|
59
|
+
if (newValue0 >= minFinalValue && newValue1 >= minFinalValue) {
|
60
|
+
setLayoutProperty(layoutElement0, property, newValue0.toFixed(2) + "%");
|
61
|
+
setLayoutProperty(layoutElement1, property, newValue1.toFixed(2) + "%");
|
62
|
+
}
|
63
|
+
setLayout({ ...layout });
|
64
|
+
}
|
65
|
+
}
|
66
|
+
catch (e) {
|
67
|
+
// If an error occurred, we're trying to resize something invalid, so don't do anything
|
68
|
+
return;
|
69
|
+
}
|
70
|
+
};
|
71
|
+
const processResizeRow = (pos, prevPos, args) => {
|
72
|
+
processResize(pos, prevPos, args.row, args.column, args.row + 1, args.column, "y", props.containerSize.height, "height", 5);
|
73
|
+
};
|
74
|
+
const processResizeColumn = (pos, prevPos, args) => {
|
75
|
+
processResize(pos, prevPos, undefined, args.column, undefined, args.column + 1, "x", props.containerSize.width, "width", 5);
|
76
|
+
};
|
77
|
+
const onResize = (row, column, pos, prevPos, type) => {
|
78
|
+
if (type === "row") {
|
79
|
+
processResizeRow(pos, prevPos, { row, column });
|
80
|
+
}
|
81
|
+
else {
|
82
|
+
processResizeColumn(pos, prevPos, { row, column });
|
83
|
+
}
|
84
|
+
pointerPos.current = pos;
|
85
|
+
};
|
86
|
+
return (_jsx("div", { ref: drop, style: { width: "100%", height: "100%" }, children: props.children }));
|
87
|
+
};
|
88
|
+
//# sourceMappingURL=FlexibleDragHandler.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleDragHandler.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleDragHandler.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,O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AAK,EAAE;YAChB,gBAAgB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;SACnD;aAAM;YACH,mBAAmB,CAAC,GAAG,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC;SACtD;QACD,UAAU,CAAC,OAAO,GAAG,GAAG,CAAC;IAC7B,CAAC,CAAC;IAEF,OAAO,CACH,cAAK,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YACnD,KAAK,CAAC,QAAQ,GACb,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport { useContext, useRef } from \"react\";\r\nimport { Vector2 } from \"core/Maths/math\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { useDrop } from \"react-dnd\";\r\nimport { ElementTypes } from \"./types\";\r\nimport type { LayoutTabsRow, LayoutColumn } from \"./types\";\r\nimport { addPercentageStringToNumber, getPosInLayout } from \"./utils\";\r\nimport { LayoutContext } from \"./LayoutContext\";\r\nimport type { ResizeItem } from \"./FlexibleResizeBar\";\r\n\r\n/**\r\n * Arguments for the DragHandler component.\r\n */\r\nexport interface IFlexibleDragHandlerProps {\r\n /**\r\n * The size of the containing element. Used to calculate the percentage of\r\n * space occupied by the component\r\n */\r\n containerSize: { width: number; height: number };\r\n}\r\n\r\n/**\r\n * This component receives the drop events and updates the layout accordingly\r\n */\r\nexport const FlexibleDragHandler: FC<IFlexibleDragHandlerProps> = (props) => {\r\n const { layout, setLayout } = useContext(LayoutContext);\r\n // CLICK/DRAG INFORMATION\r\n const pointerPos = useRef<Nullable<Vector2>>(null);\r\n const [_, drop] = useDrop(() => ({\r\n accept: [ElementTypes.RESIZE_BAR],\r\n hover(item, monitor) {\r\n const anyitem = item as ResizeItem;\r\n\r\n const xy = monitor.getClientOffset();\r\n const pos = new Vector2(xy!.x, xy!.y);\r\n if (pointerPos.current) {\r\n if (monitor.getItemType() === ElementTypes.RESIZE_BAR) {\r\n onResize(anyitem.rowNumber, anyitem.columnNumber, pos, pointerPos.current, anyitem.direction);\r\n }\r\n }\r\n pointerPos.current = pos;\r\n },\r\n drop(item, monitor) {\r\n pointerPos.current = null;\r\n },\r\n }));\r\n\r\n const getLayoutProperty = (layout: LayoutColumn | LayoutTabsRow, property: \"width\" | \"height\") => {\r\n if (property === \"width\") {\r\n return (layout as LayoutColumn)[property];\r\n } else {\r\n return (layout as LayoutTabsRow)[property];\r\n }\r\n };\r\n\r\n const setLayoutProperty = (layout: LayoutColumn | LayoutTabsRow, property: \"width\" | \"height\", value: string) => {\r\n if (property === \"width\") {\r\n (layout as LayoutColumn)[property] = value;\r\n } else {\r\n (layout as LayoutTabsRow)[property] = value;\r\n }\r\n };\r\n\r\n const processResize = (\r\n pos: Vector2,\r\n prevPos: Vector2,\r\n row0: number | undefined,\r\n column0: number,\r\n row1: number | undefined,\r\n column1: number,\r\n axis: \"x\" | \"y\",\r\n maxAxisValue: number,\r\n property: \"width\" | \"height\",\r\n minFinalValue: number\r\n ) => {\r\n // Check axis difference\r\n const axisDiff = pos[axis] - prevPos[axis];\r\n\r\n try {\r\n // Get layout rows\r\n const layoutElement0 = getPosInLayout(layout, column0, row0);\r\n const layoutElement1 = getPosInLayout(layout, column1, row1);\r\n\r\n if (layoutElement0 && layoutElement1) {\r\n const percDiff = (axisDiff / maxAxisValue) * 100;\r\n\r\n const newValue0 = addPercentageStringToNumber(getLayoutProperty(layoutElement0, property), percDiff);\r\n const newValue1 = addPercentageStringToNumber(getLayoutProperty(layoutElement1, property), -percDiff);\r\n\r\n if (newValue0 >= minFinalValue && newValue1 >= minFinalValue) {\r\n setLayoutProperty(layoutElement0, property, newValue0.toFixed(2) + \"%\");\r\n setLayoutProperty(layoutElement1, property, newValue1.toFixed(2) + \"%\");\r\n }\r\n\r\n setLayout({ ...layout });\r\n }\r\n } catch (e) {\r\n // If an error occurred, we're trying to resize something invalid, so don't do anything\r\n return;\r\n }\r\n };\r\n\r\n const processResizeRow = (pos: Vector2, prevPos: Vector2, args: { row: number; column: number }) => {\r\n processResize(pos, prevPos, args.row, args.column, args.row + 1, args.column, \"y\", props.containerSize.height, \"height\", 5);\r\n };\r\n\r\n const processResizeColumn = (pos: Vector2, prevPos: Vector2, args: { row: number; column: number }) => {\r\n processResize(pos, prevPos, undefined, args.column, undefined, args.column + 1, \"x\", props.containerSize.width, \"width\", 5);\r\n };\r\n\r\n const onResize = (row: number, column: number, pos: Vector2, prevPos: Vector2, type: \"row\" | \"column\") => {\r\n if (type === \"row\") {\r\n processResizeRow(pos, prevPos, { row, column });\r\n } else {\r\n processResizeColumn(pos, prevPos, { row, column });\r\n }\r\n pointerPos.current = pos;\r\n };\r\n\r\n return (\r\n <div ref={drop} style={{ width: \"100%\", height: \"100%\" }}>\r\n {props.children}\r\n </div>\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
/**
|
3
|
+
* Arguments for the FlexibleDropZone component.
|
4
|
+
*/
|
5
|
+
export interface IFlexibleDropZoneProps {
|
6
|
+
/**
|
7
|
+
* The row number of the component in the layout
|
8
|
+
*/
|
9
|
+
rowNumber: number;
|
10
|
+
/**
|
11
|
+
* The column number of the component in the layout
|
12
|
+
*/
|
13
|
+
columnNumber: number;
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* This component contains the drag and drop zone for the resize bars that
|
17
|
+
* allow redefining width and height of layout elements
|
18
|
+
*/
|
19
|
+
export declare const FlexibleDropZone: FC<IFlexibleDropZoneProps>;
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import style from "./FlexibleDropZone.modules.scss";
|
3
|
+
import { FlexibleResizeBar } from "./FlexibleResizeBar.js";
|
4
|
+
import { ResizeDirections } from "./types.js";
|
5
|
+
/**
|
6
|
+
* This component contains the drag and drop zone for the resize bars that
|
7
|
+
* allow redefining width and height of layout elements
|
8
|
+
*/
|
9
|
+
export const FlexibleDropZone = (props) => {
|
10
|
+
return (_jsxs("div", { className: style.flexibleDropZoneContainer, children: [props.children, _jsx(FlexibleResizeBar, { rowNumber: props.rowNumber, columnNumber: props.columnNumber, direction: ResizeDirections.COLUMN }), _jsx(FlexibleResizeBar, { rowNumber: props.rowNumber, columnNumber: props.columnNumber, direction: ResizeDirections.ROW })] }));
|
11
|
+
};
|
12
|
+
//# sourceMappingURL=FlexibleDropZone.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleDropZone.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleDropZone.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,MAAM,iCAAiC,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAgB3C;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAA+B,CAAC,KAAK,EAAE,EAAE;IAClE,OAAO,CACH,eAAK,SAAS,EAAE,KAAK,CAAC,yBAAyB,aAC1C,KAAK,CAAC,QAAQ,EACf,KAAC,iBAAiB,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,CAAC,MAAM,GAAI,EACvH,KAAC,iBAAiB,IAAC,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE,SAAS,EAAE,gBAAgB,CAAC,GAAG,GAAI,IAClH,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport style from \"./FlexibleDropZone.modules.scss\";\r\nimport { FlexibleResizeBar } from \"./FlexibleResizeBar\";\r\nimport { ResizeDirections } from \"./types\";\r\n\r\n/**\r\n * Arguments for the FlexibleDropZone component.\r\n */\r\nexport interface IFlexibleDropZoneProps {\r\n /**\r\n * The row number of the component in the layout\r\n */\r\n rowNumber: number;\r\n /**\r\n * The column number of the component in the layout\r\n */\r\n columnNumber: number;\r\n}\r\n\r\n/**\r\n * This component contains the drag and drop zone for the resize bars that\r\n * allow redefining width and height of layout elements\r\n */\r\nexport const FlexibleDropZone: FC<IFlexibleDropZoneProps> = (props) => {\r\n return (\r\n <div className={style.flexibleDropZoneContainer}>\r\n {props.children}\r\n <FlexibleResizeBar rowNumber={props.rowNumber} columnNumber={props.columnNumber} direction={ResizeDirections.COLUMN} />\r\n <FlexibleResizeBar rowNumber={props.rowNumber} columnNumber={props.columnNumber} direction={ResizeDirections.ROW} />\r\n </div>\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
/**
|
3
|
+
* Arguments for the GridContainer component.
|
4
|
+
*/
|
5
|
+
export interface IFlexibleGridContainerProps {
|
6
|
+
}
|
7
|
+
/**
|
8
|
+
* Component responsible for mapping the layout to the actual components
|
9
|
+
*/
|
10
|
+
export declare const FlexibleGridContainer: FC<IFlexibleGridContainerProps>;
|
@@ -0,0 +1,23 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useContext } from "react";
|
3
|
+
import { LayoutContext } from "./LayoutContext.js";
|
4
|
+
import { FlexibleColumn } from "./FlexibleColumn.js";
|
5
|
+
import { FlexibleDropZone } from "./FlexibleDropZone.js";
|
6
|
+
import { FlexibleTabsContainer } from "./FlexibleTabsContainer.js";
|
7
|
+
import style from "./FlexibleGridContainer.modules.scss";
|
8
|
+
/**
|
9
|
+
* Component responsible for mapping the layout to the actual components
|
10
|
+
*/
|
11
|
+
export const FlexibleGridContainer = () => {
|
12
|
+
const context = useContext(LayoutContext);
|
13
|
+
const { layout } = context;
|
14
|
+
const columns = layout && layout.columns
|
15
|
+
? layout.columns.map((column, columnIdx) => {
|
16
|
+
return (_jsx(FlexibleColumn, { width: column.width, children: column.rows.map((row, rowIdx) => {
|
17
|
+
return (_jsx("div", { style: { height: row.height }, children: _jsx(FlexibleDropZone, { rowNumber: rowIdx, columnNumber: columnIdx, children: _jsx(FlexibleTabsContainer, { tabs: row.tabs, selectedTab: row.selectedTab, rowIndex: rowIdx, columnIndex: columnIdx }) }) }, row.id));
|
18
|
+
}) }, column.id));
|
19
|
+
})
|
20
|
+
: [];
|
21
|
+
return _jsx("div", { className: style.flexibleGrid, children: columns });
|
22
|
+
};
|
23
|
+
//# sourceMappingURL=FlexibleGridContainer.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleGridContainer.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleGridContainer.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,KAAK,MAAM,sCAAsC,CAAC;AAOzD;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAoC,GAAG,EAAE;IACvE,MAAM,OAAO,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IAC1C,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAC3B,MAAM,OAAO,GACT,MAAM,IAAI,MAAM,CAAC,OAAO;QACpB,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,SAAiB,EAAE,EAAE;YAClD,OAAO,CACH,KAAC,cAAc,IAAiB,KAAK,EAAE,MAAM,CAAC,KAAK,YAC9C,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAQ,EAAE,MAAc,EAAE,EAAE;oBAC1C,OAAO,CACH,cAAK,KAAK,EAAE,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,YAC9B,KAAC,gBAAgB,IAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,SAAS,YACxD,KAAC,qBAAqB,IAAC,IAAI,EAAE,GAAG,CAAC,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,WAAW,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,GAAI,GAClG,IAHkB,GAAG,CAAC,EAAE,CAIzC,CACT,CAAC;gBACN,CAAC,CAAC,IATe,MAAM,CAAC,EAAE,CAUb,CACpB,CAAC;QACN,CAAC,CAAC;QACJ,CAAC,CAAC,EAAE,CAAC;IACb,OAAO,cAAK,SAAS,EAAE,KAAK,CAAC,YAAY,YAAG,OAAO,GAAO,CAAC;AAC/D,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport { useContext } from \"react\";\r\nimport { LayoutContext } from \"./LayoutContext\";\r\nimport { FlexibleColumn } from \"./FlexibleColumn\";\r\nimport { FlexibleDropZone } from \"./FlexibleDropZone\";\r\nimport { FlexibleTabsContainer } from \"./FlexibleTabsContainer\";\r\nimport style from \"./FlexibleGridContainer.modules.scss\";\r\n\r\n/**\r\n * Arguments for the GridContainer component.\r\n */\r\nexport interface IFlexibleGridContainerProps {}\r\n\r\n/**\r\n * Component responsible for mapping the layout to the actual components\r\n */\r\nexport const FlexibleGridContainer: FC<IFlexibleGridContainerProps> = () => {\r\n const context = useContext(LayoutContext);\r\n const { layout } = context;\r\n const columns =\r\n layout && layout.columns\r\n ? layout.columns.map((column: any, columnIdx: number) => {\r\n return (\r\n <FlexibleColumn key={column.id} width={column.width}>\r\n {column.rows.map((row: any, rowIdx: number) => {\r\n return (\r\n <div style={{ height: row.height }} key={row.id}>\r\n <FlexibleDropZone rowNumber={rowIdx} columnNumber={columnIdx}>\r\n <FlexibleTabsContainer tabs={row.tabs} selectedTab={row.selectedTab} rowIndex={rowIdx} columnIndex={columnIdx} />\r\n </FlexibleDropZone>\r\n </div>\r\n );\r\n })}\r\n </FlexibleColumn>\r\n );\r\n })\r\n : [];\r\n return <div className={style.flexibleGrid}>{columns}</div>;\r\n};\r\n"]}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
import type { Layout } from "./types";
|
3
|
+
/**
|
4
|
+
* Arguments for the Layout component.
|
5
|
+
*/
|
6
|
+
export interface IFlexibleGridLayoutProps {
|
7
|
+
/**
|
8
|
+
* A definition of the layout which can be changed by the user
|
9
|
+
*/
|
10
|
+
layoutDefinition: Layout;
|
11
|
+
}
|
12
|
+
/**
|
13
|
+
* This component represents a grid layout that can be resized and rearranged
|
14
|
+
* by the user.
|
15
|
+
*/
|
16
|
+
export declare const FlexibleGridLayout: FC<IFlexibleGridLayoutProps>;
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useRef, useEffect, useState } from "react";
|
3
|
+
import { DndProvider } from "react-dnd";
|
4
|
+
import { TouchBackend } from "react-dnd-touch-backend";
|
5
|
+
import { FlexibleDragHandler } from "./FlexibleDragHandler.js";
|
6
|
+
import { LayoutContext } from "./LayoutContext.js";
|
7
|
+
import { FlexibleGridContainer } from "./FlexibleGridContainer.js";
|
8
|
+
/**
|
9
|
+
* This component represents a grid layout that can be resized and rearranged
|
10
|
+
* by the user.
|
11
|
+
*/
|
12
|
+
export const FlexibleGridLayout = (props) => {
|
13
|
+
const [layout, setLayout] = useState(props.layoutDefinition);
|
14
|
+
const containerDiv = useRef(null);
|
15
|
+
const containerSize = useRef({ width: 0, height: 0 });
|
16
|
+
useEffect(() => {
|
17
|
+
if (containerDiv.current) {
|
18
|
+
containerSize.current.width = containerDiv.current.clientWidth;
|
19
|
+
containerSize.current.height = containerDiv.current.clientHeight;
|
20
|
+
}
|
21
|
+
}, [containerDiv]);
|
22
|
+
return (_jsx(DndProvider, { backend: TouchBackend, options: { enableMouseEvents: true }, children: _jsx(LayoutContext.Provider, { value: { layout, setLayout }, children: _jsx(FlexibleDragHandler, { containerSize: containerSize.current, children: _jsx("div", { style: { width: "100%", height: "100%" }, ref: containerDiv, children: _jsx(FlexibleGridContainer, {}) }) }) }) }));
|
23
|
+
};
|
24
|
+
//# sourceMappingURL=FlexibleGridLayout.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleGridLayout.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleGridLayout.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEpD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAahE;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAiC,CAAC,KAAK,EAAE,EAAE;IACtE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IAC7D,MAAM,YAAY,GAAG,MAAM,CAA2B,IAAI,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,CAAC;IAEtD,SAAS,CAAC,GAAG,EAAE;QACX,IAAI,YAAY,CAAC,OAAO,EAAE;YACtB,aAAa,CAAC,OAAO,CAAC,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,WAAW,CAAC;YAC/D,aAAa,CAAC,OAAO,CAAC,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,YAAY,CAAC;SACpE;IACL,CAAC,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IAEnB,OAAO,CACH,KAAC,WAAW,IAAC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,EAAE,iBAAiB,EAAE,IAAI,EAAE,YACpE,KAAC,aAAa,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,YAChD,KAAC,mBAAmB,IAAC,aAAa,EAAE,aAAa,CAAC,OAAO,YACrD,cAAK,KAAK,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,YAAY,YAC5D,KAAC,qBAAqB,KAAG,GACvB,GACY,GACD,GACf,CACjB,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport { useRef, useEffect, useState } from \"react\";\r\nimport type { Nullable } from \"core/types\";\r\nimport { DndProvider } from \"react-dnd\";\r\nimport { TouchBackend } from \"react-dnd-touch-backend\";\r\nimport { FlexibleDragHandler } from \"./FlexibleDragHandler\";\r\nimport { LayoutContext } from \"./LayoutContext\";\r\nimport { FlexibleGridContainer } from \"./FlexibleGridContainer\";\r\nimport type { Layout } from \"./types\";\r\n\r\n/**\r\n * Arguments for the Layout component.\r\n */\r\nexport interface IFlexibleGridLayoutProps {\r\n /**\r\n * A definition of the layout which can be changed by the user\r\n */\r\n layoutDefinition: Layout;\r\n}\r\n\r\n/**\r\n * This component represents a grid layout that can be resized and rearranged\r\n * by the user.\r\n */\r\nexport const FlexibleGridLayout: FC<IFlexibleGridLayoutProps> = (props) => {\r\n const [layout, setLayout] = useState(props.layoutDefinition);\r\n const containerDiv = useRef<Nullable<HTMLDivElement>>(null);\r\n const containerSize = useRef({ width: 0, height: 0 });\r\n\r\n useEffect(() => {\r\n if (containerDiv.current) {\r\n containerSize.current.width = containerDiv.current.clientWidth;\r\n containerSize.current.height = containerDiv.current.clientHeight;\r\n }\r\n }, [containerDiv]);\r\n\r\n return (\r\n <DndProvider backend={TouchBackend} options={{ enableMouseEvents: true }}>\r\n <LayoutContext.Provider value={{ layout, setLayout }}>\r\n <FlexibleDragHandler containerSize={containerSize.current}>\r\n <div style={{ width: \"100%\", height: \"100%\" }} ref={containerDiv}>\r\n <FlexibleGridContainer />\r\n </div>\r\n </FlexibleDragHandler>\r\n </LayoutContext.Provider>\r\n </DndProvider>\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
import { ResizeDirections } from "./types";
|
3
|
+
/**
|
4
|
+
* Arguments for the ResizeBar component.
|
5
|
+
*/
|
6
|
+
export interface IFlexibleRowResizerProps {
|
7
|
+
/**
|
8
|
+
* Row number of the component that is being resized
|
9
|
+
*/
|
10
|
+
rowNumber: number;
|
11
|
+
/**
|
12
|
+
* Column number of the component being resized
|
13
|
+
*/
|
14
|
+
columnNumber: number;
|
15
|
+
/**
|
16
|
+
* If the resizing happens in row or column direction
|
17
|
+
*/
|
18
|
+
direction: ResizeDirections;
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* The item that will be sent to the drag event
|
22
|
+
*/
|
23
|
+
export declare type ResizeItem = {
|
24
|
+
/**
|
25
|
+
* If the resizing happens in row or column direction
|
26
|
+
*/
|
27
|
+
direction: ResizeDirections;
|
28
|
+
/**
|
29
|
+
* The row number of the component that is being resized
|
30
|
+
*/
|
31
|
+
rowNumber: number;
|
32
|
+
/**
|
33
|
+
* the column number of the component being resized
|
34
|
+
*/
|
35
|
+
columnNumber: number;
|
36
|
+
};
|
37
|
+
/**
|
38
|
+
* A component that renders a bar that the user can drag to resize.
|
39
|
+
*/
|
40
|
+
export declare const FlexibleResizeBar: FC<IFlexibleRowResizerProps>;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
2
|
+
import { useDrag } from "react-dnd";
|
3
|
+
import { ResizeDirections, ElementTypes } from "./types.js";
|
4
|
+
import { ClassNames } from "../classNames.js";
|
5
|
+
import style from "./FlexibleResizeBar.modules.scss";
|
6
|
+
/**
|
7
|
+
* A component that renders a bar that the user can drag to resize.
|
8
|
+
*/
|
9
|
+
export const FlexibleResizeBar = (props) => {
|
10
|
+
const [_, drag] = useDrag(() => ({
|
11
|
+
type: ElementTypes.RESIZE_BAR,
|
12
|
+
item: { direction: props.direction, rowNumber: props.rowNumber, columnNumber: props.columnNumber },
|
13
|
+
collect(monitor) {
|
14
|
+
return {
|
15
|
+
isDragging: !!monitor.isDragging(),
|
16
|
+
};
|
17
|
+
},
|
18
|
+
}));
|
19
|
+
return (_jsx("div", { className: ClassNames({ rowDragHandler: props.direction === ResizeDirections.ROW, columnDragHandler: props.direction === ResizeDirections.COLUMN }, style), ref: drag }));
|
20
|
+
};
|
21
|
+
//# sourceMappingURL=FlexibleResizeBar.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleResizeBar.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleResizeBar.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,MAAM,kCAAkC,CAAC;AAsCrD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAiC,CAAC,KAAK,EAAE,EAAE;IACrE,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7B,IAAI,EAAE,YAAY,CAAC,UAAU;QAC7B,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,YAAY,EAAE,KAAK,CAAC,YAAY,EAAE;QAClG,OAAO,CAAC,OAAO;YACX,OAAO;gBACH,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,EAAE;aACrC,CAAC;QACN,CAAC;KACJ,CAAC,CAAC,CAAC;IACJ,OAAO,CACH,cACI,SAAS,EAAE,UAAU,CAAC,EAAE,cAAc,EAAE,KAAK,CAAC,SAAS,KAAK,gBAAgB,CAAC,GAAG,EAAE,iBAAiB,EAAE,KAAK,CAAC,SAAS,KAAK,gBAAgB,CAAC,MAAM,EAAE,EAAE,KAAK,CAAC,EAC1J,GAAG,EAAE,IAAI,GACX,CACL,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport { useDrag } from \"react-dnd\";\r\nimport { ResizeDirections, ElementTypes } from \"./types\";\r\nimport { ClassNames } from \"../classNames\";\r\nimport style from \"./FlexibleResizeBar.modules.scss\";\r\n\r\n/**\r\n * Arguments for the ResizeBar component.\r\n */\r\nexport interface IFlexibleRowResizerProps {\r\n /**\r\n * Row number of the component that is being resized\r\n */\r\n rowNumber: number;\r\n /**\r\n * Column number of the component being resized\r\n */\r\n columnNumber: number;\r\n /**\r\n * If the resizing happens in row or column direction\r\n */\r\n direction: ResizeDirections;\r\n}\r\n\r\n/**\r\n * The item that will be sent to the drag event\r\n */\r\nexport type ResizeItem = {\r\n /**\r\n * If the resizing happens in row or column direction\r\n */\r\n direction: ResizeDirections;\r\n /**\r\n * The row number of the component that is being resized\r\n */\r\n rowNumber: number;\r\n /**\r\n * the column number of the component being resized\r\n */\r\n columnNumber: number;\r\n};\r\n\r\n/**\r\n * A component that renders a bar that the user can drag to resize.\r\n */\r\nexport const FlexibleResizeBar: FC<IFlexibleRowResizerProps> = (props) => {\r\n const [_, drag] = useDrag(() => ({\r\n type: ElementTypes.RESIZE_BAR,\r\n item: { direction: props.direction, rowNumber: props.rowNumber, columnNumber: props.columnNumber },\r\n collect(monitor) {\r\n return {\r\n isDragging: !!monitor.isDragging(),\r\n };\r\n },\r\n }));\r\n return (\r\n <div\r\n className={ClassNames({ rowDragHandler: props.direction === ResizeDirections.ROW, columnDragHandler: props.direction === ResizeDirections.COLUMN }, style)}\r\n ref={drag}\r\n />\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,34 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
import type { TabDrag } from "./types";
|
3
|
+
/**
|
4
|
+
* Arguments for the FlexibleTab component.
|
5
|
+
*/
|
6
|
+
export interface IFlexibleTabProps {
|
7
|
+
/**
|
8
|
+
* The tab's title.
|
9
|
+
*/
|
10
|
+
title: string;
|
11
|
+
/**
|
12
|
+
* If the tab is currently selected or not
|
13
|
+
*/
|
14
|
+
selected: boolean;
|
15
|
+
/**
|
16
|
+
* What happens when the user clicks on the tab
|
17
|
+
*/
|
18
|
+
onClick: () => void;
|
19
|
+
/**
|
20
|
+
* The object that will be sent to the drag event
|
21
|
+
*/
|
22
|
+
item: TabDrag;
|
23
|
+
/**
|
24
|
+
* What happens when the user drops another tab after this one
|
25
|
+
*/
|
26
|
+
onTabDroppedAction: (item: TabDrag) => void;
|
27
|
+
}
|
28
|
+
/**
|
29
|
+
* A component that renders a tab that the user can click
|
30
|
+
* to activate or drag to reorder. It also listens for
|
31
|
+
* drop events if the user wants to drop another tab
|
32
|
+
* after it.
|
33
|
+
*/
|
34
|
+
export declare const FlexibleTab: FC<IFlexibleTabProps>;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
+
import { useDrag, useDrop } from "react-dnd";
|
3
|
+
import { ClassNames } from "../classNames.js";
|
4
|
+
import { ElementTypes } from "./types.js";
|
5
|
+
import style from "./FlexibleTab.modules.scss";
|
6
|
+
/**
|
7
|
+
* A component that renders a tab that the user can click
|
8
|
+
* to activate or drag to reorder. It also listens for
|
9
|
+
* drop events if the user wants to drop another tab
|
10
|
+
* after it.
|
11
|
+
*/
|
12
|
+
export const FlexibleTab = (props) => {
|
13
|
+
const [{ isDragging }, drag] = useDrag(() => ({
|
14
|
+
type: ElementTypes.TAB,
|
15
|
+
item: props.item,
|
16
|
+
collect(monitor) {
|
17
|
+
return {
|
18
|
+
isDragging: !!monitor.isDragging(),
|
19
|
+
};
|
20
|
+
},
|
21
|
+
}), [props.item]);
|
22
|
+
const [{ isOver, canDrop }, drop] = useDrop(() => ({
|
23
|
+
accept: ElementTypes.TAB,
|
24
|
+
drop: (item, monitor) => {
|
25
|
+
props.onTabDroppedAction(item);
|
26
|
+
},
|
27
|
+
collect(monitor) {
|
28
|
+
return {
|
29
|
+
isOver: !!monitor.isOver(),
|
30
|
+
canDrop: !!monitor.canDrop(),
|
31
|
+
};
|
32
|
+
},
|
33
|
+
}), [props.onTabDroppedAction]);
|
34
|
+
return (_jsxs("div", { className: ClassNames({ tab: true, tabSelected: props.selected, tabGrabbed: isDragging, tabNormal: !props.selected && !isDragging }, style), children: [_jsx("div", { ref: drag, className: style.tabText, onClick: props.onClick, children: props.title }), _jsx("div", { className: ClassNames({ dropZone: true, dropZoneCanDrop: canDrop }, style), ref: drop }), _jsx("div", { className: ClassNames({ dropBarIndicator: true, dropBarIndicatorOver: isOver }, style) })] }));
|
35
|
+
};
|
36
|
+
//# sourceMappingURL=FlexibleTab.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"FlexibleTab.js","sourceRoot":"","sources":["../../../../../../dev/sharedUiComponents/src/components/layout/FlexibleTab.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,MAAM,4BAA4B,CAAC;AA4B/C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,WAAW,GAA0B,CAAC,KAAK,EAAE,EAAE;IACxD,MAAM,CAAC,EAAE,UAAU,EAAE,EAAE,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KAAK,CAAC,EAAE,GAAG,EAAE,IAAI,GAAQ,EAClG,cAAK,SAAS,EAAE,UAAU,CAAC,EAAE,gBAAgB,EAAE,IAAI,EAAE,oBAAoB,EAAE,MAAM,EAAE,EAAE,KAAK,CAAC,GAAQ,IACjG,CACT,CAAC;AACN,CAAC,CAAC","sourcesContent":["import type { FC } from \"react\";\r\nimport { useDrag, useDrop } from \"react-dnd\";\r\nimport { ClassNames } from \"../classNames\";\r\nimport { ElementTypes } from \"./types\";\r\nimport type { TabDrag } from \"./types\";\r\nimport style from \"./FlexibleTab.modules.scss\";\r\n\r\n/**\r\n * Arguments for the FlexibleTab component.\r\n */\r\nexport interface IFlexibleTabProps {\r\n /**\r\n * The tab's title.\r\n */\r\n title: string;\r\n /**\r\n * If the tab is currently selected or not\r\n */\r\n selected: boolean;\r\n /**\r\n * What happens when the user clicks on the tab\r\n */\r\n onClick: () => void;\r\n /**\r\n * The object that will be sent to the drag event\r\n */\r\n item: TabDrag;\r\n /**\r\n * What happens when the user drops another tab after this one\r\n */\r\n onTabDroppedAction: (item: TabDrag) => void;\r\n}\r\n\r\n/**\r\n * A component that renders a tab that the user can click\r\n * to activate or drag to reorder. It also listens for\r\n * drop events if the user wants to drop another tab\r\n * after it.\r\n */\r\nexport const FlexibleTab: FC<IFlexibleTabProps> = (props) => {\r\n const [{ isDragging }, drag] = useDrag(\r\n () => ({\r\n type: ElementTypes.TAB,\r\n item: props.item,\r\n collect(monitor) {\r\n return {\r\n isDragging: !!monitor.isDragging(),\r\n };\r\n },\r\n }),\r\n [props.item]\r\n );\r\n\r\n const [{ isOver, canDrop }, drop] = useDrop(\r\n () => ({\r\n accept: ElementTypes.TAB,\r\n drop: (item: any, monitor) => {\r\n props.onTabDroppedAction(item);\r\n },\r\n collect(monitor) {\r\n return {\r\n isOver: !!monitor.isOver(),\r\n canDrop: !!monitor.canDrop(),\r\n };\r\n },\r\n }),\r\n [props.onTabDroppedAction]\r\n );\r\n return (\r\n <div className={ClassNames({ tab: true, tabSelected: props.selected, tabGrabbed: isDragging, tabNormal: !props.selected && !isDragging }, style)}>\r\n <div ref={drag} className={style.tabText} onClick={props.onClick}>\r\n {props.title}\r\n </div>\r\n <div className={ClassNames({ dropZone: true, dropZoneCanDrop: canDrop }, style)} ref={drop}></div>\r\n <div className={ClassNames({ dropBarIndicator: true, dropBarIndicatorOver: isOver }, style)}></div>\r\n </div>\r\n );\r\n};\r\n"]}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import type { FC } from "react";
|
2
|
+
import type { LayoutTab } from "./types";
|
3
|
+
/**
|
4
|
+
* Arguments for the TabsContainer component.
|
5
|
+
*/
|
6
|
+
export interface IFlexibleTabsContainerProps {
|
7
|
+
/**
|
8
|
+
* The tabs to display
|
9
|
+
*/
|
10
|
+
tabs: LayoutTab[];
|
11
|
+
/**
|
12
|
+
* Row index of component in layout
|
13
|
+
*/
|
14
|
+
rowIndex: number;
|
15
|
+
/**
|
16
|
+
* Column index of component in layout
|
17
|
+
*/
|
18
|
+
columnIndex: number;
|
19
|
+
/**
|
20
|
+
* Which tab is selected in the layout
|
21
|
+
*/
|
22
|
+
selectedTab?: string;
|
23
|
+
}
|
24
|
+
/**
|
25
|
+
* This component contains a set of tabs of which only one is visible at a time.
|
26
|
+
* The tabs can also be dragged from and to different containers.
|
27
|
+
*/
|
28
|
+
export declare const FlexibleTabsContainer: FC<IFlexibleTabsContainerProps>;
|