@neo4j-ndl/react-charts 1.0.22 → 1.0.23
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/lib/cjs/charts/Legend.js
CHANGED
|
@@ -55,7 +55,7 @@ const LegendItem = function LegendItemComponent(_a) {
|
|
|
55
55
|
if ((_b = (0, legend_utils_1.isThresholdLine)(name)) !== null && _b !== void 0 ? _b : false) {
|
|
56
56
|
return null;
|
|
57
57
|
}
|
|
58
|
-
return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ className: classes, ref: ref, "data-labelname": name, onClick: hasButtons ? onLegendItemClick : undefined, onMouseEnter: onLegendItemMouseEnter, onMouseLeave: onLegendItemMouseLeave }, restProps, { children: [(0, jsx_runtime_1.jsx)("span", { className: "ndl-chart-legend-item-square", style: {
|
|
58
|
+
return ((0, jsx_runtime_1.jsxs)(Component, Object.assign({ className: classes, ref: ref, "data-labelname": name, title: name, onClick: hasButtons ? onLegendItemClick : undefined, onMouseEnter: onLegendItemMouseEnter, onMouseLeave: onLegendItemMouseLeave }, restProps, { children: [(0, jsx_runtime_1.jsx)("span", { className: "ndl-chart-legend-item-square", style: {
|
|
59
59
|
'--ndl-chart-legend-item-color': color,
|
|
60
60
|
backgroundColor: deSelected === true ? 'transparent' : color,
|
|
61
61
|
}, children: selected === true && ((0, jsx_runtime_1.jsx)(icons_1.CheckIconOutline, { className: "ndl-chart-legend-item-square-checkmark" })) }), (0, jsx_runtime_1.jsx)(react_1.Typography, { variant: "body-medium", className: "ndl-chart-legend-item-text", children: children })] })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.js","sourceRoot":"","sources":["../../../src/charts/Legend.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,0CAAyC;AACzC,4CAK0B;AAC1B,kDAA0D;AAC1D,4DAAoC;AACpC,qCAA6D;AAE7D,iCAAoD;AAEp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AA,EAAA,CAC1C,CAAC;gCAEJ,IAAI,0BAA0B,EAAE,CAAC;oCAC/B,eAAe,EAAE,CAAC;oCAClB,OAAO;gCACT,CAAC;gCAED,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oCACzC,MAAM,mBAAmB,GACvB,oBAAoB,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,CAAC,CAAC;oCAExD,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CACtB,IAAI,CAAC,IAAI,EACT,mBAAmB,EACnB,KAAK,EACL,MAAM,CACP,CAAC;gCACJ,CAAC,CAAC,CAAC;4BACL,CAAC,aAEA,kBAAkB,CAAC,MAAM,aACf,GACG,EAClB,uBAAC,eAAO,CAAC,OAAO,cACb,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAChC,wCAAoB,IAAI,CAAC,IAAI,IAArB,IAAI,CAAC,IAAI,CAAiB,CACnC,CAAC,GACc,IACV,CACX,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport {\n ConditionalWrap,\n Tooltip,\n Typography,\n useResizeObserver,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { type EChartsType, getInstanceByDom } from 'echarts';\nimport type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {\n getComputedElementWidth,\n highlightOrDownplaySeries,\n isThresholdLine,\n resetAllSeriesHighlight,\n useLegendVisibility,\n} from './legend-utils';\n\ninterface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n selected?: boolean;\n deSelected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nconst LegendItem = function LegendItemComponent({\n children,\n as,\n className,\n name,\n selected,\n deSelected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': deSelected,\n 'ndl-chart-legend-item-selected': selected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: deSelected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {selected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n\nexport interface LegendProps extends React.HTMLAttributes<HTMLDivElement> {\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\n series: {\n name: string;\n color: string;\n }[];\n chartRef: React.RefObject<HTMLDivElement | null>;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport const Legend = function LegendComponent({\n className,\n wrappingType = 'wrapping',\n series,\n chartRef,\n ref,\n}: LegendProps) {\n const [selectedSeries, setSelectedSeries] = useState<Record<string, boolean>>(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n const highlightTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const downplayTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hoverTimeOut = 80;\n\n const highlightSeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the downplay timeout when a new item is hovered\n if (downplayTimeOut.current) {\n clearTimeout(downplayTimeOut.current);\n }\n\n // Delay the highlight to avoid flickering when quickly hovering the legend items\n highlightTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'highlight',\n );\n }, hoverTimeOut);\n };\n\n const downplaySeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the highlight timeout when the mouse is leaving the legend item\n if (highlightTimeOut.current) {\n clearTimeout(highlightTimeOut.current);\n }\n\n // Delay the downplay to avoid flickering when moving the highlight between legend items (no downplay needed in between)\n downplayTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'downplay',\n );\n }, hoverTimeOut);\n };\n\n useEffect(() => {\n setSelectedSeries(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n if (chartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartRef.current);\n\n const eventTypes = [\n 'legendselectchanged',\n 'legendselectall',\n 'legendselected',\n 'legendunselected',\n ] as const;\n\n eventTypes.forEach((eventType) => {\n chart?.on(eventType, (params) => {\n if (\n typeof params === 'object' &&\n params !== null &&\n 'selected' in params &&\n params.selected !== null\n ) {\n const selected = params.selected ?? {};\n const filteredSelected = Object.fromEntries(\n Object.entries(selected).filter(\n ([key]) => !(isThresholdLine(key) ?? false),\n ),\n );\n\n // Reset the series highlight to avoid series to stay blurred on selection change\n if (eventType === 'legendselectchanged') {\n resetAllSeriesHighlight(chart as EChartsType);\n }\n\n setSelectedSeries(filteredSelected);\n }\n });\n });\n\n return () => {\n eventTypes.forEach((eventType) => {\n chart?.off(eventType);\n });\n };\n }, [chartRef, series]);\n\n const classes = classNames(\n `ndl-chart-legend`,\n {\n 'ndl-chart-legend-truncation': wrappingType === 'truncation',\n 'ndl-chart-legend-wrapping': wrappingType === 'wrapping',\n },\n className,\n );\n\n const { toggleLegendVisibility, setAllVisible } = useLegendVisibility(\n chartRef,\n selectedSeries,\n );\n\n return (\n <div ref={ref} className=\"ndl-chart-legend-container\">\n {wrappingType === 'truncation' || wrappingType === 'wrapping' ? (\n <div className={classes}>\n {series.map((currentSeries, index) => {\n const hasMoreThanOneItem = series.length > 1;\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const color = currentSeries.color;\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <ConditionalWrap\n key={index}\n shouldWrap={wrappingType === 'truncation'}\n wrap={(children) => (\n <Tooltip type=\"simple\" key={index}>\n <Tooltip.Trigger hasButtonWrapper>\n {children}\n </Tooltip.Trigger>\n </Tooltip>\n )}\n >\n <LegendItem\n name={currentSeries.name}\n color={color}\n hasButtons={\n hasMoreThanOneItem && currentSeries.name !== undefined\n }\n onLegendItemMouseEnter={() => {\n !isDeselected && highlightSeries([currentSeries]);\n }}\n onLegendItemMouseLeave={() => {\n !isDeselected && downplaySeries([currentSeries]);\n }}\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesSelected,\n isOnlyVisible,\n );\n }}\n selected={\n !isAllSeriesVisible &&\n selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n </ConditionalWrap>\n );\n })}\n </div>\n ) : (\n <LegendOverflowType\n className={classes}\n selectedSeries={selectedSeries}\n wrappingType={wrappingType}\n chartRef={chartRef}\n series={series}\n onSetAllVisible={setAllVisible}\n onLegendItemMouseEnter={(seriesToUpdate) =>\n highlightSeries(seriesToUpdate)\n }\n onLegendItemMouseLeave={(seriesToUpdate) =>\n downplaySeries(seriesToUpdate)\n }\n onToggleLegendVisibility={(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n ) => {\n toggleLegendVisibility(name, isAllSeriesSelected, isOnlyVisible);\n }}\n />\n )}\n </div>\n );\n};\n\ninterface LegendOverflowProps extends LegendProps {\n selectedSeries: Record<string, boolean>;\n onSetAllVisible: () => void;\n onToggleLegendVisibility?: (\n name: string,\n isAllSeriesSelected: boolean,\n isOnlyVisible: boolean,\n allSeries: { name: string; color: string }[],\n ) => void;\n onLegendItemMouseEnter: (series: { name: string; color: string }[]) => void;\n onLegendItemMouseLeave: (series: { name: string; color: string }[]) => void;\n}\n\nconst LegendOverflowType = function LegendOverflow({\n className,\n series,\n onSetAllVisible,\n onToggleLegendVisibility,\n selectedSeries,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n}: LegendOverflowProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [nonOverflowItemsNames, setNonOverflowItemsNames] = useState<string[]>(\n series.map((s) => s.name),\n );\n\n useEffect(() => {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }, [series]);\n\n const overflowItemsNames = series.filter(\n (item) => !nonOverflowItemsNames.includes(item.name),\n );\n\n const [width, setWidth] = useState(Infinity);\n useResizeObserver({\n // TODO: remove type cast. use-hooks.ts 3.1.1 has a type issue with the ref, it should be HTMLElement | null\n // https://github.com/juliencrn/usehooks-ts/pull/680\n ref: containerRef as React.RefObject<HTMLElement>,\n onResize: (entry) => {\n if (entry.width === undefined) {\n return;\n }\n if (width < entry.width) {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }\n setWidth(entry.width);\n },\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n let elements = Array.from(container.children);\n if (elements.length === 0 || series.length === 0) {\n return;\n }\n\n let totalWidth = 0;\n\n if (overflowItemsNames.length > 0) {\n const lastElementItem = elements[elements.length - 1];\n const lastItemWidth = getComputedElementWidth(lastElementItem);\n\n elements = elements.slice(0, elements.length - 1);\n totalWidth += lastItemWidth;\n }\n\n elements.forEach((element) => {\n const elementWidth = getComputedElementWidth(element);\n totalWidth += elementWidth;\n const textContent = element.textContent;\n if (!textContent) {\n return;\n }\n const itemName = element.getAttribute('data-labelname');\n if (itemName === null) {\n return;\n }\n if (totalWidth > width) {\n setNonOverflowItemsNames((oldNames) =>\n oldNames.filter((name) => name !== itemName),\n );\n }\n });\n }, [overflowItemsNames.length, series.length, width]);\n\n const classes = classNames(\n {\n 'ndl-chart-legend-calculating': width === Infinity,\n },\n className,\n );\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const hasMoreThanOneItem = nonOverflowItemsNames.length > 1;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const isOverflowItemsDeselected = overflowItemsNames.every(\n (item) => !selectedSeries[item.name ?? ''],\n );\n\n return (\n <div className={classes} ref={containerRef}>\n {nonOverflowItemsNames.map((name) => {\n const currentSeries = series.find((s) => s.name === name);\n if (currentSeries === undefined) {\n return null;\n }\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <LegendItem\n key={name}\n name={name}\n color={currentSeries.color}\n onLegendItemMouseEnter={() =>\n !isDeselected && onLegendItemMouseEnter([currentSeries])\n }\n onLegendItemMouseLeave={() =>\n !isDeselected && onLegendItemMouseLeave([currentSeries])\n }\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[name ?? ''] && selectedSeriesLength === 1;\n\n onToggleLegendVisibility?.(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n series,\n );\n }}\n hasButtons={hasMoreThanOneItem}\n selected={\n !isAllSeriesVisible && selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {name}\n </LegendItem>\n );\n })}\n\n {overflowItemsNames.length > 0 && (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger hasButtonWrapper>\n <LegendItem\n name=\"ndl-overflow-items\"\n color={tokens.palette.neutral[30]}\n selected={\n !isAllSeriesVisible &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n )\n }\n deSelected={isOverflowItemsDeselected}\n onLegendItemMouseEnter={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseEnter(overflowItemsNames)\n }\n onLegendItemMouseLeave={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseLeave(overflowItemsNames)\n }\n onLegendItemClick={() => {\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isOnlyOverflowItemsVisible =\n selectedSeriesLength === overflowItemsNames.length &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n );\n\n if (isOnlyOverflowItemsVisible) {\n onSetAllVisible();\n return;\n }\n\n overflowItemsNames.forEach((item, index) => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length && index === 0;\n\n onToggleLegendVisibility?.(\n item.name,\n isAllSeriesSelected,\n false,\n series,\n );\n });\n }}\n >\n {overflowItemsNames.length} more\n </LegendItem>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {overflowItemsNames.map((item) => (\n <p key={item.name}>{item.name}</p>\n ))}\n </Tooltip.Content>\n </Tooltip>\n )}\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"Legend.js","sourceRoot":"","sources":["../../../src/charts/Legend.t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CAEvD,MAAM,0BAA0B,GAC9B,oBAAoB,KAAK,kBAAkB,CAAC,MAAM;oCAClD,kBAAkB,CAAC,KAAK,CACtB,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,cAAc,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAA,EAAA,CAC1C,CAAC;gCAEJ,IAAI,0BAA0B,EAAE,CAAC;oCAC/B,eAAe,EAAE,CAAC;oCAClB,OAAO;gCACT,CAAC;gCAED,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oCACzC,MAAM,mBAAmB,GACvB,oBAAoB,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,CAAC,CAAC;oCAExD,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CACtB,IAAI,CAAC,IAAI,EACT,mBAAmB,EACnB,KAAK,EACL,MAAM,CACP,CAAC;gCACJ,CAAC,CAAC,CAAC;4BACL,CAAC,aAEA,kBAAkB,CAAC,MAAM,aACf,GACG,EAClB,uBAAC,eAAO,CAAC,OAAO,cACb,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAChC,wCAAoB,IAAI,CAAC,IAAI,IAArB,IAAI,CAAC,IAAI,CAAiB,CACnC,CAAC,GACc,IACV,CACX,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport {\n ConditionalWrap,\n Tooltip,\n Typography,\n useResizeObserver,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { type EChartsType, getInstanceByDom } from 'echarts';\nimport type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {\n getComputedElementWidth,\n highlightOrDownplaySeries,\n isThresholdLine,\n resetAllSeriesHighlight,\n useLegendVisibility,\n} from './legend-utils';\n\ninterface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n selected?: boolean;\n deSelected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nconst LegendItem = function LegendItemComponent({\n children,\n as,\n className,\n name,\n selected,\n deSelected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': deSelected,\n 'ndl-chart-legend-item-selected': selected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n title={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: deSelected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {selected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n\nexport interface LegendProps extends React.HTMLAttributes<HTMLDivElement> {\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\n series: {\n name: string;\n color: string;\n }[];\n chartRef: React.RefObject<HTMLDivElement | null>;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport const Legend = function LegendComponent({\n className,\n wrappingType = 'wrapping',\n series,\n chartRef,\n ref,\n}: LegendProps) {\n const [selectedSeries, setSelectedSeries] = useState<Record<string, boolean>>(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n const highlightTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const downplayTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hoverTimeOut = 80;\n\n const highlightSeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the downplay timeout when a new item is hovered\n if (downplayTimeOut.current) {\n clearTimeout(downplayTimeOut.current);\n }\n\n // Delay the highlight to avoid flickering when quickly hovering the legend items\n highlightTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'highlight',\n );\n }, hoverTimeOut);\n };\n\n const downplaySeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the highlight timeout when the mouse is leaving the legend item\n if (highlightTimeOut.current) {\n clearTimeout(highlightTimeOut.current);\n }\n\n // Delay the downplay to avoid flickering when moving the highlight between legend items (no downplay needed in between)\n downplayTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'downplay',\n );\n }, hoverTimeOut);\n };\n\n useEffect(() => {\n setSelectedSeries(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n if (chartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartRef.current);\n\n const eventTypes = [\n 'legendselectchanged',\n 'legendselectall',\n 'legendselected',\n 'legendunselected',\n ] as const;\n\n eventTypes.forEach((eventType) => {\n chart?.on(eventType, (params) => {\n if (\n typeof params === 'object' &&\n params !== null &&\n 'selected' in params &&\n params.selected !== null\n ) {\n const selected = params.selected ?? {};\n const filteredSelected = Object.fromEntries(\n Object.entries(selected).filter(\n ([key]) => !(isThresholdLine(key) ?? false),\n ),\n );\n\n // Reset the series highlight to avoid series to stay blurred on selection change\n if (eventType === 'legendselectchanged') {\n resetAllSeriesHighlight(chart as EChartsType);\n }\n\n setSelectedSeries(filteredSelected);\n }\n });\n });\n\n return () => {\n eventTypes.forEach((eventType) => {\n chart?.off(eventType);\n });\n };\n }, [chartRef, series]);\n\n const classes = classNames(\n `ndl-chart-legend`,\n {\n 'ndl-chart-legend-truncation': wrappingType === 'truncation',\n 'ndl-chart-legend-wrapping': wrappingType === 'wrapping',\n },\n className,\n );\n\n const { toggleLegendVisibility, setAllVisible } = useLegendVisibility(\n chartRef,\n selectedSeries,\n );\n\n return (\n <div ref={ref} className=\"ndl-chart-legend-container\">\n {wrappingType === 'truncation' || wrappingType === 'wrapping' ? (\n <div className={classes}>\n {series.map((currentSeries, index) => {\n const hasMoreThanOneItem = series.length > 1;\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const color = currentSeries.color;\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <ConditionalWrap\n key={index}\n shouldWrap={wrappingType === 'truncation'}\n wrap={(children) => (\n <Tooltip type=\"simple\" key={index}>\n <Tooltip.Trigger hasButtonWrapper>\n {children}\n </Tooltip.Trigger>\n </Tooltip>\n )}\n >\n <LegendItem\n name={currentSeries.name}\n color={color}\n hasButtons={\n hasMoreThanOneItem && currentSeries.name !== undefined\n }\n onLegendItemMouseEnter={() => {\n !isDeselected && highlightSeries([currentSeries]);\n }}\n onLegendItemMouseLeave={() => {\n !isDeselected && downplaySeries([currentSeries]);\n }}\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesSelected,\n isOnlyVisible,\n );\n }}\n selected={\n !isAllSeriesVisible &&\n selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n </ConditionalWrap>\n );\n })}\n </div>\n ) : (\n <LegendOverflowType\n className={classes}\n selectedSeries={selectedSeries}\n wrappingType={wrappingType}\n chartRef={chartRef}\n series={series}\n onSetAllVisible={setAllVisible}\n onLegendItemMouseEnter={(seriesToUpdate) =>\n highlightSeries(seriesToUpdate)\n }\n onLegendItemMouseLeave={(seriesToUpdate) =>\n downplaySeries(seriesToUpdate)\n }\n onToggleLegendVisibility={(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n ) => {\n toggleLegendVisibility(name, isAllSeriesSelected, isOnlyVisible);\n }}\n />\n )}\n </div>\n );\n};\n\ninterface LegendOverflowProps extends LegendProps {\n selectedSeries: Record<string, boolean>;\n onSetAllVisible: () => void;\n onToggleLegendVisibility?: (\n name: string,\n isAllSeriesSelected: boolean,\n isOnlyVisible: boolean,\n allSeries: { name: string; color: string }[],\n ) => void;\n onLegendItemMouseEnter: (series: { name: string; color: string }[]) => void;\n onLegendItemMouseLeave: (series: { name: string; color: string }[]) => void;\n}\n\nconst LegendOverflowType = function LegendOverflow({\n className,\n series,\n onSetAllVisible,\n onToggleLegendVisibility,\n selectedSeries,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n}: LegendOverflowProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [nonOverflowItemsNames, setNonOverflowItemsNames] = useState<string[]>(\n series.map((s) => s.name),\n );\n\n useEffect(() => {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }, [series]);\n\n const overflowItemsNames = series.filter(\n (item) => !nonOverflowItemsNames.includes(item.name),\n );\n\n const [width, setWidth] = useState(Infinity);\n useResizeObserver({\n // TODO: remove type cast. use-hooks.ts 3.1.1 has a type issue with the ref, it should be HTMLElement | null\n // https://github.com/juliencrn/usehooks-ts/pull/680\n ref: containerRef as React.RefObject<HTMLElement>,\n onResize: (entry) => {\n if (entry.width === undefined) {\n return;\n }\n if (width < entry.width) {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }\n setWidth(entry.width);\n },\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n let elements = Array.from(container.children);\n if (elements.length === 0 || series.length === 0) {\n return;\n }\n\n let totalWidth = 0;\n\n if (overflowItemsNames.length > 0) {\n const lastElementItem = elements[elements.length - 1];\n const lastItemWidth = getComputedElementWidth(lastElementItem);\n\n elements = elements.slice(0, elements.length - 1);\n totalWidth += lastItemWidth;\n }\n\n elements.forEach((element) => {\n const elementWidth = getComputedElementWidth(element);\n totalWidth += elementWidth;\n const textContent = element.textContent;\n if (!textContent) {\n return;\n }\n const itemName = element.getAttribute('data-labelname');\n if (itemName === null) {\n return;\n }\n if (totalWidth > width) {\n setNonOverflowItemsNames((oldNames) =>\n oldNames.filter((name) => name !== itemName),\n );\n }\n });\n }, [overflowItemsNames.length, series.length, width]);\n\n const classes = classNames(\n {\n 'ndl-chart-legend-calculating': width === Infinity,\n },\n className,\n );\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const hasMoreThanOneItem = nonOverflowItemsNames.length > 1;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const isOverflowItemsDeselected = overflowItemsNames.every(\n (item) => !selectedSeries[item.name ?? ''],\n );\n\n return (\n <div className={classes} ref={containerRef}>\n {nonOverflowItemsNames.map((name) => {\n const currentSeries = series.find((s) => s.name === name);\n if (currentSeries === undefined) {\n return null;\n }\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <LegendItem\n key={name}\n name={name}\n color={currentSeries.color}\n onLegendItemMouseEnter={() =>\n !isDeselected && onLegendItemMouseEnter([currentSeries])\n }\n onLegendItemMouseLeave={() =>\n !isDeselected && onLegendItemMouseLeave([currentSeries])\n }\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[name ?? ''] && selectedSeriesLength === 1;\n\n onToggleLegendVisibility?.(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n series,\n );\n }}\n hasButtons={hasMoreThanOneItem}\n selected={\n !isAllSeriesVisible && selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {name}\n </LegendItem>\n );\n })}\n\n {overflowItemsNames.length > 0 && (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger hasButtonWrapper>\n <LegendItem\n name=\"ndl-overflow-items\"\n color={tokens.palette.neutral[30]}\n selected={\n !isAllSeriesVisible &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n )\n }\n deSelected={isOverflowItemsDeselected}\n onLegendItemMouseEnter={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseEnter(overflowItemsNames)\n }\n onLegendItemMouseLeave={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseLeave(overflowItemsNames)\n }\n onLegendItemClick={() => {\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isOnlyOverflowItemsVisible =\n selectedSeriesLength === overflowItemsNames.length &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n );\n\n if (isOnlyOverflowItemsVisible) {\n onSetAllVisible();\n return;\n }\n\n overflowItemsNames.forEach((item, index) => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length && index === 0;\n\n onToggleLegendVisibility?.(\n item.name,\n isAllSeriesSelected,\n false,\n series,\n );\n });\n }}\n >\n {overflowItemsNames.length} more\n </LegendItem>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {overflowItemsNames.map((item) => (\n <p key={item.name}>{item.name}</p>\n ))}\n </Tooltip.Content>\n </Tooltip>\n )}\n </div>\n );\n};\n"]}
|
package/lib/esm/charts/Legend.js
CHANGED
|
@@ -49,7 +49,7 @@ const LegendItem = function LegendItemComponent(_a) {
|
|
|
49
49
|
if ((_b = isThresholdLine(name)) !== null && _b !== void 0 ? _b : false) {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
|
-
return (_jsxs(Component, Object.assign({ className: classes, ref: ref, "data-labelname": name, onClick: hasButtons ? onLegendItemClick : undefined, onMouseEnter: onLegendItemMouseEnter, onMouseLeave: onLegendItemMouseLeave }, restProps, { children: [_jsx("span", { className: "ndl-chart-legend-item-square", style: {
|
|
52
|
+
return (_jsxs(Component, Object.assign({ className: classes, ref: ref, "data-labelname": name, title: name, onClick: hasButtons ? onLegendItemClick : undefined, onMouseEnter: onLegendItemMouseEnter, onMouseLeave: onLegendItemMouseLeave }, restProps, { children: [_jsx("span", { className: "ndl-chart-legend-item-square", style: {
|
|
53
53
|
'--ndl-chart-legend-item-color': color,
|
|
54
54
|
backgroundColor: deSelected === true ? 'transparent' : color,
|
|
55
55
|
}, children: selected === true && (_jsx(CheckIconOutline, { className: "ndl-chart-legend-item-square-checkmark" })) }), _jsx(Typography, { variant: "body-medium", className: "ndl-chart-legend-item-text", children: children })] })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.js","sourceRoot":"","sources":["../../../src/charts/Legend.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EACL,eAAe,EACf,OAAO,EACP,UAAU,EACV,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,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,OAAA,cAAc,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAA,EAAA,CAC1C,CAAC;gCAEJ,IAAI,0BAA0B,EAAE,CAAC;oCAC/B,eAAe,EAAE,CAAC;oCAClB,OAAO;gCACT,CAAC;gCAED,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oCACzC,MAAM,mBAAmB,GACvB,oBAAoB,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,CAAC,CAAC;oCAExD,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CACtB,IAAI,CAAC,IAAI,EACT,mBAAmB,EACnB,KAAK,EACL,MAAM,CACP,CAAC;gCACJ,CAAC,CAAC,CAAC;4BACL,CAAC,aAEA,kBAAkB,CAAC,MAAM,aACf,GACG,EAClB,KAAC,OAAO,CAAC,OAAO,cACb,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAChC,sBAAoB,IAAI,CAAC,IAAI,IAArB,IAAI,CAAC,IAAI,CAAiB,CACnC,CAAC,GACc,IACV,CACX,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport {\n ConditionalWrap,\n Tooltip,\n Typography,\n useResizeObserver,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { type EChartsType, getInstanceByDom } from 'echarts';\nimport type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {\n getComputedElementWidth,\n highlightOrDownplaySeries,\n isThresholdLine,\n resetAllSeriesHighlight,\n useLegendVisibility,\n} from './legend-utils';\n\ninterface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n selected?: boolean;\n deSelected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nconst LegendItem = function LegendItemComponent({\n children,\n as,\n className,\n name,\n selected,\n deSelected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': deSelected,\n 'ndl-chart-legend-item-selected': selected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: deSelected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {selected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n\nexport interface LegendProps extends React.HTMLAttributes<HTMLDivElement> {\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\n series: {\n name: string;\n color: string;\n }[];\n chartRef: React.RefObject<HTMLDivElement | null>;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport const Legend = function LegendComponent({\n className,\n wrappingType = 'wrapping',\n series,\n chartRef,\n ref,\n}: LegendProps) {\n const [selectedSeries, setSelectedSeries] = useState<Record<string, boolean>>(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n const highlightTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const downplayTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hoverTimeOut = 80;\n\n const highlightSeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the downplay timeout when a new item is hovered\n if (downplayTimeOut.current) {\n clearTimeout(downplayTimeOut.current);\n }\n\n // Delay the highlight to avoid flickering when quickly hovering the legend items\n highlightTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'highlight',\n );\n }, hoverTimeOut);\n };\n\n const downplaySeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the highlight timeout when the mouse is leaving the legend item\n if (highlightTimeOut.current) {\n clearTimeout(highlightTimeOut.current);\n }\n\n // Delay the downplay to avoid flickering when moving the highlight between legend items (no downplay needed in between)\n downplayTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'downplay',\n );\n }, hoverTimeOut);\n };\n\n useEffect(() => {\n setSelectedSeries(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n if (chartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartRef.current);\n\n const eventTypes = [\n 'legendselectchanged',\n 'legendselectall',\n 'legendselected',\n 'legendunselected',\n ] as const;\n\n eventTypes.forEach((eventType) => {\n chart?.on(eventType, (params) => {\n if (\n typeof params === 'object' &&\n params !== null &&\n 'selected' in params &&\n params.selected !== null\n ) {\n const selected = params.selected ?? {};\n const filteredSelected = Object.fromEntries(\n Object.entries(selected).filter(\n ([key]) => !(isThresholdLine(key) ?? false),\n ),\n );\n\n // Reset the series highlight to avoid series to stay blurred on selection change\n if (eventType === 'legendselectchanged') {\n resetAllSeriesHighlight(chart as EChartsType);\n }\n\n setSelectedSeries(filteredSelected);\n }\n });\n });\n\n return () => {\n eventTypes.forEach((eventType) => {\n chart?.off(eventType);\n });\n };\n }, [chartRef, series]);\n\n const classes = classNames(\n `ndl-chart-legend`,\n {\n 'ndl-chart-legend-truncation': wrappingType === 'truncation',\n 'ndl-chart-legend-wrapping': wrappingType === 'wrapping',\n },\n className,\n );\n\n const { toggleLegendVisibility, setAllVisible } = useLegendVisibility(\n chartRef,\n selectedSeries,\n );\n\n return (\n <div ref={ref} className=\"ndl-chart-legend-container\">\n {wrappingType === 'truncation' || wrappingType === 'wrapping' ? (\n <div className={classes}>\n {series.map((currentSeries, index) => {\n const hasMoreThanOneItem = series.length > 1;\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const color = currentSeries.color;\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <ConditionalWrap\n key={index}\n shouldWrap={wrappingType === 'truncation'}\n wrap={(children) => (\n <Tooltip type=\"simple\" key={index}>\n <Tooltip.Trigger hasButtonWrapper>\n {children}\n </Tooltip.Trigger>\n </Tooltip>\n )}\n >\n <LegendItem\n name={currentSeries.name}\n color={color}\n hasButtons={\n hasMoreThanOneItem && currentSeries.name !== undefined\n }\n onLegendItemMouseEnter={() => {\n !isDeselected && highlightSeries([currentSeries]);\n }}\n onLegendItemMouseLeave={() => {\n !isDeselected && downplaySeries([currentSeries]);\n }}\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesSelected,\n isOnlyVisible,\n );\n }}\n selected={\n !isAllSeriesVisible &&\n selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n </ConditionalWrap>\n );\n })}\n </div>\n ) : (\n <LegendOverflowType\n className={classes}\n selectedSeries={selectedSeries}\n wrappingType={wrappingType}\n chartRef={chartRef}\n series={series}\n onSetAllVisible={setAllVisible}\n onLegendItemMouseEnter={(seriesToUpdate) =>\n highlightSeries(seriesToUpdate)\n }\n onLegendItemMouseLeave={(seriesToUpdate) =>\n downplaySeries(seriesToUpdate)\n }\n onToggleLegendVisibility={(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n ) => {\n toggleLegendVisibility(name, isAllSeriesSelected, isOnlyVisible);\n }}\n />\n )}\n </div>\n );\n};\n\ninterface LegendOverflowProps extends LegendProps {\n selectedSeries: Record<string, boolean>;\n onSetAllVisible: () => void;\n onToggleLegendVisibility?: (\n name: string,\n isAllSeriesSelected: boolean,\n isOnlyVisible: boolean,\n allSeries: { name: string; color: string }[],\n ) => void;\n onLegendItemMouseEnter: (series: { name: string; color: string }[]) => void;\n onLegendItemMouseLeave: (series: { name: string; color: string }[]) => void;\n}\n\nconst LegendOverflowType = function LegendOverflow({\n className,\n series,\n onSetAllVisible,\n onToggleLegendVisibility,\n selectedSeries,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n}: LegendOverflowProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [nonOverflowItemsNames, setNonOverflowItemsNames] = useState<string[]>(\n series.map((s) => s.name),\n );\n\n useEffect(() => {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }, [series]);\n\n const overflowItemsNames = series.filter(\n (item) => !nonOverflowItemsNames.includes(item.name),\n );\n\n const [width, setWidth] = useState(Infinity);\n useResizeObserver({\n // TODO: remove type cast. use-hooks.ts 3.1.1 has a type issue with the ref, it should be HTMLElement | null\n // https://github.com/juliencrn/usehooks-ts/pull/680\n ref: containerRef as React.RefObject<HTMLElement>,\n onResize: (entry) => {\n if (entry.width === undefined) {\n return;\n }\n if (width < entry.width) {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }\n setWidth(entry.width);\n },\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n let elements = Array.from(container.children);\n if (elements.length === 0 || series.length === 0) {\n return;\n }\n\n let totalWidth = 0;\n\n if (overflowItemsNames.length > 0) {\n const lastElementItem = elements[elements.length - 1];\n const lastItemWidth = getComputedElementWidth(lastElementItem);\n\n elements = elements.slice(0, elements.length - 1);\n totalWidth += lastItemWidth;\n }\n\n elements.forEach((element) => {\n const elementWidth = getComputedElementWidth(element);\n totalWidth += elementWidth;\n const textContent = element.textContent;\n if (!textContent) {\n return;\n }\n const itemName = element.getAttribute('data-labelname');\n if (itemName === null) {\n return;\n }\n if (totalWidth > width) {\n setNonOverflowItemsNames((oldNames) =>\n oldNames.filter((name) => name !== itemName),\n );\n }\n });\n }, [overflowItemsNames.length, series.length, width]);\n\n const classes = classNames(\n {\n 'ndl-chart-legend-calculating': width === Infinity,\n },\n className,\n );\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const hasMoreThanOneItem = nonOverflowItemsNames.length > 1;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const isOverflowItemsDeselected = overflowItemsNames.every(\n (item) => !selectedSeries[item.name ?? ''],\n );\n\n return (\n <div className={classes} ref={containerRef}>\n {nonOverflowItemsNames.map((name) => {\n const currentSeries = series.find((s) => s.name === name);\n if (currentSeries === undefined) {\n return null;\n }\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <LegendItem\n key={name}\n name={name}\n color={currentSeries.color}\n onLegendItemMouseEnter={() =>\n !isDeselected && onLegendItemMouseEnter([currentSeries])\n }\n onLegendItemMouseLeave={() =>\n !isDeselected && onLegendItemMouseLeave([currentSeries])\n }\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[name ?? ''] && selectedSeriesLength === 1;\n\n onToggleLegendVisibility?.(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n series,\n );\n }}\n hasButtons={hasMoreThanOneItem}\n selected={\n !isAllSeriesVisible && selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {name}\n </LegendItem>\n );\n })}\n\n {overflowItemsNames.length > 0 && (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger hasButtonWrapper>\n <LegendItem\n name=\"ndl-overflow-items\"\n color={tokens.palette.neutral[30]}\n selected={\n !isAllSeriesVisible &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n )\n }\n deSelected={isOverflowItemsDeselected}\n onLegendItemMouseEnter={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseEnter(overflowItemsNames)\n }\n onLegendItemMouseLeave={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseLeave(overflowItemsNames)\n }\n onLegendItemClick={() => {\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isOnlyOverflowItemsVisible =\n selectedSeriesLength === overflowItemsNames.length &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n );\n\n if (isOnlyOverflowItemsVisible) {\n onSetAllVisible();\n return;\n }\n\n overflowItemsNames.forEach((item, index) => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length && index === 0;\n\n onToggleLegendVisibility?.(\n item.name,\n isAllSeriesSelected,\n false,\n series,\n );\n });\n }}\n >\n {overflowItemsNames.length} more\n </LegendItem>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {overflowItemsNames.map((item) => (\n <p key={item.name}>{item.name}</p>\n ))}\n </Tooltip.Content>\n </Tooltip>\n )}\n </div>\n );\n};\n"]}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AsB,EAAE,GAAG,EAAE,CAC3B,CAAC,yBAAyB;gCAC1B,sBAAsB,CAAC,kBAAkB,CAAC,EAE5C,iBAAiB,EAAE,GAAG,EAAE;gCACtB,MAAM,oBAAoB,GACxB,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC;gCAEvD,MAAM,0BAA0B,GAC9B,oBAAoB,KAAK,kBAAkB,CAAC,MAAM;oCAClD,kBAAkB,CAAC,KAAK,CACtB,CAAC,IAAI,EAAE,EAAE,WAAC,OAAA,cAAc,CAAC,MAAA,IAAI,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAA,EAAA,CAC1C,CAAC;gCAEJ,IAAI,0BAA0B,EAAE,CAAC;oCAC/B,eAAe,EAAE,CAAC;oCAClB,OAAO;gCACT,CAAC;gCAED,kBAAkB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;oCACzC,MAAM,mBAAmB,GACvB,oBAAoB,KAAK,MAAM,CAAC,MAAM,IAAI,KAAK,KAAK,CAAC,CAAC;oCAExD,wBAAwB,aAAxB,wBAAwB,uBAAxB,wBAAwB,CACtB,IAAI,CAAC,IAAI,EACT,mBAAmB,EACnB,KAAK,EACL,MAAM,CACP,CAAC;gCACJ,CAAC,CAAC,CAAC;4BACL,CAAC,aAEA,kBAAkB,CAAC,MAAM,aACf,GACG,EAClB,KAAC,OAAO,CAAC,OAAO,cACb,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAChC,sBAAoB,IAAI,CAAC,IAAI,IAArB,IAAI,CAAC,IAAI,CAAiB,CACnC,CAAC,GACc,IACV,CACX,IACG,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["/**\n *\n * Copyright (c) \"Neo4j\"\n * Neo4j Sweden AB [http://neo4j.com]\n *\n * This file is part of Neo4j.\n *\n * Neo4j is free software: you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation, either version 3 of the License, or\n * (at your option) any later version.\n *\n * This program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see <http://www.gnu.org/licenses/>.\n */\n\nimport { tokens } from '@neo4j-ndl/base';\nimport {\n ConditionalWrap,\n Tooltip,\n Typography,\n useResizeObserver,\n} from '@neo4j-ndl/react';\nimport { CheckIconOutline } from '@neo4j-ndl/react/icons';\nimport classNames from 'classnames';\nimport { type EChartsType, getInstanceByDom } from 'echarts';\nimport type React from 'react';\nimport { useEffect, useRef, useState } from 'react';\n\nimport {\n getComputedElementWidth,\n highlightOrDownplaySeries,\n isThresholdLine,\n resetAllSeriesHighlight,\n useLegendVisibility,\n} from './legend-utils';\n\ninterface LegendItemProps {\n name: string;\n children: React.ReactNode;\n as?: 'button' | 'div';\n className?: string;\n color?: string;\n selected?: boolean;\n deSelected?: boolean;\n onLegendItemClick?: () => void;\n hasButtons?: boolean;\n onLegendItemMouseEnter?: () => void;\n onLegendItemMouseLeave?: () => void;\n ref?: React.Ref<HTMLButtonElement> & React.Ref<HTMLDivElement>;\n}\n\nconst LegendItem = function LegendItemComponent({\n children,\n as,\n className,\n name,\n selected,\n deSelected,\n onLegendItemClick,\n color,\n hasButtons = true,\n ref,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n ...restProps\n}: LegendItemProps) {\n const Component = as ?? (hasButtons ? 'button' : 'div');\n\n const classes = classNames(\n 'ndl-chart-legend-item',\n {\n 'ndl-chart-legend-item-deselected': deSelected,\n 'ndl-chart-legend-item-selected': selected,\n },\n className,\n );\n\n // We don't want to display threshold lines in the legend\n if (isThresholdLine(name) ?? false) {\n return null;\n }\n\n return (\n <Component\n className={classes}\n ref={ref}\n data-labelname={name}\n title={name}\n onClick={hasButtons ? onLegendItemClick : undefined}\n onMouseEnter={onLegendItemMouseEnter}\n onMouseLeave={onLegendItemMouseLeave}\n {...restProps}\n >\n <span\n className=\"ndl-chart-legend-item-square\"\n style={\n {\n '--ndl-chart-legend-item-color': color,\n backgroundColor: deSelected === true ? 'transparent' : color,\n } as React.CSSProperties\n }\n >\n {selected === true && (\n <CheckIconOutline className=\"ndl-chart-legend-item-square-checkmark\" />\n )}\n </span>\n <Typography variant=\"body-medium\" className=\"ndl-chart-legend-item-text\">\n {children}\n </Typography>\n </Component>\n );\n};\n\nexport interface LegendProps extends React.HTMLAttributes<HTMLDivElement> {\n wrappingType?: 'wrapping' | 'truncation' | 'overflow';\n series: {\n name: string;\n color: string;\n }[];\n chartRef: React.RefObject<HTMLDivElement | null>;\n ref?: React.Ref<HTMLDivElement>;\n}\n\nexport const Legend = function LegendComponent({\n className,\n wrappingType = 'wrapping',\n series,\n chartRef,\n ref,\n}: LegendProps) {\n const [selectedSeries, setSelectedSeries] = useState<Record<string, boolean>>(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n const highlightTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const downplayTimeOut = useRef<ReturnType<typeof setTimeout> | null>(null);\n const hoverTimeOut = 80;\n\n const highlightSeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the downplay timeout when a new item is hovered\n if (downplayTimeOut.current) {\n clearTimeout(downplayTimeOut.current);\n }\n\n // Delay the highlight to avoid flickering when quickly hovering the legend items\n highlightTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'highlight',\n );\n }, hoverTimeOut);\n };\n\n const downplaySeries = (\n seriesToUpdate: { name: string; color: string }[],\n ) => {\n // Clear the highlight timeout when the mouse is leaving the legend item\n if (highlightTimeOut.current) {\n clearTimeout(highlightTimeOut.current);\n }\n\n // Delay the downplay to avoid flickering when moving the highlight between legend items (no downplay needed in between)\n downplayTimeOut.current = setTimeout(() => {\n highlightOrDownplaySeries(\n chartRef,\n series,\n selectedSeries,\n seriesToUpdate,\n 'downplay',\n );\n }, hoverTimeOut);\n };\n\n useEffect(() => {\n setSelectedSeries(\n Object.fromEntries(series.map((s) => [s.name ?? '', true])),\n );\n\n if (chartRef.current === null) {\n return;\n }\n const chart = getInstanceByDom(chartRef.current);\n\n const eventTypes = [\n 'legendselectchanged',\n 'legendselectall',\n 'legendselected',\n 'legendunselected',\n ] as const;\n\n eventTypes.forEach((eventType) => {\n chart?.on(eventType, (params) => {\n if (\n typeof params === 'object' &&\n params !== null &&\n 'selected' in params &&\n params.selected !== null\n ) {\n const selected = params.selected ?? {};\n const filteredSelected = Object.fromEntries(\n Object.entries(selected).filter(\n ([key]) => !(isThresholdLine(key) ?? false),\n ),\n );\n\n // Reset the series highlight to avoid series to stay blurred on selection change\n if (eventType === 'legendselectchanged') {\n resetAllSeriesHighlight(chart as EChartsType);\n }\n\n setSelectedSeries(filteredSelected);\n }\n });\n });\n\n return () => {\n eventTypes.forEach((eventType) => {\n chart?.off(eventType);\n });\n };\n }, [chartRef, series]);\n\n const classes = classNames(\n `ndl-chart-legend`,\n {\n 'ndl-chart-legend-truncation': wrappingType === 'truncation',\n 'ndl-chart-legend-wrapping': wrappingType === 'wrapping',\n },\n className,\n );\n\n const { toggleLegendVisibility, setAllVisible } = useLegendVisibility(\n chartRef,\n selectedSeries,\n );\n\n return (\n <div ref={ref} className=\"ndl-chart-legend-container\">\n {wrappingType === 'truncation' || wrappingType === 'wrapping' ? (\n <div className={classes}>\n {series.map((currentSeries, index) => {\n const hasMoreThanOneItem = series.length > 1;\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const color = currentSeries.color;\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <ConditionalWrap\n key={index}\n shouldWrap={wrappingType === 'truncation'}\n wrap={(children) => (\n <Tooltip type=\"simple\" key={index}>\n <Tooltip.Trigger hasButtonWrapper>\n {children}\n </Tooltip.Trigger>\n </Tooltip>\n )}\n >\n <LegendItem\n name={currentSeries.name}\n color={color}\n hasButtons={\n hasMoreThanOneItem && currentSeries.name !== undefined\n }\n onLegendItemMouseEnter={() => {\n !isDeselected && highlightSeries([currentSeries]);\n }}\n onLegendItemMouseLeave={() => {\n !isDeselected && downplaySeries([currentSeries]);\n }}\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[currentSeries.name ?? ''] &&\n selectedSeriesLength === 1;\n\n toggleLegendVisibility(\n currentSeries.name,\n isAllSeriesSelected,\n isOnlyVisible,\n );\n }}\n selected={\n !isAllSeriesVisible &&\n selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {currentSeries.name ?? `Series ${index}`}\n </LegendItem>\n </ConditionalWrap>\n );\n })}\n </div>\n ) : (\n <LegendOverflowType\n className={classes}\n selectedSeries={selectedSeries}\n wrappingType={wrappingType}\n chartRef={chartRef}\n series={series}\n onSetAllVisible={setAllVisible}\n onLegendItemMouseEnter={(seriesToUpdate) =>\n highlightSeries(seriesToUpdate)\n }\n onLegendItemMouseLeave={(seriesToUpdate) =>\n downplaySeries(seriesToUpdate)\n }\n onToggleLegendVisibility={(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n ) => {\n toggleLegendVisibility(name, isAllSeriesSelected, isOnlyVisible);\n }}\n />\n )}\n </div>\n );\n};\n\ninterface LegendOverflowProps extends LegendProps {\n selectedSeries: Record<string, boolean>;\n onSetAllVisible: () => void;\n onToggleLegendVisibility?: (\n name: string,\n isAllSeriesSelected: boolean,\n isOnlyVisible: boolean,\n allSeries: { name: string; color: string }[],\n ) => void;\n onLegendItemMouseEnter: (series: { name: string; color: string }[]) => void;\n onLegendItemMouseLeave: (series: { name: string; color: string }[]) => void;\n}\n\nconst LegendOverflowType = function LegendOverflow({\n className,\n series,\n onSetAllVisible,\n onToggleLegendVisibility,\n selectedSeries,\n onLegendItemMouseEnter,\n onLegendItemMouseLeave,\n}: LegendOverflowProps) {\n const containerRef = useRef<HTMLDivElement>(null);\n\n const [nonOverflowItemsNames, setNonOverflowItemsNames] = useState<string[]>(\n series.map((s) => s.name),\n );\n\n useEffect(() => {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }, [series]);\n\n const overflowItemsNames = series.filter(\n (item) => !nonOverflowItemsNames.includes(item.name),\n );\n\n const [width, setWidth] = useState(Infinity);\n useResizeObserver({\n // TODO: remove type cast. use-hooks.ts 3.1.1 has a type issue with the ref, it should be HTMLElement | null\n // https://github.com/juliencrn/usehooks-ts/pull/680\n ref: containerRef as React.RefObject<HTMLElement>,\n onResize: (entry) => {\n if (entry.width === undefined) {\n return;\n }\n if (width < entry.width) {\n setNonOverflowItemsNames(series.map((s) => s.name));\n }\n setWidth(entry.width);\n },\n });\n\n useEffect(() => {\n const container = containerRef.current;\n if (!container) {\n return;\n }\n\n let elements = Array.from(container.children);\n if (elements.length === 0 || series.length === 0) {\n return;\n }\n\n let totalWidth = 0;\n\n if (overflowItemsNames.length > 0) {\n const lastElementItem = elements[elements.length - 1];\n const lastItemWidth = getComputedElementWidth(lastElementItem);\n\n elements = elements.slice(0, elements.length - 1);\n totalWidth += lastItemWidth;\n }\n\n elements.forEach((element) => {\n const elementWidth = getComputedElementWidth(element);\n totalWidth += elementWidth;\n const textContent = element.textContent;\n if (!textContent) {\n return;\n }\n const itemName = element.getAttribute('data-labelname');\n if (itemName === null) {\n return;\n }\n if (totalWidth > width) {\n setNonOverflowItemsNames((oldNames) =>\n oldNames.filter((name) => name !== itemName),\n );\n }\n });\n }, [overflowItemsNames.length, series.length, width]);\n\n const classes = classNames(\n {\n 'ndl-chart-legend-calculating': width === Infinity,\n },\n className,\n );\n\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const hasMoreThanOneItem = nonOverflowItemsNames.length > 1;\n const isAllSeriesVisible = selectedSeriesLength === series.length;\n\n const isOverflowItemsDeselected = overflowItemsNames.every(\n (item) => !selectedSeries[item.name ?? ''],\n );\n\n return (\n <div className={classes} ref={containerRef}>\n {nonOverflowItemsNames.map((name) => {\n const currentSeries = series.find((s) => s.name === name);\n if (currentSeries === undefined) {\n return null;\n }\n\n const isDeselected =\n currentSeries.name === undefined\n ? false\n : !selectedSeries[currentSeries.name];\n\n return (\n <LegendItem\n key={name}\n name={name}\n color={currentSeries.color}\n onLegendItemMouseEnter={() =>\n !isDeselected && onLegendItemMouseEnter([currentSeries])\n }\n onLegendItemMouseLeave={() =>\n !isDeselected && onLegendItemMouseLeave([currentSeries])\n }\n onLegendItemClick={() => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length;\n\n const isOnlyVisible =\n selectedSeries[name ?? ''] && selectedSeriesLength === 1;\n\n onToggleLegendVisibility?.(\n name,\n isAllSeriesSelected,\n isOnlyVisible,\n series,\n );\n }}\n hasButtons={hasMoreThanOneItem}\n selected={\n !isAllSeriesVisible && selectedSeries[currentSeries.name ?? '']\n }\n deSelected={isDeselected}\n >\n {name}\n </LegendItem>\n );\n })}\n\n {overflowItemsNames.length > 0 && (\n <Tooltip type=\"simple\">\n <Tooltip.Trigger hasButtonWrapper>\n <LegendItem\n name=\"ndl-overflow-items\"\n color={tokens.palette.neutral[30]}\n selected={\n !isAllSeriesVisible &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n )\n }\n deSelected={isOverflowItemsDeselected}\n onLegendItemMouseEnter={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseEnter(overflowItemsNames)\n }\n onLegendItemMouseLeave={() =>\n !isOverflowItemsDeselected &&\n onLegendItemMouseLeave(overflowItemsNames)\n }\n onLegendItemClick={() => {\n const selectedSeriesLength =\n Object.values(selectedSeries).filter(Boolean).length;\n\n const isOnlyOverflowItemsVisible =\n selectedSeriesLength === overflowItemsNames.length &&\n overflowItemsNames.every(\n (item) => selectedSeries[item.name ?? ''],\n );\n\n if (isOnlyOverflowItemsVisible) {\n onSetAllVisible();\n return;\n }\n\n overflowItemsNames.forEach((item, index) => {\n const isAllSeriesSelected =\n selectedSeriesLength === series.length && index === 0;\n\n onToggleLegendVisibility?.(\n item.name,\n isAllSeriesSelected,\n false,\n series,\n );\n });\n }}\n >\n {overflowItemsNames.length} more\n </LegendItem>\n </Tooltip.Trigger>\n <Tooltip.Content>\n {overflowItemsNames.map((item) => (\n <p key={item.name}>{item.name}</p>\n ))}\n </Tooltip.Content>\n </Tooltip>\n )}\n </div>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../../src/charts/Legend.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAYH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../../src/charts/Legend.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAYH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAwF/B,MAAM,WAAW,WAAY,SAAQ,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC;IACvE,YAAY,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,UAAU,CAAC;IACtD,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;KACf,EAAE,CAAC;IACJ,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACjD,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;CACjC;AAED,eAAO,MAAM,MAAM,GAA4B,qDAM5C,WAAW,4CA8Mb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neo4j-ndl/react-charts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "React implementation of charts from Neo4j Design System",
|
|
6
6
|
"keywords": [
|
|
@@ -53,8 +53,8 @@
|
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"react": ">=19.0.0",
|
|
55
55
|
"react-dom": ">=19.0.0",
|
|
56
|
-
"@neo4j-ndl/base": "^4.1.
|
|
57
|
-
"@neo4j-ndl/react": "^4.1.
|
|
56
|
+
"@neo4j-ndl/base": "^4.1.2",
|
|
57
|
+
"@neo4j-ndl/react": "^4.1.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"classnames": "2.5.1",
|