@babylonjs/shared-ui-components 5.28.0 → 5.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. package/colorPicker/colorComponentEntry.d.ts +18 -18
  2. package/colorPicker/colorComponentEntry.js +36 -36
  3. package/colorPicker/colorPicker.d.ts +43 -43
  4. package/colorPicker/colorPicker.js +136 -136
  5. package/colorPicker/hexColor.d.ts +20 -20
  6. package/colorPicker/hexColor.js +42 -42
  7. package/components/Button.d.ts +10 -10
  8. package/components/Button.js +6 -6
  9. package/components/Icon.d.ts +6 -6
  10. package/components/Icon.js +6 -6
  11. package/components/Label.d.ts +7 -7
  12. package/components/Label.js +6 -6
  13. package/components/MessageDialog.d.ts +7 -7
  14. package/components/MessageDialog.js +22 -22
  15. package/components/Toggle.d.ts +8 -8
  16. package/components/Toggle.js +15 -15
  17. package/components/bars/CommandBarComponent.d.ts +16 -16
  18. package/components/bars/CommandBarComponent.js +68 -68
  19. package/components/bars/CommandButtonComponent.d.ts +11 -11
  20. package/components/bars/CommandButtonComponent.js +6 -6
  21. package/components/bars/CommandDropdownComponent.d.ts +26 -26
  22. package/components/bars/CommandDropdownComponent.js +48 -48
  23. package/components/classNames.d.ts +2 -2
  24. package/components/classNames.js +18 -18
  25. package/components/colorPicker/ColorComponentEntry.d.ts +18 -18
  26. package/components/colorPicker/ColorComponentEntry.js +37 -37
  27. package/components/colorPicker/ColorPicker.d.ts +43 -43
  28. package/components/colorPicker/ColorPicker.js +137 -137
  29. package/components/colorPicker/HexColor.d.ts +20 -20
  30. package/components/colorPicker/HexColor.js +45 -45
  31. package/components/layout/DraggableIcon.d.ts +23 -0
  32. package/components/layout/DraggableIcon.js +18 -0
  33. package/components/layout/DraggableIcon.js.map +1 -0
  34. package/components/layout/FlexibleColumn.d.ts +17 -0
  35. package/components/layout/FlexibleColumn.js +12 -0
  36. package/components/layout/FlexibleColumn.js.map +1 -0
  37. package/components/layout/FlexibleDragHandler.d.ts +18 -0
  38. package/components/layout/FlexibleDragHandler.js +88 -0
  39. package/components/layout/FlexibleDragHandler.js.map +1 -0
  40. package/components/layout/FlexibleDropZone.d.ts +19 -0
  41. package/components/layout/FlexibleDropZone.js +12 -0
  42. package/components/layout/FlexibleDropZone.js.map +1 -0
  43. package/components/layout/FlexibleGridContainer.d.ts +10 -0
  44. package/components/layout/FlexibleGridContainer.js +23 -0
  45. package/components/layout/FlexibleGridContainer.js.map +1 -0
  46. package/components/layout/FlexibleGridLayout.d.ts +16 -0
  47. package/components/layout/FlexibleGridLayout.js +24 -0
  48. package/components/layout/FlexibleGridLayout.js.map +1 -0
  49. package/components/layout/FlexibleResizeBar.d.ts +40 -0
  50. package/components/layout/FlexibleResizeBar.js +21 -0
  51. package/components/layout/FlexibleResizeBar.js.map +1 -0
  52. package/components/layout/FlexibleTab.d.ts +34 -0
  53. package/components/layout/FlexibleTab.js +36 -0
  54. package/components/layout/FlexibleTab.js.map +1 -0
  55. package/components/layout/FlexibleTabsContainer.d.ts +28 -0
  56. package/components/layout/FlexibleTabsContainer.js +54 -0
  57. package/components/layout/FlexibleTabsContainer.js.map +1 -0
  58. package/components/layout/LayoutContext.d.ts +12 -0
  59. package/components/layout/LayoutContext.js +3 -0
  60. package/components/layout/LayoutContext.js.map +1 -0
  61. package/components/layout/types.d.ts +78 -0
  62. package/components/layout/types.js +13 -0
  63. package/components/layout/types.js.map +1 -0
  64. package/components/layout/utils.d.ts +25 -0
  65. package/components/layout/utils.js +68 -0
  66. package/components/layout/utils.js.map +1 -0
  67. package/components/lines/ColorLineComponent.d.ts +40 -40
  68. package/components/lines/ColorLineComponent.js +145 -145
  69. package/components/lines/ColorPickerLineComponent.d.ts +33 -33
  70. package/components/lines/ColorPickerLineComponent.js +61 -61
  71. package/components/lines/FileButtonLineComponent.d.ts +16 -16
  72. package/components/lines/FileButtonLineComponent.js +21 -21
  73. package/components/lines/NumericInputComponent.d.ts +31 -31
  74. package/components/lines/NumericInputComponent.js +86 -86
  75. package/lines/booleanLineComponent.d.ts +11 -11
  76. package/lines/booleanLineComponent.js +14 -14
  77. package/lines/buttonLineComponent.d.ts +12 -12
  78. package/lines/buttonLineComponent.js +10 -10
  79. package/lines/checkBoxLineComponent.d.ts +36 -36
  80. package/lines/checkBoxLineComponent.js +88 -88
  81. package/lines/color3LineComponent.d.ts +18 -18
  82. package/lines/color3LineComponent.js +9 -9
  83. package/lines/color4LineComponent.d.ts +18 -18
  84. package/lines/color4LineComponent.js +9 -9
  85. package/lines/colorLineComponent.d.ts +40 -40
  86. package/lines/colorLineComponent.js +144 -144
  87. package/lines/colorPickerComponent.d.ts +31 -31
  88. package/lines/colorPickerComponent.js +60 -60
  89. package/lines/draggableLineComponent.d.ts +9 -9
  90. package/lines/draggableLineComponent.js +12 -12
  91. package/lines/fileButtonLineComponent.d.ts +17 -17
  92. package/lines/fileButtonLineComponent.js +20 -20
  93. package/lines/fileMultipleButtonLineComponent.d.ts +17 -17
  94. package/lines/fileMultipleButtonLineComponent.js +20 -20
  95. package/lines/floatLineComponent.d.ts +50 -50
  96. package/lines/floatLineComponent.js +175 -175
  97. package/lines/hexLineComponent.d.ts +40 -40
  98. package/lines/hexLineComponent.js +121 -121
  99. package/lines/iSelectedLineContainer.d.ts +4 -4
  100. package/lines/iSelectedLineContainer.js +1 -1
  101. package/lines/iconButtonLineComponent.d.ts +11 -11
  102. package/lines/iconButtonLineComponent.js +10 -10
  103. package/lines/iconComponent.d.ts +9 -9
  104. package/lines/iconComponent.js +7 -7
  105. package/lines/indentedTextLineComponent.d.ts +16 -16
  106. package/lines/indentedTextLineComponent.js +26 -26
  107. package/lines/inputArrowsComponent.d.ts +13 -13
  108. package/lines/inputArrowsComponent.js +37 -37
  109. package/lines/lineContainerComponent.d.ts +19 -19
  110. package/lines/lineContainerComponent.js +49 -49
  111. package/lines/linkButtonComponent.d.ts +16 -16
  112. package/lines/linkButtonComponent.js +20 -20
  113. package/lines/matrixLineComponent.d.ts +36 -36
  114. package/lines/matrixLineComponent.js +102 -102
  115. package/lines/messageLineComponent.d.ts +12 -12
  116. package/lines/messageLineComponent.js +14 -14
  117. package/lines/numericInputComponent.d.ts +31 -31
  118. package/lines/numericInputComponent.js +85 -85
  119. package/lines/optionsLineComponent.d.ts +48 -48
  120. package/lines/optionsLineComponent.js +118 -118
  121. package/lines/popup.d.ts +4 -4
  122. package/lines/popup.js +67 -67
  123. package/lines/radioLineComponent.d.ts +21 -21
  124. package/lines/radioLineComponent.js +26 -26
  125. package/lines/sliderLineComponent.d.ts +37 -37
  126. package/lines/sliderLineComponent.js +89 -89
  127. package/lines/targetsProxy.d.ts +11 -11
  128. package/lines/targetsProxy.js +42 -42
  129. package/lines/textInputLineComponent.d.ts +47 -47
  130. package/lines/textInputLineComponent.js +154 -154
  131. package/lines/textLineComponent.d.ts +21 -21
  132. package/lines/textLineComponent.js +30 -30
  133. package/lines/unitButton.d.ts +8 -8
  134. package/lines/unitButton.js +7 -7
  135. package/lines/valueLineComponent.d.ts +15 -15
  136. package/lines/valueLineComponent.js +12 -12
  137. package/lines/vector2LineComponent.d.ts +36 -36
  138. package/lines/vector2LineComponent.js +63 -63
  139. package/lines/vector3LineComponent.d.ts +41 -41
  140. package/lines/vector3LineComponent.js +74 -74
  141. package/lines/vector4LineComponent.d.ts +42 -42
  142. package/lines/vector4LineComponent.js +81 -81
  143. package/nodeGraphSystem/displayLedger.d.ts +5 -5
  144. package/nodeGraphSystem/displayLedger.js +3 -3
  145. package/nodeGraphSystem/frameNodePort.d.ts +25 -25
  146. package/nodeGraphSystem/frameNodePort.js +59 -59
  147. package/nodeGraphSystem/graphCanvas.d.ts +111 -111
  148. package/nodeGraphSystem/graphCanvas.js +1131 -1131
  149. package/nodeGraphSystem/graphFrame.d.ts +153 -153
  150. package/nodeGraphSystem/graphFrame.js +1328 -1328
  151. package/nodeGraphSystem/graphNode.d.ts +79 -79
  152. package/nodeGraphSystem/graphNode.js +459 -459
  153. package/nodeGraphSystem/interfaces/displayManager.d.ts +13 -13
  154. package/nodeGraphSystem/interfaces/displayManager.js +1 -1
  155. package/nodeGraphSystem/interfaces/nodeContainer.d.ts +6 -6
  156. package/nodeGraphSystem/interfaces/nodeContainer.js +1 -1
  157. package/nodeGraphSystem/interfaces/nodeData.d.ts +15 -15
  158. package/nodeGraphSystem/interfaces/nodeData.js +1 -1
  159. package/nodeGraphSystem/interfaces/nodeLocationInfo.d.ts +26 -26
  160. package/nodeGraphSystem/interfaces/nodeLocationInfo.js +1 -1
  161. package/nodeGraphSystem/interfaces/portData.d.ts +28 -28
  162. package/nodeGraphSystem/interfaces/portData.js +7 -7
  163. package/nodeGraphSystem/interfaces/propertyComponentProps.d.ts +6 -6
  164. package/nodeGraphSystem/interfaces/propertyComponentProps.js +1 -1
  165. package/nodeGraphSystem/interfaces/selectionChangedOptions.d.ts +11 -11
  166. package/nodeGraphSystem/interfaces/selectionChangedOptions.js +1 -1
  167. package/nodeGraphSystem/nodeLink.d.ts +31 -31
  168. package/nodeGraphSystem/nodeLink.js +182 -182
  169. package/nodeGraphSystem/nodePort.d.ts +35 -35
  170. package/nodeGraphSystem/nodePort.js +128 -128
  171. package/nodeGraphSystem/propertyLedger.d.ts +8 -8
  172. package/nodeGraphSystem/propertyLedger.js +3 -3
  173. package/nodeGraphSystem/stateManager.d.ts +45 -45
  174. package/nodeGraphSystem/stateManager.js +18 -18
  175. package/nodeGraphSystem/tools.d.ts +5 -5
  176. package/nodeGraphSystem/tools.js +36 -36
  177. package/nodeGraphSystem/typeLedger.d.ts +8 -8
  178. package/nodeGraphSystem/typeLedger.js +2 -2
  179. package/nodeGraphSystem/types/framePortData.d.ts +7 -7
  180. package/nodeGraphSystem/types/framePortData.js +1 -1
  181. package/package.json +4 -3
  182. package/propertyChangedEvent.d.ts +7 -7
  183. package/propertyChangedEvent.js +2 -2
  184. package/stories/Button.stories.d.ts +10 -10
  185. package/stories/Button.stories.js +19 -19
  186. package/stories/Icon.stories.d.ts +9 -9
  187. package/stories/Icon.stories.js +16 -16
  188. package/stories/Label.stories.d.ts +8 -8
  189. package/stories/Label.stories.js +10 -10
  190. package/stories/MessageDialog.stories.d.ts +9 -9
  191. package/stories/MessageDialog.stories.js +19 -19
  192. package/stories/Toggle.stories.d.ts +9 -9
  193. package/stories/Toggle.stories.js +17 -17
  194. package/stories/bars/CommandBarComponent.stories.d.ts +11 -11
  195. package/stories/bars/CommandBarComponent.stories.js +12 -12
  196. package/stories/bars/CommandButtonComponent.stories.d.ts +6 -6
  197. package/stories/bars/CommandButtonComponent.stories.js +6 -6
  198. package/stories/colorPicker/ColorPicker.stories.d.ts +11 -11
  199. package/stories/colorPicker/ColorPicker.stories.js +4 -4
  200. package/stories/layout/FlexibleGridLayout.stories.d.ts +46 -0
  201. package/stories/layout/FlexibleGridLayout.stories.js +48 -0
  202. package/stories/layout/FlexibleGridLayout.stories.js.map +1 -0
  203. package/stories/lines/ColorLineComponent.stories.d.ts +21 -21
  204. package/stories/lines/ColorLineComponent.stories.js +9 -9
  205. package/stories/lines/ColorPickerLineComponent.stories.d.ts +14 -14
  206. package/stories/lines/ColorPickerLineComponent.stories.js +10 -10
  207. package/stories/lines/FileButtonLineComponent.stories.d.ts +6 -6
  208. package/stories/lines/FileButtonLineComponent.stories.js +5 -5
  209. package/stories/lines/NumericInputComponent.stories.d.ts +11 -11
  210. package/stories/lines/NumericInputComponent.stories.js +5 -5
  211. package/stringTools.d.ts +11 -11
  212. package/stringTools.js +88 -88
  213. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.d.ts +15 -15
  214. package/tabs/propertyGrids/gui/checkboxPropertyGridComponent.js +15 -15
  215. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.d.ts +15 -15
  216. package/tabs/propertyGrids/gui/colorPickerPropertyGridComponent.js +14 -14
  217. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.d.ts +17 -17
  218. package/tabs/propertyGrids/gui/commonControlPropertyGridComponent.js +55 -55
  219. package/tabs/propertyGrids/gui/controlPropertyGridComponent.d.ts +15 -15
  220. package/tabs/propertyGrids/gui/controlPropertyGridComponent.js +12 -12
  221. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.d.ts +15 -15
  222. package/tabs/propertyGrids/gui/ellipsePropertyGridComponent.js +15 -15
  223. package/tabs/propertyGrids/gui/gridPropertyGridComponent.d.ts +17 -17
  224. package/tabs/propertyGrids/gui/gridPropertyGridComponent.js +38 -38
  225. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.d.ts +15 -15
  226. package/tabs/propertyGrids/gui/imageBasedSliderPropertyGridComponent.js +16 -16
  227. package/tabs/propertyGrids/gui/imagePropertyGridComponent.d.ts +15 -15
  228. package/tabs/propertyGrids/gui/imagePropertyGridComponent.js +25 -25
  229. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.d.ts +15 -15
  230. package/tabs/propertyGrids/gui/inputTextPropertyGridComponent.js +17 -17
  231. package/tabs/propertyGrids/gui/linePropertyGridComponent.d.ts +16 -16
  232. package/tabs/propertyGrids/gui/linePropertyGridComponent.js +27 -27
  233. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.d.ts +15 -15
  234. package/tabs/propertyGrids/gui/radioButtonPropertyGridComponent.js +17 -17
  235. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.d.ts +15 -15
  236. package/tabs/propertyGrids/gui/rectanglePropertyGridComponent.js +15 -15
  237. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.d.ts +15 -15
  238. package/tabs/propertyGrids/gui/scrollViewerPropertyGridComponent.js +15 -15
  239. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.d.ts +15 -15
  240. package/tabs/propertyGrids/gui/sliderPropertyGridComponent.js +16 -16
  241. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.d.ts +15 -15
  242. package/tabs/propertyGrids/gui/stackPanelPropertyGridComponent.js +14 -14
  243. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.d.ts +15 -15
  244. package/tabs/propertyGrids/gui/textBlockPropertyGridComponent.js +34 -34
  245. package/tabs/propertyGrids/lockObject.d.ts +9 -9
  246. package/tabs/propertyGrids/lockObject.js +11 -11
