FPSMS-frontend
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 

82 строки
2.0 KiB

  1. "use client";
  2. import Box from "@mui/material/Box";
  3. import type { ReactNode } from "react";
  4. import type { WorkbenchGridRegionId } from "@/components/PoWorkbench/mock/workbenchMockData";
  5. export interface PoWorkbenchRegionProps {
  6. /** Which pane to render; must match {@link WorkbenchGridRegionId}. */
  7. region: WorkbenchGridRegionId;
  8. children?: ReactNode;
  9. }
  10. const basePaneSx = {
  11. minWidth: 0,
  12. minHeight: 0,
  13. height: "100%",
  14. display: "flex",
  15. flexDirection: "column" as const,
  16. border: 1,
  17. borderColor: "divider",
  18. bgcolor: "background.paper",
  19. boxSizing: "border-box" as const,
  20. };
  21. /**
  22. * One scrollable pane in the PO Workbench grid.
  23. *
  24. * Right-column panes (`detailsHeader`, `details`) use an outer rounded wrapper with
  25. * `overflow: hidden` so `borderTopRightRadius` / `borderBottomRightRadius` stay visible;
  26. * scroll lives on an inner box.
  27. *
  28. * @remarks
  29. * The root sets `data-workbench-region` to the `region` value for automated tests and debugging.
  30. * Values are stable and correspond to {@link WorkbenchGridRegionId}.
  31. */
  32. export default function PoWorkbenchRegion({
  33. region,
  34. children,
  35. }: PoWorkbenchRegionProps) {
  36. const isDetailsHeader = region === "detailsHeader";
  37. const isDetailsBody = region === "details";
  38. const useRoundedRightShell = isDetailsHeader || isDetailsBody;
  39. if (useRoundedRightShell) {
  40. return (
  41. <Box
  42. data-workbench-region={region}
  43. sx={{
  44. ...basePaneSx,
  45. overflow: "hidden",
  46. ...(isDetailsHeader ? { borderTopRightRadius: 16 } : {}),
  47. ...(isDetailsBody ? { borderBottomRightRadius: 16 } : {}),
  48. }}
  49. >
  50. <Box
  51. sx={{
  52. flex: 1,
  53. minHeight: 0,
  54. overflow: "auto",
  55. display: "flex",
  56. flexDirection: "column",
  57. }}
  58. >
  59. {children}
  60. </Box>
  61. </Box>
  62. );
  63. }
  64. return (
  65. <Box
  66. data-workbench-region={region}
  67. sx={{
  68. ...basePaneSx,
  69. overflow: "auto",
  70. }}
  71. >
  72. {children}
  73. </Box>
  74. );
  75. }