@automattic/charts 1.1.0 → 1.1.1
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/AGENTS.md +14 -1
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs +1162 -1137
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +0 -67
- package/dist/index.css.map +1 -1
- package/dist/index.js +1187 -1162
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +0 -21
- package/src/charts/conversion-funnel-chart/conversion-funnel-chart.tsx +17 -10
- package/src/charts/geo-chart/geo-chart.module.scss +0 -3
- package/src/charts/geo-chart/geo-chart.tsx +9 -4
- package/src/charts/line-chart/line-chart.module.scss +0 -10
- package/src/charts/line-chart/line-chart.tsx +9 -2
- package/src/charts/line-chart/private/line-chart-annotation-label-popover.tsx +3 -2
- package/src/components/legend/private/base-legend.module.scss +0 -49
- package/src/components/legend/private/base-legend.tsx +30 -28
package/dist/index.js
CHANGED
|
@@ -474,7 +474,7 @@ import clsx3 from "clsx";
|
|
|
474
474
|
import { useCallback as useCallback7, useContext as useContext9, useState as useState6, useRef as useRef7, useMemo as useMemo15 } from "react";
|
|
475
475
|
|
|
476
476
|
// src/components/legend/legend.tsx
|
|
477
|
-
import { useContext as
|
|
477
|
+
import { useContext as useContext6, useMemo as useMemo10, forwardRef as forwardRef3 } from "react";
|
|
478
478
|
|
|
479
479
|
// src/charts/private/single-chart-context/single-chart-context.tsx
|
|
480
480
|
import { createContext } from "react";
|
|
@@ -1629,1237 +1629,1242 @@ var useGlobalChartsTheme = () => {
|
|
|
1629
1629
|
import { Group } from "@visx/group";
|
|
1630
1630
|
import { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from "@visx/legend";
|
|
1631
1631
|
import { scaleOrdinal } from "@visx/scale";
|
|
1632
|
-
import clsx from "clsx";
|
|
1633
|
-
import { forwardRef, useCallback as useCallback4, useContext as useContext4 } from "react";
|
|
1634
1632
|
|
|
1635
|
-
//
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1633
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useRefWithInit.js
|
|
1634
|
+
import * as React from "react";
|
|
1635
|
+
var UNINITIALIZED = {};
|
|
1636
|
+
function useRefWithInit(init, initArg) {
|
|
1637
|
+
const ref = React.useRef(UNINITIALIZED);
|
|
1638
|
+
if (ref.current === UNINITIALIZED) {
|
|
1639
|
+
ref.current = init(initArg);
|
|
1640
|
+
}
|
|
1641
|
+
return ref;
|
|
1640
1642
|
}
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
+
|
|
1644
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/warn.js
|
|
1645
|
+
var set;
|
|
1646
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1647
|
+
set = /* @__PURE__ */ new Set();
|
|
1648
|
+
}
|
|
1649
|
+
function warn(...messages) {
|
|
1650
|
+
if (process.env.NODE_ENV !== "production") {
|
|
1651
|
+
const messageKey = messages.join(" ");
|
|
1652
|
+
if (!set.has(messageKey)) {
|
|
1653
|
+
set.add(messageKey);
|
|
1654
|
+
console.warn(`Base UI: ${messageKey}`);
|
|
1655
|
+
}
|
|
1656
|
+
}
|
|
1643
1657
|
}
|
|
1644
1658
|
|
|
1645
|
-
//
|
|
1646
|
-
function
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
text: `${labelFormat(d, i)}`,
|
|
1654
|
-
value: scale(d)
|
|
1655
|
-
});
|
|
1659
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/formatErrorMessage.js
|
|
1660
|
+
function createFormatErrorMessage(baseUrl, prefix2) {
|
|
1661
|
+
return function formatErrorMessage2(code, ...args) {
|
|
1662
|
+
const url = new URL(baseUrl);
|
|
1663
|
+
url.searchParams.set("code", code.toString());
|
|
1664
|
+
args.forEach((arg) => url.searchParams.append("args[]", arg));
|
|
1665
|
+
return `${prefix2} error #${code}; visit ${url} for the full message.`;
|
|
1666
|
+
};
|
|
1656
1667
|
}
|
|
1668
|
+
var formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
|
|
1669
|
+
var formatErrorMessage_default = formatErrorMessage;
|
|
1657
1670
|
|
|
1658
|
-
//
|
|
1659
|
-
|
|
1660
|
-
"legend": "a8ccharts-89ApsU",
|
|
1661
|
-
"legend--horizontal": "a8ccharts-AELBvX",
|
|
1662
|
-
"legend--vertical": "a8ccharts-fX8uQe",
|
|
1663
|
-
"legend--alignment-start": "a8ccharts-DEe0wg",
|
|
1664
|
-
"legend--alignment-center": "a8ccharts-WBKF9I",
|
|
1665
|
-
"legend--alignment-end": "a8ccharts-JfwMng",
|
|
1666
|
-
"legend-item": "a8ccharts-Vflwq8",
|
|
1667
|
-
"legend-item--interactive": "a8ccharts-qGsavM",
|
|
1668
|
-
"legend-item--inactive": "a8ccharts-ZtDY-Q",
|
|
1669
|
-
"legend-item-label": "a8ccharts-2H65Kr",
|
|
1670
|
-
"legend-item-text--wrap": "a8ccharts-faSDBI",
|
|
1671
|
-
"legend-item-text--ellipsis": "a8ccharts-FISUIO",
|
|
1672
|
-
"legend-item-value": "a8ccharts-DTZlT-"
|
|
1673
|
-
};
|
|
1671
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
|
|
1672
|
+
import * as React4 from "react";
|
|
1674
1673
|
|
|
1675
|
-
//
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
}
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
return
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
labelStyles,
|
|
1714
|
-
labelClassName,
|
|
1715
|
-
shapeStyles,
|
|
1716
|
-
render,
|
|
1717
|
-
interactive = false,
|
|
1718
|
-
chartId
|
|
1719
|
-
}, ref) => {
|
|
1720
|
-
const {
|
|
1721
|
-
margin: itemMargin = "0",
|
|
1722
|
-
flexDirection: itemDirection = "row"
|
|
1723
|
-
} = itemStyles ?? {};
|
|
1724
|
-
const {
|
|
1725
|
-
justifyContent: labelJustifyContent = "flex-start",
|
|
1726
|
-
flex: labelFlex = "0 0 auto",
|
|
1727
|
-
margin: labelMargin = "0 4px",
|
|
1728
|
-
maxWidth,
|
|
1729
|
-
textOverflow = "wrap"
|
|
1730
|
-
} = labelStyles ?? {};
|
|
1731
|
-
const {
|
|
1732
|
-
width: shapeWidth = 16,
|
|
1733
|
-
height: shapeHeight = 16,
|
|
1734
|
-
margin: shapeMargin = "2px 4px 2px 0"
|
|
1735
|
-
} = shapeStyles ?? {};
|
|
1736
|
-
const theme = useGlobalChartsTheme();
|
|
1737
|
-
const context = useContext4(GlobalChartsContext);
|
|
1738
|
-
const legendScale = scaleOrdinal({
|
|
1739
|
-
domain: items.map((item) => item.label),
|
|
1740
|
-
range: items.map((item) => item.color)
|
|
1741
|
-
});
|
|
1742
|
-
const domain = legendScale.domain();
|
|
1743
|
-
const getShapeStyle = useCallback4(({
|
|
1744
|
-
index
|
|
1745
|
-
}) => items[index]?.shapeStyle, [items]);
|
|
1746
|
-
const handleLegendClick = useCallback4((seriesLabel) => {
|
|
1747
|
-
if (interactive && chartId && context) {
|
|
1748
|
-
context.toggleSeriesVisibility(chartId, seriesLabel);
|
|
1749
|
-
}
|
|
1750
|
-
}, [interactive, chartId, context]);
|
|
1751
|
-
const isSeriesVisible = useCallback4((seriesLabel) => {
|
|
1752
|
-
if (!interactive || !chartId || !context) {
|
|
1753
|
-
return true;
|
|
1754
|
-
}
|
|
1755
|
-
return context.isSeriesVisible(chartId, seriesLabel);
|
|
1756
|
-
}, [interactive, chartId, context]);
|
|
1757
|
-
const createClickHandler = useCallback4((labelText) => {
|
|
1758
|
-
if (!interactive) {
|
|
1759
|
-
return void 0;
|
|
1760
|
-
}
|
|
1761
|
-
return () => handleLegendClick(labelText);
|
|
1762
|
-
}, [interactive, handleLegendClick]);
|
|
1763
|
-
const createKeyDownHandler = useCallback4((labelText) => {
|
|
1764
|
-
if (!interactive) {
|
|
1765
|
-
return void 0;
|
|
1674
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/useMergedRefs.js
|
|
1675
|
+
function useMergedRefs(a, b, c, d) {
|
|
1676
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
1677
|
+
if (didChange(forkRef, a, b, c, d)) {
|
|
1678
|
+
update(forkRef, [a, b, c, d]);
|
|
1679
|
+
}
|
|
1680
|
+
return forkRef.callback;
|
|
1681
|
+
}
|
|
1682
|
+
function useMergedRefsN(refs) {
|
|
1683
|
+
const forkRef = useRefWithInit(createForkRef).current;
|
|
1684
|
+
if (didChangeN(forkRef, refs)) {
|
|
1685
|
+
update(forkRef, refs);
|
|
1686
|
+
}
|
|
1687
|
+
return forkRef.callback;
|
|
1688
|
+
}
|
|
1689
|
+
function createForkRef() {
|
|
1690
|
+
return {
|
|
1691
|
+
callback: null,
|
|
1692
|
+
cleanup: null,
|
|
1693
|
+
refs: []
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
function didChange(forkRef, a, b, c, d) {
|
|
1697
|
+
return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
|
|
1698
|
+
}
|
|
1699
|
+
function didChangeN(forkRef, newRefs) {
|
|
1700
|
+
return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
|
|
1701
|
+
}
|
|
1702
|
+
function update(forkRef, refs) {
|
|
1703
|
+
forkRef.refs = refs;
|
|
1704
|
+
if (refs.every((ref) => ref == null)) {
|
|
1705
|
+
forkRef.callback = null;
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
forkRef.callback = (instance) => {
|
|
1709
|
+
if (forkRef.cleanup) {
|
|
1710
|
+
forkRef.cleanup();
|
|
1711
|
+
forkRef.cleanup = null;
|
|
1766
1712
|
}
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1713
|
+
if (instance != null) {
|
|
1714
|
+
const cleanupCallbacks = Array(refs.length).fill(null);
|
|
1715
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
1716
|
+
const ref = refs[i];
|
|
1717
|
+
if (ref == null) {
|
|
1718
|
+
continue;
|
|
1719
|
+
}
|
|
1720
|
+
switch (typeof ref) {
|
|
1721
|
+
case "function": {
|
|
1722
|
+
const refCleanup = ref(instance);
|
|
1723
|
+
if (typeof refCleanup === "function") {
|
|
1724
|
+
cleanupCallbacks[i] = refCleanup;
|
|
1725
|
+
}
|
|
1726
|
+
break;
|
|
1727
|
+
}
|
|
1728
|
+
case "object": {
|
|
1729
|
+
ref.current = instance;
|
|
1730
|
+
break;
|
|
1731
|
+
}
|
|
1732
|
+
default:
|
|
1733
|
+
}
|
|
1771
1734
|
}
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
"aria-pressed": interactive ? visible : void 0,
|
|
1800
|
-
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
1801
|
-
children: [items[i]?.renderGlyph ? /* @__PURE__ */ _jsx2("svg", {
|
|
1802
|
-
width: items[i]?.glyphSize * 2,
|
|
1803
|
-
height: items[i]?.glyphSize * 2,
|
|
1804
|
-
children: /* @__PURE__ */ _jsx2(Group, {
|
|
1805
|
-
children: items[i]?.renderGlyph({
|
|
1806
|
-
key: `legend-glyph-${label.text}`,
|
|
1807
|
-
datum: {},
|
|
1808
|
-
index: i,
|
|
1809
|
-
color: fill(label),
|
|
1810
|
-
size: items[i]?.glyphSize,
|
|
1811
|
-
x: items[i]?.glyphSize,
|
|
1812
|
-
y: items[i]?.glyphSize
|
|
1813
|
-
})
|
|
1814
|
-
})
|
|
1815
|
-
}) : /* @__PURE__ */ _jsx2(LegendShape, {
|
|
1816
|
-
shape,
|
|
1817
|
-
height: shapeHeight,
|
|
1818
|
-
width: shapeWidth,
|
|
1819
|
-
margin: shapeMargin,
|
|
1820
|
-
item: domain[i],
|
|
1821
|
-
itemIndex: i,
|
|
1822
|
-
label,
|
|
1823
|
-
fill,
|
|
1824
|
-
size,
|
|
1825
|
-
shapeStyle: getShapeStyle
|
|
1826
|
-
}), /* @__PURE__ */ _jsxs(LegendLabel, {
|
|
1827
|
-
className: clsx("visx-legend-label", base_legend_module_default["legend-item-label"], labelClassName),
|
|
1828
|
-
style: {
|
|
1829
|
-
justifyContent: labelJustifyContent,
|
|
1830
|
-
flex: labelFlex,
|
|
1831
|
-
margin: labelMargin,
|
|
1832
|
-
...theme.legend?.labelStyles
|
|
1833
|
-
},
|
|
1834
|
-
children: [/* @__PURE__ */ _jsx2(LegendText, {
|
|
1835
|
-
text: label.text,
|
|
1836
|
-
textOverflow,
|
|
1837
|
-
maxWidth
|
|
1838
|
-
}), matchedItem?.value != null && matchedItem.value !== "" && /* @__PURE__ */ _jsxs("span", {
|
|
1839
|
-
className: base_legend_module_default["legend-item-value"],
|
|
1840
|
-
children: ["\xA0", matchedItem.value]
|
|
1841
|
-
})]
|
|
1842
|
-
})]
|
|
1843
|
-
}, `legend-${label.text}-${i}`);
|
|
1844
|
-
})
|
|
1845
|
-
})
|
|
1846
|
-
});
|
|
1847
|
-
});
|
|
1735
|
+
forkRef.cleanup = () => {
|
|
1736
|
+
for (let i = 0; i < refs.length; i += 1) {
|
|
1737
|
+
const ref = refs[i];
|
|
1738
|
+
if (ref == null) {
|
|
1739
|
+
continue;
|
|
1740
|
+
}
|
|
1741
|
+
switch (typeof ref) {
|
|
1742
|
+
case "function": {
|
|
1743
|
+
const cleanupCallback = cleanupCallbacks[i];
|
|
1744
|
+
if (typeof cleanupCallback === "function") {
|
|
1745
|
+
cleanupCallback();
|
|
1746
|
+
} else {
|
|
1747
|
+
ref(null);
|
|
1748
|
+
}
|
|
1749
|
+
break;
|
|
1750
|
+
}
|
|
1751
|
+
case "object": {
|
|
1752
|
+
ref.current = null;
|
|
1753
|
+
break;
|
|
1754
|
+
}
|
|
1755
|
+
default:
|
|
1756
|
+
}
|
|
1757
|
+
}
|
|
1758
|
+
};
|
|
1759
|
+
}
|
|
1760
|
+
};
|
|
1761
|
+
}
|
|
1848
1762
|
|
|
1849
|
-
//
|
|
1850
|
-
import
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
}
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
...props
|
|
1863
|
-
}, ref) => {
|
|
1864
|
-
const context = useContext5(GlobalChartsContext);
|
|
1865
|
-
const singleChartContext = useContext5(SingleChartContext);
|
|
1866
|
-
const contextChartId = chartId ?? singleChartContext?.chartId;
|
|
1867
|
-
const chartData = useMemo9(() => contextChartId && context ? context.getChartData(contextChartId) : void 0, [contextChartId, context]);
|
|
1868
|
-
const contextItems = chartData?.legendItems;
|
|
1869
|
-
const resolvedShape = shape ?? (chartData?.chartType ? defaultShapeByChartType[chartData.chartType] : void 0);
|
|
1870
|
-
const legendItems = items || contextItems;
|
|
1871
|
-
if (!legendItems) {
|
|
1763
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
|
|
1764
|
+
import * as React3 from "react";
|
|
1765
|
+
|
|
1766
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/reactVersion.js
|
|
1767
|
+
import * as React2 from "react";
|
|
1768
|
+
var majorVersion = parseInt(React2.version, 10);
|
|
1769
|
+
function isReactVersionAtLeast(reactVersionToCheck) {
|
|
1770
|
+
return majorVersion >= reactVersionToCheck;
|
|
1771
|
+
}
|
|
1772
|
+
|
|
1773
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/getReactElementRef.js
|
|
1774
|
+
function getReactElementRef(element) {
|
|
1775
|
+
if (!/* @__PURE__ */ React3.isValidElement(element)) {
|
|
1872
1776
|
return null;
|
|
1873
1777
|
}
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
...props,
|
|
1879
|
-
chartId: contextChartId
|
|
1880
|
-
});
|
|
1881
|
-
});
|
|
1778
|
+
const reactElement = element;
|
|
1779
|
+
const propsWithRef = reactElement.props;
|
|
1780
|
+
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
|
|
1781
|
+
}
|
|
1882
1782
|
|
|
1883
|
-
//
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
if (!showValues || legendValueDisplay === "none") {
|
|
1888
|
-
return "";
|
|
1783
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/mergeObjects.js
|
|
1784
|
+
function mergeObjects(a, b) {
|
|
1785
|
+
if (a && !b) {
|
|
1786
|
+
return a;
|
|
1889
1787
|
}
|
|
1890
|
-
if (
|
|
1891
|
-
|
|
1892
|
-
case "percentage":
|
|
1893
|
-
return formatPercentage(point.percentage);
|
|
1894
|
-
case "value":
|
|
1895
|
-
return formatNumber3(point.value);
|
|
1896
|
-
case "valueDisplay":
|
|
1897
|
-
return point.valueDisplay || formatNumber3(point.value);
|
|
1898
|
-
default:
|
|
1899
|
-
return "";
|
|
1900
|
-
}
|
|
1788
|
+
if (!a && b) {
|
|
1789
|
+
return b;
|
|
1901
1790
|
}
|
|
1902
|
-
if (
|
|
1903
|
-
return
|
|
1791
|
+
if (a || b) {
|
|
1792
|
+
return {
|
|
1793
|
+
...a,
|
|
1794
|
+
...b
|
|
1795
|
+
};
|
|
1904
1796
|
}
|
|
1905
|
-
return
|
|
1797
|
+
return void 0;
|
|
1906
1798
|
}
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
|
|
1912
|
-
|
|
1913
|
-
|
|
1914
|
-
|
|
1915
|
-
|
|
1799
|
+
|
|
1800
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/getStateAttributesProps.js
|
|
1801
|
+
function getStateAttributesProps(state, customMapping) {
|
|
1802
|
+
const props = {};
|
|
1803
|
+
for (const key in state) {
|
|
1804
|
+
const value = state[key];
|
|
1805
|
+
if (customMapping?.hasOwnProperty(key)) {
|
|
1806
|
+
const customProps = customMapping[key](value);
|
|
1807
|
+
if (customProps != null) {
|
|
1808
|
+
Object.assign(props, customProps);
|
|
1809
|
+
}
|
|
1810
|
+
continue;
|
|
1811
|
+
}
|
|
1812
|
+
if (value === true) {
|
|
1813
|
+
props[`data-${key.toLowerCase()}`] = "";
|
|
1814
|
+
} else if (value) {
|
|
1815
|
+
props[`data-${key.toLowerCase()}`] = value.toString();
|
|
1916
1816
|
}
|
|
1917
1817
|
}
|
|
1918
|
-
return
|
|
1818
|
+
return props;
|
|
1919
1819
|
}
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1820
|
+
|
|
1821
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveClassName.js
|
|
1822
|
+
function resolveClassName(className, state) {
|
|
1823
|
+
return typeof className === "function" ? className(state) : className;
|
|
1824
|
+
}
|
|
1825
|
+
|
|
1826
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveStyle.js
|
|
1827
|
+
function resolveStyle(style, state) {
|
|
1828
|
+
return typeof style === "function" ? style(state) : style;
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/merge-props/mergeProps.js
|
|
1832
|
+
var EMPTY_PROPS = {};
|
|
1833
|
+
function mergeProps(a, b, c, d, e) {
|
|
1834
|
+
let merged = {
|
|
1835
|
+
...resolvePropsGetter(a, EMPTY_PROPS)
|
|
1934
1836
|
};
|
|
1935
|
-
|
|
1837
|
+
if (b) {
|
|
1838
|
+
merged = mergeOne(merged, b);
|
|
1839
|
+
}
|
|
1840
|
+
if (c) {
|
|
1841
|
+
merged = mergeOne(merged, c);
|
|
1842
|
+
}
|
|
1843
|
+
if (d) {
|
|
1844
|
+
merged = mergeOne(merged, d);
|
|
1845
|
+
}
|
|
1846
|
+
if (e) {
|
|
1847
|
+
merged = mergeOne(merged, e);
|
|
1848
|
+
}
|
|
1849
|
+
return merged;
|
|
1936
1850
|
}
|
|
1937
|
-
function
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
value: formatPointValue(point, showValues, legendValueDisplay),
|
|
1947
|
-
color,
|
|
1948
|
-
shapeStyle: shapeStyles
|
|
1949
|
-
};
|
|
1950
|
-
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
1851
|
+
function mergePropsN(props) {
|
|
1852
|
+
if (props.length === 0) {
|
|
1853
|
+
return EMPTY_PROPS;
|
|
1854
|
+
}
|
|
1855
|
+
if (props.length === 1) {
|
|
1856
|
+
return resolvePropsGetter(props[0], EMPTY_PROPS);
|
|
1857
|
+
}
|
|
1858
|
+
let merged = {
|
|
1859
|
+
...resolvePropsGetter(props[0], EMPTY_PROPS)
|
|
1951
1860
|
};
|
|
1952
|
-
|
|
1861
|
+
for (let i = 1; i < props.length; i += 1) {
|
|
1862
|
+
merged = mergeOne(merged, props[i]);
|
|
1863
|
+
}
|
|
1864
|
+
return merged;
|
|
1953
1865
|
}
|
|
1954
|
-
function
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1866
|
+
function mergeOne(merged, inputProps) {
|
|
1867
|
+
if (isPropsGetter(inputProps)) {
|
|
1868
|
+
return inputProps(merged);
|
|
1869
|
+
}
|
|
1870
|
+
return mutablyMergeInto(merged, inputProps);
|
|
1871
|
+
}
|
|
1872
|
+
function mutablyMergeInto(mergedProps, externalProps) {
|
|
1873
|
+
if (!externalProps) {
|
|
1874
|
+
return mergedProps;
|
|
1875
|
+
}
|
|
1876
|
+
for (const propName in externalProps) {
|
|
1877
|
+
const externalPropValue = externalProps[propName];
|
|
1878
|
+
switch (propName) {
|
|
1879
|
+
case "style": {
|
|
1880
|
+
mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
|
|
1881
|
+
break;
|
|
1882
|
+
}
|
|
1883
|
+
case "className": {
|
|
1884
|
+
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
|
|
1885
|
+
break;
|
|
1886
|
+
}
|
|
1887
|
+
default: {
|
|
1888
|
+
if (isEventHandler(propName, externalPropValue)) {
|
|
1889
|
+
mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
|
|
1890
|
+
} else {
|
|
1891
|
+
mergedProps[propName] = externalPropValue;
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1966
1894
|
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1895
|
+
}
|
|
1896
|
+
return mergedProps;
|
|
1897
|
+
}
|
|
1898
|
+
function isEventHandler(key, value) {
|
|
1899
|
+
const code0 = key.charCodeAt(0);
|
|
1900
|
+
const code1 = key.charCodeAt(1);
|
|
1901
|
+
const code2 = key.charCodeAt(2);
|
|
1902
|
+
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
|
|
1903
|
+
}
|
|
1904
|
+
function isPropsGetter(inputProps) {
|
|
1905
|
+
return typeof inputProps === "function";
|
|
1906
|
+
}
|
|
1907
|
+
function resolvePropsGetter(inputProps, previousProps) {
|
|
1908
|
+
if (isPropsGetter(inputProps)) {
|
|
1909
|
+
return inputProps(previousProps);
|
|
1910
|
+
}
|
|
1911
|
+
return inputProps ?? EMPTY_PROPS;
|
|
1912
|
+
}
|
|
1913
|
+
function mergeEventHandlers(ourHandler, theirHandler) {
|
|
1914
|
+
if (!theirHandler) {
|
|
1915
|
+
return ourHandler;
|
|
1916
|
+
}
|
|
1917
|
+
if (!ourHandler) {
|
|
1918
|
+
return theirHandler;
|
|
1919
|
+
}
|
|
1920
|
+
return (event) => {
|
|
1921
|
+
if (isSyntheticEvent(event)) {
|
|
1922
|
+
const baseUIEvent = event;
|
|
1923
|
+
makeEventPreventable(baseUIEvent);
|
|
1924
|
+
const result2 = theirHandler(baseUIEvent);
|
|
1925
|
+
if (!baseUIEvent.baseUIHandlerPrevented) {
|
|
1926
|
+
ourHandler?.(baseUIEvent);
|
|
1927
|
+
}
|
|
1928
|
+
return result2;
|
|
1977
1929
|
}
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1930
|
+
const result = theirHandler(event);
|
|
1931
|
+
ourHandler?.(event);
|
|
1932
|
+
return result;
|
|
1933
|
+
};
|
|
1934
|
+
}
|
|
1935
|
+
function makeEventPreventable(event) {
|
|
1936
|
+
event.preventBaseUIHandler = () => {
|
|
1937
|
+
event.baseUIHandlerPrevented = true;
|
|
1938
|
+
};
|
|
1939
|
+
return event;
|
|
1940
|
+
}
|
|
1941
|
+
function mergeClassNames(ourClassName, theirClassName) {
|
|
1942
|
+
if (theirClassName) {
|
|
1943
|
+
if (ourClassName) {
|
|
1944
|
+
return theirClassName + " " + ourClassName;
|
|
1945
|
+
}
|
|
1946
|
+
return theirClassName;
|
|
1947
|
+
}
|
|
1948
|
+
return ourClassName;
|
|
1949
|
+
}
|
|
1950
|
+
function isSyntheticEvent(event) {
|
|
1951
|
+
return event != null && typeof event === "object" && "nativeEvent" in event;
|
|
1998
1952
|
}
|
|
1999
1953
|
|
|
2000
|
-
//
|
|
2001
|
-
|
|
1954
|
+
// ../../../node_modules/.pnpm/@base-ui+utils@0.2.6_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/esm/empty.js
|
|
1955
|
+
var EMPTY_ARRAY = Object.freeze([]);
|
|
1956
|
+
var EMPTY_OBJECT = Object.freeze({});
|
|
2002
1957
|
|
|
2003
|
-
//
|
|
2004
|
-
var
|
|
2005
|
-
|
|
2006
|
-
}
|
|
1958
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/constants.js
|
|
1959
|
+
var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
|
|
1960
|
+
var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
|
|
1961
|
+
var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
|
|
1962
|
+
var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
|
|
2007
1963
|
|
|
2008
|
-
//
|
|
2009
|
-
import {
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
var BaseTooltip = ({
|
|
2016
|
-
data,
|
|
2017
|
-
top,
|
|
2018
|
-
left,
|
|
2019
|
-
component: Component2 = DefaultTooltipContent,
|
|
2020
|
-
children,
|
|
2021
|
-
className,
|
|
2022
|
-
style,
|
|
2023
|
-
renderContainer = true
|
|
2024
|
-
}) => {
|
|
2025
|
-
const content = children || data && /* @__PURE__ */ _jsx4(Component2, {
|
|
2026
|
-
data,
|
|
2027
|
-
className
|
|
2028
|
-
});
|
|
2029
|
-
if (!renderContainer) {
|
|
2030
|
-
return content;
|
|
1964
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
|
|
1965
|
+
import { createElement as _createElement } from "react";
|
|
1966
|
+
function useRenderElement(element, componentProps, params = {}) {
|
|
1967
|
+
const renderProp = componentProps.render;
|
|
1968
|
+
const outProps = useRenderElementProps(componentProps, params);
|
|
1969
|
+
if (params.enabled === false) {
|
|
1970
|
+
return null;
|
|
2031
1971
|
}
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
1972
|
+
const state = params.state ?? EMPTY_OBJECT;
|
|
1973
|
+
return evaluateRenderProp(element, renderProp, outProps, state);
|
|
1974
|
+
}
|
|
1975
|
+
function useRenderElementProps(componentProps, params = {}) {
|
|
1976
|
+
const {
|
|
1977
|
+
className: classNameProp,
|
|
1978
|
+
style: styleProp,
|
|
1979
|
+
render: renderProp
|
|
1980
|
+
} = componentProps;
|
|
1981
|
+
const {
|
|
1982
|
+
state = EMPTY_OBJECT,
|
|
1983
|
+
ref,
|
|
1984
|
+
props,
|
|
1985
|
+
stateAttributesMapping,
|
|
1986
|
+
enabled = true
|
|
1987
|
+
} = params;
|
|
1988
|
+
const className = enabled ? resolveClassName(classNameProp, state) : void 0;
|
|
1989
|
+
const style = enabled ? resolveStyle(styleProp, state) : void 0;
|
|
1990
|
+
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
1991
|
+
const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
|
|
1992
|
+
if (typeof document !== "undefined") {
|
|
1993
|
+
if (!enabled) {
|
|
1994
|
+
useMergedRefs(null, null);
|
|
1995
|
+
} else if (Array.isArray(ref)) {
|
|
1996
|
+
outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
|
|
1997
|
+
} else {
|
|
1998
|
+
outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
|
|
1999
|
+
}
|
|
2000
|
+
}
|
|
2001
|
+
if (!enabled) {
|
|
2002
|
+
return EMPTY_OBJECT;
|
|
2003
|
+
}
|
|
2004
|
+
if (className !== void 0) {
|
|
2005
|
+
outProps.className = mergeClassNames(outProps.className, className);
|
|
2006
|
+
}
|
|
2007
|
+
if (style !== void 0) {
|
|
2008
|
+
outProps.style = mergeObjects(outProps.style, style);
|
|
2009
|
+
}
|
|
2010
|
+
return outProps;
|
|
2011
|
+
}
|
|
2012
|
+
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
|
|
2013
|
+
function evaluateRenderProp(element, render, props, state) {
|
|
2014
|
+
if (render) {
|
|
2015
|
+
if (typeof render === "function") {
|
|
2016
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2017
|
+
warnIfRenderPropLooksLikeComponent(render);
|
|
2074
2018
|
}
|
|
2019
|
+
return render(props, state);
|
|
2075
2020
|
}
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
if (
|
|
2080
|
-
|
|
2081
|
-
|
|
2021
|
+
const mergedProps = mergeProps(props, render.props);
|
|
2022
|
+
mergedProps.ref = props.ref;
|
|
2023
|
+
let newElement = render;
|
|
2024
|
+
if (newElement?.$$typeof === REACT_LAZY_TYPE) {
|
|
2025
|
+
const children = React4.Children.toArray(render);
|
|
2026
|
+
newElement = children[0];
|
|
2082
2027
|
}
|
|
2083
|
-
if (
|
|
2084
|
-
|
|
2085
|
-
|
|
2086
|
-
const datum = s.data[selectedIndex];
|
|
2087
|
-
tooltipContext?.showTooltip({
|
|
2088
|
-
datum,
|
|
2089
|
-
key: s.label,
|
|
2090
|
-
index
|
|
2091
|
-
});
|
|
2092
|
-
}
|
|
2093
|
-
});
|
|
2094
|
-
} else if (mode === "individual") {
|
|
2095
|
-
if (selectedIndex < tooltipData.length) {
|
|
2096
|
-
const tooltipItem = tooltipData[selectedIndex];
|
|
2097
|
-
tooltipContext?.showTooltip({
|
|
2098
|
-
datum: tooltipItem.datum,
|
|
2099
|
-
key: tooltipItem.seriesLabel,
|
|
2100
|
-
index: tooltipItem.seriesIndex
|
|
2101
|
-
});
|
|
2028
|
+
if (process.env.NODE_ENV !== "production") {
|
|
2029
|
+
if (!/* @__PURE__ */ React4.isValidElement(newElement)) {
|
|
2030
|
+
throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
|
|
2102
2031
|
}
|
|
2103
2032
|
}
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
if (selectedIndex !== void 0) {
|
|
2110
|
-
return /* @__PURE__ */ _jsx5("div", {
|
|
2111
|
-
ref: tooltipRef,
|
|
2112
|
-
tabIndex: -1,
|
|
2113
|
-
role: "tooltip",
|
|
2114
|
-
"aria-atomic": "true",
|
|
2115
|
-
className: keyboardFocusedClassName,
|
|
2116
|
-
children: tooltipContent
|
|
2117
|
-
}, `chart-tooltip-${selectedIndex}`);
|
|
2118
|
-
}
|
|
2119
|
-
return /* @__PURE__ */ _jsx5("div", {
|
|
2120
|
-
role: "tooltip",
|
|
2121
|
-
"aria-live": "polite",
|
|
2122
|
-
children: tooltipContent
|
|
2123
|
-
});
|
|
2124
|
-
};
|
|
2125
|
-
}, [renderTooltip, selectedIndex, tooltipRef, keyboardFocusedClassName]);
|
|
2126
|
-
return /* @__PURE__ */ _jsx5(Tooltip, {
|
|
2127
|
-
...props,
|
|
2128
|
-
renderTooltip: focusableRenderTooltip
|
|
2129
|
-
});
|
|
2130
|
-
};
|
|
2131
|
-
var useKeyboardNavigation = ({
|
|
2132
|
-
selectedIndex,
|
|
2133
|
-
setSelectedIndex,
|
|
2134
|
-
isNavigating,
|
|
2135
|
-
setIsNavigating,
|
|
2136
|
-
chartRef,
|
|
2137
|
-
totalPoints
|
|
2138
|
-
}) => {
|
|
2139
|
-
const tooltipRef = useCallback5((element) => {
|
|
2140
|
-
if (element && selectedIndex !== void 0) {
|
|
2141
|
-
element.focus();
|
|
2142
|
-
}
|
|
2143
|
-
}, [selectedIndex]);
|
|
2144
|
-
const onChartFocus = useCallback5(() => {
|
|
2145
|
-
if (!isNavigating && selectedIndex !== void 0) {
|
|
2146
|
-
setSelectedIndex(0);
|
|
2147
|
-
}
|
|
2148
|
-
}, [isNavigating, selectedIndex, setSelectedIndex]);
|
|
2149
|
-
const onChartBlur = useCallback5(() => {
|
|
2150
|
-
setIsNavigating(false);
|
|
2151
|
-
}, [setIsNavigating]);
|
|
2152
|
-
const onChartKeyDown = useCallback5((event) => {
|
|
2153
|
-
if (totalPoints === 0) return;
|
|
2154
|
-
if (event.key === "Tab") {
|
|
2155
|
-
chartRef.current?.focus();
|
|
2156
|
-
setSelectedIndex(void 0);
|
|
2157
|
-
setIsNavigating(false);
|
|
2158
|
-
return;
|
|
2159
|
-
}
|
|
2160
|
-
const currentSelectedIndex = selectedIndex === void 0 ? -1 : selectedIndex;
|
|
2161
|
-
if (currentSelectedIndex + 1 >= totalPoints && ["ArrowRight"].includes(event.key)) {
|
|
2162
|
-
chartRef.current?.focus();
|
|
2163
|
-
setSelectedIndex(void 0);
|
|
2164
|
-
setIsNavigating(false);
|
|
2165
|
-
return;
|
|
2166
|
-
}
|
|
2167
|
-
event.preventDefault();
|
|
2168
|
-
if (["ArrowRight"].includes(event.key)) {
|
|
2169
|
-
setIsNavigating(true);
|
|
2170
|
-
setSelectedIndex((currentSelectedIndex + 1) % totalPoints);
|
|
2171
|
-
} else if (["ArrowLeft"].includes(event.key)) {
|
|
2172
|
-
setIsNavigating(true);
|
|
2173
|
-
setSelectedIndex((currentSelectedIndex - 1 + totalPoints) % totalPoints);
|
|
2174
|
-
} else if (event.key === "Escape") {
|
|
2175
|
-
setSelectedIndex(void 0);
|
|
2176
|
-
setIsNavigating(false);
|
|
2177
|
-
chartRef.current?.focus();
|
|
2033
|
+
return /* @__PURE__ */ React4.cloneElement(newElement, mergedProps);
|
|
2034
|
+
}
|
|
2035
|
+
if (element) {
|
|
2036
|
+
if (typeof element === "string") {
|
|
2037
|
+
return renderTag(element, props);
|
|
2178
2038
|
}
|
|
2179
|
-
}
|
|
2180
|
-
|
|
2181
|
-
tooltipRef,
|
|
2182
|
-
onChartFocus,
|
|
2183
|
-
onChartBlur,
|
|
2184
|
-
onChartKeyDown
|
|
2185
|
-
};
|
|
2186
|
-
};
|
|
2187
|
-
|
|
2188
|
-
// src/charts/private/chart-composition/chart-svg.tsx
|
|
2189
|
-
import { Fragment as _Fragment2, jsx as _jsx6 } from "react/jsx-runtime";
|
|
2190
|
-
var ChartSVG = ({
|
|
2191
|
-
children
|
|
2192
|
-
}) => {
|
|
2193
|
-
return /* @__PURE__ */ _jsx6(_Fragment2, {
|
|
2194
|
-
children
|
|
2195
|
-
});
|
|
2196
|
-
};
|
|
2197
|
-
ChartSVG.displayName = "Chart.SVG";
|
|
2198
|
-
|
|
2199
|
-
// src/charts/private/chart-composition/chart-html.tsx
|
|
2200
|
-
import { Fragment as _Fragment3, jsx as _jsx7 } from "react/jsx-runtime";
|
|
2201
|
-
var ChartHTML = ({
|
|
2202
|
-
children
|
|
2203
|
-
}) => {
|
|
2204
|
-
return /* @__PURE__ */ _jsx7(_Fragment3, {
|
|
2205
|
-
children
|
|
2206
|
-
});
|
|
2207
|
-
};
|
|
2208
|
-
ChartHTML.displayName = "Chart.HTML";
|
|
2209
|
-
|
|
2210
|
-
// src/charts/private/chart-composition/render-legend-slot.ts
|
|
2211
|
-
import { createElement, Fragment } from "react";
|
|
2212
|
-
function renderLegendSlot(legendChildren, position2) {
|
|
2213
|
-
return legendChildren.filter((l) => l.position === position2).map(
|
|
2214
|
-
(l, i) => createElement(Fragment, { key: `legend-${position2}-${i}` }, l.element)
|
|
2215
|
-
);
|
|
2039
|
+
}
|
|
2040
|
+
throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
|
|
2216
2041
|
}
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
return;
|
|
2235
|
-
}
|
|
2236
|
-
const childType = child.type;
|
|
2237
|
-
const displayName = childType?.displayName;
|
|
2238
|
-
if (displayName === `${chartType}.SVG` || displayName === "Chart.SVG") {
|
|
2239
|
-
if (child.props?.children) {
|
|
2240
|
-
Children.forEach(child.props.children, (svgChild) => {
|
|
2241
|
-
svg.push(svgChild);
|
|
2242
|
-
});
|
|
2243
|
-
}
|
|
2244
|
-
} else if (displayName === `${chartType}.HTML` || displayName === "Chart.HTML") {
|
|
2245
|
-
if (child.props?.children) {
|
|
2246
|
-
Children.forEach(child.props.children, (htmlChild) => {
|
|
2247
|
-
html.push(htmlChild);
|
|
2248
|
-
});
|
|
2249
|
-
}
|
|
2250
|
-
} else if (child.type === Group2) {
|
|
2251
|
-
svg.push(child);
|
|
2252
|
-
} else {
|
|
2253
|
-
other.push(child);
|
|
2254
|
-
}
|
|
2255
|
-
}
|
|
2256
|
-
nonLegend.push(child);
|
|
2042
|
+
function warnIfRenderPropLooksLikeComponent(renderFn) {
|
|
2043
|
+
const functionName = renderFn.name;
|
|
2044
|
+
if (functionName.length === 0) {
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
const firstCharacterCode = functionName.charCodeAt(0);
|
|
2048
|
+
if (firstCharacterCode < 65 || firstCharacterCode > 90) {
|
|
2049
|
+
return;
|
|
2050
|
+
}
|
|
2051
|
+
warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
|
|
2052
|
+
}
|
|
2053
|
+
function renderTag(Tag, props) {
|
|
2054
|
+
if (Tag === "button") {
|
|
2055
|
+
return /* @__PURE__ */ _createElement("button", {
|
|
2056
|
+
type: "button",
|
|
2057
|
+
...props,
|
|
2058
|
+
key: props.key
|
|
2257
2059
|
});
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
};
|
|
2265
|
-
}
|
|
2060
|
+
}
|
|
2061
|
+
if (Tag === "img") {
|
|
2062
|
+
return /* @__PURE__ */ _createElement("img", {
|
|
2063
|
+
alt: "",
|
|
2064
|
+
...props,
|
|
2065
|
+
key: props.key
|
|
2066
|
+
});
|
|
2067
|
+
}
|
|
2068
|
+
return /* @__PURE__ */ React4.createElement(Tag, props);
|
|
2266
2069
|
}
|
|
2267
2070
|
|
|
2268
|
-
// ../../../node_modules/.pnpm/@base-ui+
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
function useRefWithInit(init, initArg) {
|
|
2272
|
-
const ref = React.useRef(UNINITIALIZED);
|
|
2273
|
-
if (ref.current === UNINITIALIZED) {
|
|
2274
|
-
ref.current = init(initArg);
|
|
2275
|
-
}
|
|
2276
|
-
return ref;
|
|
2071
|
+
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/use-render/useRender.js
|
|
2072
|
+
function useRender(params) {
|
|
2073
|
+
return useRenderElement(params.defaultTagName ?? "div", params, params);
|
|
2277
2074
|
}
|
|
2278
2075
|
|
|
2279
|
-
// ../../../node_modules/.pnpm/@
|
|
2280
|
-
|
|
2281
|
-
|
|
2282
|
-
|
|
2076
|
+
// ../../../node_modules/.pnpm/@wordpress+element@6.43.0/node_modules/@wordpress/element/build-module/react.mjs
|
|
2077
|
+
import {
|
|
2078
|
+
Children as Children2,
|
|
2079
|
+
cloneElement as cloneElement2,
|
|
2080
|
+
Component,
|
|
2081
|
+
createContext as createContext3,
|
|
2082
|
+
createElement as createElement2,
|
|
2083
|
+
createRef,
|
|
2084
|
+
forwardRef,
|
|
2085
|
+
Fragment,
|
|
2086
|
+
isValidElement as isValidElement3,
|
|
2087
|
+
memo,
|
|
2088
|
+
PureComponent,
|
|
2089
|
+
StrictMode,
|
|
2090
|
+
useCallback as useCallback4,
|
|
2091
|
+
useContext as useContext4,
|
|
2092
|
+
useDebugValue,
|
|
2093
|
+
useDeferredValue,
|
|
2094
|
+
useEffect as useEffect5,
|
|
2095
|
+
useId as useId2,
|
|
2096
|
+
useMemo as useMemo9,
|
|
2097
|
+
useImperativeHandle,
|
|
2098
|
+
useInsertionEffect,
|
|
2099
|
+
useLayoutEffect as useLayoutEffect2,
|
|
2100
|
+
useReducer,
|
|
2101
|
+
useRef as useRef6,
|
|
2102
|
+
useState as useState5,
|
|
2103
|
+
useSyncExternalStore,
|
|
2104
|
+
useTransition,
|
|
2105
|
+
startTransition,
|
|
2106
|
+
lazy,
|
|
2107
|
+
Suspense
|
|
2108
|
+
} from "react";
|
|
2109
|
+
|
|
2110
|
+
// ../../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs
|
|
2111
|
+
function isObject(o) {
|
|
2112
|
+
return Object.prototype.toString.call(o) === "[object Object]";
|
|
2283
2113
|
}
|
|
2284
|
-
function
|
|
2285
|
-
|
|
2286
|
-
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2114
|
+
function isPlainObject(o) {
|
|
2115
|
+
var ctor, prot;
|
|
2116
|
+
if (isObject(o) === false) return false;
|
|
2117
|
+
ctor = o.constructor;
|
|
2118
|
+
if (ctor === void 0) return true;
|
|
2119
|
+
prot = ctor.prototype;
|
|
2120
|
+
if (isObject(prot) === false) return false;
|
|
2121
|
+
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
2122
|
+
return false;
|
|
2291
2123
|
}
|
|
2124
|
+
return true;
|
|
2292
2125
|
}
|
|
2293
2126
|
|
|
2294
|
-
// ../../../node_modules/.pnpm
|
|
2295
|
-
function
|
|
2296
|
-
return
|
|
2297
|
-
const url = new URL(baseUrl);
|
|
2298
|
-
url.searchParams.set("code", code.toString());
|
|
2299
|
-
args.forEach((arg) => url.searchParams.append("args[]", arg));
|
|
2300
|
-
return `${prefix2} error #${code}; visit ${url} for the full message.`;
|
|
2301
|
-
};
|
|
2127
|
+
// ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist.es2015/index.js
|
|
2128
|
+
function lowerCase(str) {
|
|
2129
|
+
return str.toLowerCase();
|
|
2302
2130
|
}
|
|
2303
|
-
var formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
|
|
2304
|
-
var formatErrorMessage_default = formatErrorMessage;
|
|
2305
|
-
|
|
2306
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/useRenderElement.js
|
|
2307
|
-
import * as React4 from "react";
|
|
2308
2131
|
|
|
2309
|
-
// ../../../node_modules/.pnpm
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2132
|
+
// ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist.es2015/index.js
|
|
2133
|
+
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
2134
|
+
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
2135
|
+
function noCase(input, options) {
|
|
2136
|
+
if (options === void 0) {
|
|
2137
|
+
options = {};
|
|
2138
|
+
}
|
|
2139
|
+
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter2 = _d === void 0 ? " " : _d;
|
|
2140
|
+
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
|
2141
|
+
var start = 0;
|
|
2142
|
+
var end = result.length;
|
|
2143
|
+
while (result.charAt(start) === "\0")
|
|
2144
|
+
start++;
|
|
2145
|
+
while (result.charAt(end - 1) === "\0")
|
|
2146
|
+
end--;
|
|
2147
|
+
return result.slice(start, end).split("\0").map(transform).join(delimiter2);
|
|
2316
2148
|
}
|
|
2317
|
-
function
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2149
|
+
function replace(input, re, value) {
|
|
2150
|
+
if (re instanceof RegExp)
|
|
2151
|
+
return input.replace(re, value);
|
|
2152
|
+
return re.reduce(function(input2, re2) {
|
|
2153
|
+
return input2.replace(re2, value);
|
|
2154
|
+
}, input);
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
// ../../../node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist.es2015/index.js
|
|
2158
|
+
import { __assign } from "tslib";
|
|
2159
|
+
function dotCase(input, options) {
|
|
2160
|
+
if (options === void 0) {
|
|
2161
|
+
options = {};
|
|
2321
2162
|
}
|
|
2322
|
-
return
|
|
2163
|
+
return noCase(input, __assign({ delimiter: "." }, options));
|
|
2323
2164
|
}
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2165
|
+
|
|
2166
|
+
// ../../../node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist.es2015/index.js
|
|
2167
|
+
import { __assign as __assign2 } from "tslib";
|
|
2168
|
+
function paramCase(input, options) {
|
|
2169
|
+
if (options === void 0) {
|
|
2170
|
+
options = {};
|
|
2171
|
+
}
|
|
2172
|
+
return dotCase(input, __assign2({ delimiter: "-" }, options));
|
|
2330
2173
|
}
|
|
2331
|
-
|
|
2332
|
-
|
|
2174
|
+
|
|
2175
|
+
// ../../../node_modules/.pnpm/@wordpress+ui@0.10.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@17.7.0/node_modules/@wordpress/ui/build-module/text/text.mjs
|
|
2176
|
+
import clsx from "clsx";
|
|
2177
|
+
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='8bc43893d6']")) {
|
|
2178
|
+
const style = document.createElement("style");
|
|
2179
|
+
style.setAttribute("data-wp-hash", "8bc43893d6");
|
|
2180
|
+
style.appendChild(document.createTextNode('@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._14437cfb77831647__heading-2xl{font-size:var(--wpds-font-size-2xl,32px);line-height:var(--wpds-font-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{font-size:var(--wpds-font-size-xl,20px);line-height:var(--wpds-font-line-height-md,24px)}.aa58f227716bcde2__heading-lg{font-size:var(--wpds-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{font-size:var(--wpds-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{font-family:var(--wpds-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-font-size-xs,11px);font-weight:var(--wpds-font-weight-medium,499);line-height:var(--wpds-font-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{font-size:var(--wpds-font-size-xl,20px);line-height:var(--wpds-font-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{font-size:var(--wpds-font-size-lg,15px);line-height:var(--wpds-font-line-height-md,24px)}._131101940be12424__body-md{font-size:var(--wpds-font-size-md,13px);line-height:var(--wpds-font-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{font-size:var(--wpds-font-size-sm,12px);line-height:var(--wpds-font-line-height-xs,16px)}}'));
|
|
2181
|
+
document.head.appendChild(style);
|
|
2333
2182
|
}
|
|
2334
|
-
|
|
2335
|
-
|
|
2183
|
+
var style_default = { "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
|
|
2184
|
+
var Text = forwardRef(function Text2({ variant = "body-md", render, className, ...props }, ref) {
|
|
2185
|
+
const element = useRender({
|
|
2186
|
+
render,
|
|
2187
|
+
defaultTagName: "span",
|
|
2188
|
+
ref,
|
|
2189
|
+
props: mergeProps(props, {
|
|
2190
|
+
className: clsx(style_default[variant], className)
|
|
2191
|
+
})
|
|
2192
|
+
});
|
|
2193
|
+
return element;
|
|
2194
|
+
});
|
|
2195
|
+
|
|
2196
|
+
// ../../../node_modules/.pnpm/@wordpress+ui@0.10.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1_stylelint@17.7.0/node_modules/@wordpress/ui/build-module/stack/stack.mjs
|
|
2197
|
+
if (typeof document !== "undefined" && process.env.NODE_ENV !== "test" && !document.head.querySelector("style[data-wp-hash='b51ff41489']")) {
|
|
2198
|
+
const style = document.createElement("style");
|
|
2199
|
+
style.setAttribute("data-wp-hash", "b51ff41489");
|
|
2200
|
+
style.appendChild(document.createTextNode("@layer wp-ui-utilities, wp-ui-components, wp-ui-compositions, wp-ui-overrides;@layer wp-ui-components{._19ce0419607e1896__stack{display:flex}}"));
|
|
2201
|
+
document.head.appendChild(style);
|
|
2336
2202
|
}
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
}
|
|
2355
|
-
switch (typeof ref) {
|
|
2356
|
-
case "function": {
|
|
2357
|
-
const refCleanup = ref(instance);
|
|
2358
|
-
if (typeof refCleanup === "function") {
|
|
2359
|
-
cleanupCallbacks[i] = refCleanup;
|
|
2360
|
-
}
|
|
2361
|
-
break;
|
|
2362
|
-
}
|
|
2363
|
-
case "object": {
|
|
2364
|
-
ref.current = instance;
|
|
2365
|
-
break;
|
|
2366
|
-
}
|
|
2367
|
-
default:
|
|
2368
|
-
}
|
|
2369
|
-
}
|
|
2370
|
-
forkRef.cleanup = () => {
|
|
2371
|
-
for (let i = 0; i < refs.length; i += 1) {
|
|
2372
|
-
const ref = refs[i];
|
|
2373
|
-
if (ref == null) {
|
|
2374
|
-
continue;
|
|
2375
|
-
}
|
|
2376
|
-
switch (typeof ref) {
|
|
2377
|
-
case "function": {
|
|
2378
|
-
const cleanupCallback = cleanupCallbacks[i];
|
|
2379
|
-
if (typeof cleanupCallback === "function") {
|
|
2380
|
-
cleanupCallback();
|
|
2381
|
-
} else {
|
|
2382
|
-
ref(null);
|
|
2383
|
-
}
|
|
2384
|
-
break;
|
|
2385
|
-
}
|
|
2386
|
-
case "object": {
|
|
2387
|
-
ref.current = null;
|
|
2388
|
-
break;
|
|
2389
|
-
}
|
|
2390
|
-
default:
|
|
2391
|
-
}
|
|
2392
|
-
}
|
|
2393
|
-
};
|
|
2394
|
-
}
|
|
2203
|
+
var style_default2 = { "stack": "_19ce0419607e1896__stack" };
|
|
2204
|
+
var gapTokens = {
|
|
2205
|
+
xs: "var(--wpds-dimension-gap-xs, 4px)",
|
|
2206
|
+
sm: "var(--wpds-dimension-gap-sm, 8px)",
|
|
2207
|
+
md: "var(--wpds-dimension-gap-md, 12px)",
|
|
2208
|
+
lg: "var(--wpds-dimension-gap-lg, 16px)",
|
|
2209
|
+
xl: "var(--wpds-dimension-gap-xl, 24px)",
|
|
2210
|
+
"2xl": "var(--wpds-dimension-gap-2xl, 32px)",
|
|
2211
|
+
"3xl": "var(--wpds-dimension-gap-3xl, 40px)"
|
|
2212
|
+
};
|
|
2213
|
+
var Stack = forwardRef(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
|
|
2214
|
+
const style = {
|
|
2215
|
+
gap: gap && gapTokens[gap],
|
|
2216
|
+
alignItems: align,
|
|
2217
|
+
justifyContent: justify,
|
|
2218
|
+
flexDirection: direction,
|
|
2219
|
+
flexWrap: wrap
|
|
2395
2220
|
};
|
|
2396
|
-
|
|
2221
|
+
const element = useRender({
|
|
2222
|
+
render,
|
|
2223
|
+
ref,
|
|
2224
|
+
props: mergeProps(props, { style, className: style_default2.stack })
|
|
2225
|
+
});
|
|
2226
|
+
return element;
|
|
2227
|
+
});
|
|
2397
2228
|
|
|
2398
|
-
//
|
|
2399
|
-
import
|
|
2229
|
+
// src/components/legend/private/base-legend.tsx
|
|
2230
|
+
import clsx2 from "clsx";
|
|
2231
|
+
import { forwardRef as forwardRef2, useCallback as useCallback5, useContext as useContext5 } from "react";
|
|
2400
2232
|
|
|
2401
|
-
//
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
return
|
|
2233
|
+
// src/components/legend/utils/value-or-identity.ts
|
|
2234
|
+
function valueOrIdentity(_) {
|
|
2235
|
+
if (_ && typeof _ === "object" && "value" in _ && typeof _.value !== "undefined")
|
|
2236
|
+
return _.value;
|
|
2237
|
+
return _;
|
|
2238
|
+
}
|
|
2239
|
+
function valueOrIdentityString(_) {
|
|
2240
|
+
return String(valueOrIdentity(_));
|
|
2406
2241
|
}
|
|
2407
2242
|
|
|
2408
|
-
//
|
|
2409
|
-
function
|
|
2410
|
-
|
|
2243
|
+
// src/components/legend/utils/label-transform-factory.ts
|
|
2244
|
+
function labelTransformFactory({
|
|
2245
|
+
scale,
|
|
2246
|
+
labelFormat
|
|
2247
|
+
}) {
|
|
2248
|
+
return (d, i) => ({
|
|
2249
|
+
datum: d,
|
|
2250
|
+
index: i,
|
|
2251
|
+
text: `${labelFormat(d, i)}`,
|
|
2252
|
+
value: scale(d)
|
|
2253
|
+
});
|
|
2254
|
+
}
|
|
2255
|
+
|
|
2256
|
+
// src/components/legend/private/base-legend.module.scss
|
|
2257
|
+
var base_legend_module_default = {
|
|
2258
|
+
"legend": "a8ccharts-89ApsU",
|
|
2259
|
+
"legend-item": "a8ccharts-Vflwq8",
|
|
2260
|
+
"legend-item--interactive": "a8ccharts-qGsavM",
|
|
2261
|
+
"legend-item--inactive": "a8ccharts-ZtDY-Q",
|
|
2262
|
+
"legend-item-label": "a8ccharts-2H65Kr",
|
|
2263
|
+
"legend-item-text--wrap": "a8ccharts-faSDBI",
|
|
2264
|
+
"legend-item-text--ellipsis": "a8ccharts-FISUIO",
|
|
2265
|
+
"legend-item-value": "a8ccharts-DTZlT-"
|
|
2266
|
+
};
|
|
2267
|
+
|
|
2268
|
+
// src/components/legend/private/base-legend.tsx
|
|
2269
|
+
import { jsx as _jsx2, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2270
|
+
var ALIGNMENT_TO_FLEX = {
|
|
2271
|
+
start: "flex-start",
|
|
2272
|
+
center: "center",
|
|
2273
|
+
end: "flex-end"
|
|
2274
|
+
};
|
|
2275
|
+
var LegendText = ({
|
|
2276
|
+
text,
|
|
2277
|
+
textOverflow,
|
|
2278
|
+
maxWidth
|
|
2279
|
+
}) => {
|
|
2280
|
+
const isEllipsis = maxWidth != null && textOverflow === "ellipsis";
|
|
2281
|
+
const [textRef, isTruncated] = useTextTruncation(Boolean(isEllipsis));
|
|
2282
|
+
return /* @__PURE__ */ _jsx2("span", {
|
|
2283
|
+
ref: textRef,
|
|
2284
|
+
className: clsx2(base_legend_module_default["legend-item-text"], maxWidth != null && base_legend_module_default[`legend-item-text--${textOverflow}`]),
|
|
2285
|
+
style: {
|
|
2286
|
+
...maxWidth != null && {
|
|
2287
|
+
maxWidth,
|
|
2288
|
+
minWidth: 0
|
|
2289
|
+
}
|
|
2290
|
+
},
|
|
2291
|
+
title: isEllipsis && isTruncated ? text : void 0,
|
|
2292
|
+
children: text
|
|
2293
|
+
});
|
|
2294
|
+
};
|
|
2295
|
+
var BaseLegend = /* @__PURE__ */ forwardRef2(({
|
|
2296
|
+
items,
|
|
2297
|
+
className,
|
|
2298
|
+
orientation = "horizontal",
|
|
2299
|
+
alignment = "center",
|
|
2300
|
+
shape = "rect",
|
|
2301
|
+
fill = valueOrIdentityString,
|
|
2302
|
+
size = valueOrIdentityString,
|
|
2303
|
+
labelFormat = valueOrIdentity,
|
|
2304
|
+
labelTransform = labelTransformFactory,
|
|
2305
|
+
itemStyles,
|
|
2306
|
+
itemClassName,
|
|
2307
|
+
labelStyles,
|
|
2308
|
+
labelClassName,
|
|
2309
|
+
shapeStyles,
|
|
2310
|
+
render,
|
|
2311
|
+
interactive = false,
|
|
2312
|
+
chartId
|
|
2313
|
+
}, ref) => {
|
|
2314
|
+
const {
|
|
2315
|
+
margin: itemMargin = "0",
|
|
2316
|
+
flexDirection: itemDirection = "row"
|
|
2317
|
+
} = itemStyles ?? {};
|
|
2318
|
+
const {
|
|
2319
|
+
justifyContent: labelJustifyContent = "flex-start",
|
|
2320
|
+
flex: labelFlex = "0 0 auto",
|
|
2321
|
+
margin: labelMargin = "0 4px",
|
|
2322
|
+
maxWidth,
|
|
2323
|
+
textOverflow = "wrap"
|
|
2324
|
+
} = labelStyles ?? {};
|
|
2325
|
+
const {
|
|
2326
|
+
width: shapeWidth = 16,
|
|
2327
|
+
height: shapeHeight = 16,
|
|
2328
|
+
margin: shapeMargin = "2px 4px 2px 0"
|
|
2329
|
+
} = shapeStyles ?? {};
|
|
2330
|
+
const theme = useGlobalChartsTheme();
|
|
2331
|
+
const context = useContext5(GlobalChartsContext);
|
|
2332
|
+
const legendScale = scaleOrdinal({
|
|
2333
|
+
domain: items.map((item) => item.label),
|
|
2334
|
+
range: items.map((item) => item.color)
|
|
2335
|
+
});
|
|
2336
|
+
const domain = legendScale.domain();
|
|
2337
|
+
const getShapeStyle = useCallback5(({
|
|
2338
|
+
index
|
|
2339
|
+
}) => items[index]?.shapeStyle, [items]);
|
|
2340
|
+
const handleLegendClick = useCallback5((seriesLabel) => {
|
|
2341
|
+
if (interactive && chartId && context) {
|
|
2342
|
+
context.toggleSeriesVisibility(chartId, seriesLabel);
|
|
2343
|
+
}
|
|
2344
|
+
}, [interactive, chartId, context]);
|
|
2345
|
+
const isSeriesVisible = useCallback5((seriesLabel) => {
|
|
2346
|
+
if (!interactive || !chartId || !context) {
|
|
2347
|
+
return true;
|
|
2348
|
+
}
|
|
2349
|
+
return context.isSeriesVisible(chartId, seriesLabel);
|
|
2350
|
+
}, [interactive, chartId, context]);
|
|
2351
|
+
const createClickHandler = useCallback5((labelText) => {
|
|
2352
|
+
if (!interactive) {
|
|
2353
|
+
return void 0;
|
|
2354
|
+
}
|
|
2355
|
+
return () => handleLegendClick(labelText);
|
|
2356
|
+
}, [interactive, handleLegendClick]);
|
|
2357
|
+
const createKeyDownHandler = useCallback5((labelText) => {
|
|
2358
|
+
if (!interactive) {
|
|
2359
|
+
return void 0;
|
|
2360
|
+
}
|
|
2361
|
+
return (event) => {
|
|
2362
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
2363
|
+
event.preventDefault();
|
|
2364
|
+
handleLegendClick(labelText);
|
|
2365
|
+
}
|
|
2366
|
+
};
|
|
2367
|
+
}, [interactive, handleLegendClick]);
|
|
2368
|
+
const flexAlignment = ALIGNMENT_TO_FLEX[alignment] ?? "center";
|
|
2369
|
+
return render ? render(items) : /* @__PURE__ */ _jsx2(LegendOrdinal, {
|
|
2370
|
+
scale: legendScale,
|
|
2371
|
+
labelFormat,
|
|
2372
|
+
labelTransform,
|
|
2373
|
+
children: (labels) => /* @__PURE__ */ _jsx2(Stack, {
|
|
2374
|
+
ref,
|
|
2375
|
+
direction: orientation === "vertical" ? "column" : "row",
|
|
2376
|
+
gap: orientation === "vertical" ? "sm" : "lg",
|
|
2377
|
+
align: orientation === "vertical" ? flexAlignment : void 0,
|
|
2378
|
+
justify: orientation === "horizontal" ? flexAlignment : void 0,
|
|
2379
|
+
wrap: orientation === "horizontal" ? "wrap" : void 0,
|
|
2380
|
+
role: "list",
|
|
2381
|
+
className: clsx2(base_legend_module_default.legend, className),
|
|
2382
|
+
style: theme.legend?.containerStyles,
|
|
2383
|
+
children: labels.map((label, i) => {
|
|
2384
|
+
const visible = isSeriesVisible(label.text);
|
|
2385
|
+
const handleClick = createClickHandler(label.text);
|
|
2386
|
+
const handleKeyDown = createKeyDownHandler(label.text);
|
|
2387
|
+
const matchedItem = items[i];
|
|
2388
|
+
return /* @__PURE__ */ _jsxs(LegendItem, {
|
|
2389
|
+
className: clsx2("visx-legend-item", base_legend_module_default["legend-item"], interactive && base_legend_module_default["legend-item--interactive"], !visible && base_legend_module_default["legend-item--inactive"], itemClassName),
|
|
2390
|
+
margin: itemMargin,
|
|
2391
|
+
flexDirection: orientation === "vertical" && alignment === "end" ? "row-reverse" : itemDirection,
|
|
2392
|
+
onClick: handleClick,
|
|
2393
|
+
onKeyDown: handleKeyDown,
|
|
2394
|
+
role: interactive ? "button" : void 0,
|
|
2395
|
+
tabIndex: interactive ? 0 : void 0,
|
|
2396
|
+
"aria-pressed": interactive ? visible : void 0,
|
|
2397
|
+
"aria-label": interactive ? `${label.text}: ${visible ? "visible" : "hidden"}. Toggle visibility.` : void 0,
|
|
2398
|
+
children: [items[i]?.renderGlyph ? /* @__PURE__ */ _jsx2("svg", {
|
|
2399
|
+
width: items[i]?.glyphSize * 2,
|
|
2400
|
+
height: items[i]?.glyphSize * 2,
|
|
2401
|
+
children: /* @__PURE__ */ _jsx2(Group, {
|
|
2402
|
+
children: items[i]?.renderGlyph({
|
|
2403
|
+
key: `legend-glyph-${label.text}`,
|
|
2404
|
+
datum: {},
|
|
2405
|
+
index: i,
|
|
2406
|
+
color: fill(label),
|
|
2407
|
+
size: items[i]?.glyphSize,
|
|
2408
|
+
x: items[i]?.glyphSize,
|
|
2409
|
+
y: items[i]?.glyphSize
|
|
2410
|
+
})
|
|
2411
|
+
})
|
|
2412
|
+
}) : /* @__PURE__ */ _jsx2(LegendShape, {
|
|
2413
|
+
shape,
|
|
2414
|
+
height: shapeHeight,
|
|
2415
|
+
width: shapeWidth,
|
|
2416
|
+
margin: shapeMargin,
|
|
2417
|
+
item: domain[i],
|
|
2418
|
+
itemIndex: i,
|
|
2419
|
+
label,
|
|
2420
|
+
fill,
|
|
2421
|
+
size,
|
|
2422
|
+
shapeStyle: getShapeStyle
|
|
2423
|
+
}), /* @__PURE__ */ _jsx2(LegendLabel, {
|
|
2424
|
+
className: clsx2("visx-legend-label", base_legend_module_default["legend-item-label"], labelClassName),
|
|
2425
|
+
style: {
|
|
2426
|
+
flex: labelFlex,
|
|
2427
|
+
margin: labelMargin,
|
|
2428
|
+
...theme.legend?.labelStyles
|
|
2429
|
+
},
|
|
2430
|
+
children: /* @__PURE__ */ _jsxs(Stack, {
|
|
2431
|
+
align: "center",
|
|
2432
|
+
gap: "sm",
|
|
2433
|
+
justify: labelJustifyContent,
|
|
2434
|
+
children: [/* @__PURE__ */ _jsx2(LegendText, {
|
|
2435
|
+
text: label.text,
|
|
2436
|
+
textOverflow,
|
|
2437
|
+
maxWidth
|
|
2438
|
+
}), matchedItem?.value != null && matchedItem.value !== "" && /* @__PURE__ */ _jsxs("span", {
|
|
2439
|
+
className: base_legend_module_default["legend-item-value"],
|
|
2440
|
+
children: ["\xA0", matchedItem.value]
|
|
2441
|
+
})]
|
|
2442
|
+
})
|
|
2443
|
+
})]
|
|
2444
|
+
}, `legend-${label.text}-${i}`);
|
|
2445
|
+
})
|
|
2446
|
+
})
|
|
2447
|
+
});
|
|
2448
|
+
});
|
|
2449
|
+
|
|
2450
|
+
// src/components/legend/legend.tsx
|
|
2451
|
+
import { jsx as _jsx3 } from "react/jsx-runtime";
|
|
2452
|
+
var defaultShapeByChartType = {
|
|
2453
|
+
line: "line",
|
|
2454
|
+
bar: "rect",
|
|
2455
|
+
pie: "circle",
|
|
2456
|
+
"pie-semi-circle": "circle",
|
|
2457
|
+
leaderboard: "circle"
|
|
2458
|
+
};
|
|
2459
|
+
var Legend = /* @__PURE__ */ forwardRef3(({
|
|
2460
|
+
chartId,
|
|
2461
|
+
items,
|
|
2462
|
+
shape,
|
|
2463
|
+
...props
|
|
2464
|
+
}, ref) => {
|
|
2465
|
+
const context = useContext6(GlobalChartsContext);
|
|
2466
|
+
const singleChartContext = useContext6(SingleChartContext);
|
|
2467
|
+
const contextChartId = chartId ?? singleChartContext?.chartId;
|
|
2468
|
+
const chartData = useMemo10(() => contextChartId && context ? context.getChartData(contextChartId) : void 0, [contextChartId, context]);
|
|
2469
|
+
const contextItems = chartData?.legendItems;
|
|
2470
|
+
const resolvedShape = shape ?? (chartData?.chartType ? defaultShapeByChartType[chartData.chartType] : void 0);
|
|
2471
|
+
const legendItems = items || contextItems;
|
|
2472
|
+
if (!legendItems) {
|
|
2411
2473
|
return null;
|
|
2412
2474
|
}
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2475
|
+
return /* @__PURE__ */ _jsx3(BaseLegend, {
|
|
2476
|
+
ref,
|
|
2477
|
+
items: legendItems,
|
|
2478
|
+
shape: resolvedShape,
|
|
2479
|
+
...props,
|
|
2480
|
+
chartId: contextChartId
|
|
2481
|
+
});
|
|
2482
|
+
});
|
|
2417
2483
|
|
|
2418
|
-
//
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
return b;
|
|
2425
|
-
}
|
|
2426
|
-
if (a || b) {
|
|
2427
|
-
return {
|
|
2428
|
-
...a,
|
|
2429
|
-
...b
|
|
2430
|
-
};
|
|
2484
|
+
// src/components/legend/hooks/use-chart-legend-items.ts
|
|
2485
|
+
import { formatNumber as formatNumber3 } from "@automattic/number-formatters";
|
|
2486
|
+
import { useMemo as useMemo11 } from "react";
|
|
2487
|
+
function formatPointValue(point, showValues, legendValueDisplay = "percentage") {
|
|
2488
|
+
if (!showValues || legendValueDisplay === "none") {
|
|
2489
|
+
return "";
|
|
2431
2490
|
}
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
if (customProps != null) {
|
|
2443
|
-
Object.assign(props, customProps);
|
|
2444
|
-
}
|
|
2445
|
-
continue;
|
|
2446
|
-
}
|
|
2447
|
-
if (value === true) {
|
|
2448
|
-
props[`data-${key.toLowerCase()}`] = "";
|
|
2449
|
-
} else if (value) {
|
|
2450
|
-
props[`data-${key.toLowerCase()}`] = value.toString();
|
|
2491
|
+
if ("percentage" in point) {
|
|
2492
|
+
switch (legendValueDisplay) {
|
|
2493
|
+
case "percentage":
|
|
2494
|
+
return formatPercentage(point.percentage);
|
|
2495
|
+
case "value":
|
|
2496
|
+
return formatNumber3(point.value);
|
|
2497
|
+
case "valueDisplay":
|
|
2498
|
+
return point.valueDisplay || formatNumber3(point.value);
|
|
2499
|
+
default:
|
|
2500
|
+
return "";
|
|
2451
2501
|
}
|
|
2452
2502
|
}
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveClassName.js
|
|
2457
|
-
function resolveClassName(className, state) {
|
|
2458
|
-
return typeof className === "function" ? className(state) : className;
|
|
2459
|
-
}
|
|
2460
|
-
|
|
2461
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/utils/resolveStyle.js
|
|
2462
|
-
function resolveStyle(style, state) {
|
|
2463
|
-
return typeof style === "function" ? style(state) : style;
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/merge-props/mergeProps.js
|
|
2467
|
-
var EMPTY_PROPS = {};
|
|
2468
|
-
function mergeProps(a, b, c, d, e) {
|
|
2469
|
-
let merged = {
|
|
2470
|
-
...resolvePropsGetter(a, EMPTY_PROPS)
|
|
2471
|
-
};
|
|
2472
|
-
if (b) {
|
|
2473
|
-
merged = mergeOne(merged, b);
|
|
2474
|
-
}
|
|
2475
|
-
if (c) {
|
|
2476
|
-
merged = mergeOne(merged, c);
|
|
2477
|
-
}
|
|
2478
|
-
if (d) {
|
|
2479
|
-
merged = mergeOne(merged, d);
|
|
2480
|
-
}
|
|
2481
|
-
if (e) {
|
|
2482
|
-
merged = mergeOne(merged, e);
|
|
2483
|
-
}
|
|
2484
|
-
return merged;
|
|
2485
|
-
}
|
|
2486
|
-
function mergePropsN(props) {
|
|
2487
|
-
if (props.length === 0) {
|
|
2488
|
-
return EMPTY_PROPS;
|
|
2489
|
-
}
|
|
2490
|
-
if (props.length === 1) {
|
|
2491
|
-
return resolvePropsGetter(props[0], EMPTY_PROPS);
|
|
2492
|
-
}
|
|
2493
|
-
let merged = {
|
|
2494
|
-
...resolvePropsGetter(props[0], EMPTY_PROPS)
|
|
2495
|
-
};
|
|
2496
|
-
for (let i = 1; i < props.length; i += 1) {
|
|
2497
|
-
merged = mergeOne(merged, props[i]);
|
|
2498
|
-
}
|
|
2499
|
-
return merged;
|
|
2500
|
-
}
|
|
2501
|
-
function mergeOne(merged, inputProps) {
|
|
2502
|
-
if (isPropsGetter(inputProps)) {
|
|
2503
|
-
return inputProps(merged);
|
|
2503
|
+
if ("value" in point) {
|
|
2504
|
+
return point.value !== null ? formatNumber3(point.value) : "";
|
|
2504
2505
|
}
|
|
2505
|
-
return
|
|
2506
|
+
return "";
|
|
2506
2507
|
}
|
|
2507
|
-
function
|
|
2508
|
-
if (
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
break;
|
|
2517
|
-
}
|
|
2518
|
-
case "className": {
|
|
2519
|
-
mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
|
|
2520
|
-
break;
|
|
2521
|
-
}
|
|
2522
|
-
default: {
|
|
2523
|
-
if (isEventHandler(propName, externalPropValue)) {
|
|
2524
|
-
mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
|
|
2525
|
-
} else {
|
|
2526
|
-
mergedProps[propName] = externalPropValue;
|
|
2527
|
-
}
|
|
2528
|
-
}
|
|
2508
|
+
function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize) {
|
|
2509
|
+
if (withGlyph) {
|
|
2510
|
+
const glyphToUse = glyph || renderGlyph;
|
|
2511
|
+
if (glyphToUse) {
|
|
2512
|
+
return {
|
|
2513
|
+
...baseItem,
|
|
2514
|
+
glyphSize,
|
|
2515
|
+
renderGlyph: glyphToUse
|
|
2516
|
+
};
|
|
2529
2517
|
}
|
|
2530
2518
|
}
|
|
2531
|
-
return
|
|
2532
|
-
}
|
|
2533
|
-
function isEventHandler(key, value) {
|
|
2534
|
-
const code0 = key.charCodeAt(0);
|
|
2535
|
-
const code1 = key.charCodeAt(1);
|
|
2536
|
-
const code2 = key.charCodeAt(2);
|
|
2537
|
-
return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
|
|
2538
|
-
}
|
|
2539
|
-
function isPropsGetter(inputProps) {
|
|
2540
|
-
return typeof inputProps === "function";
|
|
2541
|
-
}
|
|
2542
|
-
function resolvePropsGetter(inputProps, previousProps) {
|
|
2543
|
-
if (isPropsGetter(inputProps)) {
|
|
2544
|
-
return inputProps(previousProps);
|
|
2545
|
-
}
|
|
2546
|
-
return inputProps ?? EMPTY_PROPS;
|
|
2519
|
+
return baseItem;
|
|
2547
2520
|
}
|
|
2548
|
-
function
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
}
|
|
2563
|
-
return result2;
|
|
2564
|
-
}
|
|
2565
|
-
const result = theirHandler(event);
|
|
2566
|
-
ourHandler?.(event);
|
|
2567
|
-
return result;
|
|
2521
|
+
function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
2522
|
+
const mapper = (series, index) => {
|
|
2523
|
+
const { color, glyph, shapeStyles } = getElementStyles({
|
|
2524
|
+
data: series,
|
|
2525
|
+
index,
|
|
2526
|
+
legendShape
|
|
2527
|
+
});
|
|
2528
|
+
const baseItem = {
|
|
2529
|
+
label: series.label,
|
|
2530
|
+
value: showValues ? series.data?.length?.toString() || "0" : "",
|
|
2531
|
+
color,
|
|
2532
|
+
shapeStyle: shapeStyles
|
|
2533
|
+
};
|
|
2534
|
+
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
2568
2535
|
};
|
|
2536
|
+
return seriesData.map(mapper);
|
|
2569
2537
|
}
|
|
2570
|
-
function
|
|
2571
|
-
|
|
2572
|
-
|
|
2538
|
+
function processPointData(pointData, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape) {
|
|
2539
|
+
const mapper = (point, index) => {
|
|
2540
|
+
const { color, glyph, shapeStyles } = getElementStyles({
|
|
2541
|
+
data: point,
|
|
2542
|
+
index,
|
|
2543
|
+
legendShape
|
|
2544
|
+
});
|
|
2545
|
+
const baseItem = {
|
|
2546
|
+
label: point.label,
|
|
2547
|
+
value: formatPointValue(point, showValues, legendValueDisplay),
|
|
2548
|
+
color,
|
|
2549
|
+
shapeStyle: shapeStyles
|
|
2550
|
+
};
|
|
2551
|
+
return applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSize);
|
|
2573
2552
|
};
|
|
2574
|
-
return
|
|
2553
|
+
return pointData.map(mapper);
|
|
2575
2554
|
}
|
|
2576
|
-
function
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2555
|
+
function useChartLegendItems(data, options = {}, legendShape) {
|
|
2556
|
+
const {
|
|
2557
|
+
showValues = false,
|
|
2558
|
+
legendValueDisplay = "percentage",
|
|
2559
|
+
withGlyph = false,
|
|
2560
|
+
glyphSize = 8,
|
|
2561
|
+
renderGlyph
|
|
2562
|
+
} = options;
|
|
2563
|
+
const { getElementStyles } = useGlobalChartsContext();
|
|
2564
|
+
return useMemo11(() => {
|
|
2565
|
+
if (!data || !Array.isArray(data) || data.length === 0) {
|
|
2566
|
+
return [];
|
|
2567
|
+
}
|
|
2568
|
+
if ("data" in data[0]) {
|
|
2569
|
+
return processSeriesData(
|
|
2570
|
+
data,
|
|
2571
|
+
getElementStyles,
|
|
2572
|
+
showValues,
|
|
2573
|
+
withGlyph,
|
|
2574
|
+
glyphSize,
|
|
2575
|
+
renderGlyph,
|
|
2576
|
+
legendShape
|
|
2577
|
+
);
|
|
2580
2578
|
}
|
|
2581
|
-
return
|
|
2582
|
-
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2579
|
+
return processPointData(
|
|
2580
|
+
data,
|
|
2581
|
+
getElementStyles,
|
|
2582
|
+
showValues,
|
|
2583
|
+
legendValueDisplay,
|
|
2584
|
+
withGlyph,
|
|
2585
|
+
glyphSize,
|
|
2586
|
+
renderGlyph,
|
|
2587
|
+
legendShape
|
|
2588
|
+
);
|
|
2589
|
+
}, [
|
|
2590
|
+
data,
|
|
2591
|
+
getElementStyles,
|
|
2592
|
+
showValues,
|
|
2593
|
+
legendValueDisplay,
|
|
2594
|
+
withGlyph,
|
|
2595
|
+
glyphSize,
|
|
2596
|
+
renderGlyph,
|
|
2597
|
+
legendShape
|
|
2598
|
+
]);
|
|
2587
2599
|
}
|
|
2588
2600
|
|
|
2589
|
-
//
|
|
2590
|
-
|
|
2591
|
-
var EMPTY_OBJECT = Object.freeze({});
|
|
2601
|
+
// src/components/tooltip/base-tooltip.tsx
|
|
2602
|
+
import { formatNumber as formatNumber4 } from "@automattic/number-formatters";
|
|
2592
2603
|
|
|
2593
|
-
//
|
|
2594
|
-
var
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
|
|
2604
|
+
// src/components/tooltip/base-tooltip.module.scss
|
|
2605
|
+
var base_tooltip_module_default = {
|
|
2606
|
+
"tooltip": "a8ccharts-OfX6nd"
|
|
2607
|
+
};
|
|
2598
2608
|
|
|
2599
|
-
//
|
|
2600
|
-
import {
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
const {
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
} = params;
|
|
2623
|
-
const className = enabled ? resolveClassName(classNameProp, state) : void 0;
|
|
2624
|
-
const style = enabled ? resolveStyle(styleProp, state) : void 0;
|
|
2625
|
-
const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
|
|
2626
|
-
const outProps = enabled ? mergeObjects(stateProps, Array.isArray(props) ? mergePropsN(props) : props) ?? EMPTY_OBJECT : EMPTY_OBJECT;
|
|
2627
|
-
if (typeof document !== "undefined") {
|
|
2628
|
-
if (!enabled) {
|
|
2629
|
-
useMergedRefs(null, null);
|
|
2630
|
-
} else if (Array.isArray(ref)) {
|
|
2631
|
-
outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
|
|
2632
|
-
} else {
|
|
2633
|
-
outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
|
|
2634
|
-
}
|
|
2635
|
-
}
|
|
2636
|
-
if (!enabled) {
|
|
2637
|
-
return EMPTY_OBJECT;
|
|
2638
|
-
}
|
|
2639
|
-
if (className !== void 0) {
|
|
2640
|
-
outProps.className = mergeClassNames(outProps.className, className);
|
|
2641
|
-
}
|
|
2642
|
-
if (style !== void 0) {
|
|
2643
|
-
outProps.style = mergeObjects(outProps.style, style);
|
|
2609
|
+
// src/components/tooltip/base-tooltip.tsx
|
|
2610
|
+
import { Fragment as _Fragment, jsxs as _jsxs2, jsx as _jsx4 } from "react/jsx-runtime";
|
|
2611
|
+
var DefaultTooltipContent = ({
|
|
2612
|
+
data
|
|
2613
|
+
}) => /* @__PURE__ */ _jsxs2(_Fragment, {
|
|
2614
|
+
children: [data?.label, ": ", data?.valueDisplay || formatNumber4(data?.value)]
|
|
2615
|
+
});
|
|
2616
|
+
var BaseTooltip = ({
|
|
2617
|
+
data,
|
|
2618
|
+
top,
|
|
2619
|
+
left,
|
|
2620
|
+
component: Component2 = DefaultTooltipContent,
|
|
2621
|
+
children,
|
|
2622
|
+
className,
|
|
2623
|
+
style,
|
|
2624
|
+
renderContainer = true
|
|
2625
|
+
}) => {
|
|
2626
|
+
const content = children || data && /* @__PURE__ */ _jsx4(Component2, {
|
|
2627
|
+
data,
|
|
2628
|
+
className
|
|
2629
|
+
});
|
|
2630
|
+
if (!renderContainer) {
|
|
2631
|
+
return content;
|
|
2644
2632
|
}
|
|
2645
|
-
return
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2650
|
-
|
|
2651
|
-
|
|
2652
|
-
|
|
2633
|
+
return /* @__PURE__ */ _jsx4("div", {
|
|
2634
|
+
className: base_tooltip_module_default.tooltip,
|
|
2635
|
+
style: {
|
|
2636
|
+
top,
|
|
2637
|
+
left,
|
|
2638
|
+
...style
|
|
2639
|
+
},
|
|
2640
|
+
role: "tooltip",
|
|
2641
|
+
children: content
|
|
2642
|
+
});
|
|
2643
|
+
};
|
|
2644
|
+
|
|
2645
|
+
// src/components/tooltip/accessible-tooltip.tsx
|
|
2646
|
+
import { Tooltip, TooltipContext } from "@visx/xychart";
|
|
2647
|
+
import { useContext as useContext7, useEffect as useEffect6, useCallback as useCallback6, useMemo as useMemo12 } from "react";
|
|
2648
|
+
import { jsx as _jsx5 } from "react/jsx-runtime";
|
|
2649
|
+
var AccessibleTooltip = ({
|
|
2650
|
+
renderTooltip,
|
|
2651
|
+
selectedIndex,
|
|
2652
|
+
tooltipRef,
|
|
2653
|
+
keyboardFocusedClassName,
|
|
2654
|
+
series = [],
|
|
2655
|
+
mode = "group",
|
|
2656
|
+
...props
|
|
2657
|
+
}) => {
|
|
2658
|
+
const tooltipContext = useContext7(TooltipContext);
|
|
2659
|
+
const tooltipData = useMemo12(() => {
|
|
2660
|
+
if (mode !== "individual") return [];
|
|
2661
|
+
if (series.length === 0) return [];
|
|
2662
|
+
const maxDataPoints = Math.max(...series.map((s) => s.data.length));
|
|
2663
|
+
const flattened = [];
|
|
2664
|
+
for (let dataPointIndex = 0; dataPointIndex < maxDataPoints; dataPointIndex++) {
|
|
2665
|
+
for (let seriesIndex = 0; seriesIndex < series.length; seriesIndex++) {
|
|
2666
|
+
const seriesData = series[seriesIndex];
|
|
2667
|
+
if (dataPointIndex < seriesData.data.length) {
|
|
2668
|
+
flattened.push({
|
|
2669
|
+
datum: seriesData.data[dataPointIndex],
|
|
2670
|
+
seriesLabel: seriesData.label,
|
|
2671
|
+
seriesIndex,
|
|
2672
|
+
dataPointIndex
|
|
2673
|
+
});
|
|
2674
|
+
}
|
|
2653
2675
|
}
|
|
2654
|
-
return render(props, state);
|
|
2655
2676
|
}
|
|
2656
|
-
|
|
2657
|
-
|
|
2658
|
-
|
|
2659
|
-
if (
|
|
2660
|
-
|
|
2661
|
-
|
|
2677
|
+
return flattened;
|
|
2678
|
+
}, [series, mode]);
|
|
2679
|
+
useEffect6(() => {
|
|
2680
|
+
if (selectedIndex === void 0) {
|
|
2681
|
+
tooltipContext?.hideTooltip();
|
|
2682
|
+
return;
|
|
2662
2683
|
}
|
|
2663
|
-
if (
|
|
2664
|
-
|
|
2665
|
-
|
|
2684
|
+
if (mode === "group") {
|
|
2685
|
+
series.forEach((s, index) => {
|
|
2686
|
+
if (selectedIndex < s.data.length) {
|
|
2687
|
+
const datum = s.data[selectedIndex];
|
|
2688
|
+
tooltipContext?.showTooltip({
|
|
2689
|
+
datum,
|
|
2690
|
+
key: s.label,
|
|
2691
|
+
index
|
|
2692
|
+
});
|
|
2693
|
+
}
|
|
2694
|
+
});
|
|
2695
|
+
} else if (mode === "individual") {
|
|
2696
|
+
if (selectedIndex < tooltipData.length) {
|
|
2697
|
+
const tooltipItem = tooltipData[selectedIndex];
|
|
2698
|
+
tooltipContext?.showTooltip({
|
|
2699
|
+
datum: tooltipItem.datum,
|
|
2700
|
+
key: tooltipItem.seriesLabel,
|
|
2701
|
+
index: tooltipItem.seriesIndex
|
|
2702
|
+
});
|
|
2666
2703
|
}
|
|
2667
2704
|
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2705
|
+
}, [selectedIndex, tooltipData, series]);
|
|
2706
|
+
const focusableRenderTooltip = useMemo12(() => {
|
|
2707
|
+
if (!renderTooltip) return void 0;
|
|
2708
|
+
return (params) => {
|
|
2709
|
+
const tooltipContent = renderTooltip(params);
|
|
2710
|
+
if (selectedIndex !== void 0) {
|
|
2711
|
+
return /* @__PURE__ */ _jsx5("div", {
|
|
2712
|
+
ref: tooltipRef,
|
|
2713
|
+
tabIndex: -1,
|
|
2714
|
+
role: "tooltip",
|
|
2715
|
+
"aria-atomic": "true",
|
|
2716
|
+
className: keyboardFocusedClassName,
|
|
2717
|
+
children: tooltipContent
|
|
2718
|
+
}, `chart-tooltip-${selectedIndex}`);
|
|
2719
|
+
}
|
|
2720
|
+
return /* @__PURE__ */ _jsx5("div", {
|
|
2721
|
+
role: "tooltip",
|
|
2722
|
+
"aria-live": "polite",
|
|
2723
|
+
children: tooltipContent
|
|
2724
|
+
});
|
|
2725
|
+
};
|
|
2726
|
+
}, [renderTooltip, selectedIndex, tooltipRef, keyboardFocusedClassName]);
|
|
2727
|
+
return /* @__PURE__ */ _jsx5(Tooltip, {
|
|
2728
|
+
...props,
|
|
2729
|
+
renderTooltip: focusableRenderTooltip
|
|
2730
|
+
});
|
|
2731
|
+
};
|
|
2732
|
+
var useKeyboardNavigation = ({
|
|
2733
|
+
selectedIndex,
|
|
2734
|
+
setSelectedIndex,
|
|
2735
|
+
isNavigating,
|
|
2736
|
+
setIsNavigating,
|
|
2737
|
+
chartRef,
|
|
2738
|
+
totalPoints
|
|
2739
|
+
}) => {
|
|
2740
|
+
const tooltipRef = useCallback6((element) => {
|
|
2741
|
+
if (element && selectedIndex !== void 0) {
|
|
2742
|
+
element.focus();
|
|
2743
|
+
}
|
|
2744
|
+
}, [selectedIndex]);
|
|
2745
|
+
const onChartFocus = useCallback6(() => {
|
|
2746
|
+
if (!isNavigating && selectedIndex !== void 0) {
|
|
2747
|
+
setSelectedIndex(0);
|
|
2748
|
+
}
|
|
2749
|
+
}, [isNavigating, selectedIndex, setSelectedIndex]);
|
|
2750
|
+
const onChartBlur = useCallback6(() => {
|
|
2751
|
+
setIsNavigating(false);
|
|
2752
|
+
}, [setIsNavigating]);
|
|
2753
|
+
const onChartKeyDown = useCallback6((event) => {
|
|
2754
|
+
if (totalPoints === 0) return;
|
|
2755
|
+
if (event.key === "Tab") {
|
|
2756
|
+
chartRef.current?.focus();
|
|
2757
|
+
setSelectedIndex(void 0);
|
|
2758
|
+
setIsNavigating(false);
|
|
2759
|
+
return;
|
|
2760
|
+
}
|
|
2761
|
+
const currentSelectedIndex = selectedIndex === void 0 ? -1 : selectedIndex;
|
|
2762
|
+
if (currentSelectedIndex + 1 >= totalPoints && ["ArrowRight"].includes(event.key)) {
|
|
2763
|
+
chartRef.current?.focus();
|
|
2764
|
+
setSelectedIndex(void 0);
|
|
2765
|
+
setIsNavigating(false);
|
|
2766
|
+
return;
|
|
2673
2767
|
}
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
|
|
2679
|
-
|
|
2680
|
-
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2688
|
-
|
|
2689
|
-
|
|
2690
|
-
|
|
2691
|
-
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
});
|
|
2695
|
-
}
|
|
2696
|
-
if (Tag === "img") {
|
|
2697
|
-
return /* @__PURE__ */ _createElement("img", {
|
|
2698
|
-
alt: "",
|
|
2699
|
-
...props,
|
|
2700
|
-
key: props.key
|
|
2701
|
-
});
|
|
2702
|
-
}
|
|
2703
|
-
return /* @__PURE__ */ React4.createElement(Tag, props);
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
// ../../../node_modules/.pnpm/@base-ui+react@1.3.0_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/esm/use-render/useRender.js
|
|
2707
|
-
function useRender(params) {
|
|
2708
|
-
return useRenderElement(params.defaultTagName ?? "div", params, params);
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
// ../../../node_modules/.pnpm/@wordpress+element@6.43.0/node_modules/@wordpress/element/build-module/react.mjs
|
|
2712
|
-
import {
|
|
2713
|
-
Children as Children3,
|
|
2714
|
-
cloneElement as cloneElement2,
|
|
2715
|
-
Component,
|
|
2716
|
-
createContext as createContext3,
|
|
2717
|
-
createElement as createElement3,
|
|
2718
|
-
createRef,
|
|
2719
|
-
forwardRef as forwardRef3,
|
|
2720
|
-
Fragment as Fragment2,
|
|
2721
|
-
isValidElement as isValidElement4,
|
|
2722
|
-
memo,
|
|
2723
|
-
PureComponent,
|
|
2724
|
-
StrictMode,
|
|
2725
|
-
useCallback as useCallback6,
|
|
2726
|
-
useContext as useContext7,
|
|
2727
|
-
useDebugValue,
|
|
2728
|
-
useDeferredValue,
|
|
2729
|
-
useEffect as useEffect6,
|
|
2730
|
-
useId as useId2,
|
|
2731
|
-
useMemo as useMemo13,
|
|
2732
|
-
useImperativeHandle,
|
|
2733
|
-
useInsertionEffect,
|
|
2734
|
-
useLayoutEffect as useLayoutEffect2,
|
|
2735
|
-
useReducer,
|
|
2736
|
-
useRef as useRef6,
|
|
2737
|
-
useState as useState5,
|
|
2738
|
-
useSyncExternalStore,
|
|
2739
|
-
useTransition,
|
|
2740
|
-
startTransition,
|
|
2741
|
-
lazy,
|
|
2742
|
-
Suspense
|
|
2743
|
-
} from "react";
|
|
2744
|
-
|
|
2745
|
-
// ../../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs
|
|
2746
|
-
function isObject(o) {
|
|
2747
|
-
return Object.prototype.toString.call(o) === "[object Object]";
|
|
2748
|
-
}
|
|
2749
|
-
function isPlainObject(o) {
|
|
2750
|
-
var ctor, prot;
|
|
2751
|
-
if (isObject(o) === false) return false;
|
|
2752
|
-
ctor = o.constructor;
|
|
2753
|
-
if (ctor === void 0) return true;
|
|
2754
|
-
prot = ctor.prototype;
|
|
2755
|
-
if (isObject(prot) === false) return false;
|
|
2756
|
-
if (prot.hasOwnProperty("isPrototypeOf") === false) {
|
|
2757
|
-
return false;
|
|
2758
|
-
}
|
|
2759
|
-
return true;
|
|
2760
|
-
}
|
|
2761
|
-
|
|
2762
|
-
// ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist.es2015/index.js
|
|
2763
|
-
function lowerCase(str) {
|
|
2764
|
-
return str.toLowerCase();
|
|
2765
|
-
}
|
|
2766
|
-
|
|
2767
|
-
// ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist.es2015/index.js
|
|
2768
|
-
var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
|
|
2769
|
-
var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
|
|
2770
|
-
function noCase(input, options) {
|
|
2771
|
-
if (options === void 0) {
|
|
2772
|
-
options = {};
|
|
2773
|
-
}
|
|
2774
|
-
var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter2 = _d === void 0 ? " " : _d;
|
|
2775
|
-
var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
|
|
2776
|
-
var start = 0;
|
|
2777
|
-
var end = result.length;
|
|
2778
|
-
while (result.charAt(start) === "\0")
|
|
2779
|
-
start++;
|
|
2780
|
-
while (result.charAt(end - 1) === "\0")
|
|
2781
|
-
end--;
|
|
2782
|
-
return result.slice(start, end).split("\0").map(transform).join(delimiter2);
|
|
2783
|
-
}
|
|
2784
|
-
function replace(input, re, value) {
|
|
2785
|
-
if (re instanceof RegExp)
|
|
2786
|
-
return input.replace(re, value);
|
|
2787
|
-
return re.reduce(function(input2, re2) {
|
|
2788
|
-
return input2.replace(re2, value);
|
|
2789
|
-
}, input);
|
|
2790
|
-
}
|
|
2768
|
+
event.preventDefault();
|
|
2769
|
+
if (["ArrowRight"].includes(event.key)) {
|
|
2770
|
+
setIsNavigating(true);
|
|
2771
|
+
setSelectedIndex((currentSelectedIndex + 1) % totalPoints);
|
|
2772
|
+
} else if (["ArrowLeft"].includes(event.key)) {
|
|
2773
|
+
setIsNavigating(true);
|
|
2774
|
+
setSelectedIndex((currentSelectedIndex - 1 + totalPoints) % totalPoints);
|
|
2775
|
+
} else if (event.key === "Escape") {
|
|
2776
|
+
setSelectedIndex(void 0);
|
|
2777
|
+
setIsNavigating(false);
|
|
2778
|
+
chartRef.current?.focus();
|
|
2779
|
+
}
|
|
2780
|
+
}, [totalPoints, selectedIndex, setSelectedIndex, setIsNavigating, chartRef]);
|
|
2781
|
+
return {
|
|
2782
|
+
tooltipRef,
|
|
2783
|
+
onChartFocus,
|
|
2784
|
+
onChartBlur,
|
|
2785
|
+
onChartKeyDown
|
|
2786
|
+
};
|
|
2787
|
+
};
|
|
2791
2788
|
|
|
2792
|
-
//
|
|
2793
|
-
import {
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2798
|
-
|
|
2799
|
-
}
|
|
2789
|
+
// src/charts/private/chart-composition/chart-svg.tsx
|
|
2790
|
+
import { Fragment as _Fragment2, jsx as _jsx6 } from "react/jsx-runtime";
|
|
2791
|
+
var ChartSVG = ({
|
|
2792
|
+
children
|
|
2793
|
+
}) => {
|
|
2794
|
+
return /* @__PURE__ */ _jsx6(_Fragment2, {
|
|
2795
|
+
children
|
|
2796
|
+
});
|
|
2797
|
+
};
|
|
2798
|
+
ChartSVG.displayName = "Chart.SVG";
|
|
2800
2799
|
|
|
2801
|
-
//
|
|
2802
|
-
import {
|
|
2803
|
-
|
|
2804
|
-
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
|
|
2808
|
-
}
|
|
2800
|
+
// src/charts/private/chart-composition/chart-html.tsx
|
|
2801
|
+
import { Fragment as _Fragment3, jsx as _jsx7 } from "react/jsx-runtime";
|
|
2802
|
+
var ChartHTML = ({
|
|
2803
|
+
children
|
|
2804
|
+
}) => {
|
|
2805
|
+
return /* @__PURE__ */ _jsx7(_Fragment3, {
|
|
2806
|
+
children
|
|
2807
|
+
});
|
|
2808
|
+
};
|
|
2809
|
+
ChartHTML.displayName = "Chart.HTML";
|
|
2809
2810
|
|
|
2810
|
-
//
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2811
|
+
// src/charts/private/chart-composition/render-legend-slot.ts
|
|
2812
|
+
import { createElement as createElement3, Fragment as Fragment2 } from "react";
|
|
2813
|
+
function renderLegendSlot(legendChildren, position2) {
|
|
2814
|
+
return legendChildren.filter((l) => l.position === position2).map(
|
|
2815
|
+
(l, i) => createElement3(Fragment2, { key: `legend-${position2}-${i}` }, l.element)
|
|
2816
|
+
);
|
|
2816
2817
|
}
|
|
2817
|
-
var style_default = { "stack": "_19ce0419607e1896__stack" };
|
|
2818
|
-
var gapTokens = {
|
|
2819
|
-
xs: "var(--wpds-dimension-gap-xs, 4px)",
|
|
2820
|
-
sm: "var(--wpds-dimension-gap-sm, 8px)",
|
|
2821
|
-
md: "var(--wpds-dimension-gap-md, 12px)",
|
|
2822
|
-
lg: "var(--wpds-dimension-gap-lg, 16px)",
|
|
2823
|
-
xl: "var(--wpds-dimension-gap-xl, 24px)",
|
|
2824
|
-
"2xl": "var(--wpds-dimension-gap-2xl, 32px)",
|
|
2825
|
-
"3xl": "var(--wpds-dimension-gap-3xl, 40px)"
|
|
2826
|
-
};
|
|
2827
|
-
var Stack = forwardRef3(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
|
|
2828
|
-
const style = {
|
|
2829
|
-
gap: gap && gapTokens[gap],
|
|
2830
|
-
alignItems: align,
|
|
2831
|
-
justifyContent: justify,
|
|
2832
|
-
flexDirection: direction,
|
|
2833
|
-
flexWrap: wrap
|
|
2834
|
-
};
|
|
2835
|
-
const element = useRender({
|
|
2836
|
-
render,
|
|
2837
|
-
ref,
|
|
2838
|
-
props: mergeProps(props, { style, className: style_default.stack })
|
|
2839
|
-
});
|
|
2840
|
-
return element;
|
|
2841
|
-
});
|
|
2842
2818
|
|
|
2843
|
-
//
|
|
2844
|
-
import
|
|
2845
|
-
|
|
2846
|
-
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2819
|
+
// src/charts/private/chart-composition/use-chart-children.ts
|
|
2820
|
+
import { Group as Group2 } from "@visx/group";
|
|
2821
|
+
import { useMemo as useMemo13, Children as Children3, isValidElement as isValidElement4 } from "react";
|
|
2822
|
+
function useChartChildren(children, chartType) {
|
|
2823
|
+
return useMemo13(() => {
|
|
2824
|
+
const svg = [];
|
|
2825
|
+
const html = [];
|
|
2826
|
+
const legend = [];
|
|
2827
|
+
const other = [];
|
|
2828
|
+
const nonLegend = [];
|
|
2829
|
+
Children3.forEach(children, (child) => {
|
|
2830
|
+
if (isValidElement4(child)) {
|
|
2831
|
+
if (child.type === Legend) {
|
|
2832
|
+
const rawPosition = child.props?.position;
|
|
2833
|
+
const position2 = rawPosition === "top" || rawPosition === "bottom" ? rawPosition : "bottom";
|
|
2834
|
+
legend.push({ element: child, position: position2 });
|
|
2835
|
+
return;
|
|
2836
|
+
}
|
|
2837
|
+
const childType = child.type;
|
|
2838
|
+
const displayName = childType?.displayName;
|
|
2839
|
+
if (displayName === `${chartType}.SVG` || displayName === "Chart.SVG") {
|
|
2840
|
+
if (child.props?.children) {
|
|
2841
|
+
Children3.forEach(child.props.children, (svgChild) => {
|
|
2842
|
+
svg.push(svgChild);
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
} else if (displayName === `${chartType}.HTML` || displayName === "Chart.HTML") {
|
|
2846
|
+
if (child.props?.children) {
|
|
2847
|
+
Children3.forEach(child.props.children, (htmlChild) => {
|
|
2848
|
+
html.push(htmlChild);
|
|
2849
|
+
});
|
|
2850
|
+
}
|
|
2851
|
+
} else if (child.type === Group2) {
|
|
2852
|
+
svg.push(child);
|
|
2853
|
+
} else {
|
|
2854
|
+
other.push(child);
|
|
2855
|
+
}
|
|
2856
|
+
}
|
|
2857
|
+
nonLegend.push(child);
|
|
2858
|
+
});
|
|
2859
|
+
return {
|
|
2860
|
+
svgChildren: svg,
|
|
2861
|
+
htmlChildren: html,
|
|
2862
|
+
legendChildren: legend,
|
|
2863
|
+
otherChildren: other,
|
|
2864
|
+
nonLegendChildren: nonLegend
|
|
2865
|
+
};
|
|
2866
|
+
}, [children, chartType]);
|
|
2850
2867
|
}
|
|
2851
|
-
var style_default2 = { "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
|
|
2852
|
-
var Text = forwardRef3(function Text2({ variant = "body-md", render, className, ...props }, ref) {
|
|
2853
|
-
const element = useRender({
|
|
2854
|
-
render,
|
|
2855
|
-
defaultTagName: "span",
|
|
2856
|
-
ref,
|
|
2857
|
-
props: mergeProps(props, {
|
|
2858
|
-
className: clsx2(style_default2[variant], className)
|
|
2859
|
-
})
|
|
2860
|
-
});
|
|
2861
|
-
return element;
|
|
2862
|
-
});
|
|
2863
2868
|
|
|
2864
2869
|
// src/charts/private/chart-layout/chart-layout.tsx
|
|
2865
2870
|
import { useEffect as useEffect7 } from "react";
|
|
@@ -3808,7 +3813,6 @@ var conversion_funnel_chart_module_default = {
|
|
|
3808
3813
|
"funnel-step": "a8ccharts-VqFY0l",
|
|
3809
3814
|
"funnel-step--animated": "a8ccharts-fk-hCl",
|
|
3810
3815
|
"funnel-step--blurred": "a8ccharts-1zOc9c",
|
|
3811
|
-
"step-header": "a8ccharts-2JsQiV",
|
|
3812
3816
|
"step-label": "a8ccharts-6OabC4",
|
|
3813
3817
|
"step-rate": "a8ccharts-9wSZ6n",
|
|
3814
3818
|
"bar-container": "a8ccharts-sSmCTi",
|
|
@@ -4048,7 +4052,10 @@ var ConversionFunnelChartInternal = ({
|
|
|
4048
4052
|
children: changeIndicator
|
|
4049
4053
|
})]
|
|
4050
4054
|
});
|
|
4051
|
-
const renderDefaultTooltip2 = (step) => /* @__PURE__ */ _jsxs6(
|
|
4055
|
+
const renderDefaultTooltip2 = (step) => /* @__PURE__ */ _jsxs6(Stack, {
|
|
4056
|
+
direction: "column",
|
|
4057
|
+
align: "flex-start",
|
|
4058
|
+
gap: "xs",
|
|
4052
4059
|
children: [/* @__PURE__ */ _jsx14("div", {
|
|
4053
4060
|
className: conversion_funnel_chart_module_default["tooltip-title"],
|
|
4054
4061
|
children: step.label
|
|
@@ -4089,6 +4096,7 @@ var ConversionFunnelChartInternal = ({
|
|
|
4089
4096
|
return /* @__PURE__ */ _jsxs6(_Fragment5, {
|
|
4090
4097
|
children: [/* @__PURE__ */ _jsxs6(Stack, {
|
|
4091
4098
|
direction: "column",
|
|
4099
|
+
gap: "xl",
|
|
4092
4100
|
ref: (node2) => {
|
|
4093
4101
|
portalContainerRef(node2);
|
|
4094
4102
|
chartRef.current = node2;
|
|
@@ -4103,20 +4111,27 @@ var ConversionFunnelChartInternal = ({
|
|
|
4103
4111
|
changeIndicator,
|
|
4104
4112
|
className: conversion_funnel_chart_module_default["main-metric"],
|
|
4105
4113
|
changeColor
|
|
4106
|
-
}) : /* @__PURE__ */ _jsx14(
|
|
4114
|
+
}) : /* @__PURE__ */ _jsx14(Stack, {
|
|
4115
|
+
direction: "row",
|
|
4116
|
+
align: "baseline",
|
|
4117
|
+
gap: "sm",
|
|
4107
4118
|
className: conversion_funnel_chart_module_default["main-metric"],
|
|
4108
4119
|
children: renderDefaultMainMetric()
|
|
4109
|
-
}), /* @__PURE__ */ _jsx14(
|
|
4120
|
+
}), /* @__PURE__ */ _jsx14(Stack, {
|
|
4121
|
+
direction: "row",
|
|
4122
|
+
align: "flex-end",
|
|
4123
|
+
gap: "lg",
|
|
4110
4124
|
className: conversion_funnel_chart_module_default["funnel-container"],
|
|
4111
4125
|
children: steps.map((step, index) => {
|
|
4112
4126
|
const barHeight = step.rate / maxRate * 100;
|
|
4113
4127
|
const {
|
|
4114
4128
|
isBlurred
|
|
4115
4129
|
} = getStepState(step.id);
|
|
4116
|
-
return /* @__PURE__ */ _jsxs6(
|
|
4130
|
+
return /* @__PURE__ */ _jsxs6(Stack, {
|
|
4131
|
+
direction: "column",
|
|
4117
4132
|
className: clsx4(conversion_funnel_chart_module_default["funnel-step"], isColorPaletteResolved && conversion_funnel_chart_module_default["funnel-step--animated"], isBlurred && conversion_funnel_chart_module_default["funnel-step--blurred"]),
|
|
4133
|
+
gap: "xl",
|
|
4118
4134
|
children: [/* @__PURE__ */ _jsxs6("div", {
|
|
4119
|
-
className: conversion_funnel_chart_module_default["step-header"],
|
|
4120
4135
|
children: [renderStepLabel ? renderStepLabel({
|
|
4121
4136
|
step,
|
|
4122
4137
|
index,
|
|
@@ -4132,7 +4147,9 @@ var ConversionFunnelChartInternal = ({
|
|
|
4132
4147
|
className: conversion_funnel_chart_module_default["step-rate"],
|
|
4133
4148
|
children: formatPercentage(step.rate)
|
|
4134
4149
|
})]
|
|
4135
|
-
}), /* @__PURE__ */ _jsx14(
|
|
4150
|
+
}), /* @__PURE__ */ _jsx14(Stack, {
|
|
4151
|
+
direction: "column",
|
|
4152
|
+
justify: "flex-end",
|
|
4136
4153
|
className: conversion_funnel_chart_module_default["bar-container"],
|
|
4137
4154
|
onClick: stepHandlers.get(step.id)?.onClick,
|
|
4138
4155
|
onKeyDown: stepHandlers.get(step.id)?.onKeyDown,
|
|
@@ -4262,7 +4279,9 @@ var GeoChartInternal = ({
|
|
|
4262
4279
|
backgroundColor
|
|
4263
4280
|
}
|
|
4264
4281
|
} = useGlobalChartsContext();
|
|
4265
|
-
const loadingPlaceholder = /* @__PURE__ */ _jsx15(
|
|
4282
|
+
const loadingPlaceholder = /* @__PURE__ */ _jsx15(Stack, {
|
|
4283
|
+
align: "center",
|
|
4284
|
+
justify: "center",
|
|
4266
4285
|
className: clsx5("geo-chart", geo_chart_module_default.container, className),
|
|
4267
4286
|
style: {
|
|
4268
4287
|
width,
|
|
@@ -4330,7 +4349,9 @@ var GeoChartInternal = ({
|
|
|
4330
4349
|
legend: "none",
|
|
4331
4350
|
keepAspectRatio: true
|
|
4332
4351
|
}), [region, resolution, lightColorHex, fullColorHex, backgroundColorHex, defaultFillColorHex, sanitizedData.hasHtmlTooltips]);
|
|
4333
|
-
return /* @__PURE__ */ _jsx15(
|
|
4352
|
+
return /* @__PURE__ */ _jsx15(Stack, {
|
|
4353
|
+
align: "center",
|
|
4354
|
+
justify: "center",
|
|
4334
4355
|
className: clsx5("geo-chart", geo_chart_module_default.container, className),
|
|
4335
4356
|
style: {
|
|
4336
4357
|
width,
|
|
@@ -4366,14 +4387,14 @@ var GeoChartResponsive = withResponsive(GeoChartWithProvider);
|
|
|
4366
4387
|
// ../../../node_modules/.pnpm/@wordpress+components@32.5.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/components/build-module/utils/hooks/use-update-effect.mjs
|
|
4367
4388
|
function useUpdateEffect(effect, deps) {
|
|
4368
4389
|
const mountedRef = useRef6(false);
|
|
4369
|
-
|
|
4390
|
+
useEffect5(() => {
|
|
4370
4391
|
if (mountedRef.current) {
|
|
4371
4392
|
return effect();
|
|
4372
4393
|
}
|
|
4373
4394
|
mountedRef.current = true;
|
|
4374
4395
|
return void 0;
|
|
4375
4396
|
}, deps);
|
|
4376
|
-
|
|
4397
|
+
useEffect5(() => () => {
|
|
4377
4398
|
mountedRef.current = false;
|
|
4378
4399
|
}, []);
|
|
4379
4400
|
}
|
|
@@ -5821,7 +5842,7 @@ var cache = _createEmotion.cache;
|
|
|
5821
5842
|
var isSerializedStyles = (o) => typeof o !== "undefined" && o !== null && ["name", "styles"].every((p) => typeof o[p] !== "undefined");
|
|
5822
5843
|
var useCx = () => {
|
|
5823
5844
|
const cache2 = __unsafe_useEmotionCache();
|
|
5824
|
-
const cx2 =
|
|
5845
|
+
const cx2 = useCallback4((...classNames) => {
|
|
5825
5846
|
if (cache2 === null) {
|
|
5826
5847
|
throw new Error("The `useCx` hook should be only used within a valid Emotion Cache Context");
|
|
5827
5848
|
}
|
|
@@ -6086,7 +6107,7 @@ var ComponentsContext = createContext3(
|
|
|
6086
6107
|
{}
|
|
6087
6108
|
);
|
|
6088
6109
|
ComponentsContext.displayName = "ComponentsContext";
|
|
6089
|
-
var useComponentsContext = () =>
|
|
6110
|
+
var useComponentsContext = () => useContext4(ComponentsContext);
|
|
6090
6111
|
function useContextSystemBridge({
|
|
6091
6112
|
value
|
|
6092
6113
|
}) {
|
|
@@ -6101,7 +6122,7 @@ function useContextSystemBridge({
|
|
|
6101
6122
|
globalThis.SCRIPT_DEBUG === true ? warning(`Please memoize your context: ${JSON.stringify(value)}`) : void 0;
|
|
6102
6123
|
}
|
|
6103
6124
|
}, [value]);
|
|
6104
|
-
const config =
|
|
6125
|
+
const config = useMemo9(() => {
|
|
6105
6126
|
return deepmerge2(parentContext ?? {}, value ?? {}, {
|
|
6106
6127
|
isMergeableObject: isPlainObject
|
|
6107
6128
|
});
|
|
@@ -6141,7 +6162,7 @@ function contextConnect(Component2, namespace) {
|
|
|
6141
6162
|
});
|
|
6142
6163
|
}
|
|
6143
6164
|
function _contextConnect(Component2, namespace, options) {
|
|
6144
|
-
const WrappedComponent = options?.forwardsRef ?
|
|
6165
|
+
const WrappedComponent = options?.forwardsRef ? forwardRef(Component2) : Component2;
|
|
6145
6166
|
if (typeof namespace === "undefined") {
|
|
6146
6167
|
globalThis.SCRIPT_DEBUG === true ? warning("contextConnect: Please provide a namespace") : void 0;
|
|
6147
6168
|
}
|
|
@@ -6373,7 +6394,7 @@ function UnforwardedView({
|
|
|
6373
6394
|
...restProps
|
|
6374
6395
|
});
|
|
6375
6396
|
}
|
|
6376
|
-
var View = Object.assign(
|
|
6397
|
+
var View = Object.assign(forwardRef(UnforwardedView), {
|
|
6377
6398
|
selector: ".components-view"
|
|
6378
6399
|
});
|
|
6379
6400
|
var component_default = View;
|
|
@@ -6390,7 +6411,7 @@ var useBreakpointIndex = (options = {}) => {
|
|
|
6390
6411
|
throw new RangeError(`Default breakpoint index out of range. Theme has ${breakpoints.length} breakpoints, got index ${defaultIndex}`);
|
|
6391
6412
|
}
|
|
6392
6413
|
const [value, setValue] = useState5(defaultIndex);
|
|
6393
|
-
|
|
6414
|
+
useEffect5(() => {
|
|
6394
6415
|
const getIndex = () => breakpoints.filter((bp) => {
|
|
6395
6416
|
return typeof window !== "undefined" ? window.matchMedia(`screen and (min-width: ${bp})`).matches : false;
|
|
6396
6417
|
}).length;
|
|
@@ -6496,7 +6517,7 @@ function useGrid(props) {
|
|
|
6496
6517
|
const gridTemplateColumns = templateColumns || !!columns && `repeat( ${column2}, 1fr )`;
|
|
6497
6518
|
const gridTemplateRows = templateRows || !!rows && `repeat( ${row}, 1fr )`;
|
|
6498
6519
|
const cx2 = useCx();
|
|
6499
|
-
const classes =
|
|
6520
|
+
const classes = useMemo9(() => {
|
|
6500
6521
|
const alignmentProps = getAlignmentProps(alignment);
|
|
6501
6522
|
const gridClasses = /* @__PURE__ */ css({
|
|
6502
6523
|
alignItems: align,
|
|
@@ -6826,7 +6847,7 @@ var LeaderboardChartInternal = ({
|
|
|
6826
6847
|
children: data.map((entry) => {
|
|
6827
6848
|
const colorIndex = Math.sign(entry.delta) + 1;
|
|
6828
6849
|
const deltaColor = deltaColors[colorIndex];
|
|
6829
|
-
return /* @__PURE__ */ _jsxs7(
|
|
6850
|
+
return /* @__PURE__ */ _jsxs7(Fragment, {
|
|
6830
6851
|
children: [/* @__PURE__ */ _jsx19(Stack, {
|
|
6831
6852
|
direction: "column",
|
|
6832
6853
|
gap: labelSpacing,
|
|
@@ -6930,7 +6951,6 @@ var line_chart_module_default = {
|
|
|
6930
6951
|
"line-chart__annotation-label-trigger-button": "a8ccharts-7mh3Cl",
|
|
6931
6952
|
"line-chart__annotation-label-popover--visible": "a8ccharts-VAeVuJ",
|
|
6932
6953
|
"line-chart__annotation-label-popover--safari": "a8ccharts-TEe-iV",
|
|
6933
|
-
"line-chart__annotation-label-popover-header": "a8ccharts-LAUpx7",
|
|
6934
6954
|
"line-chart__annotation-label-popover-content": "a8ccharts-b76gEu",
|
|
6935
6955
|
"line-chart__annotation-label-popover-close-button": "a8ccharts-LIpFoS"
|
|
6936
6956
|
};
|
|
@@ -6998,8 +7018,10 @@ var LineChartAnnotationLabelWithPopover = ({
|
|
|
6998
7018
|
id: popoverId,
|
|
6999
7019
|
popover: "auto",
|
|
7000
7020
|
className: clsx7(line_chart_module_default["line-chart__annotation-label-popover"], isPositioned && line_chart_module_default["line-chart__annotation-label-popover--visible"], isBrowserSafari && line_chart_module_default["line-chart__annotation-label-popover--safari"]),
|
|
7001
|
-
children: /* @__PURE__ */ _jsxs8(
|
|
7002
|
-
|
|
7021
|
+
children: /* @__PURE__ */ _jsxs8(Stack, {
|
|
7022
|
+
direction: "row",
|
|
7023
|
+
align: "flex-start",
|
|
7024
|
+
justify: "space-between",
|
|
7003
7025
|
children: [/* @__PURE__ */ _jsx21("div", {
|
|
7004
7026
|
className: line_chart_module_default["line-chart__annotation-label-popover-content"],
|
|
7005
7027
|
children: renderLabelPopover({
|
|
@@ -7442,7 +7464,10 @@ var renderDefaultTooltip = (params) => {
|
|
|
7442
7464
|
children: [/* @__PURE__ */ _jsx24("div", {
|
|
7443
7465
|
className: line_chart_module_default["line-chart__tooltip-date"],
|
|
7444
7466
|
children: nearestDatum.date?.toLocaleDateString()
|
|
7445
|
-
}), tooltipPoints.map((point) => /* @__PURE__ */ _jsxs10(
|
|
7467
|
+
}), tooltipPoints.map((point) => /* @__PURE__ */ _jsxs10(Stack, {
|
|
7468
|
+
direction: "row",
|
|
7469
|
+
align: "center",
|
|
7470
|
+
justify: "space-between",
|
|
7446
7471
|
className: line_chart_module_default["line-chart__tooltip-row"],
|
|
7447
7472
|
children: [/* @__PURE__ */ _jsxs10("span", {
|
|
7448
7473
|
className: line_chart_module_default["line-chart__tooltip-label"],
|