@@ -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,MAA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I,IAAI,KAAK,KAAK,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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{ 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;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,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,IAAI,CAAC,GAA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E,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 type { TabDrag } from \"./types\";\r\nimport { ElementTypes } 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>;
@@ -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.id, 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":";AACA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,MAAM,sCAAsC,CAAC;AAEzD,OAAO,QAAQ,MAAM,mCAAmC,CAAC;AACzD,OAAO,EAAE,cAAc,EAAE,yCAAyC,EAAE,MAAM,SAAS,CAAC;AACpF,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAwBvC;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAoC,CAAC,KAAK,EAAE,EAAE;IAC5E,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,UAAU,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IACpC,MAAM,aAAa,GAAG,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,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AW,EAAE,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,EAC5F,kBAAkB,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC,IALlD,GAAG,CAAC,EAAE,CAMb,CACL,CAAC;wBACN,CAAC,CAAC,GACA,EACN,KAAC,aAAa,IACV,GAAG,EAAE,QAAQ,EACb,IAAI,EAAE,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,EAC3G,IAAI,EAAE,YAAY,CAAC,SAAS,GAC9B,IACA,EACN,cAAK,SAAS,EAAE,KAAK,CAAC,gBAAgB,YAAG,iBAAiB,aAAjB,iBAAiB,uBAAjB,iBAAiB,CAAE,SAAS,GAAO,IAC1E,CACT,CAAC;AACN,CAAC,CAAC","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.id}\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,3 @@
1
+ import { createContext } from "react";
2
+ export const LayoutContext = createContext({ layout: {}, setLayout: () => { } });
3
+ //# sourceMappingURL=LayoutContext.js.map
@@ -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"]}