synapse-react-client 4.0.23 → 4.0.25

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 (108) hide show
  1. package/dist/SWC.index.d.ts +1 -0
  2. package/dist/SWC.index.d.ts.map +1 -1
  3. package/dist/SWC.index.js +2 -1
  4. package/dist/SWC.index.js.map +1 -1
  5. package/dist/components/AccessRequirementList/ManagedACTAccessRequirementRequestFlow/DataAccessRequestAccessorsFilesForm/DataAccessRequestAccessorsFilesForm.js.map +1 -1
  6. package/dist/components/AclEditor/useUpdateAcl.js.map +1 -1
  7. package/dist/components/Authentication/TwoFactorBackupCodes.js.map +1 -1
  8. package/dist/components/Authentication/TwoFactorEnrollmentForm.js.map +1 -1
  9. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts +3 -0
  10. package/dist/components/Breadcrumbs/Breadcrumbs.d.ts.map +1 -1
  11. package/dist/components/Breadcrumbs/Breadcrumbs.js +43 -30
  12. package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
  13. package/dist/components/CannedRejectionDialog/CannedRejectionDialog.js.map +1 -1
  14. package/dist/components/ChallengeSubmission/SubmissionDirectoryList.js.map +1 -1
  15. package/dist/components/CopyToClipboardString/CopyToClipboardString.d.ts +7 -1
  16. package/dist/components/CopyToClipboardString/CopyToClipboardString.d.ts.map +1 -1
  17. package/dist/components/CopyToClipboardString/CopyToClipboardString.js +22 -16
  18. package/dist/components/CopyToClipboardString/CopyToClipboardString.js.map +1 -1
  19. package/dist/components/EntityCitation/EntityCitation.d.ts.map +1 -1
  20. package/dist/components/EntityCitation/EntityCitation.js +28 -26
  21. package/dist/components/EntityCitation/EntityCitation.js.map +1 -1
  22. package/dist/components/EntityFinder/tree/EntityTree.js.map +1 -1
  23. package/dist/components/EntityFinder/tree/VirtualizedTree.js.map +1 -1
  24. package/dist/components/EntityIcon.d.ts +1 -0
  25. package/dist/components/EntityIcon.d.ts.map +1 -1
  26. package/dist/components/EntityIcon.js +37 -36
  27. package/dist/components/EntityIcon.js.map +1 -1
  28. package/dist/components/EntitySidebar/EntitySidebar.css +1 -0
  29. package/dist/components/EntitySidebar/EntitySidebar.d.ts +7 -0
  30. package/dist/components/EntitySidebar/EntitySidebar.d.ts.map +1 -0
  31. package/dist/components/EntitySidebar/EntitySidebar.js +62 -0
  32. package/dist/components/EntitySidebar/EntitySidebar.js.map +1 -0
  33. package/dist/components/EntitySidebar/EntitySidebar.module.js +17 -0
  34. package/dist/components/EntitySidebar/EntitySidebar.module.js.map +1 -0
  35. package/dist/components/EntitySidebar/EntitySidebar.module.scss +87 -0
  36. package/dist/components/Evaluation/EvaluationRoundEditorList.js.map +1 -1
  37. package/dist/components/GenericCard/BioregistryRules.js.map +1 -1
  38. package/dist/components/IconSvg/IconSvg.d.ts +2 -1
  39. package/dist/components/IconSvg/IconSvg.d.ts.map +1 -1
  40. package/dist/components/IconSvg/IconSvg.js +112 -89
  41. package/dist/components/IconSvg/IconSvg.js.map +1 -1
  42. package/dist/components/Plot/SynapsePlot.d.ts +4 -0
  43. package/dist/components/Plot/SynapsePlot.d.ts.map +1 -1
  44. package/dist/components/Plot/SynapsePlot.js +57 -44
  45. package/dist/components/Plot/SynapsePlot.js.map +1 -1
  46. package/dist/components/Plot/UpsetPlot.js.map +1 -1
  47. package/dist/components/QueryWrapperPlotNav/QueryWrapperSynapsePlot.d.ts.map +1 -1
  48. package/dist/components/QueryWrapperPlotNav/QueryWrapperSynapsePlot.js +77 -34
  49. package/dist/components/QueryWrapperPlotNav/QueryWrapperSynapsePlot.js.map +1 -1
  50. package/dist/components/SchemaDrivenAnnotationEditor/field/AdditionalPropertiesSchemaField.js.map +1 -1
  51. package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts.map +1 -1
  52. package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js +1 -0
  53. package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js.map +1 -1
  54. package/dist/components/StorybookComponentWrapper.js.map +1 -1
  55. package/dist/components/SynapseTable/TablePagination.js.map +1 -1
  56. package/dist/components/SynapseTable/datasets/DatasetItemsEditor.js.map +1 -1
  57. package/dist/components/TableColumnSchemaEditor/TableColumnSchemaForm.js.map +1 -1
  58. package/dist/components/TanStackTable/StyledTanStackTable.js.map +1 -1
  59. package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts +2 -0
  60. package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts.map +1 -1
  61. package/dist/components/entity/page/action_menu/EntityActionMenu.js +46 -27
  62. package/dist/components/entity/page/action_menu/EntityActionMenu.js.map +1 -1
  63. package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.d.ts +1 -8
  64. package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.d.ts.map +1 -1
  65. package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js +17 -13
  66. package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js.map +1 -1
  67. package/dist/components/entity/page/title_bar/EntityPageTitleBar.d.ts +1 -0
  68. package/dist/components/entity/page/title_bar/EntityPageTitleBar.d.ts.map +1 -1
  69. package/dist/components/entity/page/title_bar/EntityPageTitleBar.js +35 -22
  70. package/dist/components/entity/page/title_bar/EntityPageTitleBar.js.map +1 -1
  71. package/dist/components/entity/page/title_bar/EntityTitleBarVersionInfo.d.ts.map +1 -1
  72. package/dist/components/entity/page/title_bar/EntityTitleBarVersionInfo.js +34 -20
  73. package/dist/components/entity/page/title_bar/EntityTitleBarVersionInfo.js.map +1 -1
  74. package/dist/components/entity/page/title_bar/TitleBarProperties.d.ts +0 -1
  75. package/dist/components/entity/page/title_bar/TitleBarProperties.d.ts.map +1 -1
  76. package/dist/components/entity/page/title_bar/TitleBarProperties.js +17 -82
  77. package/dist/components/entity/page/title_bar/TitleBarProperties.js.map +1 -1
  78. package/dist/components/entity/page/title_bar/useGetEntityTitleBarProperties.d.ts.map +1 -1
  79. package/dist/components/entity/page/title_bar/useGetEntityTitleBarProperties.js +3 -4
  80. package/dist/components/entity/page/title_bar/useGetEntityTitleBarProperties.js.map +1 -1
  81. package/dist/components/favorites/FavoriteButton.d.ts +1 -0
  82. package/dist/components/favorites/FavoriteButton.d.ts.map +1 -1
  83. package/dist/components/favorites/FavoriteButton.js +8 -8
  84. package/dist/components/favorites/FavoriteButton.js.map +1 -1
  85. package/dist/components/menu/ComplexMenu.d.ts.map +1 -1
  86. package/dist/components/menu/ComplexMenu.js +5 -3
  87. package/dist/components/menu/ComplexMenu.js.map +1 -1
  88. package/dist/components/menu/DropdownMenu.d.ts +1 -0
  89. package/dist/components/menu/DropdownMenu.d.ts.map +1 -1
  90. package/dist/components/menu/DropdownMenu.js +24 -24
  91. package/dist/components/menu/DropdownMenu.js.map +1 -1
  92. package/dist/components/widgets/facet-nav/FacetNavPanel.d.ts.map +1 -1
  93. package/dist/components/widgets/facet-nav/FacetNavPanel.js +59 -49
  94. package/dist/components/widgets/facet-nav/FacetNavPanel.js.map +1 -1
  95. package/dist/components/widgets/facet-nav/PlotsContainer.d.ts.map +1 -1
  96. package/dist/components/widgets/facet-nav/PlotsContainer.js +8 -2
  97. package/dist/components/widgets/facet-nav/PlotsContainer.js.map +1 -1
  98. package/dist/style/components/facet_nav/_facet-nav-panel.scss +11 -0
  99. package/dist/style/main.css +1 -1
  100. package/dist/testutils/ReactQueryMockUtils.js.map +1 -1
  101. package/dist/tsconfig.build.tsbuildinfo +1 -1
  102. package/dist/types/ThemeTypes.d.ts +2 -2
  103. package/dist/utils/functions/IsEqualTreatUndefinedAsMissing.js.map +1 -1
  104. package/dist/utils/hooks/useDebouncedEffect.js.map +1 -1
  105. package/dist/utils/hooks/useDetectSSOCode.js.map +1 -1
  106. package/dist/utils/hooks/useImmutableTableQuery/useImmutableTableQuery.js.map +1 -1
  107. package/dist/utils/hooks/useLogin.js.map +1 -1
  108. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"FavoriteButton.js","names":[],"sources":["../../../src/components/favorites/FavoriteButton.tsx"],"sourcesContent":["import ConditionalWrapper from '@/components/utils/ConditionalWrapper'\nimport {\n useAddFavorite,\n useIsFavorite,\n useRemoveFavorite,\n} from '@/synapse-queries'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { IconButton, Skeleton, Tooltip } from '@mui/material'\nimport IconSvg from '../IconSvg/IconSvg'\n\nexport type FavoriteButtonProps = {\n /* The entity for which to show a favorite button */\n entityId: string\n}\n\n/**\n * Renders a button that indicates if an entity is favorited by the logged-in user. When clicked, the entity is\n * added to/removed from their favorites\n */\nexport default function FavoriteButton(props: FavoriteButtonProps) {\n const { entityId } = props\n const { isAuthenticated } = useSynapseContext()\n const { isFavorite, isLoading } = useIsFavorite(entityId)\n const { mutate: onAddFavorite, isPending: isAddingFavorite } =\n useAddFavorite()\n const { mutate: onRemoveFavorite, isPending: isRemovingFavorite } =\n useRemoveFavorite()\n\n const disableButton =\n isLoading || isAddingFavorite || isRemovingFavorite || !isAuthenticated\n\n let tooltipText = 'Add to Favorites'\n if (!isAuthenticated) {\n tooltipText = 'Sign in to add this to your favorites'\n } else if (isFavorite) {\n tooltipText = 'Remove from Favorites'\n }\n return (\n <ConditionalWrapper condition={isLoading} wrapper={Skeleton}>\n <Tooltip title={tooltipText} placement={'top'}>\n <span>\n <IconButton\n size={'small'}\n disabled={disableButton}\n onClick={() => {\n if (isFavorite) {\n onRemoveFavorite(entityId)\n } else {\n onAddFavorite(entityId)\n }\n }}\n sx={{ padding: '2px' }}\n >\n <IconSvg\n icon={isFavorite ? 'fav' : 'favOutline'}\n sx={{\n color: 'tertiary.main',\n width: '21px',\n height: '21px',\n }}\n wrap={false}\n />\n </IconButton>\n </span>\n </Tooltip>\n </ConditionalWrapper>\n )\n}\n"],"mappings":";;;;;;;;AAmBA,SAAwB,EAAe,GAA4B;CACjE,IAAM,EAAE,gBAAa,GACf,EAAE,uBAAoB,EAAkB,GACxC,EAAE,eAAY,iBAAc,EAAc,CAAQ,GAClD,EAAE,QAAQ,GAAe,WAAW,MACxC,EAAe,GACX,EAAE,QAAQ,GAAkB,WAAW,MAC3C,EAAkB,GAEd,IACJ,KAAa,KAAoB,KAAsB,CAAC,GAEtD,IAAc;CAMlB,OALK,IAEM,MACT,IAAc,2BAFd,IAAc,yCAKd,kBAAC,GAAD;EAAoB,WAAW;EAAW,SAAS;YACjD,kBAAC,GAAD;GAAS,OAAO;GAAa,WAAW;aACtC,kBAAC,QAAD,EAAA,UACE,kBAAC,GAAD;IACE,MAAM;IACN,UAAU;IACV,eAAe;KACb,AAAI,IACF,EAAiB,CAAQ,IAEzB,EAAc,CAAQ;IAE1B;IACA,IAAI,EAAE,SAAS,MAAM;cAErB,kBAAC,GAAD;KACE,MAAM,IAAa,QAAQ;KAC3B,IAAI;MACF,OAAO;MACP,OAAO;MACP,QAAQ;KACV;KACA,MAAM;IACP,CAAA;GACS,CAAA,EACR,CAAA;EACC,CAAA;CACS,CAAA;AAExB"}
