synapse-react-client 4.0.22 → 4.0.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/SWC.index.js +1 -1
- package/dist/assets/icons/GeneticsIcon.d.ts +3 -0
- package/dist/assets/icons/GeneticsIcon.d.ts.map +1 -0
- package/dist/assets/icons/GeneticsIcon.js +14 -0
- package/dist/assets/icons/GeneticsIcon.js.map +1 -0
- package/dist/components/EntityCitation/EntityCitation.d.ts.map +1 -1
- package/dist/components/EntityCitation/EntityCitation.js +49 -32
- package/dist/components/EntityCitation/EntityCitation.js.map +1 -1
- package/dist/components/GenericCard/DuoTermTags/DuoTermTags.d.ts +18 -0
- package/dist/components/GenericCard/DuoTermTags/DuoTermTags.d.ts.map +1 -0
- package/dist/components/GenericCard/DuoTermTags/DuoTermTags.js +112 -0
- package/dist/components/GenericCard/DuoTermTags/DuoTermTags.js.map +1 -0
- package/dist/components/GenericCard/DuoTermTags/duoTerms.d.ts +31 -0
- package/dist/components/GenericCard/DuoTermTags/duoTerms.d.ts.map +1 -0
- package/dist/components/GenericCard/DuoTermTags/duoTerms.js +198 -0
- package/dist/components/GenericCard/DuoTermTags/duoTerms.js.map +1 -0
- package/dist/components/GenericCard/SynapseCardLabel.d.ts.map +1 -1
- package/dist/components/GenericCard/SynapseCardLabel.js +4 -8
- package/dist/components/GenericCard/SynapseCardLabel.js.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.d.ts +6 -0
- package/dist/components/GenericCard/TableRowGenericCard.d.ts.map +1 -1
- package/dist/components/GenericCard/TableRowGenericCard.js +168 -153
- package/dist/components/GenericCard/TableRowGenericCard.js.map +1 -1
- package/dist/components/IconSvg/IconSvg.d.ts +1 -1
- package/dist/components/IconSvg/IconSvg.d.ts.map +1 -1
- package/dist/components/IconSvg/IconSvg.js +19 -18
- package/dist/components/IconSvg/IconSvg.js.map +1 -1
- package/dist/components/Plot/SynapsePlot.d.ts +4 -0
- package/dist/components/Plot/SynapsePlot.d.ts.map +1 -1
- package/dist/components/Plot/SynapsePlot.js +57 -44
- package/dist/components/Plot/SynapsePlot.js.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationContext.d.ts +21 -0
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationContext.d.ts.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationContext.js.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.d.ts +10 -0
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.d.ts.map +1 -1
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js +65 -59
- package/dist/components/QueryVisualizationWrapper/QueryVisualizationWrapper.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js +2 -0
- package/dist/components/QueryWrapperPlotNav/QueryWrapperPlotNav.js.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperSynapsePlot.d.ts.map +1 -1
- package/dist/components/QueryWrapperPlotNav/QueryWrapperSynapsePlot.js +77 -34
- package/dist/components/QueryWrapperPlotNav/QueryWrapperSynapsePlot.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts +33 -6
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js +93 -55
- package/dist/components/SearchQueryWrapper/SearchQueryUseQueryOptions.js.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.d.ts +3 -0
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js +39 -37
- package/dist/components/SearchQueryWrapper/SearchQueryWrapper.js.map +1 -1
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts +3 -1
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.d.ts.map +1 -1
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js +5 -0
- package/dist/components/SearchQueryWrapperPlotNav/SearchQueryWrapperPlotNav.js.map +1 -1
- package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts +7 -2
- package/dist/components/entity/page/action_menu/EntityActionMenu.d.ts.map +1 -1
- package/dist/components/entity/page/action_menu/EntityActionMenu.js +87 -51
- package/dist/components/entity/page/action_menu/EntityActionMenu.js.map +1 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.d.ts.map +1 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js +0 -1
- package/dist/components/entity/page/breadcrumbs/EntityPageBreadcrumbs.js.map +1 -1
- package/dist/components/entity/page/title_bar/EntityPageTitleBar.d.ts +1 -0
- package/dist/components/entity/page/title_bar/EntityPageTitleBar.d.ts.map +1 -1
- package/dist/components/entity/page/title_bar/EntityPageTitleBar.js +31 -22
- package/dist/components/entity/page/title_bar/EntityPageTitleBar.js.map +1 -1
- package/dist/components/entity/page/title_bar/EntityTitleBarVersionInfo.d.ts.map +1 -1
- package/dist/components/entity/page/title_bar/EntityTitleBarVersionInfo.js +34 -20
- package/dist/components/entity/page/title_bar/EntityTitleBarVersionInfo.js.map +1 -1
- package/dist/components/favorites/FavoriteButton.d.ts +1 -0
- package/dist/components/favorites/FavoriteButton.d.ts.map +1 -1
- package/dist/components/favorites/FavoriteButton.js +8 -8
- package/dist/components/favorites/FavoriteButton.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/menu/ComplexMenu.d.ts +8 -1
- package/dist/components/menu/ComplexMenu.d.ts.map +1 -1
- package/dist/components/menu/ComplexMenu.js +50 -20
- package/dist/components/menu/ComplexMenu.js.map +1 -1
- package/dist/components/menu/DropdownMenu.d.ts +1 -0
- package/dist/components/menu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/menu/DropdownMenu.js +24 -24
- package/dist/components/menu/DropdownMenu.js.map +1 -1
- package/dist/components/widgets/facet-nav/FacetNavPanel.d.ts.map +1 -1
- package/dist/components/widgets/facet-nav/FacetNavPanel.js +59 -49
- package/dist/components/widgets/facet-nav/FacetNavPanel.js.map +1 -1
- package/dist/components/widgets/facet-nav/FacetValueChip.d.ts +25 -0
- package/dist/components/widgets/facet-nav/FacetValueChip.d.ts.map +1 -0
- package/dist/components/widgets/facet-nav/FacetValueChip.js +40 -0
- package/dist/components/widgets/facet-nav/FacetValueChip.js.map +1 -0
- package/dist/components/widgets/facet-nav/PlotsContainer.d.ts.map +1 -1
- package/dist/components/widgets/facet-nav/PlotsContainer.js +8 -2
- package/dist/components/widgets/facet-nav/PlotsContainer.js.map +1 -1
- package/dist/components/widgets/facet-nav/SelectionCriteriaPill.d.ts +10 -5
- package/dist/components/widgets/facet-nav/SelectionCriteriaPill.d.ts.map +1 -1
- package/dist/components/widgets/facet-nav/SelectionCriteriaPill.js +10 -17
- package/dist/components/widgets/facet-nav/SelectionCriteriaPill.js.map +1 -1
- package/dist/components/widgets/facet-nav/SelectionCriteriaPills.d.ts.map +1 -1
- package/dist/components/widgets/facet-nav/SelectionCriteriaPills.js +11 -10
- package/dist/components/widgets/facet-nav/SelectionCriteriaPills.js.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.js +70 -54
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilter.js.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterOption.d.ts +2 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterOption.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterOption.js +17 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterOption.js.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.d.ts +2 -0
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.d.ts.map +1 -1
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.js +7 -7
- package/dist/components/widgets/query-filter/EnumFacetFilter/EnumFacetFilterUI.js.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.d.ts.map +1 -1
- package/dist/features/curator/dashboard/components/CurationTaskCard.js +99 -45
- package/dist/features/curator/dashboard/components/CurationTaskCard.js.map +1 -1
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.js +174 -149
- package/dist/features/entity/metadata-task/components/CreateOrUpdateCurationTaskDialog.js.map +1 -1
- package/dist/features/entity/metadata-task/utils/constants.d.ts +6 -0
- package/dist/features/entity/metadata-task/utils/constants.d.ts.map +1 -1
- package/dist/features/entity/metadata-task/utils/constants.js +19 -2
- package/dist/features/entity/metadata-task/utils/constants.js.map +1 -1
- package/dist/style/components/_total-query-results.scss +10 -34
- package/dist/style/components/facet_nav/_facet-nav-panel.scss +11 -0
- package/dist/style/main.css +1 -1
- package/dist/synapse-queries/curation/task/useCurationTask.d.ts.map +1 -1
- package/dist/synapse-queries/curation/task/useCurationTask.js +1 -1
- package/dist/synapse-queries/curation/task/useCurationTask.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplexMenu.d.ts","sourceRoot":"","sources":["../../../src/components/menu/ComplexMenu.tsx"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -16,29 +16,59 @@ function u(u) {
|
|
|
16
16
|
paddingTop: "10px"
|
|
17
17
|
}
|
|
18
18
|
}),
|
|
19
|
-
children: [d.map((n) =>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
children: [d.map((n) => {
|
|
20
|
+
if (n.variant != null) {
|
|
21
|
+
let t = n.text ?? n.tooltipText;
|
|
22
|
+
return /* @__PURE__ */ c(r, {
|
|
23
|
+
sx: (e) => ({ [e.breakpoints.down("sm")]: {
|
|
24
|
+
width: "100%",
|
|
25
|
+
".MuiButton-root": { width: "100%" }
|
|
26
|
+
} }),
|
|
27
|
+
children: /* @__PURE__ */ c(i, {
|
|
28
|
+
variant: n.variant,
|
|
29
|
+
startIcon: n.icon ? /* @__PURE__ */ c(e, {
|
|
30
|
+
icon: n.icon,
|
|
31
|
+
wrap: !1,
|
|
32
|
+
fontSize: "inherit",
|
|
33
|
+
sx: n.iconSx
|
|
34
|
+
}) : void 0,
|
|
35
|
+
onClick: n.onClick,
|
|
36
|
+
href: n.href,
|
|
37
|
+
disabled: n.disabled,
|
|
38
|
+
children: /* @__PURE__ */ c(a, {
|
|
39
|
+
variant: "buttonLink",
|
|
40
|
+
children: t
|
|
41
|
+
})
|
|
42
|
+
})
|
|
43
|
+
}, t);
|
|
44
|
+
}
|
|
45
|
+
return p && n.tooltipText ? /* @__PURE__ */ c(r, {
|
|
32
46
|
sx: {
|
|
33
|
-
|
|
34
|
-
|
|
47
|
+
width: "100%",
|
|
48
|
+
textAlign: "center"
|
|
35
49
|
},
|
|
36
|
-
children: /* @__PURE__ */ c(
|
|
37
|
-
variant: "
|
|
38
|
-
|
|
50
|
+
children: /* @__PURE__ */ c(i, {
|
|
51
|
+
variant: "text",
|
|
52
|
+
startIcon: /* @__PURE__ */ c(e, {
|
|
53
|
+
icon: n.icon,
|
|
54
|
+
wrap: !1,
|
|
55
|
+
fontSize: "inherit"
|
|
56
|
+
}, n.tooltipText),
|
|
57
|
+
onClick: n.onClick,
|
|
58
|
+
sx: {
|
|
59
|
+
padding: "6px 12px",
|
|
60
|
+
minWidth: "unset"
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ c(a, {
|
|
63
|
+
variant: "buttonLink",
|
|
64
|
+
children: n.tooltipText
|
|
65
|
+
})
|
|
39
66
|
})
|
|
40
|
-
})
|
|
41
|
-
|
|
67
|
+
}) : /* @__PURE__ */ c(t, {
|
|
68
|
+
...n,
|
|
69
|
+
icon: n.icon
|
|
70
|
+
}, n.tooltipText);
|
|
71
|
+
}), f.map((e, t) => e.items && e.items.length > 0 && /* @__PURE__ */ c(r, {
|
|
42
72
|
sx: (e) => ({ [e.breakpoints.down("sm")]: {
|
|
43
73
|
width: "100%",
|
|
44
74
|
".MuiButton-root": { width: "100%" }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ComplexMenu.js","names":[],"sources":["../../../src/components/menu/ComplexMenu.tsx"],"sourcesContent":["import {
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DropdownMenu.d.ts","sourceRoot":"","sources":["../../../src/components/menu/DropdownMenu.tsx"],"names":[],"mappings":"A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,QAAQ,CAAA;IAEf,OAAO,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI,CAAA;IAEjC,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,WAAW,CAAC,EAAE,MAAM,CAAA;IAEpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAElB,MAAM,CAAC,EAAE,OAAO,CAAA;IAEhB,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAE9B,KAAK,EAAE,gBAAgB,EAAE,EAAE,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,
|
|
8
|
-
if (!w &&
|
|
9
|
-
if (C &&
|
|
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:
|
|
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
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
29
|
+
let M = () => {
|
|
30
|
+
k((e) => !e);
|
|
31
|
+
}, N = (e) => {
|
|
32
|
+
A.current && A.current.contains(e.target) || k(!1);
|
|
33
33
|
};
|
|
34
|
-
function
|
|
35
|
-
e.key === "Tab" ? (e.preventDefault(),
|
|
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:
|
|
45
|
-
ref:
|
|
46
|
-
id: `composition-button-${
|
|
47
|
-
"aria-controls":
|
|
48
|
-
"aria-expanded":
|
|
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:
|
|
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:
|
|
59
|
-
anchorEl:
|
|
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:
|
|
67
|
+
onClickAway: N,
|
|
68
68
|
children: /* @__PURE__ */ _(d, {
|
|
69
|
-
autoFocusItem:
|
|
70
|
-
id: `composition-menu-${
|
|
71
|
-
"aria-labelledby": `composition-button-${
|
|
72
|
-
onKeyDown:
|
|
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 && (
|
|
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,uB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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,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,MAAqB,KAKxD,EAAQ,EAAK;CACf;CAEA,SAAS,EAAkB,GAAsB;EAC/C,AAAI,EAAM,QAAQ,SAChB,EAAM,eAAe,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,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,MAAM,wBAAwB,CAAA;AAGjE,MAAM,MAAM,kBAAkB,GAAG;IAC/B,wBAAwB,EAAE,CACxB,KAAK,EAAE,uBAAuB,EAC9B,KAAK,EAAE,2BAA2B,GAAG,SAAS,EAC9C,UAAU,EAAE,OAAO,KAChB,IAAI,CAAA;IACT,yBAAyB,EAAE,CAAC,MAAM,EAAE,kBAAkB,EAAE,KAAK,IAAI,CAAA;IACjE,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,uBAAuB,CAAA;IACpC,QAAQ,EAAE,QAAQ,CAAA;IAClB,aAAa,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CA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jB,CAAA;AAED,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,uBAAuB,EACpC,UAAU,EAAE,cAAc,GAAG,SAAS,EACtC,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,QAAQ,EAClB,WAAW,CAAC,EAAE,MAAM;;;;;;;;;GA+JrB;AAsBD,wBAAgB,YAAY,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
|
|
27
|
-
|
|
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
|
|
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
|
|
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
|
|
130
|
-
let { onHide: t, isModalView: n, applyChangesToGraphSlice: f, index: h, facetToPlot: O, plotType: M, onSetPlotType:
|
|
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
|
-
|
|
136
|
+
J,
|
|
135
137
|
h,
|
|
136
138
|
M,
|
|
137
|
-
|
|
139
|
+
R
|
|
138
140
|
],
|
|
139
|
-
queryFn: () =>
|
|
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
|
-
|
|
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 !
|
|
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:
|
|
167
|
-
onCancel: () =>
|
|
168
|
-
title:
|
|
169
|
-
content: /* @__PURE__ */ E(
|
|
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: () =>
|
|
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:
|
|
183
|
-
isLoading:
|
|
184
|
-
title:
|
|
184
|
+
data: z,
|
|
185
|
+
isLoading: B,
|
|
186
|
+
title: K,
|
|
185
187
|
facetToPlot: O,
|
|
186
188
|
onHide: t,
|
|
187
|
-
setShowModal:
|
|
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: "
|
|
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:
|
|
221
|
+
ref: H,
|
|
222
|
+
style: { height: "100%" },
|
|
219
223
|
children: /* @__PURE__ */ E(d, {
|
|
220
|
-
layout:
|
|
224
|
+
layout: Y,
|
|
221
225
|
data: X?.data ?? [],
|
|
222
|
-
style:
|
|
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) =>
|
|
225
|
-
}, `${O.columnName}-${O.jsonPath}-${M}-${
|
|
226
|
-
}), /* @__PURE__ */ E(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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 {
|
|
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,GACA,CACF;GACA,KAAK,IAAM,KAAU,EAAS,SAC5B,EAAI,IAAI,EAAO,IAAI,EAAO,IAAI;EAElC,OAAO,IACL,MAAe,EAAe,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
|
+
{"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,MAAe,EAAe,aAC9B;GACA,IAAM,IAAW,MAAM,EAAc,qBACnC,GACA,CACF;GACA,KAAK,IAAM,KAAU,EAAS,UAC5B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,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"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { TooltipProps } from '@mui/material';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
export type FacetValueChipProps = {
|
|
4
|
+
/** The chip label. */
|
|
5
|
+
label: ReactNode;
|
|
6
|
+
/** Optional leading icon. */
|
|
7
|
+
icon?: ReactNode;
|
|
8
|
+
/** Optional tooltip content. When set, the chip is wrapped in a Tooltip. */
|
|
9
|
+
tooltipTitle?: ReactNode;
|
|
10
|
+
/** Tooltip placement. @default 'top' */
|
|
11
|
+
placement?: TooltipProps['placement'];
|
|
12
|
+
/** When provided, the chip shows a delete/remove button that calls this. */
|
|
13
|
+
onDelete?: () => void;
|
|
14
|
+
/** Cap the width and truncate long labels with an ellipsis (full text in tooltip). */
|
|
15
|
+
truncate?: boolean;
|
|
16
|
+
className?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The shared chip used to render a facet value (or DUO term) consistently
|
|
20
|
+
* wherever it appears: in the facet sidebar, as an active-filter pill, and on
|
|
21
|
+
* cards. Owning the icon, tooltip, and delete affordance in one place keeps the
|
|
22
|
+
* styling identical across those contexts.
|
|
23
|
+
*/
|
|
24
|
+
export default function FacetValueChip(props: FacetValueChipProps): import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
//# sourceMappingURL=FacetValueChip.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FacetValueChip.d.ts","sourceRoot":"","sources":["../../../../src/components/widgets/facet-nav/FacetValueChip.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAgB,SAAS,EAAE,MAAM,OAAO,CAAA;AAE/C,MAAM,MAAM,mBAAmB,GAAG;IAChC,sBAAsB;IACtB,KAAK,EAAE,SAAS,CAAA;IAChB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,4EAA4E;IAC5E,YAAY,CAAC,EAAE,SAAS,CAAA;IACxB,wCAAwC;IACxC,SAAS,CAAC,EAAE,YAAY,CAAC,WAAW,CAAC,CAAA;IACrC,4EAA4E;IAC5E,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,sFAAsF;IACtF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAA;AAgBD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,KAAK,EAAE,mBAAmB,2CA+BhE"}
|