1
+ {"version":3,"file":"FavoriteButton.js","names":[],"sources":["../../../src/components/favorites/FavoriteButton.tsx"],"sourcesContent":["import ConditionalWrapper from '@/components/utils/ConditionalWrapper'\nimport {\n useAddFavorite,\n useIsFavorite,\n useRemoveFavorite,\n} from '@/synapse-queries'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { IconButton, Skeleton, Tooltip } from '@mui/material'\nimport IconSvg from '../IconSvg/IconSvg'\n\nexport type FavoriteButtonProps = {\n /* The entity for which to show a favorite button */\n entityId: string\n iconColor?: string\n}\n\n/**\n * Renders a button that indicates if an entity is favorited by the logged-in user. When clicked, the entity is\n * added to/removed from their favorites\n */\nexport default function FavoriteButton(props: FavoriteButtonProps) {\n const { entityId, iconColor } = props\n const { isAuthenticated } = useSynapseContext()\n const { isFavorite, isLoading } = useIsFavorite(entityId)\n const { mutate: onAddFavorite, isPending: isAddingFavorite } =\n useAddFavorite()\n const { mutate: onRemoveFavorite, isPending: isRemovingFavorite } =\n useRemoveFavorite()\n\n const disableButton =\n isLoading || isAddingFavorite || isRemovingFavorite || !isAuthenticated\n\n let tooltipText = 'Add to Favorites'\n if (!isAuthenticated) {\n tooltipText = 'Sign in to add this to your favorites'\n } else if (isFavorite) {\n tooltipText = 'Remove from Favorites'\n }\n return (\n <ConditionalWrapper condition={isLoading} wrapper={Skeleton}>\n <Tooltip title={tooltipText} placement={'top'}>\n <span>\n <IconButton\n size={'small'}\n disabled={disableButton}\n onClick={() => {\n if (isFavorite) {\n onRemoveFavorite(entityId)\n } else {\n onAddFavorite(entityId)\n }\n }}\n sx={{ padding: '2px' }}\n >\n <IconSvg\n icon={isFavorite ? 'fav' : 'favOutline'}\n sx={{\n color: isFavorite\n ? 'tertiary.main'\n : (iconColor ?? 'tertiary.main'),\n width: '21px',\n height: '21px',\n }}\n wrap={false}\n />\n </IconButton>\n </span>\n </Tooltip>\n </ConditionalWrapper>\n )\n}\n"],"mappings":";;;;;;;;AAoBA,SAAwB,EAAe,GAA4B;CACjE,IAAM,EAAE,aAAU,iBAAc,GAC1B,EAAE,uBAAoB,EAAkB,GACxC,EAAE,eAAY,iBAAc,EAAc,CAAQ,GAClD,EAAE,QAAQ,GAAe,WAAW,MACxC,EAAe,GACX,EAAE,QAAQ,GAAkB,WAAW,MAC3C,EAAkB,GAEd,IACJ,KAAa,KAAoB,KAAsB,CAAC,GAEtD,IAAc;CAMlB,OALK,IAEM,MACT,IAAc,2BAFd,IAAc,yCAKd,kBAAC,GAAD;EAAoB,WAAW;EAAW,SAAS;YACjD,kBAAC,GAAD;GAAS,OAAO;GAAa,WAAW;aACtC,kBAAC,QAAD,EAAA,UACE,kBAAC,GAAD;IACE,MAAM;IACN,UAAU;IACV,eAAe;KACb,AAAI,IACF,EAAiB,CAAQ,IAEzB,EAAc,CAAQ;IAE1B;IACA,IAAI,EAAE,SAAS,MAAM;cAErB,kBAAC,GAAD;KACE,MAAM,IAAa,QAAQ;KAC3B,IAAI;MACF,OAAO,IACH,kBACC,KAAa;MAClB,OAAO;MACP,QAAQ;KACV;KACA,MAAM;IACP,CAAA;GACS,CAAA,EACR,CAAA;EACC,CAAA;CACS,CAAA;AAExB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ComplexMenu.d.ts","sourceRoot":"","sources":["../../../src/components/menu/ComplexMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,OAAO,EAIR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,GAAG;IACtE,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAK7B,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAA;IAMtC,aAAa,CAAC,EAAE,iBAAiB,EAAE,CAAA;CACpC,CAAA;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CAyGlD"}
1
+ {"version":3,"file":"ComplexMenu.d.ts","sourceRoot":"","sources":["../../../src/components/menu/ComplexMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAGL,WAAW,EACX,OAAO,EAIR,MAAM,eAAe,CAAA;AACtB,OAAO,EAAgB,iBAAiB,EAAE,MAAM,gBAAgB,CAAA;AAChE,OAAO,EAAiB,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AAGpE,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,kBAAkB,EAAE,MAAM,CAAC,GAAG;IACtE,IAAI,CAAC,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAA;IACjC,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAChC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAK7B,WAAW,CAAC,EAAE,sBAAsB,EAAE,CAAA;IAMtC,aAAa,CAAC,EAAE,iBAAiB,EAAE,CAAA;CACpC,CAAA;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,2CA2GlD"}
@@ -11,7 +11,9 @@ function u(u) {
11
11
  display: "flex",
12
12
  alignItems: "center",
13
13
  gap: "10px",
14
- [e.breakpoints.down("sm")]: {
14
+ flexWrap: "wrap",
15
+ justifyContent: "flex-end",
16
+ [e.breakpoints.down("md")]: {
15
17
  flexDirection: "column",
16
18
  paddingTop: "10px"
17
19
  }
@@ -20,7 +22,7 @@ function u(u) {
20
22
  if (n.variant != null) {
21
23
  let t = n.text ?? n.tooltipText;
22
24
  return /* @__PURE__ */ c(r, {
23
- sx: (e) => ({ [e.breakpoints.down("sm")]: {
25
+ sx: (e) => ({ [e.breakpoints.down("md")]: {
24
26
  width: "100%",
25
27
  ".MuiButton-root": { width: "100%" }
26
28
  } }),
@@ -69,7 +71,7 @@ function u(u) {
69
71
  icon: n.icon
70
72
  }, n.tooltipText);
71
73
  }), f.map((e, t) => e.items && e.items.length > 0 && /* @__PURE__ */ c(r, {
72
- sx: (e) => ({ [e.breakpoints.down("sm")]: {
74
+ sx: (e) => ({ [e.breakpoints.down("md")]: {
73
75
  width: "100%",
74
76
  ".MuiButton-root": { width: "100%" }
75
77
  } }),
@@ -1 +1 @@
1
- {"version":3,"file":"ComplexMenu.js","names":[],"sources":["../../../src/components/menu/ComplexMenu.tsx"],"sourcesContent":["import {\n Box,\n Button,\n ButtonProps,\n SxProps,\n Typography,\n useMediaQuery,\n useTheme,\n} from '@mui/material'\nimport { DropdownMenu, DropdownMenuProps } from './DropdownMenu'\nimport { IconSvgButton, IconSvgButtonProps } from '../IconSvgButton'\nimport IconSvg from '../IconSvg'\n\nexport type ComplexMenuButtonProps = Omit<IconSvgButtonProps, 'icon'> & {\n icon?: IconSvgButtonProps['icon']\n variant?: ButtonProps['variant']\n text?: string\n iconSx?: SxProps\n}\n\nexport type ComplexMenuProps = {\n /*\n * Configuration for buttons. Each entry corresponds to one button.\n * See the ComplexMenuButtonProps type for more info.\n */\n iconButtons?: ComplexMenuButtonProps[]\n /*\n * Configuration for DropdownMenus. Each entry corresponds to one dropdown menu button, which\n * itself can contain multiple groups of items.\n * See the DropdownMenuProps type for more info.\n */\n dropdownMenus?: DropdownMenuProps[]\n}\n\n/**\n * The ComplexMenu component allows you to create a generic menu with\n * icon buttons and multiple dropdown menus that contain groups of items.\n */\nexport function ComplexMenu(props: ComplexMenuProps) {\n const { iconButtons = [], dropdownMenus = [] } = props\n const theme = useTheme()\n const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm'))\n\n return (\n <Box\n sx={theme => ({\n display: 'flex',\n alignItems: 'center',\n gap: '10px',\n [theme.breakpoints.down('sm')]: {\n flexDirection: 'column',\n paddingTop: '10px',\n },\n })}\n >\n {iconButtons.map(iconButton => {\n if (iconButton.variant != null) {\n const label = iconButton.text ?? iconButton.tooltipText\n return (\n <Box\n key={label}\n sx={theme => ({\n [theme.breakpoints.down('sm')]: {\n width: '100%',\n '.MuiButton-root': { width: '100%' },\n },\n })}\n >\n <Button\n variant={iconButton.variant}\n startIcon={\n iconButton.icon ? (\n <IconSvg\n icon={iconButton.icon}\n wrap={false}\n fontSize={'inherit'}\n sx={iconButton.iconSx}\n />\n ) : undefined\n }\n onClick={iconButton.onClick}\n href={iconButton.href}\n disabled={iconButton.disabled}\n >\n <Typography variant=\"buttonLink\">{label}</Typography>\n </Button>\n </Box>\n )\n }\n return isSmallScreen && iconButton.tooltipText ? (\n <Box\n sx={{\n width: '100%',\n textAlign: 'center',\n }}\n >\n <Button\n variant=\"text\"\n startIcon={\n <IconSvg\n key={iconButton.tooltipText}\n icon={iconButton.icon!}\n wrap={false}\n fontSize={'inherit'}\n />\n }\n onClick={iconButton.onClick}\n sx={{\n padding: '6px 12px',\n minWidth: 'unset',\n }}\n >\n <Typography variant=\"buttonLink\">\n {iconButton.tooltipText}\n </Typography>\n </Button>\n </Box>\n ) : (\n <IconSvgButton\n key={iconButton.tooltipText}\n {...iconButton}\n icon={iconButton.icon!}\n />\n )\n })}\n {dropdownMenus.map(\n (menuProps, index) =>\n menuProps.items &&\n menuProps.items.length > 0 && (\n <Box\n sx={theme => ({\n [theme.breakpoints.down('sm')]: {\n width: '100%',\n '.MuiButton-root': { width: '100%' },\n },\n })}\n >\n <DropdownMenu key={index} {...menuProps} />\n </Box>\n ),\n )}\n </Box>\n )\n}\n"],"mappings":";;;;;;AAsCA,SAAgB,EAAY,GAAyB;CACnD,IAAM,EAAE,iBAAc,CAAC,GAAG,mBAAgB,CAAC,MAAM,GAE3C,IAAgB,EADR,EACsB,EAAM,YAAY,KAAK,IAAI,CAAC;CAEhE,OACE,kBAAC,GAAD;EACE,KAAI,OAAU;GACZ,SAAS;GACT,YAAY;GACZ,KAAK;IACJ,EAAM,YAAY,KAAK,IAAI,IAAI;IAC9B,eAAe;IACf,YAAY;GACd;EACF;YATF,CAWG,EAAY,KAAI,MAAc;GAC7B,IAAI,EAAW,WAAW,MAAM;IAC9B,IAAM,IAAQ,EAAW,QAAQ,EAAW;IAC5C,OACE,kBAAC,GAAD;KAEE,KAAI,OAAU,GACX,EAAM,YAAY,KAAK,IAAI,IAAI;MAC9B,OAAO;MACP,mBAAmB,EAAE,OAAO,OAAO;KACrC,EACF;eAEA,kBAAC,GAAD;MACE,SAAS,EAAW;MACpB,WACE,EAAW,OACT,kBAAC,GAAD;OACE,MAAM,EAAW;OACjB,MAAM;OACN,UAAU;OACV,IAAI,EAAW;MAChB,CAAA,IACC,KAAA;MAEN,SAAS,EAAW;MACpB,MAAM,EAAW;MACjB,UAAU,EAAW;gBAErB,kBAAC,GAAD;OAAY,SAAQ;iBAAc;MAAkB,CAAA;KAC9C,CAAA;IACL,GA1BE,CA0BF;GAET;GACA,OAAO,KAAiB,EAAW,cACjC,kBAAC,GAAD;IACE,IAAI;KACF,OAAO;KACP,WAAW;IACb;cAEA,kBAAC,GAAD;KACE,SAAQ;KACR,WACE,kBAAC,GAAD;MAEE,MAAM,EAAW;MACjB,MAAM;MACN,UAAU;KACX,GAJM,EAAW,WAIjB;KAEH,SAAS,EAAW;KACpB,IAAI;MACF,SAAS;MACT,UAAU;KACZ;eAEA,kBAAC,GAAD;MAAY,SAAQ;gBACjB,EAAW;KACF,CAAA;IACN,CAAA;GACL,CAAA,IAEL,kBAAC,GAAD;IAEE,GAAI;IACJ,MAAM,EAAW;GAClB,GAHM,EAAW,WAGjB;EAEL,CAAC,GACA,EAAc,KACZ,GAAW,MACV,EAAU,SACV,EAAU,MAAM,SAAS,KACvB,kBAAC,GAAD;GACE,KAAI,OAAU,GACX,EAAM,YAAY,KAAK,IAAI,IAAI;IAC9B,OAAO;IACP,mBAAmB,EAAE,OAAO,OAAO;GACrC,EACF;aAEA,kBAAC,GAAD,EAA0B,GAAI,EAAY,GAAvB,CAAuB;EACvC,CAAA,CAEX,CACG;;AAET"}
1
+ {"version":3,"file":"ComplexMenu.js","names":[],"sources":["../../../src/components/menu/ComplexMenu.tsx"],"sourcesContent":["import {\n Box,\n Button,\n ButtonProps,\n SxProps,\n Typography,\n useMediaQuery,\n useTheme,\n} from '@mui/material'\nimport { DropdownMenu, DropdownMenuProps } from './DropdownMenu'\nimport { IconSvgButton, IconSvgButtonProps } from '../IconSvgButton'\nimport IconSvg from '../IconSvg'\n\nexport type ComplexMenuButtonProps = Omit<IconSvgButtonProps, 'icon'> & {\n icon?: IconSvgButtonProps['icon']\n variant?: ButtonProps['variant']\n text?: string\n iconSx?: SxProps\n}\n\nexport type ComplexMenuProps = {\n /*\n * Configuration for buttons. Each entry corresponds to one button.\n * See the ComplexMenuButtonProps type for more info.\n */\n iconButtons?: ComplexMenuButtonProps[]\n /*\n * Configuration for DropdownMenus. Each entry corresponds to one dropdown menu button, which\n * itself can contain multiple groups of items.\n * See the DropdownMenuProps type for more info.\n */\n dropdownMenus?: DropdownMenuProps[]\n}\n\n/**\n * The ComplexMenu component allows you to create a generic menu with\n * icon buttons and multiple dropdown menus that contain groups of items.\n */\nexport function ComplexMenu(props: ComplexMenuProps) {\n const { iconButtons = [], dropdownMenus = [] } = props\n const theme = useTheme()\n const isSmallScreen = useMediaQuery(theme.breakpoints.down('sm'))\n\n return (\n <Box\n sx={theme => ({\n display: 'flex',\n alignItems: 'center',\n gap: '10px',\n flexWrap: 'wrap',\n justifyContent: 'flex-end',\n [theme.breakpoints.down('md')]: {\n flexDirection: 'column',\n paddingTop: '10px',\n },\n })}\n >\n {iconButtons.map(iconButton => {\n if (iconButton.variant != null) {\n const label = iconButton.text ?? iconButton.tooltipText\n return (\n <Box\n key={label}\n sx={theme => ({\n [theme.breakpoints.down('md')]: {\n width: '100%',\n '.MuiButton-root': { width: '100%' },\n },\n })}\n >\n <Button\n variant={iconButton.variant}\n startIcon={\n iconButton.icon ? (\n <IconSvg\n icon={iconButton.icon}\n wrap={false}\n fontSize={'inherit'}\n sx={iconButton.iconSx}\n />\n ) : undefined\n }\n onClick={iconButton.onClick}\n href={iconButton.href}\n disabled={iconButton.disabled}\n >\n <Typography variant=\"buttonLink\">{label}</Typography>\n </Button>\n </Box>\n )\n }\n return isSmallScreen && iconButton.tooltipText ? (\n <Box\n sx={{\n width: '100%',\n textAlign: 'center',\n }}\n >\n <Button\n variant=\"text\"\n startIcon={\n <IconSvg\n key={iconButton.tooltipText}\n icon={iconButton.icon!}\n wrap={false}\n fontSize={'inherit'}\n />\n }\n onClick={iconButton.onClick}\n sx={{\n padding: '6px 12px',\n minWidth: 'unset',\n }}\n >\n <Typography variant=\"buttonLink\">\n {iconButton.tooltipText}\n </Typography>\n </Button>\n </Box>\n ) : (\n <IconSvgButton\n key={iconButton.tooltipText}\n {...iconButton}\n icon={iconButton.icon!}\n />\n )\n })}\n {dropdownMenus.map(\n (menuProps, index) =>\n menuProps.items &&\n menuProps.items.length > 0 && (\n <Box\n sx={theme => ({\n [theme.breakpoints.down('md')]: {\n width: '100%',\n '.MuiButton-root': { width: '100%' },\n },\n })}\n >\n <DropdownMenu key={index} {...menuProps} />\n </Box>\n ),\n )}\n </Box>\n )\n}\n"],"mappings":";;;;;;AAsCA,SAAgB,EAAY,GAAyB;CACnD,IAAM,EAAE,iBAAc,CAAC,GAAG,mBAAgB,CAAC,MAAM,GAE3C,IAAgB,EADR,EACsB,EAAM,YAAY,KAAK,IAAI,CAAC;CAEhE,OACE,kBAAC,GAAD;EACE,KAAI,OAAU;GACZ,SAAS;GACT,YAAY;GACZ,KAAK;GACL,UAAU;GACV,gBAAgB;IACf,EAAM,YAAY,KAAK,IAAI,IAAI;IAC9B,eAAe;IACf,YAAY;GACd;EACF;YAXF,CAaG,EAAY,KAAI,MAAc;GAC7B,IAAI,EAAW,WAAW,MAAM;IAC9B,IAAM,IAAQ,EAAW,QAAQ,EAAW;IAC5C,OACE,kBAAC,GAAD;KAEE,KAAI,OAAU,GACX,EAAM,YAAY,KAAK,IAAI,IAAI;MAC9B,OAAO;MACP,mBAAmB,EAAE,OAAO,OAAO;KACrC,EACF;eAEA,kBAAC,GAAD;MACE,SAAS,EAAW;MACpB,WACE,EAAW,OACT,kBAAC,GAAD;OACE,MAAM,EAAW;OACjB,MAAM;OACN,UAAU;OACV,IAAI,EAAW;MAChB,CAAA,IACC,KAAA;MAEN,SAAS,EAAW;MACpB,MAAM,EAAW;MACjB,UAAU,EAAW;gBAErB,kBAAC,GAAD;OAAY,SAAQ;iBAAc;MAAkB,CAAA;KAC9C,CAAA;IACL,GA1BE,CA0BF;GAET;GACA,OAAO,KAAiB,EAAW,cACjC,kBAAC,GAAD;IACE,IAAI;KACF,OAAO;KACP,WAAW;IACb;cAEA,kBAAC,GAAD;KACE,SAAQ;KACR,WACE,kBAAC,GAAD;MAEE,MAAM,EAAW;MACjB,MAAM;MACN,UAAU;KACX,GAJM,EAAW,WAIjB;KAEH,SAAS,EAAW;KACpB,IAAI;MACF,SAAS;MACT,UAAU;KACZ;eAEA,kBAAC,GAAD;MAAY,SAAQ;gBACjB,EAAW;KACF,CAAA;IACN,CAAA;GACL,CAAA,IAEL,kBAAC,GAAD;IAEE,GAAI;IACJ,MAAM,EAAW;GAClB,GAHM,EAAW,WAGjB;EAEL,CAAC,GACA,EAAc,KACZ,GAAW,MACV,EAAU,SACV,EAAU,MAAM,SAAS,KACvB,kBAAC,GAAD;GACE,KAAI,OAAU,GACX,EAAM,YAAY,KAAK,IAAI,IAAI;IAC9B,OAAO;IACP,mBAAmB,EAAE,OAAO,OAAO;GACrC,EACF;aAEA,kBAAC,GAAD,EAA0B,GAAI,EAAY,GAAvB,CAAuB;EACvC,CAAA,CAEX,CACG;;AAET"}
@@ -19,6 +19,7 @@ export type DropdownMenuProps = {
19
19
  dropdownButtonText: string;
20
20
  buttonTooltip?: string;
21
21
  buttonProps?: ButtonProps;
22
+ variant?: ButtonProps['variant'];
22
23
  convertSingleItemToButton?: boolean;
23
24
  renderMenuIfNoItems?: boolean;
24
25
  };
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/menu/DropdownMenu.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,EAUX,OAAO,EAGR,MAAM,eAAe,CAAA;AACtB,OAAO,EAEL,UAAU,EAKX,MAAM,OAAO,CAAA;AACd,OAAgB,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAEtD;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAE7B,IAAI,EAAE,MAAM,CAAA;IAEZ,IAAI,CAAC,EAAE,QAAQ,CAAA;IAEf,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;IAEjC,IAAI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CAAA;IAE3B,kBAAkB,EAAE,MAAM,CAAA;IAE1B,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,WAAW,CAAC,EAAE,WAAW,CAAA;IAEzB,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAA;IAEhC,yBAAyB,CAAC,EAAE,OAAO,CAAA;IAEnC,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAC9B,CAAA;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,kDA4MpD"}
@@ -4,14 +4,14 @@ import { Button as i, ClickAwayListener as a, Divider as o, Fade as s, ListItemI
4
4
  import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
5
5
  //#region src/components/menu/DropdownMenu.tsx
6
6
  function y(y) {
7
- let { buttonTooltip: b, dropdownButtonText: x, items: S = [], convertSingleItemToButton: C = !0, renderMenuIfNoItems: w = !1, buttonProps: T = {} } = y, E = t(), [D, O] = r(!1), k = n(null), A = S.flat().length;
8
- if (!w && A === 0) return null;
9
- if (C && A === 1) {
7
+ let { buttonTooltip: b, dropdownButtonText: x, items: S = [], convertSingleItemToButton: C = !0, renderMenuIfNoItems: w = !1, buttonProps: T = {}, variant: E = "outlined" } = y, D = t(), [O, k] = r(!1), A = n(null), j = S.flat().length;
8
+ if (!w && j === 0) return null;
9
+ if (C && j === 1) {
10
10
  let t = S.flat()[0];
11
11
  return /* @__PURE__ */ _(i, {
12
12
  component: "href" in t ? "a" : "button",
13
13
  title: t.tooltipText,
14
- variant: "outlined",
14
+ variant: E,
15
15
  href: "href" in t ? t.href : void 0,
16
16
  rel: "href" in t ? "noopener noreferrer" : void 0,
17
17
  onClick: "onClick" in t ? t.onClick : void 0,
@@ -26,13 +26,13 @@ function y(y) {
26
26
  })
27
27
  });
28
28
  }
29
- let j = () => {
30
- O((e) => !e);
31
- }, M = (e) => {
32
- k.current && k.current.contains(e.target) || O(!1);
29
+ let M = () => {
30
+ k((e) => !e);
31
+ }, N = (e) => {
32
+ A.current && A.current.contains(e.target) || k(!1);
33
33
  };
34
- function N(e) {
35
- e.key === "Tab" ? (e.preventDefault(), O(!1)) : e.key === "Escape" && O(!1);
34
+ function P(e) {
35
+ e.key === "Tab" ? (e.preventDefault(), k(!1)) : e.key === "Escape" && k(!1);
36
36
  }
37
37
  return /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(m, {
38
38
  title: b ? /* @__PURE__ */ _("div", {
@@ -41,13 +41,13 @@ function y(y) {
41
41
  }) : void 0,
42
42
  placement: "top",
43
43
  children: /* @__PURE__ */ _("span", { children: /* @__PURE__ */ _(i, {
44
- variant: "outlined",
45
- ref: k,
46
- id: `composition-button-${E}`,
47
- "aria-controls": D ? `composition-menu-${E}` : void 0,
48
- "aria-expanded": D ? "true" : void 0,
44
+ variant: E,
45
+ ref: A,
46
+ id: `composition-button-${D}`,
47
+ "aria-controls": O ? `composition-menu-${D}` : void 0,
48
+ "aria-expanded": O ? "true" : void 0,
49
49
  "aria-haspopup": "true",
50
- onClick: j,
50
+ onClick: M,
51
51
  ...T,
52
52
  children: /* @__PURE__ */ _(h, {
53
53
  variant: "buttonLink",
@@ -55,8 +55,8 @@ function y(y) {
55
55
  })
56
56
  }) })
57
57
  }), /* @__PURE__ */ _(p, {
58
- open: D,
59
- anchorEl: k.current,
58
+ open: O,
59
+ anchorEl: A.current,
60
60
  role: void 0,
61
61
  placement: "bottom-end",
62
62
  transition: !0,
@@ -64,12 +64,12 @@ function y(y) {
64
64
  children: ({ TransitionProps: t }) => /* @__PURE__ */ _(s, {
65
65
  ...t,
66
66
  children: /* @__PURE__ */ _(f, { children: /* @__PURE__ */ _(a, {
67
- onClickAway: M,
67
+ onClickAway: N,
68
68
  children: /* @__PURE__ */ _(d, {
69
- autoFocusItem: D,
70
- id: `composition-menu-${E}`,
71
- "aria-labelledby": `composition-button-${E}`,
72
- onKeyDown: N,
69
+ autoFocusItem: O,
70
+ id: `composition-menu-${D}`,
71
+ "aria-labelledby": `composition-button-${D}`,
72
+ onKeyDown: P,
73
73
  children: S.map((t, n, r) => [t.map((t) => /* @__PURE__ */ _(m, {
74
74
  title: t.tooltipText,
75
75
  placement: "left",
@@ -87,7 +87,7 @@ function y(y) {
87
87
  rel: "href" in t ? "noopener noreferrer" : void 0,
88
88
  style: { pointerEvents: "auto" },
89
89
  onClick: (e) => {
90
- !t.disabled && "onClick" in t && t.onClick && (O(!1), t.onClick(e));
90
+ !t.disabled && "onClick" in t && t.onClick && (k(!1), t.onClick(e));
91
91
  },
92
92
  children: [/* @__PURE__ */ _(c, {
93
93
  style: { minWidth: "30px" },
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../../src/components/menu/DropdownMenu.tsx"],"sourcesContent":["import {\n Button,\n ButtonProps,\n ClickAwayListener,\n Divider,\n Fade,\n ListItemIcon,\n ListItemText,\n MenuItem,\n MenuList,\n Paper,\n Popper,\n SxProps,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport {\n KeyboardEvent,\n MouseEvent,\n SyntheticEvent,\n useId,\n useRef,\n useState,\n} from 'react'\nimport IconSvg, { IconName } from '../IconSvg/IconSvg'\n\n/**\n * Defines a configuration for a particular dropdown menu item\n */\nexport type DropdownMenuItem = {\n /* The text to show on the menu item. */\n text: string\n /* The icon to show for this item in the menu. */\n icon?: IconName\n /* A function invoked upon clicking the item, assuming `disabled` is falsy */\n onClick?: (e: MouseEvent) => void\n /* A link that the item should point to. */\n href?: string\n /* The optional tooltipText to show for this item. Compatible with the `disabled` prop. */\n tooltipText?: string\n /* Whether the item should be disabled from selection. */\n disabled?: boolean\n /* Additional MUI SxProps to pass to the text component */\n textSx?: SxProps\n /* Additional MUI SxProps to pass to the icon component */\n iconSx?: SxProps\n}\n\nexport type DropdownMenuProps = {\n /* Groups of menu items. Each group will be split with a divider. See DropdownMenuItem for per-item configuration */\n items: DropdownMenuItem[][]\n /* The text to show on the dropdown menu button. */\n dropdownButtonText: string\n /* The optional tooltip text for the dropdown menu button. */\n buttonTooltip?: string\n /* Any additional props to pass to the dropdown menu button. */\n buttonProps?: ButtonProps\n /* If true, will render a single action as a standalone button. Default true. */\n convertSingleItemToButton?: boolean\n /* If true, nothing will be rendered if no actions are passed. Default false. */\n renderMenuIfNoItems?: boolean\n}\n\n/**\n * The DropdownMenu component provides a generic way to compose a MUI dropdown menu.\n */\nexport function DropdownMenu(props: DropdownMenuProps) {\n const {\n buttonTooltip,\n dropdownButtonText,\n items = [] as DropdownMenuItem[][],\n convertSingleItemToButton = true,\n renderMenuIfNoItems = false,\n buttonProps = {},\n } = props\n\n const dropdownMenuId = useId()\n const [open, setOpen] = useState(false)\n const anchorRef = useRef<HTMLButtonElement>(null)\n\n const numberOfMenuItems = items.flat().length\n\n if (!renderMenuIfNoItems && numberOfMenuItems === 0) {\n // Hide menu if no actions will be in the menu\n return null\n }\n\n if (convertSingleItemToButton && numberOfMenuItems === 1) {\n // If one action is in the menu, show it as a button\n const menuItem = items.flat()[0]\n return (\n <Button\n component={'href' in menuItem ? 'a' : 'button'}\n title={menuItem.tooltipText}\n variant=\"outlined\"\n href={'href' in menuItem ? menuItem.href : undefined}\n rel={'href' in menuItem ? 'noopener noreferrer' : undefined}\n onClick={'onClick' in menuItem ? menuItem.onClick : undefined}\n disabled={menuItem.disabled}\n endIcon={menuItem.icon && <IconSvg icon={menuItem.icon} wrap={false} />}\n >\n <Typography variant={'buttonLink'}>{menuItem.text}</Typography>\n </Button>\n )\n }\n\n const handleToggle = () => {\n setOpen(prevOpen => !prevOpen)\n }\n\n const handleClose = (event: Event | SyntheticEvent) => {\n if (\n anchorRef.current &&\n anchorRef.current.contains(event.target as HTMLElement)\n ) {\n return\n }\n\n setOpen(false)\n }\n\n function handleListKeyDown(event: KeyboardEvent) {\n if (event.key === 'Tab') {\n event.preventDefault()\n setOpen(false)\n } else if (event.key === 'Escape') {\n setOpen(false)\n }\n }\n\n return (\n <>\n <Tooltip\n title={\n buttonTooltip ? (\n <div style={{ whiteSpace: 'pre-line' }}>{buttonTooltip}</div>\n ) : undefined\n }\n placement={'top'}\n >\n <span>\n <Button\n variant=\"outlined\"\n ref={anchorRef}\n id={`composition-button-${dropdownMenuId}`}\n aria-controls={\n open ? `composition-menu-${dropdownMenuId}` : undefined\n }\n aria-expanded={open ? 'true' : undefined}\n aria-haspopup=\"true\"\n onClick={handleToggle}\n {...buttonProps}\n >\n <Typography variant={'buttonLink'}>{dropdownButtonText}</Typography>\n </Button>\n </span>\n </Tooltip>\n <Popper\n open={open}\n anchorEl={anchorRef.current}\n role={undefined}\n placement=\"bottom-end\"\n transition\n style={{\n // Fixes issue where react-flow (provenance) would appear above the menu\n zIndex: 10,\n }}\n >\n {({ TransitionProps }) => (\n <Fade {...TransitionProps}>\n <Paper>\n <ClickAwayListener onClickAway={handleClose}>\n <MenuList\n autoFocusItem={open}\n id={`composition-menu-${dropdownMenuId}`}\n aria-labelledby={`composition-button-${dropdownMenuId}`}\n onKeyDown={handleListKeyDown}\n >\n {items.map((itemGroup, index, array) => {\n return [\n itemGroup.map(item => {\n return (\n <Tooltip\n key={item.text}\n title={item.tooltipText}\n placement={'left'}\n >\n <MenuItem\n // Always make the component an anchor in case href is defined.\n component=\"a\"\n sx={{\n // Override the anchor-specific state styles, we don't want it to look like an anchor\n '&:hover': {\n color: 'unset',\n },\n '&:focus': {\n color: 'unset',\n textDecoration: 'unset',\n },\n }}\n disabled={item.disabled}\n href={'href' in item ? item.href : undefined}\n rel={\n 'href' in item\n ? 'noopener noreferrer'\n : undefined\n }\n // Allow pointer events on disabled item so tooltip works.\n style={{ pointerEvents: 'auto' }}\n onClick={(e: MouseEvent) => {\n /*\n * Must check if the item is disabled because we set\n * `pointer-events: 'auto'`\n */\n if (\n !item.disabled &&\n 'onClick' in item &&\n item.onClick\n ) {\n setOpen(false)\n item.onClick(e)\n }\n }}\n >\n <ListItemIcon\n style={{\n // MUI has specified a more specific minWidth for ListItemIcon inside a MenuList than\n // we can create with sx, so apply an inline style for this property only.\n minWidth: '30px',\n }}\n >\n {item.icon && (\n <IconSvg\n icon={item.icon}\n sx={{\n width: '17px',\n height: '17px',\n ...item.iconSx,\n }}\n wrap={false}\n />\n )}\n </ListItemIcon>\n <ListItemText\n sx={{ marginTop: 0 }}\n slotProps={{\n primary: {\n variant: 'smallText1',\n sx: item.textSx,\n },\n }}\n >\n {item.text}\n </ListItemText>\n </MenuItem>\n </Tooltip>\n )\n }),\n index < array.length - 1 && <Divider />,\n ]\n })}\n </MenuList>\n </ClickAwayListener>\n </Paper>\n </Fade>\n )}\n </Popper>\n </>\n )\n}\n"],"mappings":";;;;;AAkEA,SAAgB,EAAa,GAA0B;CACrD,IAAM,EACJ,kBACA,uBACA,WAAQ,CAAC,GACT,+BAA4B,IAC5B,yBAAsB,IACtB,iBAAc,CAAC,MACb,GAEE,IAAiB,EAAM,GACvB,CAAC,GAAM,KAAW,EAAS,EAAK,GAChC,IAAY,EAA0B,IAAI,GAE1C,IAAoB,EAAM,KAAK,EAAE;CAEvC,IAAI,CAAC,KAAuB,MAAsB,GAEhD,OAAO;CAGT,IAAI,KAA6B,MAAsB,GAAG;EAExD,IAAM,IAAW,EAAM,KAAK,EAAE;EAC9B,OACE,kBAAC,GAAD;GACE,WAAW,UAAU,IAAW,MAAM;GACtC,OAAO,EAAS;GAChB,SAAQ;GACR,MAAM,UAAU,IAAW,EAAS,OAAO,KAAA;GAC3C,KAAK,UAAU,IAAW,wBAAwB,KAAA;GAClD,SAAS,aAAa,IAAW,EAAS,UAAU,KAAA;GACpD,UAAU,EAAS;GACnB,SAAS,EAAS,QAAQ,kBAAC,GAAD;IAAS,MAAM,EAAS;IAAM,MAAM;GAAQ,CAAA;aAEtE,kBAAC,GAAD;IAAY,SAAS;cAAe,EAAS;GAAiB,CAAA;EACxD,CAAA;CAEZ;CAEA,IAAM,UAAqB;EACzB,GAAQ,MAAY,CAAC,CAAQ;CAC/B,GAEM,KAAe,MAAkC;EAEnD,EAAU,WACV,EAAU,QAAQ,SAAS,EAAM,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Ae,OAAO;OAC/B,UAAU,MAAkB;QAK1B,AACE,CAAC,EAAK,YACN,aAAa,KACb,EAAK,YAEL,EAAQ,EAAK,GACb,EAAK,QAAQ,CAAC;OAElB;iBAnCF,CAqCE,kBAAC,GAAD;QACE,OAAO,EAGL,UAAU,OACZ;kBAEC,EAAK,QACJ,kBAAC,GAAD;SACE,MAAM,EAAK;SACX,IAAI;UACF,OAAO;UACP,QAAQ;UACR,GAAG,EAAK;SACV;SACA,MAAM;QACP,CAAA;OAES,CAAA,GACd,kBAAC,GAAD;QACE,IAAI,EAAE,WAAW,EAAE;QACnB,WAAW,EACT,SAAS;SACP,SAAS;SACT,IAAI,EAAK;QACX,EACF;kBAEC,EAAK;OACM,CAAA,CACN;;KACH,GAxEF,EAAK,IAwEH,CAEZ,GACD,IAAQ,EAAM,SAAS,KAAK,kBAAC,GAAD,CAAU,CAAA,CACxC,CACD;IACO,CAAA;GACO,CAAA,EACd,CAAA;EACH,CAAA;CAEF,CAAA,CACR,EAAA,CAAA;AAEN"}
1
+ {"version":3,"file":"DropdownMenu.js","names":[],"sources":["../../../src/components/menu/DropdownMenu.tsx"],"sourcesContent":["import {\n Button,\n ButtonProps,\n ClickAwayListener,\n Divider,\n Fade,\n ListItemIcon,\n ListItemText,\n MenuItem,\n MenuList,\n Paper,\n Popper,\n SxProps,\n Tooltip,\n Typography,\n} from '@mui/material'\nimport {\n KeyboardEvent,\n MouseEvent,\n SyntheticEvent,\n useId,\n useRef,\n useState,\n} from 'react'\nimport IconSvg, { IconName } from '../IconSvg/IconSvg'\n\n/**\n * Defines a configuration for a particular dropdown menu item\n */\nexport type DropdownMenuItem = {\n /* The text to show on the menu item. */\n text: string\n /* The icon to show for this item in the menu. */\n icon?: IconName\n /* A function invoked upon clicking the item, assuming `disabled` is falsy */\n onClick?: (e: MouseEvent) => void\n /* A link that the item should point to. */\n href?: string\n /* The optional tooltipText to show for this item. Compatible with the `disabled` prop. */\n tooltipText?: string\n /* Whether the item should be disabled from selection. */\n disabled?: boolean\n /* Additional MUI SxProps to pass to the text component */\n textSx?: SxProps\n /* Additional MUI SxProps to pass to the icon component */\n iconSx?: SxProps\n}\n\nexport type DropdownMenuProps = {\n /* Groups of menu items. Each group will be split with a divider. See DropdownMenuItem for per-item configuration */\n items: DropdownMenuItem[][]\n /* The text to show on the dropdown menu button. */\n dropdownButtonText: string\n /* The optional tooltip text for the dropdown menu button. */\n buttonTooltip?: string\n /* Any additional props to pass to the dropdown menu button. */\n buttonProps?: ButtonProps\n /* Optional MUI button variant for the dropdown button (and the single-item button). Default 'outlined'. */\n variant?: ButtonProps['variant']\n /* If true, will render a single action as a standalone button. Default true. */\n convertSingleItemToButton?: boolean\n /* If true, nothing will be rendered if no actions are passed. Default false. */\n renderMenuIfNoItems?: boolean\n}\n\n/**\n * The DropdownMenu component provides a generic way to compose a MUI dropdown menu.\n */\nexport function DropdownMenu(props: DropdownMenuProps) {\n const {\n buttonTooltip,\n dropdownButtonText,\n items = [] as DropdownMenuItem[][],\n convertSingleItemToButton = true,\n renderMenuIfNoItems = false,\n buttonProps = {},\n variant = 'outlined',\n } = props\n\n const dropdownMenuId = useId()\n const [open, setOpen] = useState(false)\n const anchorRef = useRef<HTMLButtonElement>(null)\n\n const numberOfMenuItems = items.flat().length\n\n if (!renderMenuIfNoItems && numberOfMenuItems === 0) {\n // Hide menu if no actions will be in the menu\n return null\n }\n\n if (convertSingleItemToButton && numberOfMenuItems === 1) {\n // If one action is in the menu, show it as a button\n const menuItem = items.flat()[0]\n return (\n <Button\n component={'href' in menuItem ? 'a' : 'button'}\n title={menuItem.tooltipText}\n variant={variant}\n href={'href' in menuItem ? menuItem.href : undefined}\n rel={'href' in menuItem ? 'noopener noreferrer' : undefined}\n onClick={'onClick' in menuItem ? menuItem.onClick : undefined}\n disabled={menuItem.disabled}\n endIcon={menuItem.icon && <IconSvg icon={menuItem.icon} wrap={false} />}\n >\n <Typography variant={'buttonLink'}>{menuItem.text}</Typography>\n </Button>\n )\n }\n\n const handleToggle = () => {\n setOpen(prevOpen => !prevOpen)\n }\n\n const handleClose = (event: Event | SyntheticEvent) => {\n if (\n anchorRef.current &&\n anchorRef.current.contains(event.target as HTMLElement)\n ) {\n return\n }\n\n setOpen(false)\n }\n\n function handleListKeyDown(event: KeyboardEvent) {\n if (event.key === 'Tab') {\n event.preventDefault()\n setOpen(false)\n } else if (event.key === 'Escape') {\n setOpen(false)\n }\n }\n\n return (\n <>\n <Tooltip\n title={\n buttonTooltip ? (\n <div style={{ whiteSpace: 'pre-line' }}>{buttonTooltip}</div>\n ) : undefined\n }\n placement={'top'}\n >\n <span>\n <Button\n variant={variant}\n ref={anchorRef}\n id={`composition-button-${dropdownMenuId}`}\n aria-controls={\n open ? `composition-menu-${dropdownMenuId}` : undefined\n }\n aria-expanded={open ? 'true' : undefined}\n aria-haspopup=\"true\"\n onClick={handleToggle}\n {...buttonProps}\n >\n <Typography variant={'buttonLink'}>{dropdownButtonText}</Typography>\n </Button>\n </span>\n </Tooltip>\n <Popper\n open={open}\n anchorEl={anchorRef.current}\n role={undefined}\n placement=\"bottom-end\"\n transition\n style={{\n // Fixes issue where react-flow (provenance) would appear above the menu\n zIndex: 10,\n }}\n >\n {({ TransitionProps }) => (\n <Fade {...TransitionProps}>\n <Paper>\n <ClickAwayListener onClickAway={handleClose}>\n <MenuList\n autoFocusItem={open}\n id={`composition-menu-${dropdownMenuId}`}\n aria-labelledby={`composition-button-${dropdownMenuId}`}\n onKeyDown={handleListKeyDown}\n >\n {items.map((itemGroup, index, array) => {\n return [\n itemGroup.map(item => {\n return (\n <Tooltip\n key={item.text}\n title={item.tooltipText}\n placement={'left'}\n >\n <MenuItem\n // Always make the component an anchor in case href is defined.\n component=\"a\"\n sx={{\n // Override the anchor-specific state styles, we don't want it to look like an anchor\n '&:hover': {\n color: 'unset',\n },\n '&:focus': {\n color: 'unset',\n textDecoration: 'unset',\n },\n }}\n disabled={item.disabled}\n href={'href' in item ? item.href : undefined}\n rel={\n 'href' in item\n ? 'noopener noreferrer'\n : undefined\n }\n // Allow pointer events on disabled item so tooltip works.\n style={{ pointerEvents: 'auto' }}\n onClick={(e: MouseEvent) => {\n /*\n * Must check if the item is disabled because we set\n * `pointer-events: 'auto'`\n */\n if (\n !item.disabled &&\n 'onClick' in item &&\n item.onClick\n ) {\n setOpen(false)\n item.onClick(e)\n }\n }}\n >\n <ListItemIcon\n style={{\n // MUI has specified a more specific minWidth for ListItemIcon inside a MenuList than\n // we can create with sx, so apply an inline style for this property only.\n minWidth: '30px',\n }}\n >\n {item.icon && (\n <IconSvg\n icon={item.icon}\n sx={{\n width: '17px',\n height: '17px',\n ...item.iconSx,\n }}\n wrap={false}\n />\n )}\n </ListItemIcon>\n <ListItemText\n sx={{ marginTop: 0 }}\n slotProps={{\n primary: {\n variant: 'smallText1',\n sx: item.textSx,\n },\n }}\n >\n {item.text}\n </ListItemText>\n </MenuItem>\n </Tooltip>\n )\n }),\n index < array.length - 1 && <Divider />,\n ]\n })}\n </MenuList>\n </ClickAwayListener>\n </Paper>\n </Fade>\n )}\n </Popper>\n </>\n )\n}\n"],"mappings":";;;;;AAoEA,SAAgB,EAAa,GAA0B;CACrD,IAAM,EACJ,kBACA,uBACA,WAAQ,CAAC,GACT,+BAA4B,IAC5B,yBAAsB,IACtB,iBAAc,CAAC,GACf,aAAU,eACR,GAEE,IAAiB,EAAM,GACvB,CAAC,GAAM,KAAW,EAAS,EAAK,GAChC,IAAY,EAA0B,IAAI,GAE1C,IAAoB,EAAM,KAAK,EAAE;CAEvC,IAAI,CAAC,KAAuB,MAAsB,GAEhD,OAAO;CAGT,IAAI,KAA6B,MAAsB,GAAG;EAExD,IAAM,IAAW,EAAM,KAAK,EAAE;EAC9B,OACE,kBAAC,GAAD;GACE,WAAW,UAAU,IAAW,MAAM;GACtC,OAAO,EAAS;GACP;GACT,MAAM,UAAU,IAAW,EAAS,OAAO,KAAA;GAC3C,KAAK,UAAU,IAAW,wBAAwB,KAAA;GAClD,SAAS,aAAa,IAAW,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W,GAAO,MACrB,CACL,EAAU,KAAI,MAEV,kBAAC,GAAD;MAEE,OAAO,EAAK;MACZ,WAAW;gBAEX,kBAAC,GAAD;OAEE,WAAU;OACV,IAAI;QAEF,WAAW,EACT,OAAO,QACT;QACA,WAAW;SACT,OAAO;SACP,gBAAgB;QAClB;OACF;OACA,UAAU,EAAK;OACf,MAAM,UAAU,IAAO,EAAK,OAAO,KAAA;OACnC,KACE,UAAU,IACN,wBACA,KAAA;OAGN,OAAO,EAAE,eAAe,OAAO;OAC/B,UAAU,MAAkB;QAK1B,AACE,CAAC,EAAK,YACN,aAAa,KACb,EAAK,YAEL,EAAQ,EAAK,GACb,EAAK,QAAQ,CAAC;OAElB;iBAnCF,CAqCE,kBAAC,GAAD;QACE,OAAO,EAGL,UAAU,OACZ;kBAEC,EAAK,QACJ,kBAAC,GAAD;SACE,MAAM,EAAK;SACX,IAAI;UACF,OAAO;UACP,QAAQ;UACR,GAAG,EAAK;SACV;SACA,MAAM;QACP,CAAA;OAES,CAAA,GACd,kBAAC,GAAD;QACE,IAAI,EAAE,WAAW,EAAE;QACnB,WAAW,EACT,SAAS;SACP,SAAS;SACT,IAAI,EAAK;QACX,EACF;kBAEC,EAAK;OACM,CAAA,CACN;;KACH,GAxEF,EAAK,IAwEH,CAEZ,GACD,IAAQ,EAAM,SAAS,KAAK,kBAAC,GAAD,CAAU,CAAA,CACxC,CACD;IACO,CAAA;GACO,CAAA,EACd,CAAA;EACH,CAAA;CAEF,CAAA,CACR,EAAA,CAAA;AAEN"}
@@ -1 +1 @@
1
- {"version":3,"file":"FacetNavPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/widgets/facet-nav/FacetNavPanel.tsx"],"names":[],"mappings":"AAcA,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EACxB,MAAM,iCAAiC,CAAA;AAExC,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAA;AAW9C,OAAO,EAAE,cAAc,EAAY,MAA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AAY,CAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACtC,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,MAAM,GAChB;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA8BnC;AAED,iBAAS,aAAa,CAAC,KAAK,EAAE,kBAAkB,2CAoN/C;AAED,eAAe,aAAa,CAAA"}
@@ -23,26 +23,8 @@ import { useQuery as k } from "@tanstack/react-query";
23
23
  import { InfoOutlined as A } from "@mui/icons-material";
24
24
  import { useMeasure as j } from "@react-hookz/web";
25
25
  //#region src/components/widgets/facet-nav/FacetNavPanel.tsx
26
- var M = 19, N = {
27
- showlegend: !1,
28
- annotations: [],
29
- margin: {
30
- l: 0,
31
- r: 0,
32
- b: 0,
33
- t: 0,
34
- pad: 0
35
- },
36
- yaxis: {
37
- visible: !1,
38
- showgrid: !1
39
- },
40
- xaxis: {
41
- visible: !1,
42
- showgrid: !1
43
- }
44
- };
45
- async function P(r, i, a, o, s) {
26
+ var M = 19;
27
+ async function N(r, i, a, o, s) {
46
28
  let c = f("odd", 0, r.facetValues.length), l = async (r, i, a) => {
47
29
  let o = /* @__PURE__ */ new Map();
48
30
  o.set(t, e);
@@ -95,13 +77,13 @@ async function P(r, i, a, o, s) {
95
77
  colors: o === "PIE" ? b.marker?.colors : b.marker?.color
96
78
  };
97
79
  }
98
- var F = (e, t, n) => {
80
+ var P = (e, t, n) => {
99
81
  if (e.points && e.points[0]) {
100
82
  let r = e.points[0], i = r.data.facetEnumerationValues[r.pointNumber], a = t.facetValues.find((e) => e.value === i);
101
83
  n(t, a, !a.isSelected);
102
84
  }
103
85
  };
104
- function I(e, t, n) {
86
+ function F(e, t, n) {
105
87
  if (e != null) {
106
88
  let r = 1;
107
89
  switch (t) {
@@ -126,17 +108,37 @@ function I(e, t, n) {
126
108
  height: `${n}px`
127
109
  };
128
110
  }
129
- function L(e) {
130
- let { onHide: t, isModalView: n, applyChangesToGraphSlice: f, index: h, facetToPlot: O, plotType: M, onSetPlotType: R } = e, { accessToken: z } = r(), { data: B, isLoading: V } = c(), [H, U] = j(), { getColumnDisplayName: W } = l(), [G, K] = v(!1), q = W(O.columnName, O.jsonPath), J = _(() => a(O, B?.columnModels ?? []), [B?.columnModels, O]), Y = J?.columnType, { data: X } = k({
111
+ function I(e) {
112
+ let { onHide: t, isModalView: n, applyChangesToGraphSlice: f, index: h, facetToPlot: O, plotType: M, onSetPlotType: L } = e, { accessToken: R } = r(), { data: z, isLoading: B } = c(), [V, H] = j(), { getColumnDisplayName: U } = l(), [W, G] = v(!1), K = U(O.columnName, O.jsonPath), q = _(() => a(O, z?.columnModels ?? []), [z?.columnModels, O]), J = q?.columnType, Y = _(() => ({
113
+ showlegend: !1,
114
+ annotations: [],
115
+ margin: {
116
+ l: 0,
117
+ r: 0,
118
+ b: 0,
119
+ t: 0,
120
+ pad: 0
121
+ },
122
+ yaxis: {
123
+ visible: M === "BAR",
124
+ showgrid: !1,
125
+ automargin: !0
126
+ },
127
+ xaxis: {
128
+ visible: n && M === "BAR",
129
+ showgrid: !1,
130
+ automargin: !0
131
+ }
132
+ }), [n, M]), { data: X } = k({
131
133
  queryKey: [
132
134
  "extractPlotDataArray",
133
135
  O,
134
- Y,
136
+ J,
135
137
  h,
136
138
  M,
137
- z
139
+ R
138
140
  ],
139
- queryFn: () => P(O, Y, h, M, z),
141
+ queryFn: () => N(O, J, h, M, R),
140
142
  enabled: !!O
141
143
  }), Z = g(), Q = g(), $ = /* @__PURE__ */ D(s, {
142
144
  fullWidth: !0,
@@ -148,7 +150,7 @@ function L(e) {
148
150
  label: "Chart Type",
149
151
  value: M,
150
152
  onChange: (e) => {
151
- R(e.target.value);
153
+ L(e.target.value);
152
154
  },
153
155
  children: [/* @__PURE__ */ E(x, {
154
156
  value: "BAR",
@@ -159,32 +161,32 @@ function L(e) {
159
161
  })]
160
162
  })]
161
163
  });
162
- return !B && V || !O || !J ? /* @__PURE__ */ E("div", {
164
+ return !z && B || !O || !q ? /* @__PURE__ */ E("div", {
163
165
  className: "SRC-loadingContainer SRC-centerContentColumn",
164
166
  children: i
165
167
  }) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(o, {
166
- open: G,
167
- onCancel: () => K(!1),
168
- title: q ?? "",
169
- content: /* @__PURE__ */ E(L, {
168
+ open: W,
169
+ onCancel: () => G(!1),
170
+ title: K ?? "",
171
+ content: /* @__PURE__ */ E(I, {
170
172
  ...e,
171
173
  isModalView: !0
172
174
  }),
173
175
  hasCancelButton: !1,
174
176
  confirmButtonProps: { children: "Apply Filters" },
175
- onConfirm: () => K(!1),
177
+ onConfirm: () => G(!1),
176
178
  maxWidth: "md"
177
179
  }), /* @__PURE__ */ D("div", {
178
180
  role: "figure",
179
181
  className: `FacetNavPanel${n ? "--expanded" : ""}`,
180
182
  children: [
181
183
  !n && /* @__PURE__ */ E(p, {
182
- data: B,
183
- isLoading: V,
184
- title: q,
184
+ data: z,
185
+ isLoading: B,
186
+ title: K,
185
187
  facetToPlot: O,
186
188
  onHide: t,
187
- setShowModal: K
189
+ setShowModal: G
188
190
  }),
189
191
  n && /* @__PURE__ */ D(C, {
190
192
  sx: { gap: 2 },
@@ -210,29 +212,37 @@ function L(e) {
210
212
  sx: {
211
213
  display: "grid",
212
214
  gridTemplateColumns: "50% 50%",
213
- alignItems: "center"
215
+ alignItems: "stretch",
216
+ height: "100%"
214
217
  },
215
218
  role: "graphics-object",
216
219
  className: "FacetNavPanel__body",
217
220
  children: [/* @__PURE__ */ E("div", {
218
- ref: U,
221
+ ref: H,
222
+ style: { height: "100%" },
219
223
  children: /* @__PURE__ */ E(d, {
220
- layout: N,
224
+ layout: Y,
221
225
  data: X?.data ?? [],
222
- style: I(H?.width, M, n ? 300 : 150),
226
+ style: {
227
+ ...F(V?.width, M, n ? 300 : 150),
228
+ ...V?.height ? { height: `${V.height}px` } : {}
229
+ },
223
230
  config: { displayModeBar: !1 },
224
- onClick: (e) => F(e, O, f)
225
- }, `${O.columnName}-${O.jsonPath}-${M}-${H?.width}`)
226
- }), /* @__PURE__ */ E(m, {
227
- labels: X?.labels,
228
- colors: X?.colors,
229
- isExpanded: n
231
+ onClick: (e) => P(e, O, f)
232
+ }, `${O.columnName}-${O.jsonPath}-${M}-${V?.width}-${V?.height}`)
233
+ }), /* @__PURE__ */ E(y, {
234
+ sx: { alignSelf: "center" },
235
+ children: /* @__PURE__ */ E(m, {
236
+ labels: X?.labels,
237
+ colors: X?.colors,
238
+ isExpanded: n
239
+ })
230
240
  })]
231
241
  })
232
242
  ]
233
243
  })] });
234
244
  }
235
245
  //#endregion
236
- export { L as default, P as extractPlotDataArray, I as getPlotStyle };
246
+ export { I as default, N as extractPlotDataArray, F as getPlotStyle };
237
247
 
238
248
  //# sourceMappingURL=FacetNavPanel.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FacetNavPanel.js","names":[],"sources":["../../../../src/components/widgets/facet-nav/FacetNavPanel.tsx"],"sourcesContent":["import StyledFormControl from '@/components/styled/StyledFormControl'\nimport SynapseClient from '@/synapse-client'\nimport { SynapseConstants } from '@/utils'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { getCorrespondingColumnForFacet } from '@/utils/functions/queryUtils'\nimport { InfoOutlined } from '@mui/icons-material'\nimport {\n Box,\n InputLabel,\n MenuItem,\n Select,\n Stack,\n Tooltip,\n} from '@mui/material'\nimport {\n ColumnTypeEnum,\n FacetColumnRequest,\n FacetColumnResultValueCount,\n FacetColumnResultValues,\n} from '@sage-bionetworks/synapse-types'\nimport { useQuery } from '@tanstack/react-query'\nimport type Plotly from 'plotly.js-basic-dist'\nimport { useId, useMemo, useState } from 'react'\nimport { getContrastColorPalette } from '../../ColorGradient/ColorGradient'\nimport { ConfirmationDialog } from '../../ConfirmationDialog/ConfirmationDialog'\nimport loadingScreen from '../../LoadingScreen/LoadingScreen'\nimport Plot from '../../Plot/Plot'\nimport PlotPanelHeader from '../../Plot/PlotPanelHeader'\nimport { useQueryVisualizationContext } from '../../QueryVisualizationWrapper'\nimport { useGetQueryMetadata } from '../../QueryWrapper/useGetQueryMetadata'\nimport { EnumFacetFilter } from '../query-filter/EnumFacetFilter/EnumFacetFilter'\nimport { FacetPlotLegendList } from './FacetPlotLegendList'\nimport { FacetWithLabel, truncate } from './FacetPlotLegendUtils'\nimport { useMeasure } from '@react-hookz/web'\n\nexport type FacetNavPanelProps = {\n applyChangesToGraphSlice: (\n facet: FacetColumnResultValues,\n value: FacetColumnResultValueCount | undefined,\n isSelected: boolean,\n ) => void\n applyChangesToFacetFilter: (facets: FacetColumnRequest[]) => void\n index: number\n facetToPlot: FacetColumnResultValues\n plotType: PlotType\n onSetPlotType: (plotType: PlotType) => void\n onHide: () => void\n isModalView: boolean\n onCloseModal?: () => void\n}\n\nconst maxLabelLength: number = 19\n\n// STACKED_HORIZONTAL_BAR corresponds to a bar chart where we just want to show the proportion (like a pie chart)\nexport type PlotType = 'PIE' | 'BAR' | 'STACKED_HORIZONTAL_BAR'\n\nconst layout: Partial<Plotly.Layout> = {\n showlegend: false,\n annotations: [],\n margin: { l: 0, r: 0, b: 0, t: 0, pad: 0 },\n yaxis: {\n visible: false,\n showgrid: false,\n },\n xaxis: {\n visible: false,\n showgrid: false,\n },\n}\n\nexport type GraphData = {\n data: Plotly.Data[]\n labels: FacetWithLabel[]\n colors: string[]\n}\n\nexport async function extractPlotDataArray(\n facetToPlot: FacetColumnResultValues,\n columnType: ColumnTypeEnum | undefined,\n index: number,\n plotType: PlotType,\n accessToken?: string,\n) {\n const colorPalette = getContrastColorPalette(\n // Use only the odd palette, using the same offset for all plots until palettes are improved.\n // See PORTALS-2916\n 'odd', // index % 2 === 0 ? 'even' : 'odd',\n 0, // Math.floor(index / 2),\n facetToPlot.facetValues.length,\n )\n\n const getLabels = async (\n facetValues: FacetColumnResultValueCount[],\n columnType?: ColumnTypeEnum,\n accessToken?: string,\n ) => {\n const map = new Map<string, string>()\n map.set(\n SynapseConstants.VALUE_NOT_SET,\n SynapseConstants.FRIENDLY_VALUE_NOT_SET,\n )\n // Filter out empties\n const filteredValues = facetValues\n .map(value => value.value)\n .filter(val => val !== SynapseConstants.VALUE_NOT_SET)\n if (\n columnType === ColumnTypeEnum.ENTITYID ||\n columnType === ColumnTypeEnum.ENTITYID_LIST\n ) {\n // TODO: Pagination\n const response = await SynapseClient.getEntityHeadersByIds(\n filteredValues,\n accessToken,\n )\n for (const header of response.results) {\n map.set(header.id, header.name)\n }\n } else if (\n columnType === ColumnTypeEnum.USERID ||\n columnType === ColumnTypeEnum.USERID_LIST\n ) {\n const response = await SynapseClient.getGroupHeadersBatch(\n filteredValues,\n accessToken,\n )\n for (const header of response.children) {\n map.set(header.ownerId, header.userName)\n }\n }\n\n return facetValues.map(facetValue => ({\n facet: facetValue,\n label: getLabel(facetValue, false, map),\n truncatedLabel: getLabel(facetValue, true, map),\n count: facetValue.count,\n }))\n }\n\n const getLabel = (\n facetValue: FacetColumnResultValueCount,\n truncateFlag: boolean,\n labelMap: Map<string, string>,\n ): string => {\n let label = labelMap.get(facetValue.value) ?? facetValue.value\n if (truncateFlag) {\n label = truncate(label, maxLabelLength)!\n }\n return label\n }\n\n const labels = await getLabels(\n facetToPlot.facetValues,\n columnType,\n accessToken,\n )\n const text = labels.map(el => el.truncatedLabel)\n\n const anyFacetsSelected = facetToPlot.facetValues.some(\n value => value.isSelected,\n )\n const selectionAwareColorPalette = anyFacetsSelected\n ? facetToPlot.facetValues.map((facetValue, index) =>\n facetValue.isSelected\n ? colorPalette[index]\n : colorPalette[index]\n .replace('rgb(', 'rgba(')\n .replace(')', ', 0.25)'),\n )\n : colorPalette\n const counts: Plotly.Datum[] = facetToPlot.facetValues.map(\n facet => facet.count,\n )\n let x: Plotly.Datum[] | Plotly.Datum[][] | Plotly.TypedArray | undefined\n\n if (plotType === 'BAR') {\n x = facetToPlot.facetValues.map(\n facet =>\n labels.find(label => label.facet === facet)?.label ?? facet.value,\n )\n } else if (plotType === 'STACKED_HORIZONTAL_BAR') {\n x = counts\n }\n\n let y: Plotly.Datum[] | Plotly.Datum[][] | Plotly.TypedArray | undefined\n if (plotType === 'BAR') {\n y = facetToPlot.facetValues.map(facet => facet.count)\n } else if (plotType === 'STACKED_HORIZONTAL_BAR') {\n y = Array(x?.length).fill('Proportional') // single value for every x value\n }\n\n const singleChartData: Plotly.Data = {\n values: plotType === 'PIE' ? counts : undefined,\n labels: labels.map(el => el.label),\n text,\n x,\n y,\n orientation: plotType === 'STACKED_HORIZONTAL_BAR' ? 'h' : 'v',\n // @ts-expect-error\n facetEnumerationValues: facetToPlot.facetValues.map(\n facetValue => facetValue.value,\n ),\n name: facetToPlot.columnName,\n textposition:\n plotType === 'STACKED_HORIZONTAL_BAR' || plotType === 'BAR'\n ? 'none'\n : 'inside',\n hovertemplate:\n plotType === 'PIE'\n ? '<b>%{text}</b><br>%{value} (%{percent})<br><extra></extra>'\n : '<b>%{text}: </b><br>%{value} <br><extra></extra>',\n textinfo: 'none',\n type: plotType === 'PIE' ? 'pie' : 'bar',\n pull:\n plotType === 'PIE'\n ? facetToPlot.facetValues.map(facetValue =>\n facetValue.isSelected ? 0.1 : 0,\n )\n : undefined,\n selectedpoints: anyFacetsSelected\n ? facetToPlot.facetValues\n .map((facetValue, index) => (facetValue.isSelected ? index : -1))\n .filter(index => index !== -1)\n : undefined,\n selected: { marker: { opacity: 1 } },\n unselected: { marker: { opacity: 0.25 } },\n\n marker: {\n colors: plotType === 'PIE' ? selectionAwareColorPalette : undefined,\n color: plotType === 'PIE' ? undefined : selectionAwareColorPalette,\n },\n }\n const result = {\n data: [singleChartData],\n labels,\n colors:\n plotType === 'PIE'\n ? ((singleChartData as any).marker?.colors as string[])\n : ((singleChartData as any).marker?.color as string[]),\n }\n return result\n}\n\nconst applyFacetFilter = (\n event: Plotly.PlotMouseEvent,\n allFacetValues: FacetColumnResultValues,\n callbackApplyFn: FacetNavPanelProps['applyChangesToGraphSlice'],\n) => {\n if (event.points && event.points[0]) {\n const plotPointData: any = event.points[0]\n const facetValueClickedValue =\n plotPointData.data.facetEnumerationValues[plotPointData.pointNumber]\n const facetValueClicked = allFacetValues.facetValues.find(\n facet => facet.value === facetValueClickedValue,\n )\n callbackApplyFn(\n allFacetValues,\n facetValueClicked,\n !facetValueClicked!.isSelected,\n )\n }\n}\n\nexport function getPlotStyle(\n parentWidth: number | null | undefined,\n plotType: PlotType,\n maxHeight: number,\n): { width: string; height: string } {\n if (parentWidth != undefined) {\n let quotient = 1\n switch (plotType) {\n case 'BAR':\n quotient = 0.8\n break\n case 'PIE':\n quotient = 0.6\n break\n case 'STACKED_HORIZONTAL_BAR':\n quotient = 1\n break\n }\n const width = parentWidth ? parentWidth * quotient : 200\n let height = plotType === 'PIE' ? width : width / 3\n // max height of .PlotsContainer row col* is 200px, so the effective plot height max is around 150 unless it's expanded\n if (height > maxHeight) {\n height = maxHeight\n }\n return {\n width: `${width}px`,\n height: `${height}px`,\n }\n }\n //else parent width is undefined\n return {\n width: '100%',\n height: `${maxHeight}px`,\n }\n}\n\nfunction FacetNavPanel(props: FacetNavPanelProps) {\n const {\n onHide,\n isModalView,\n applyChangesToGraphSlice,\n index,\n facetToPlot,\n plotType,\n onSetPlotType,\n } = props\n const { accessToken } = useSynapseContext()\n const { data: queryMetadata, isLoading: isLoadingQueryMetadata } =\n useGetQueryMetadata()\n\n const [plotContainerMeasurements, plotContainerRef] =\n useMeasure<HTMLDivElement>()\n const { getColumnDisplayName } = useQueryVisualizationContext()\n\n const [showModal, setShowModal] = useState(false)\n\n const plotTitle = getColumnDisplayName(\n facetToPlot.columnName,\n facetToPlot.jsonPath,\n )\n\n const columnModel = useMemo(\n () =>\n getCorrespondingColumnForFacet(\n facetToPlot,\n queryMetadata?.columnModels ?? [],\n ),\n [queryMetadata?.columnModels, facetToPlot],\n )\n const columnType = columnModel?.columnType as ColumnTypeEnum\n\n const { data: plotData } = useQuery({\n queryKey: [\n 'extractPlotDataArray',\n facetToPlot,\n columnType,\n index,\n plotType,\n accessToken,\n ],\n\n queryFn: () =>\n extractPlotDataArray(\n facetToPlot,\n columnType,\n index,\n plotType,\n accessToken,\n ),\n\n enabled: !!facetToPlot,\n })\n\n const chartSelectionInputLabelId = useId()\n const filterByInputLabelId = useId()\n\n /* rendering functions */\n const chartSelectionToggle = (\n <StyledFormControl fullWidth>\n <InputLabel id={chartSelectionInputLabelId}>Chart Type</InputLabel>\n <Select\n labelId={chartSelectionInputLabelId}\n label=\"Chart Type\"\n value={plotType}\n onChange={e => {\n onSetPlotType(e.target.value as PlotType)\n }}\n >\n <MenuItem value={'BAR'}>Bar Chart</MenuItem>\n <MenuItem value={'PIE'}>Pie Chart</MenuItem>\n </Select>\n </StyledFormControl>\n )\n\n if (\n (!queryMetadata && isLoadingQueryMetadata) ||\n !facetToPlot ||\n !columnModel\n ) {\n return (\n <div className=\"SRC-loadingContainer SRC-centerContentColumn\">\n {loadingScreen}\n </div>\n )\n } else {\n return (\n <>\n <ConfirmationDialog\n open={showModal}\n onCancel={() => setShowModal(false)}\n title={plotTitle ?? ''}\n content={<FacetNavPanel {...props} isModalView={true} />}\n hasCancelButton={false}\n confirmButtonProps={{ children: 'Apply Filters' }}\n onConfirm={() => setShowModal(false)}\n maxWidth={'md'}\n />\n <div\n role=\"figure\"\n className={`FacetNavPanel${isModalView ? '--expanded' : ''}`}\n >\n {!isModalView && (\n <PlotPanelHeader\n data={queryMetadata}\n isLoading={isLoadingQueryMetadata}\n title={plotTitle}\n facetToPlot={facetToPlot}\n onHide={onHide}\n setShowModal={setShowModal}\n />\n )}\n {isModalView && (\n <Stack\n sx={{\n gap: 2,\n }}\n >\n <StyledFormControl>\n <InputLabel\n id={filterByInputLabelId}\n sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}\n >\n <span>Filter All Data By</span>\n <Tooltip title=\"Selecting items in this dropdown will affect all facets on the Explore page.\">\n <InfoOutlined className=\"SRC-hand-cursor SRC-secondary-text-color\" />\n </Tooltip>\n </InputLabel>\n <EnumFacetFilter\n labelId={filterByInputLabelId}\n facet={facetToPlot}\n containerAs=\"Dropdown\"\n dropdownType=\"SelectBox\"\n />\n </StyledFormControl>\n {chartSelectionToggle}\n </Stack>\n )}\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: '50% 50%',\n alignItems: 'center',\n }}\n role=\"graphics-object\"\n className=\"FacetNavPanel__body\"\n >\n <div ref={plotContainerRef}>\n <Plot\n key={`${facetToPlot.columnName}-${facetToPlot.jsonPath}-${plotType}-${plotContainerMeasurements?.width}`}\n layout={layout}\n data={plotData?.data ?? []}\n style={getPlotStyle(\n plotContainerMeasurements?.width,\n plotType,\n isModalView ? 300 : 150,\n )}\n config={{ displayModeBar: false }}\n onClick={evt =>\n applyFacetFilter(evt, facetToPlot, applyChangesToGraphSlice)\n }\n />\n </div>\n <FacetPlotLegendList\n labels={plotData?.labels}\n colors={plotData?.colors}\n isExpanded={isModalView}\n />\n </Box>\n </div>\n </>\n )\n }\n}\n\nexport default FacetNavPanel\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAM,IAAyB,IAKzB,IAAiC;CACrC,YAAY;CACZ,aAAa,CAAC;CACd,QAAQ;EAAE,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,GAAG;EAAG,KAAK;CAAE;CACzC,OAAO;EACL,SAAS;EACT,UAAU;CACZ;CACA,OAAO;EACL,SAAS;EACT,UAAU;CACZ;AACF;AAQA,eAAsB,EACpB,GACA,GACA,GACA,GACA,GACA;CACA,IAAM,IAAe,EAGnB,OACA,GACA,EAAY,YAAY,MAC1B,GAEM,IAAY,OAChB,GACA,GACA,MACG;EACH,IAAM,oBAAM,IAAI,IAAoB;EACpC,EAAI,IACF,GACA,CACF;EAEA,IAAM,IAAiB,EACpB,KAAI,MAAS,EAAM,KAAK,EACxB,QAAO,MAAO,MAAQ,CAA8B;EACvD,IACE,MAAe,EAAe,YAC9B,MAAe,EAAe,eAC9B;GAEA,IAAM,IAAW,MAAM,EAAc,sBACnC,GAC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GAAD;KACE,QAAQ,GAAU;KAClB,QAAQ,GAAU;KAClB,YAAY;IACb,CAAA,CACE;;EACF;GACL,EAAA,CAAA;AAGR"}
1
+ {"version":3,"file":"FacetNavPanel.js","names":[],"sources":["../../../../src/components/widgets/facet-nav/FacetNavPanel.tsx"],"sourcesContent":["import StyledFormControl from '@/components/styled/StyledFormControl'\nimport SynapseClient from '@/synapse-client'\nimport { SynapseConstants } from '@/utils'\nimport { useSynapseContext } from '@/utils/context/SynapseContext'\nimport { getCorrespondingColumnForFacet } from '@/utils/functions/queryUtils'\nimport { InfoOutlined } from '@mui/icons-material'\nimport {\n Box,\n InputLabel,\n MenuItem,\n Select,\n Stack,\n Tooltip,\n} from '@mui/material'\nimport {\n ColumnTypeEnum,\n FacetColumnRequest,\n FacetColumnResultValueCount,\n FacetColumnResultValues,\n} from '@sage-bionetworks/synapse-types'\nimport { useQuery } from '@tanstack/react-query'\nimport type Plotly from 'plotly.js-basic-dist'\nimport { useId, useMemo, useState } from 'react'\nimport { getContrastColorPalette } from '../../ColorGradient/ColorGradient'\nimport { ConfirmationDialog } from '../../ConfirmationDialog/ConfirmationDialog'\nimport loadingScreen from '../../LoadingScreen/LoadingScreen'\nimport Plot from '../../Plot/Plot'\nimport PlotPanelHeader from '../../Plot/PlotPanelHeader'\nimport { useQueryVisualizationContext } from '../../QueryVisualizationWrapper'\nimport { useGetQueryMetadata } from '../../QueryWrapper/useGetQueryMetadata'\nimport { EnumFacetFilter } from '../query-filter/EnumFacetFilter/EnumFacetFilter'\nimport { FacetPlotLegendList } from './FacetPlotLegendList'\nimport { FacetWithLabel, truncate } from './FacetPlotLegendUtils'\nimport { useMeasure } from '@react-hookz/web'\n\nexport type FacetNavPanelProps = {\n applyChangesToGraphSlice: (\n facet: FacetColumnResultValues,\n value: FacetColumnResultValueCount | undefined,\n isSelected: boolean,\n ) => void\n applyChangesToFacetFilter: (facets: FacetColumnRequest[]) => void\n index: number\n facetToPlot: FacetColumnResultValues\n plotType: PlotType\n onSetPlotType: (plotType: PlotType) => void\n onHide: () => void\n isModalView: boolean\n onCloseModal?: () => void\n}\n\nconst maxLabelLength: number = 19\n\n// STACKED_HORIZONTAL_BAR corresponds to a bar chart where we just want to show the proportion (like a pie chart)\nexport type PlotType = 'PIE' | 'BAR' | 'STACKED_HORIZONTAL_BAR'\n\nexport type GraphData = {\n data: Plotly.Data[]\n labels: FacetWithLabel[]\n colors: string[]\n}\n\nexport async function extractPlotDataArray(\n facetToPlot: FacetColumnResultValues,\n columnType: ColumnTypeEnum | undefined,\n index: number,\n plotType: PlotType,\n accessToken?: string,\n) {\n const colorPalette = getContrastColorPalette(\n // Use only the odd palette, using the same offset for all plots until palettes are improved.\n // See PORTALS-2916\n 'odd', // index % 2 === 0 ? 'even' : 'odd',\n 0, // Math.floor(index / 2),\n facetToPlot.facetValues.length,\n )\n\n const getLabels = async (\n facetValues: FacetColumnResultValueCount[],\n columnType?: ColumnTypeEnum,\n accessToken?: string,\n ) => {\n const map = new Map<string, string>()\n map.set(\n SynapseConstants.VALUE_NOT_SET,\n SynapseConstants.FRIENDLY_VALUE_NOT_SET,\n )\n // Filter out empties\n const filteredValues = facetValues\n .map(value => value.value)\n .filter(val => val !== SynapseConstants.VALUE_NOT_SET)\n if (\n columnType === ColumnTypeEnum.ENTITYID ||\n columnType === ColumnTypeEnum.ENTITYID_LIST\n ) {\n // TODO: Pagination\n const response = await SynapseClient.getEntityHeadersByIds(\n filteredValues,\n accessToken,\n )\n for (const header of response.results) {\n map.set(header.id, header.name)\n }\n } else if (\n columnType === ColumnTypeEnum.USERID ||\n columnType === ColumnTypeEnum.USERID_LIST\n ) {\n const response = await SynapseClient.getGroupHeadersBatch(\n filteredValues,\n accessToken,\n )\n for (const header of response.children) {\n map.set(header.ownerId, header.userName)\n }\n }\n\n return facetValues.map(facetValue => ({\n facet: facetValue,\n label: getLabel(facetValue, false, map),\n truncatedLabel: getLabel(facetValue, true, map),\n count: facetValue.count,\n }))\n }\n\n const getLabel = (\n facetValue: FacetColumnResultValueCount,\n truncateFlag: boolean,\n labelMap: Map<string, string>,\n ): string => {\n let label = labelMap.get(facetValue.value) ?? facetValue.value\n if (truncateFlag) {\n label = truncate(label, maxLabelLength)!\n }\n return label\n }\n\n const labels = await getLabels(\n facetToPlot.facetValues,\n columnType,\n accessToken,\n )\n const text = labels.map(el => el.truncatedLabel)\n\n const anyFacetsSelected = facetToPlot.facetValues.some(\n value => value.isSelected,\n )\n const selectionAwareColorPalette = anyFacetsSelected\n ? facetToPlot.facetValues.map((facetValue, index) =>\n facetValue.isSelected\n ? colorPalette[index]\n : colorPalette[index]\n .replace('rgb(', 'rgba(')\n .replace(')', ', 0.25)'),\n )\n : colorPalette\n const counts: Plotly.Datum[] = facetToPlot.facetValues.map(\n facet => facet.count,\n )\n let x: Plotly.Datum[] | Plotly.Datum[][] | Plotly.TypedArray | undefined\n\n if (plotType === 'BAR') {\n x = facetToPlot.facetValues.map(\n facet =>\n labels.find(label => label.facet === facet)?.label ?? facet.value,\n )\n } else if (plotType === 'STACKED_HORIZONTAL_BAR') {\n x = counts\n }\n\n let y: Plotly.Datum[] | Plotly.Datum[][] | Plotly.TypedArray | undefined\n if (plotType === 'BAR') {\n y = facetToPlot.facetValues.map(facet => facet.count)\n } else if (plotType === 'STACKED_HORIZONTAL_BAR') {\n y = Array(x?.length).fill('Proportional') // single value for every x value\n }\n\n const singleChartData: Plotly.Data = {\n values: plotType === 'PIE' ? counts : undefined,\n labels: labels.map(el => el.label),\n text,\n x,\n y,\n orientation: plotType === 'STACKED_HORIZONTAL_BAR' ? 'h' : 'v',\n // @ts-expect-error\n facetEnumerationValues: facetToPlot.facetValues.map(\n facetValue => facetValue.value,\n ),\n name: facetToPlot.columnName,\n textposition:\n plotType === 'STACKED_HORIZONTAL_BAR' || plotType === 'BAR'\n ? 'none'\n : 'inside',\n hovertemplate:\n plotType === 'PIE'\n ? '<b>%{text}</b><br>%{value} (%{percent})<br><extra></extra>'\n : '<b>%{text}: </b><br>%{value} <br><extra></extra>',\n textinfo: 'none',\n type: plotType === 'PIE' ? 'pie' : 'bar',\n pull:\n plotType === 'PIE'\n ? facetToPlot.facetValues.map(facetValue =>\n facetValue.isSelected ? 0.1 : 0,\n )\n : undefined,\n selectedpoints: anyFacetsSelected\n ? facetToPlot.facetValues\n .map((facetValue, index) => (facetValue.isSelected ? index : -1))\n .filter(index => index !== -1)\n : undefined,\n selected: { marker: { opacity: 1 } },\n unselected: { marker: { opacity: 0.25 } },\n\n marker: {\n colors: plotType === 'PIE' ? selectionAwareColorPalette : undefined,\n color: plotType === 'PIE' ? undefined : selectionAwareColorPalette,\n },\n }\n const result = {\n data: [singleChartData],\n labels,\n colors:\n plotType === 'PIE'\n ? ((singleChartData as any).marker?.colors as string[])\n : ((singleChartData as any).marker?.color as string[]),\n }\n return result\n}\n\nconst applyFacetFilter = (\n event: Plotly.PlotMouseEvent,\n allFacetValues: FacetColumnResultValues,\n callbackApplyFn: FacetNavPanelProps['applyChangesToGraphSlice'],\n) => {\n if (event.points && event.points[0]) {\n const plotPointData: any = event.points[0]\n const facetValueClickedValue =\n plotPointData.data.facetEnumerationValues[plotPointData.pointNumber]\n const facetValueClicked = allFacetValues.facetValues.find(\n facet => facet.value === facetValueClickedValue,\n )\n callbackApplyFn(\n allFacetValues,\n facetValueClicked,\n !facetValueClicked!.isSelected,\n )\n }\n}\n\nexport function getPlotStyle(\n parentWidth: number | null | undefined,\n plotType: PlotType,\n maxHeight: number,\n): { width: string; height: string } {\n if (parentWidth != undefined) {\n let quotient = 1\n switch (plotType) {\n case 'BAR':\n quotient = 0.8\n break\n case 'PIE':\n quotient = 0.6\n break\n case 'STACKED_HORIZONTAL_BAR':\n quotient = 1\n break\n }\n const width = parentWidth ? parentWidth * quotient : 200\n let height = plotType === 'PIE' ? width : width / 3\n // max height of .PlotsContainer row col* is 200px, so the effective plot height max is around 150 unless it's expanded\n if (height > maxHeight) {\n height = maxHeight\n }\n return {\n width: `${width}px`,\n height: `${height}px`,\n }\n }\n //else parent width is undefined\n return {\n width: '100%',\n height: `${maxHeight}px`,\n }\n}\n\nfunction FacetNavPanel(props: FacetNavPanelProps) {\n const {\n onHide,\n isModalView,\n applyChangesToGraphSlice,\n index,\n facetToPlot,\n plotType,\n onSetPlotType,\n } = props\n const { accessToken } = useSynapseContext()\n const { data: queryMetadata, isLoading: isLoadingQueryMetadata } =\n useGetQueryMetadata()\n\n const [plotContainerMeasurements, plotContainerRef] =\n useMeasure<HTMLDivElement>()\n const { getColumnDisplayName } = useQueryVisualizationContext()\n\n const [showModal, setShowModal] = useState(false)\n\n const plotTitle = getColumnDisplayName(\n facetToPlot.columnName,\n facetToPlot.jsonPath,\n )\n\n const columnModel = useMemo(\n () =>\n getCorrespondingColumnForFacet(\n facetToPlot,\n queryMetadata?.columnModels ?? [],\n ),\n [queryMetadata?.columnModels, facetToPlot],\n )\n const columnType = columnModel?.columnType as ColumnTypeEnum\n\n // Plotly.js mutates the layout object it receives, so each component instance\n // must have its own layout object. Sharing a single object across instances\n // (e.g. when the expand modal mounts a second FacetNavPanel) causes Plotly's\n // mutations on one chart to silently corrupt the other. Use useMemo to\n // produce a fresh layout object per instance — do NOT hoist this to module scope.\n const plotLayout = useMemo<Partial<Plotly.Layout>>(\n () => ({\n showlegend: false,\n annotations: [],\n margin: { l: 0, r: 0, b: 0, t: 0, pad: 0 },\n yaxis: {\n visible: plotType === 'BAR',\n showgrid: false,\n automargin: true,\n },\n xaxis: {\n // Show category labels on the x-axis for vertical bar charts in modal view\n visible: isModalView && plotType === 'BAR',\n showgrid: false,\n automargin: true,\n },\n }),\n [isModalView, plotType],\n )\n\n const { data: plotData } = useQuery({\n queryKey: [\n 'extractPlotDataArray',\n facetToPlot,\n columnType,\n index,\n plotType,\n accessToken,\n ],\n\n queryFn: () =>\n extractPlotDataArray(\n facetToPlot,\n columnType,\n index,\n plotType,\n accessToken,\n ),\n\n enabled: !!facetToPlot,\n })\n\n const chartSelectionInputLabelId = useId()\n const filterByInputLabelId = useId()\n\n /* rendering functions */\n const chartSelectionToggle = (\n <StyledFormControl fullWidth>\n <InputLabel id={chartSelectionInputLabelId}>Chart Type</InputLabel>\n <Select\n labelId={chartSelectionInputLabelId}\n label=\"Chart Type\"\n value={plotType}\n onChange={e => {\n onSetPlotType(e.target.value as PlotType)\n }}\n >\n <MenuItem value={'BAR'}>Bar Chart</MenuItem>\n <MenuItem value={'PIE'}>Pie Chart</MenuItem>\n </Select>\n </StyledFormControl>\n )\n\n if (\n (!queryMetadata && isLoadingQueryMetadata) ||\n !facetToPlot ||\n !columnModel\n ) {\n return (\n <div className=\"SRC-loadingContainer SRC-centerContentColumn\">\n {loadingScreen}\n </div>\n )\n } else {\n return (\n <>\n <ConfirmationDialog\n open={showModal}\n onCancel={() => setShowModal(false)}\n title={plotTitle ?? ''}\n content={<FacetNavPanel {...props} isModalView={true} />}\n hasCancelButton={false}\n confirmButtonProps={{ children: 'Apply Filters' }}\n onConfirm={() => setShowModal(false)}\n maxWidth={'md'}\n />\n <div\n role=\"figure\"\n className={`FacetNavPanel${isModalView ? '--expanded' : ''}`}\n >\n {!isModalView && (\n <PlotPanelHeader\n data={queryMetadata}\n isLoading={isLoadingQueryMetadata}\n title={plotTitle}\n facetToPlot={facetToPlot}\n onHide={onHide}\n setShowModal={setShowModal}\n />\n )}\n {isModalView && (\n <Stack\n sx={{\n gap: 2,\n }}\n >\n <StyledFormControl>\n <InputLabel\n id={filterByInputLabelId}\n sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}\n >\n <span>Filter All Data By</span>\n <Tooltip title=\"Selecting items in this dropdown will affect all facets on the Explore page.\">\n <InfoOutlined className=\"SRC-hand-cursor SRC-secondary-text-color\" />\n </Tooltip>\n </InputLabel>\n <EnumFacetFilter\n labelId={filterByInputLabelId}\n facet={facetToPlot}\n containerAs=\"Dropdown\"\n dropdownType=\"SelectBox\"\n />\n </StyledFormControl>\n {chartSelectionToggle}\n </Stack>\n )}\n <Box\n sx={{\n display: 'grid',\n gridTemplateColumns: '50% 50%',\n // alignItems:stretch + height:100% propagate the body's flex:1\n // height (set in SCSS) down into the plot container so useMeasure\n // can read it and size the Plotly chart to fill available space.\n alignItems: 'stretch',\n height: '100%',\n }}\n role=\"graphics-object\"\n className=\"FacetNavPanel__body\"\n >\n <div ref={plotContainerRef} style={{ height: '100%' }}>\n <Plot\n key={`${facetToPlot.columnName}-${facetToPlot.jsonPath}-${plotType}-${plotContainerMeasurements?.width}-${plotContainerMeasurements?.height}`}\n layout={plotLayout}\n data={plotData?.data ?? []}\n style={{\n ...getPlotStyle(\n plotContainerMeasurements?.width,\n plotType,\n isModalView ? 300 : 150,\n ),\n ...(plotContainerMeasurements?.height\n ? { height: `${plotContainerMeasurements.height}px` }\n : {}),\n }}\n config={{ displayModeBar: false }}\n onClick={evt =>\n applyFacetFilter(evt, facetToPlot, applyChangesToGraphSlice)\n }\n />\n </div>\n <Box sx={{ alignSelf: 'center' }}>\n <FacetPlotLegendList\n labels={plotData?.labels}\n colors={plotData?.colors}\n isExpanded={isModalView}\n />\n </Box>\n </Box>\n </div>\n </>\n )\n }\n}\n\nexport default FacetNavPanel\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAmDA,IAAM,IAAyB;AAW/B,eAAsB,EACpB,GACA,GACA,GACA,GACA,GACA;CACA,IAAM,IAAe,EAGnB,OACA,GACA,EAAY,YAAY,MAC1B,GAEM,IAAY,OAChB,GACA,GACA,MACG;EACH,IAAM,oBAAM,IAAI,IAAoB;EACpC,EAAI,IACF,GACA,CACF;EAEA,IAAM,IAAiB,EACpB,KAAI,MAAS,EAAM,KAAK,EACxB,QAAO,MAAO,MAAQ,CAA8B;EACvD,IACE,MAAe,EAAe,YAC9B,MAAe,EAAe,eAC9B;GAEA,IAAM,IAAW,MAAM,EAAc,sBACnC,GACA,CACF;GACA,KAAK,IAAM,KAAU,EAAS,SAC5B,EAAI,IAAI,EAAO,IAAI,EAAO,IAAI;EAElC,OAAO,IACL,MAAe,EAAe,UAC9B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L,GAAG,EACD,GAA2B,OAC3B,GACA,IAAc,MAAM,GACtB;OACA,GAAI,GAA2B,SAC3B,EAAE,QAAQ,GAAG,EAA0B,OAAO,IAAI,IAClD,CAAC;MACP;MACA,QAAQ,EAAE,gBAAgB,GAAM;MAChC,UAAS,MACP,EAAiB,GAAK,GAAa,CAAwB;KAE9D,GAjBM,GAAG,EAAY,WAAW,GAAG,EAAY,SAAS,GAAG,EAAS,GAAG,GAA2B,MAAM,GAAG,GAA2B,QAiBtI;IACE,CAAA,GACL,kBAAC,GAAD;KAAK,IAAI,EAAE,WAAW,SAAS;eAC7B,kBAAC,GAAD;MACE,QAAQ,GAAU;MAClB,QAAQ,GAAU;MAClB,YAAY;KACb,CAAA;IACE,CAAA,CACF;;EACF;GACL,EAAA,CAAA;AAGR"}
@@ -1 +1 @@
1
- {"version":3,"file":"PlotsContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/widgets/facet-nav/PlotsContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAO/C,OAAgC,EAC9B,4BAA4B,EAC7B,MAAM,mDAAmD,CAAA;AAC1D,OAAsB,EAEpB,QAAQ,EACT,MAAM,4BAA4B,CAAA;AAMnC,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,CAAC,EAAE,4BAA4B,EAAE,CAAA;IAC5C,gCAAgC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAC5D,CAAA;AACD,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AACD,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,oBAAoB,CAAA;AAEzE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,cAAc,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AA+SD,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,2CAO5E"}
1
+ {"version":3,"file":"PlotsContainer.d.ts","sourceRoot":"","sources":["../../../../src/components/widgets/facet-nav/PlotsContainer.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAA;AAO/C,OAAgC,EAC9B,4BAA4B,EAC7B,MAAM,mDAAmD,CAAA;AAC1D,OAAsB,EAEpB,QAAQ,EACT,MAAM,4BAA4B,CAAA;AAMnC,MAAM,MAAM,mBAAmB,GAAG;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAA;IACvB,WAAW,CAAC,EAAE,4BAA4B,EAAE,CAAA;IAC5C,gCAAgC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;CAC5D,CAAA;AACD,KAAK,oBAAoB,GAAG;IAC1B,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,IAAI,CAAA;CACf,CAAA;AACD,MAAM,MAAM,cAAc,GAAG,qBAAqB,GAAG,oBAAoB,CAAA;AAEzE,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,cAAc,CAAA;IACtB,QAAQ,EAAE,OAAO,CAAA;IACjB,QAAQ,EAAE,QAAQ,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAgUD,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,KAAK,EAAE,mBAAmB,2CAO5E"}
@@ -47,7 +47,13 @@ function O(e) {
47
47
  ...t,
48
48
  isHidden: n >= _
49
49
  }));
50
- }, F = (e) => A.find((t) => v(e, t.plotId) && t.isHidden === !0) !== void 0, I = u(() => A.find((e) => e.isHidden === !0) ? "MORE" : A.length <= _ ? "NONE" : "LESS", [A]), L = (e) => {
50
+ }, F = (e) => A.find((t) => v(e, t.plotId) && t.isHidden === !0) !== void 0, I = u(() => A.find((e) => e.isHidden === !0) ? "MORE" : A.length <= _ ? "NONE" : "LESS", [A]);
51
+ l(() => {
52
+ I === "LESS" && requestAnimationFrame(() => {
53
+ window.dispatchEvent(new Event("resize"));
54
+ });
55
+ }, [I]);
56
+ let L = (e) => {
51
57
  z(e, "isHidden", !0);
52
58
  }, R = (e, t) => {
53
59
  z(e, "plotType", t);
@@ -71,7 +77,7 @@ function O(e) {
71
77
  children: A.map((e) => {
72
78
  let t = "__custom" in e.plotId, n = c.find((t) => v(S(t), e.plotId)), i = M.find((t) => v(t.facetToPlot, e.plotId));
73
79
  return /* @__PURE__ */ g("div", {
74
- className: e.plotType === "BAR" ? "PlotsContainer__row__item--full-width" : void 0,
80
+ className: [t ? "PlotsContainer__row__item--custom" : void 0, t && n?.fullWidth ? "PlotsContainer__row__item--full-width" : void 0].filter(Boolean).join(" ") || void 0,
75
81
  style: {
76
82
  minWidth: "435px",
77
83
  display: F(e.plotId) ? "none" : "block"