@automattic/charts 1.11.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/TOKENS.md +19 -1
  3. package/dist/index.cjs +2196 -2711
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.css +23 -43
  6. package/dist/index.d.cts +72 -6
  7. package/dist/index.d.ts +72 -6
  8. package/dist/index.js +278 -792
  9. package/dist/index.js.map +1 -1
  10. package/package.json +5 -4
  11. package/src/charts/area-chart/area-chart.tsx +31 -10
  12. package/src/charts/area-chart/test/area-chart.test.tsx +102 -0
  13. package/src/charts/area-chart/types.ts +20 -6
  14. package/src/charts/bar-chart/bar-chart.tsx +33 -9
  15. package/src/charts/bar-chart/test/bar-chart.test.tsx +117 -0
  16. package/src/charts/conversion-funnel-chart/conversion-funnel-chart.module.scss +7 -7
  17. package/src/charts/line-chart/line-chart.module.scss +3 -3
  18. package/src/charts/line-chart/line-chart.tsx +43 -7
  19. package/src/charts/line-chart/test/line-chart.test.tsx +234 -5
  20. package/src/charts/line-chart/types.ts +14 -0
  21. package/src/charts/pie-semi-circle-chart/pie-semi-circle-chart.module.scss +1 -1
  22. package/src/charts/private/test/time-axis.test.ts +182 -0
  23. package/src/charts/private/time-axis.ts +84 -5
  24. package/src/charts/private/x-zoom/index.ts +1 -0
  25. package/src/charts/private/{test → x-zoom/test}/x-zoom.test.tsx +92 -4
  26. package/src/charts/private/x-zoom/x-zoom.module.scss +35 -0
  27. package/src/charts/private/{x-zoom.tsx → x-zoom/x-zoom.tsx} +44 -27
  28. package/src/components/legend/hooks/test/use-chart-legend-items.test.tsx +152 -0
  29. package/src/components/legend/hooks/use-chart-legend-items.ts +118 -16
  30. package/src/components/legend/private/base-legend.module.scss +1 -1
  31. package/src/components/legend/private/base-legend.tsx +21 -9
  32. package/src/components/legend/test/legend-config-types.test.tsx +32 -0
  33. package/src/components/legend/test/legend.test.tsx +121 -1
  34. package/src/components/legend/types.ts +6 -0
  35. package/src/components/tooltip/base-tooltip.module.scss +1 -1
  36. package/src/components/trend-indicator/trend-indicator.module.scss +1 -1
  37. package/src/index.ts +2 -0
  38. package/src/types.ts +31 -0
  39. package/src/charts/private/x-zoom.module.scss +0 -50
package/dist/index.js CHANGED
@@ -14,8 +14,7 @@ import { useTooltip, useTooltipInPortal } from "@visx/tooltip";
14
14
  import { createScale, getTicks, scaleBand, scaleOrdinal, scaleTime } from "@visx/scale";
15
15
  import { Group } from "@visx/group";
16
16
  import { LegendItem, LegendLabel, LegendOrdinal, LegendShape } from "@visx/legend";
17
- import { __assign } from "tslib";
18
- import { Icon, chevronRight } from "@wordpress/icons";
17
+ import { IconButton, Stack, Text as Text$1 } from "@wordpress/ui";
19
18
  import { LinearGradient } from "@visx/gradient";
20
19
  import { curveCatmullRom, curveLinear, curveMonotoneX } from "@visx/curve";
21
20
  import { useParentSize } from "@visx/responsive";
@@ -23,8 +22,10 @@ import { Annotation, CircleSubject, Connector, HtmlLabel, Label, LineSubject } f
23
22
  import { PatternCircles, PatternHexagons, PatternLines, PatternWaves } from "@visx/pattern";
24
23
  import { Chart } from "react-google-charts";
25
24
  import DOMPurify from "dompurify";
25
+ import { __assign } from "tslib";
26
26
  import "@babel/runtime/helpers/esm/extends";
27
27
  import "@babel/runtime/helpers/extends";
28
+ import { Icon, chevronRight } from "@wordpress/icons";
28
29
  import { Pie } from "@visx/shape";
29
30
  //#region \0rolldown/runtime.js
30
31
  var __create = Object.create;
@@ -1450,709 +1451,6 @@ const useGlobalChartsTheme = () => {
1450
1451
  return useContext(GlobalChartsContext)?.theme ?? defaultTheme;
1451
1452
  };
1452
1453
  //#endregion
1453
- //#region ../../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs
1454
- /*!
1455
- * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
1456
- *
1457
- * Copyright (c) 2014-2017, Jon Schlinkert.
1458
- * Released under the MIT License.
1459
- */
1460
- function isObject(o) {
1461
- return Object.prototype.toString.call(o) === "[object Object]";
1462
- }
1463
- function isPlainObject(o) {
1464
- var ctor, prot;
1465
- if (isObject(o) === false) return false;
1466
- ctor = o.constructor;
1467
- if (ctor === void 0) return true;
1468
- prot = ctor.prototype;
1469
- if (isObject(prot) === false) return false;
1470
- if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
1471
- return true;
1472
- }
1473
- //#endregion
1474
- //#region ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist.es2015/index.js
1475
- /**
1476
- * Lower case as a function.
1477
- */
1478
- function lowerCase(str) {
1479
- return str.toLowerCase();
1480
- }
1481
- //#endregion
1482
- //#region ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist.es2015/index.js
1483
- var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
1484
- var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
1485
- /**
1486
- * Normalize the string into something other libraries can manipulate easier.
1487
- */
1488
- function noCase(input, options) {
1489
- if (options === void 0) options = {};
1490
- 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, delimiter = _d === void 0 ? " " : _d;
1491
- var result = replace$1(replace$1(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
1492
- var start = 0;
1493
- var end = result.length;
1494
- while (result.charAt(start) === "\0") start++;
1495
- while (result.charAt(end - 1) === "\0") end--;
1496
- return result.slice(start, end).split("\0").map(transform).join(delimiter);
1497
- }
1498
- /**
1499
- * Replace `re` in the input string with the replacement value.
1500
- */
1501
- function replace$1(input, re, value) {
1502
- if (re instanceof RegExp) return input.replace(re, value);
1503
- return re.reduce(function(input, re) {
1504
- return input.replace(re, value);
1505
- }, input);
1506
- }
1507
- //#endregion
1508
- //#region ../../../node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist.es2015/index.js
1509
- function dotCase(input, options) {
1510
- if (options === void 0) options = {};
1511
- return noCase(input, __assign({ delimiter: "." }, options));
1512
- }
1513
- //#endregion
1514
- //#region ../../../node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist.es2015/index.js
1515
- function paramCase(input, options) {
1516
- if (options === void 0) options = {};
1517
- return dotCase(input, __assign({ delimiter: "-" }, options));
1518
- }
1519
- //#endregion
1520
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/useRefWithInit.mjs
1521
- const UNINITIALIZED = {};
1522
- /**
1523
- * A React.useRef() that is initialized with a function. Note that it accepts an optional
1524
- * initialization argument, so the initialization function doesn't need to be an inline closure.
1525
- *
1526
- * @usage
1527
- * const ref = useRefWithInit(sortColumns, columns)
1528
- */
1529
- function useRefWithInit(init, initArg) {
1530
- const ref = React.useRef(UNINITIALIZED);
1531
- if (ref.current === UNINITIALIZED) ref.current = init(initArg);
1532
- return ref;
1533
- }
1534
- //#endregion
1535
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/warn.mjs
1536
- let set;
1537
- if (process.env.NODE_ENV !== "production") set = /* @__PURE__ */ new Set();
1538
- function warn(...messages) {
1539
- if (process.env.NODE_ENV !== "production") {
1540
- const messageKey = messages.join(" ");
1541
- if (!set.has(messageKey)) {
1542
- set.add(messageKey);
1543
- console.warn(`Base UI: ${messageKey}`);
1544
- }
1545
- }
1546
- }
1547
- //#endregion
1548
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/formatErrorMessage.mjs
1549
- /**
1550
- * Creates a formatErrorMessage function with a custom URL and prefix.
1551
- * @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
1552
- * @param prefix - The prefix for the error message (e.g., 'Base UI')
1553
- * @returns A function that formats error messages with the given URL and prefix
1554
- */
1555
- function createFormatErrorMessage(baseUrl, prefix) {
1556
- return function formatErrorMessage(code, ...args) {
1557
- const url = new URL(baseUrl);
1558
- url.searchParams.set("code", code.toString());
1559
- args.forEach((arg) => url.searchParams.append("args[]", arg));
1560
- return `${prefix} error #${code}; visit ${url} for the full message.`;
1561
- };
1562
- }
1563
- /**
1564
- * WARNING: Don't import this directly. It's imported by the code generated by
1565
- * `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
1566
- * constructors to ensure the plugin works as expected. Supported patterns include:
1567
- * throw new Error('My message');
1568
- * throw new Error(`My message: ${foo}`);
1569
- * throw new Error(`My message: ${foo}` + 'another string');
1570
- * ...
1571
- */
1572
- const formatErrorMessage = createFormatErrorMessage("https://base-ui.com/production-error", "Base UI");
1573
- //#endregion
1574
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/useMergedRefs.mjs
1575
- /**
1576
- * Merges refs into a single memoized callback ref or `null`.
1577
- * This makes sure multiple refs are updated together and have the same value.
1578
- *
1579
- * This function accepts up to four refs. If you need to merge more, or have an unspecified number of refs to merge,
1580
- * use `useMergedRefsN` instead.
1581
- */
1582
- function useMergedRefs(a, b, c, d) {
1583
- const forkRef = useRefWithInit(createForkRef).current;
1584
- if (didChange(forkRef, a, b, c, d)) update(forkRef, [
1585
- a,
1586
- b,
1587
- c,
1588
- d
1589
- ]);
1590
- return forkRef.callback;
1591
- }
1592
- /**
1593
- * Merges an array of refs into a single memoized callback ref or `null`.
1594
- *
1595
- * If you need to merge a fixed number (up to four) of refs, use `useMergedRefs` instead for better performance.
1596
- */
1597
- function useMergedRefsN(refs) {
1598
- const forkRef = useRefWithInit(createForkRef).current;
1599
- if (didChangeN(forkRef, refs)) update(forkRef, refs);
1600
- return forkRef.callback;
1601
- }
1602
- function createForkRef() {
1603
- return {
1604
- callback: null,
1605
- cleanup: null,
1606
- refs: []
1607
- };
1608
- }
1609
- function didChange(forkRef, a, b, c, d) {
1610
- return forkRef.refs[0] !== a || forkRef.refs[1] !== b || forkRef.refs[2] !== c || forkRef.refs[3] !== d;
1611
- }
1612
- function didChangeN(forkRef, newRefs) {
1613
- return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index) => ref !== newRefs[index]);
1614
- }
1615
- function update(forkRef, refs) {
1616
- forkRef.refs = refs;
1617
- if (refs.every((ref) => ref == null)) {
1618
- forkRef.callback = null;
1619
- return;
1620
- }
1621
- forkRef.callback = (instance) => {
1622
- if (forkRef.cleanup) {
1623
- forkRef.cleanup();
1624
- forkRef.cleanup = null;
1625
- }
1626
- if (instance != null) {
1627
- const cleanupCallbacks = Array(refs.length).fill(null);
1628
- for (let i = 0; i < refs.length; i += 1) {
1629
- const ref = refs[i];
1630
- if (ref == null) continue;
1631
- switch (typeof ref) {
1632
- case "function": {
1633
- const refCleanup = ref(instance);
1634
- if (typeof refCleanup === "function") cleanupCallbacks[i] = refCleanup;
1635
- break;
1636
- }
1637
- case "object":
1638
- ref.current = instance;
1639
- break;
1640
- default:
1641
- }
1642
- }
1643
- forkRef.cleanup = () => {
1644
- for (let i = 0; i < refs.length; i += 1) {
1645
- const ref = refs[i];
1646
- if (ref == null) continue;
1647
- switch (typeof ref) {
1648
- case "function": {
1649
- const cleanupCallback = cleanupCallbacks[i];
1650
- if (typeof cleanupCallback === "function") cleanupCallback();
1651
- else ref(null);
1652
- break;
1653
- }
1654
- case "object":
1655
- ref.current = null;
1656
- break;
1657
- default:
1658
- }
1659
- }
1660
- };
1661
- }
1662
- };
1663
- }
1664
- //#endregion
1665
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/reactVersion.mjs
1666
- const majorVersion = parseInt(React.version, 10);
1667
- function isReactVersionAtLeast(reactVersionToCheck) {
1668
- return majorVersion >= reactVersionToCheck;
1669
- }
1670
- //#endregion
1671
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/getReactElementRef.mjs
1672
- /**
1673
- * Extracts the `ref` from a React element, handling different React versions.
1674
- */
1675
- function getReactElementRef(element) {
1676
- if (!/*#__PURE__*/ React.isValidElement(element)) return null;
1677
- const reactElement = element;
1678
- const propsWithRef = reactElement.props;
1679
- return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
1680
- }
1681
- //#endregion
1682
- //#region ../../../node_modules/.pnpm/@base-ui+utils@0.3.1_@types+react@18.3.28_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/utils/mergeObjects.mjs
1683
- function mergeObjects(a, b) {
1684
- if (a && !b) return a;
1685
- if (!a && b) return b;
1686
- if (a || b) return {
1687
- ...a,
1688
- ...b
1689
- };
1690
- }
1691
- Object.freeze([]);
1692
- const EMPTY_OBJECT = Object.freeze({});
1693
- //#endregion
1694
- //#region ../../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
1695
- function getStateAttributesProps(state, customMapping) {
1696
- const props = {};
1697
- for (const key in state) {
1698
- const value = state[key];
1699
- if (customMapping?.hasOwnProperty(key)) {
1700
- const customProps = customMapping[key](value);
1701
- if (customProps != null) Object.assign(props, customProps);
1702
- continue;
1703
- }
1704
- if (value === true) props[`data-${key.toLowerCase()}`] = "";
1705
- else if (value) props[`data-${key.toLowerCase()}`] = value.toString();
1706
- }
1707
- return props;
1708
- }
1709
- //#endregion
1710
- //#region ../../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/utils/resolveClassName.mjs
1711
- /**
1712
- * If the provided className is a string, it will be returned as is.
1713
- * Otherwise, the function will call the className function with the state as the first argument.
1714
- *
1715
- * @param className
1716
- * @param state
1717
- */
1718
- function resolveClassName(className, state) {
1719
- return typeof className === "function" ? className(state) : className;
1720
- }
1721
- //#endregion
1722
- //#region ../../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/utils/resolveStyle.mjs
1723
- /**
1724
- * If the provided style is an object, it will be returned as is.
1725
- * Otherwise, the function will call the style function with the state as the first argument.
1726
- *
1727
- * @param style
1728
- * @param state
1729
- */
1730
- function resolveStyle(style, state) {
1731
- return typeof style === "function" ? style(state) : style;
1732
- }
1733
- //#endregion
1734
- //#region ../../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/merge-props/mergeProps.mjs
1735
- const EMPTY_PROPS = {};
1736
- /**
1737
- * Merges multiple sets of React props. It follows the Object.assign pattern where the rightmost object's fields overwrite
1738
- * the conflicting ones from others. This doesn't apply to event handlers, `className` and `style` props.
1739
- *
1740
- * Event handlers are merged and called in right-to-left order (rightmost handler executes first, leftmost last).
1741
- * For React synthetic events, the rightmost handler can prevent prior (left-positioned) handlers from executing
1742
- * by calling `event.preventBaseUIHandler()`. For non-synthetic events (custom events with primitive/object values),
1743
- * all handlers always execute without prevention capability.
1744
- *
1745
- * The `className` prop is merged by concatenating classes in right-to-left order (rightmost class appears first in the string).
1746
- * The `style` prop is merged with rightmost styles overwriting the prior ones.
1747
- *
1748
- * Props can either be provided as objects or as functions that take the previous props as an argument.
1749
- * The function will receive the merged props up to that point (going from left to right):
1750
- * so in the case of `(obj1, obj2, fn, obj3)`, `fn` will receive the merged props of `obj1` and `obj2`.
1751
- * The function is responsible for chaining event handlers if needed (that is, we don't run the merge logic).
1752
- *
1753
- * Event handlers returned by the functions are not automatically prevented when `preventBaseUIHandler` is called.
1754
- * They must check `event.baseUIHandlerPrevented` themselves and bail out if it's true.
1755
- *
1756
- * @important **`ref` is not merged.**
1757
- * @param a Props object to merge.
1758
- * @param b Props object to merge. The function will overwrite conflicting props from `a`.
1759
- * @param c Props object to merge. The function will overwrite conflicting props from previous parameters.
1760
- * @param d Props object to merge. The function will overwrite conflicting props from previous parameters.
1761
- * @param e Props object to merge. The function will overwrite conflicting props from previous parameters.
1762
- * @returns The merged props.
1763
- * @public
1764
- */
1765
- function mergeProps(a, b, c, d, e) {
1766
- if (!c && !d && !e && !a) return createInitialMergedProps(b);
1767
- let merged = createInitialMergedProps(a);
1768
- if (b) merged = mergeInto(merged, b);
1769
- if (c) merged = mergeInto(merged, c);
1770
- if (d) merged = mergeInto(merged, d);
1771
- if (e) merged = mergeInto(merged, e);
1772
- return merged;
1773
- }
1774
- /**
1775
- * Merges an arbitrary number of React props using the same logic as {@link mergeProps}.
1776
- * This function accepts an array of props instead of individual arguments.
1777
- *
1778
- * This has slightly lower performance than {@link mergeProps} due to accepting an array
1779
- * instead of a fixed number of arguments. Prefer {@link mergeProps} when merging 5 or
1780
- * fewer prop sets for better performance.
1781
- *
1782
- * @param props Array of props to merge.
1783
- * @returns The merged props.
1784
- * @see mergeProps
1785
- * @public
1786
- */
1787
- function mergePropsN(props) {
1788
- if (props.length === 0) return EMPTY_PROPS;
1789
- if (props.length === 1) return createInitialMergedProps(props[0]);
1790
- let merged = createInitialMergedProps(props[0]);
1791
- for (let i = 1; i < props.length; i += 1) merged = mergeInto(merged, props[i]);
1792
- return merged;
1793
- }
1794
- function createInitialMergedProps(inputProps) {
1795
- if (isPropsGetter(inputProps)) return { ...resolvePropsGetter(inputProps, EMPTY_PROPS) };
1796
- return copyInitialProps(inputProps);
1797
- }
1798
- function mergeInto(merged, inputProps) {
1799
- if (isPropsGetter(inputProps)) return resolvePropsGetter(inputProps, merged);
1800
- return mutablyMergeInto(merged, inputProps);
1801
- }
1802
- function copyInitialProps(inputProps) {
1803
- const copiedProps = { ...inputProps };
1804
- for (const propName in copiedProps) {
1805
- const propValue = copiedProps[propName];
1806
- if (isEventHandler(propName, propValue)) copiedProps[propName] = wrapEventHandler(propValue);
1807
- }
1808
- return copiedProps;
1809
- }
1810
- /**
1811
- * Merges two sets of props. In case of conflicts, the external props take precedence.
1812
- */
1813
- function mutablyMergeInto(mergedProps, externalProps) {
1814
- if (!externalProps) return mergedProps;
1815
- for (const propName in externalProps) {
1816
- const externalPropValue = externalProps[propName];
1817
- switch (propName) {
1818
- case "style":
1819
- mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
1820
- break;
1821
- case "className":
1822
- mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
1823
- break;
1824
- default: if (isEventHandler(propName, externalPropValue)) mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
1825
- else mergedProps[propName] = externalPropValue;
1826
- }
1827
- }
1828
- return mergedProps;
1829
- }
1830
- function isEventHandler(key, value) {
1831
- const code0 = key.charCodeAt(0);
1832
- const code1 = key.charCodeAt(1);
1833
- const code2 = key.charCodeAt(2);
1834
- return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
1835
- }
1836
- function isPropsGetter(inputProps) {
1837
- return typeof inputProps === "function";
1838
- }
1839
- function resolvePropsGetter(inputProps, previousProps) {
1840
- if (isPropsGetter(inputProps)) return inputProps(previousProps);
1841
- return inputProps ?? EMPTY_PROPS;
1842
- }
1843
- function mergeEventHandlers(ourHandler, theirHandler) {
1844
- if (!theirHandler) return ourHandler;
1845
- if (!ourHandler) return wrapEventHandler(theirHandler);
1846
- return (...args) => {
1847
- const event = args[0];
1848
- if (isSyntheticEvent(event)) {
1849
- const baseUIEvent = event;
1850
- makeEventPreventable(baseUIEvent);
1851
- const result = theirHandler(...args);
1852
- if (!baseUIEvent.baseUIHandlerPrevented) ourHandler?.(...args);
1853
- return result;
1854
- }
1855
- const result = theirHandler(...args);
1856
- ourHandler?.(...args);
1857
- return result;
1858
- };
1859
- }
1860
- function wrapEventHandler(handler) {
1861
- if (!handler) return handler;
1862
- return (...args) => {
1863
- const event = args[0];
1864
- if (isSyntheticEvent(event)) makeEventPreventable(event);
1865
- return handler(...args);
1866
- };
1867
- }
1868
- function makeEventPreventable(event) {
1869
- event.preventBaseUIHandler = () => {
1870
- event.baseUIHandlerPrevented = true;
1871
- };
1872
- return event;
1873
- }
1874
- function mergeClassNames(ourClassName, theirClassName) {
1875
- if (theirClassName) {
1876
- if (ourClassName) return theirClassName + " " + ourClassName;
1877
- return theirClassName;
1878
- }
1879
- return ourClassName;
1880
- }
1881
- function isSyntheticEvent(event) {
1882
- return event != null && typeof event === "object" && "nativeEvent" in event;
1883
- }
1884
- //#endregion
1885
- //#region ../../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/internals/useRenderElement.mjs
1886
- /**
1887
- * Renders a Base UI element.
1888
- *
1889
- * @param element The default HTML element to render. Can be overridden by the `render` prop.
1890
- * @param componentProps An object containing the `render` and `className` props to be used for element customization. Other props are ignored.
1891
- * @param params Additional parameters for rendering the element.
1892
- */
1893
- function useRenderElement(element, componentProps, params = {}) {
1894
- const renderProp = componentProps.render;
1895
- const outProps = useRenderElementProps(componentProps, params);
1896
- if (params.enabled === false) return null;
1897
- return evaluateRenderProp(element, renderProp, outProps, params.state ?? EMPTY_OBJECT);
1898
- }
1899
- /**
1900
- * Computes render element final props.
1901
- */
1902
- function useRenderElementProps(componentProps, params = {}) {
1903
- const { className: classNameProp, style: styleProp, render: renderProp } = componentProps;
1904
- const { state = EMPTY_OBJECT, ref, props, stateAttributesMapping, enabled = true } = params;
1905
- const className = enabled ? resolveClassName(classNameProp, state) : void 0;
1906
- const style = enabled ? resolveStyle(styleProp, state) : void 0;
1907
- const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping) : EMPTY_OBJECT;
1908
- const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
1909
- const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
1910
- if (typeof document !== "undefined") if (!enabled) useMergedRefs(null, null);
1911
- else if (Array.isArray(ref)) outProps.ref = useMergedRefsN([
1912
- outProps.ref,
1913
- getReactElementRef(renderProp),
1914
- ...ref
1915
- ]);
1916
- else outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
1917
- if (!enabled) return EMPTY_OBJECT;
1918
- if (className !== void 0) outProps.className = mergeClassNames(outProps.className, className);
1919
- if (style !== void 0) outProps.style = mergeObjects(outProps.style, style);
1920
- return outProps;
1921
- }
1922
- function resolveRenderFunctionProps(props) {
1923
- if (Array.isArray(props)) return mergePropsN(props);
1924
- return mergeProps(void 0, props);
1925
- }
1926
- const REACT_LAZY_TYPE = Symbol.for("react.lazy");
1927
- const COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
1928
- const LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
1929
- function evaluateRenderProp(element, render, props, state) {
1930
- if (render) {
1931
- if (typeof render === "function") {
1932
- if (process.env.NODE_ENV !== "production") warnIfRenderPropLooksLikeComponent(render);
1933
- return render(props, state);
1934
- }
1935
- const mergedProps = mergeProps(props, render.props);
1936
- mergedProps.ref = props.ref;
1937
- let newElement = render;
1938
- if (newElement?.$$typeof === REACT_LAZY_TYPE) newElement = React.Children.toArray(render)[0];
1939
- if (process.env.NODE_ENV !== "production") {
1940
- if (!/*#__PURE__*/ React.isValidElement(newElement)) throw new Error([
1941
- "Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.",
1942
- "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.",
1943
- "https://base-ui.com/r/invalid-render-prop"
1944
- ].join("\n"));
1945
- }
1946
- return /*#__PURE__*/ React.cloneElement(newElement, mergedProps);
1947
- }
1948
- if (element) {
1949
- if (typeof element === "string") return renderTag(element, props);
1950
- }
1951
- throw new Error(process.env.NODE_ENV !== "production" ? "Base UI: Render element or function are not defined." : formatErrorMessage(8));
1952
- }
1953
- function warnIfRenderPropLooksLikeComponent(renderFn) {
1954
- const functionName = renderFn.name;
1955
- if (functionName.length === 0) return;
1956
- if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) return;
1957
- if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) return;
1958
- 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");
1959
- }
1960
- function renderTag(Tag, props) {
1961
- if (Tag === "button") return /*#__PURE__*/ createElement("button", {
1962
- type: "button",
1963
- ...props,
1964
- key: props.key
1965
- });
1966
- if (Tag === "img") return /*#__PURE__*/ createElement("img", {
1967
- alt: "",
1968
- ...props,
1969
- key: props.key
1970
- });
1971
- return /*#__PURE__*/ React.createElement(Tag, props);
1972
- }
1973
- //#endregion
1974
- //#region ../../../node_modules/.pnpm/@base-ui+react@1.6.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@base-ui/react/use-render/useRender.mjs
1975
- /**
1976
- * Renders a Base UI element.
1977
- *
1978
- * @public
1979
- */
1980
- function useRender(params) {
1981
- return useRenderElement(params.defaultTagName ?? "div", params, params);
1982
- }
1983
- //#endregion
1984
- //#region ../../../node_modules/.pnpm/@wordpress+ui@0.17.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/ui/build-module/text/text.mjs
1985
- var STYLE_HASH_ATTRIBUTE$1 = "data-wp-hash";
1986
- function getRuntime$1() {
1987
- const globalScope = globalThis;
1988
- if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
1989
- globalScope.__wpStyleRuntime = {
1990
- documents: /* @__PURE__ */ new Map(),
1991
- styles: /* @__PURE__ */ new Map(),
1992
- injectedStyles: /* @__PURE__ */ new WeakMap()
1993
- };
1994
- if (typeof document !== "undefined") registerDocument$1(document);
1995
- return globalScope.__wpStyleRuntime;
1996
- }
1997
- function documentContainsStyleHash$1(targetDocument, hash) {
1998
- if (!targetDocument.head) return false;
1999
- for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE$1}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE$1) === hash) return true;
2000
- return false;
2001
- }
2002
- function injectStyle$1(targetDocument, hash, css) {
2003
- if (!targetDocument.head) return;
2004
- const runtime = getRuntime$1();
2005
- let injectedStyles = runtime.injectedStyles.get(targetDocument);
2006
- if (!injectedStyles) {
2007
- injectedStyles = /* @__PURE__ */ new Set();
2008
- runtime.injectedStyles.set(targetDocument, injectedStyles);
2009
- }
2010
- if (injectedStyles.has(hash)) return;
2011
- if (documentContainsStyleHash$1(targetDocument, hash)) {
2012
- injectedStyles.add(hash);
2013
- return;
2014
- }
2015
- const style = targetDocument.createElement("style");
2016
- style.setAttribute(STYLE_HASH_ATTRIBUTE$1, hash);
2017
- style.appendChild(targetDocument.createTextNode(css));
2018
- targetDocument.head.appendChild(style);
2019
- injectedStyles.add(hash);
2020
- }
2021
- function registerDocument$1(targetDocument) {
2022
- const runtime = getRuntime$1();
2023
- runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
2024
- for (const [hash, css] of runtime.styles) injectStyle$1(targetDocument, hash, css);
2025
- return () => {
2026
- const count = runtime.documents.get(targetDocument);
2027
- if (count === void 0) return;
2028
- if (count <= 1) {
2029
- runtime.documents.delete(targetDocument);
2030
- return;
2031
- }
2032
- runtime.documents.set(targetDocument, count - 1);
2033
- };
2034
- }
2035
- function registerStyle$1(hash, css) {
2036
- const runtime = getRuntime$1();
2037
- runtime.styles.set(hash, css);
2038
- for (const targetDocument of runtime.documents.keys()) injectStyle$1(targetDocument, hash, css);
2039
- }
2040
- if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle$1("0c5702ddca", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,\"Segoe UI\",\"Roboto\",\"Oxygen-Sans\",\"Ubuntu\",\"Cantarell\",\"Helvetica Neue\",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,\"Segoe UI\",\"Roboto\",\"Oxygen-Sans\",\"Ubuntu\",\"Cantarell\",\"Helvetica Neue\",sans-serif);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-medium,499);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,\"Segoe UI\",\"Roboto\",\"Oxygen-Sans\",\"Ubuntu\",\"Cantarell\",\"Helvetica Neue\",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-medium,499);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,\"Segoe UI\",\"Roboto\",\"Oxygen-Sans\",\"Ubuntu\",\"Cantarell\",\"Helvetica Neue\",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,\"Segoe UI\",\"Roboto\",\"Oxygen-Sans\",\"Ubuntu\",\"Cantarell\",\"Helvetica Neue\",sans-serif);font-weight:var(--wpds-typography-font-weight-regular,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-regular,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}");
2041
- var style_default$1 = {
2042
- "text": "_83ed8a8da5dd50ea__text",
2043
- "heading-2xl": "_14437cfb77831647__heading-2xl",
2044
- "heading-xl": "_3c78b7fa9b4072dd__heading-xl",
2045
- "heading-lg": "aa58f227716bcde2__heading-lg",
2046
- "heading-md": "fc4da56d8dfe52c4__heading-md",
2047
- "heading-sm": "a9b78c7c82e8dff7__heading-sm",
2048
- "body-xl": "_305ff559e52180d5__body-xl",
2049
- "body-lg": "ca1aa3fc2029e958__body-lg",
2050
- "body-md": "_131101940be12424__body-md",
2051
- "body-sm": "_0e8d87a42c1f75fa__body-sm"
2052
- };
2053
- if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle$1("d390e935a7", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-medium,499));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
2054
- var global_css_defense_default = {
2055
- "button": "_6defc79820e382c6__button",
2056
- "input": "d2cff2e5dea83bd1__input",
2057
- "textarea": "_547d86373d02e108__textarea",
2058
- "div": "_8c15fd0ed9f28ba4__div",
2059
- "p": "_43cec3e1eec1066d__p",
2060
- "heading": "e97669c6d9a38497__heading",
2061
- "a": "_2c0831b0499dbd6e__a"
2062
- };
2063
- var Text$1 = forwardRef$1(function Text2({ variant = "body-md", render, className, ...props }, ref) {
2064
- return useRender({
2065
- render,
2066
- defaultTagName: "span",
2067
- ref,
2068
- props: mergeProps(props, { className: clsx(style_default$1.text, global_css_defense_default.heading, global_css_defense_default.p, style_default$1[variant], className) })
2069
- });
2070
- });
2071
- //#endregion
2072
- //#region ../../../node_modules/.pnpm/@wordpress+ui@0.17.0_@types+react@18.3.28_date-fns@4.1.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@wordpress/ui/build-module/stack/stack.mjs
2073
- var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
2074
- function getRuntime() {
2075
- const globalScope = globalThis;
2076
- if (globalScope.__wpStyleRuntime) return globalScope.__wpStyleRuntime;
2077
- globalScope.__wpStyleRuntime = {
2078
- documents: /* @__PURE__ */ new Map(),
2079
- styles: /* @__PURE__ */ new Map(),
2080
- injectedStyles: /* @__PURE__ */ new WeakMap()
2081
- };
2082
- if (typeof document !== "undefined") registerDocument(document);
2083
- return globalScope.__wpStyleRuntime;
2084
- }
2085
- function documentContainsStyleHash(targetDocument, hash) {
2086
- if (!targetDocument.head) return false;
2087
- for (const style of targetDocument.head.querySelectorAll(`style[${STYLE_HASH_ATTRIBUTE}]`)) if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) return true;
2088
- return false;
2089
- }
2090
- function injectStyle(targetDocument, hash, css) {
2091
- if (!targetDocument.head) return;
2092
- const runtime = getRuntime();
2093
- let injectedStyles = runtime.injectedStyles.get(targetDocument);
2094
- if (!injectedStyles) {
2095
- injectedStyles = /* @__PURE__ */ new Set();
2096
- runtime.injectedStyles.set(targetDocument, injectedStyles);
2097
- }
2098
- if (injectedStyles.has(hash)) return;
2099
- if (documentContainsStyleHash(targetDocument, hash)) {
2100
- injectedStyles.add(hash);
2101
- return;
2102
- }
2103
- const style = targetDocument.createElement("style");
2104
- style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
2105
- style.appendChild(targetDocument.createTextNode(css));
2106
- targetDocument.head.appendChild(style);
2107
- injectedStyles.add(hash);
2108
- }
2109
- function registerDocument(targetDocument) {
2110
- const runtime = getRuntime();
2111
- runtime.documents.set(targetDocument, (runtime.documents.get(targetDocument) ?? 0) + 1);
2112
- for (const [hash, css] of runtime.styles) injectStyle(targetDocument, hash, css);
2113
- return () => {
2114
- const count = runtime.documents.get(targetDocument);
2115
- if (count === void 0) return;
2116
- if (count <= 1) {
2117
- runtime.documents.delete(targetDocument);
2118
- return;
2119
- }
2120
- runtime.documents.set(targetDocument, count - 1);
2121
- };
2122
- }
2123
- function registerStyle(hash, css) {
2124
- const runtime = getRuntime();
2125
- runtime.styles.set(hash, css);
2126
- for (const targetDocument of runtime.documents.keys()) injectStyle(targetDocument, hash, css);
2127
- }
2128
- if (typeof process === "undefined" || process.env.NODE_ENV !== "test") registerStyle("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
2129
- var style_default = { "stack": "_19ce0419607e1896__stack" };
2130
- var gapTokens = {
2131
- xs: "var(--wpds-dimension-gap-xs, 4px)",
2132
- sm: "var(--wpds-dimension-gap-sm, 8px)",
2133
- md: "var(--wpds-dimension-gap-md, 12px)",
2134
- lg: "var(--wpds-dimension-gap-lg, 16px)",
2135
- xl: "var(--wpds-dimension-gap-xl, 24px)",
2136
- "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
2137
- "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
2138
- };
2139
- var Stack = forwardRef$1(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
2140
- return useRender({
2141
- render,
2142
- ref,
2143
- props: mergeProps(props, {
2144
- style: {
2145
- gap: gap && gapTokens[gap],
2146
- alignItems: align,
2147
- justifyContent: justify,
2148
- flexDirection: direction,
2149
- flexWrap: wrap
2150
- },
2151
- className: style_default.stack
2152
- })
2153
- });
2154
- });
2155
- //#endregion
2156
1454
  //#region src/components/legend/utils/value-or-identity.ts
2157
1455
  /**
2158
1456
  * Returns an object's value if defined, or the object.
@@ -2233,8 +1531,13 @@ const BaseLegend = forwardRef(({ items, className, orientation = "horizontal", a
2233
1531
  });
2234
1532
  const domain = legendScale.domain();
2235
1533
  const getShapeStyle = useCallback(({ index }) => items[index]?.shapeStyle, [items]);
2236
- const handleLegendClick = useCallback((seriesLabel) => {
2237
- if (interactive && chartId && context) context.toggleSeriesVisibility(chartId, seriesLabel);
1534
+ const handleLegendClick = useCallback((seriesLabels) => {
1535
+ if (interactive && chartId && context) {
1536
+ const representativeVisible = context.isSeriesVisible(chartId, seriesLabels[0]);
1537
+ seriesLabels.forEach((label) => {
1538
+ if (context.isSeriesVisible(chartId, label) === representativeVisible) context.toggleSeriesVisibility(chartId, label);
1539
+ });
1540
+ }
2238
1541
  }, [
2239
1542
  interactive,
2240
1543
  chartId,
@@ -2248,16 +1551,16 @@ const BaseLegend = forwardRef(({ items, className, orientation = "horizontal", a
2248
1551
  chartId,
2249
1552
  context
2250
1553
  ]);
2251
- const createClickHandler = useCallback((labelText) => {
1554
+ const createClickHandler = useCallback((seriesLabels) => {
2252
1555
  if (!interactive) return;
2253
- return () => handleLegendClick(labelText);
1556
+ return () => handleLegendClick(seriesLabels);
2254
1557
  }, [interactive, handleLegendClick]);
2255
- const createKeyDownHandler = useCallback((labelText) => {
1558
+ const createKeyDownHandler = useCallback((seriesLabels) => {
2256
1559
  if (!interactive) return;
2257
1560
  return (event) => {
2258
1561
  if (event.key === "Enter" || event.key === " ") {
2259
1562
  event.preventDefault();
2260
- handleLegendClick(labelText);
1563
+ handleLegendClick(seriesLabels);
2261
1564
  }
2262
1565
  };
2263
1566
  }, [interactive, handleLegendClick]);
@@ -2277,10 +1580,11 @@ const BaseLegend = forwardRef(({ items, className, orientation = "horizontal", a
2277
1580
  className: clsx(base_legend_module_default.legend, className),
2278
1581
  style: theme.legend?.containerStyles,
2279
1582
  children: labels.map((label, i) => {
2280
- const visible = isSeriesVisible(label.text);
2281
- const handleClick = createClickHandler(label.text);
2282
- const handleKeyDown = createKeyDownHandler(label.text);
2283
1583
  const matchedItem = items[i];
1584
+ const seriesLabels = matchedItem?.seriesLabels?.length ? matchedItem.seriesLabels : [label.text];
1585
+ const visible = isSeriesVisible(seriesLabels[0]);
1586
+ const handleClick = createClickHandler(seriesLabels);
1587
+ const handleKeyDown = createKeyDownHandler(seriesLabels);
2284
1588
  return /* @__PURE__ */ jsxs(LegendItem, {
2285
1589
  className: clsx("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),
2286
1590
  margin: itemMargin,
@@ -2408,31 +1712,88 @@ function applyGlyphToLegendItem(baseItem, withGlyph, glyph, renderGlyph, glyphSi
2408
1712
  return baseItem;
2409
1713
  }
2410
1714
  /**
2411
- * Processes SeriesData into legend items
1715
+ * Buckets series by their `group`, preserving first-appearance order. Series with no group — or a
1716
+ * group value unique to them — end up in a bucket of their own. Whether a multi-series bucket then
1717
+ * collapses to a single legend item is decided by the caller: with `collapseGroups` on, every
1718
+ * multi-member bucket collapses, and the comparison pattern only decides which member represents it.
1719
+ * @param seriesData - The series data to group
1720
+ * @return Ordered groups, each holding its member series with their original indices
1721
+ */
1722
+ function groupSeriesForLegend(seriesData) {
1723
+ const groups = [];
1724
+ const groupIndexByKey = /* @__PURE__ */ new Map();
1725
+ seriesData.forEach((series, index) => {
1726
+ const member = {
1727
+ series,
1728
+ index
1729
+ };
1730
+ const key = series.group;
1731
+ if (key === void 0) {
1732
+ groups.push([member]);
1733
+ return;
1734
+ }
1735
+ const existing = groupIndexByKey.get(key);
1736
+ if (existing === void 0) {
1737
+ groupIndexByKey.set(key, groups.length);
1738
+ groups.push([member]);
1739
+ } else groups[existing].push(member);
1740
+ });
1741
+ return groups;
1742
+ }
1743
+ /**
1744
+ * Builds a single legend item from a representative series, tagging it with the series it controls
1745
+ * @param member - The series (with its original index) that provides the label/colour
1746
+ * @param seriesLabels - Every series label this item toggles (grouped) or just its own
1747
+ * @param getElementStyles - Function to get element styles
1748
+ * @param showValues - Whether to show values in legend
1749
+ * @param withGlyph - Whether to include glyph rendering
1750
+ * @param glyphSize - Size of the glyph
1751
+ * @param renderGlyph - Component to render the glyph
1752
+ * @param legendShape - The shape type for legend items (string literal or React component)
1753
+ * @return The processed legend item
1754
+ */
1755
+ function buildSeriesLegendItem(member, seriesLabels, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
1756
+ const { color, glyph, shapeStyles } = getElementStyles({
1757
+ data: member.series,
1758
+ index: member.index,
1759
+ legendShape
1760
+ });
1761
+ return applyGlyphToLegendItem({
1762
+ label: member.series.label,
1763
+ value: showValues ? member.series.data?.length?.toString() || "0" : "",
1764
+ color,
1765
+ shapeStyle: shapeStyles,
1766
+ seriesLabels
1767
+ }, withGlyph, glyph, renderGlyph, glyphSize);
1768
+ }
1769
+ /**
1770
+ * Processes SeriesData into legend items. Every series keeps its own legend entry unless
1771
+ * `collapseGroups` is set, in which case series sharing a `group` collapse to one item labelled by
1772
+ * the group's primary (its first non-comparison member).
2412
1773
  * @param seriesData - The series data to process
2413
1774
  * @param getElementStyles - Function to get element styles
2414
1775
  * @param showValues - Whether to show values in legend
2415
1776
  * @param withGlyph - Whether to include glyph rendering
2416
1777
  * @param glyphSize - Size of the glyph
1778
+ * @param collapseGroups - Whether series sharing a group collapse to a single item
2417
1779
  * @param renderGlyph - Component to render the glyph
2418
1780
  * @param legendShape - The shape type for legend items (string literal or React component)
2419
1781
  * @return Array of processed legend items
2420
1782
  */
2421
- function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape) {
2422
- const mapper = (series, index) => {
2423
- const { color, glyph, shapeStyles } = getElementStyles({
2424
- data: series,
2425
- index,
2426
- legendShape
2427
- });
2428
- return applyGlyphToLegendItem({
2429
- label: series.label,
2430
- value: showValues ? series.data?.length?.toString() || "0" : "",
2431
- color,
2432
- shapeStyle: shapeStyles
2433
- }, withGlyph, glyph, renderGlyph, glyphSize);
2434
- };
2435
- return seriesData.map(mapper);
1783
+ function processSeriesData(seriesData, getElementStyles, showValues, withGlyph, glyphSize, collapseGroups, renderGlyph, legendShape) {
1784
+ const buildItem = (member, seriesLabels) => buildSeriesLegendItem(member, seriesLabels, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape);
1785
+ if (!collapseGroups) return seriesData.map((series, index) => buildItem({
1786
+ series,
1787
+ index
1788
+ }, [series.label]));
1789
+ return groupSeriesForLegend(seriesData).flatMap((members) => {
1790
+ if (members.length > 1) {
1791
+ const primary = members.find(({ series }) => series.options?.type !== "comparison") ?? members[0];
1792
+ const seriesLabels = [primary.series.label, ...members.filter((member) => member !== primary).map(({ series }) => series.label)];
1793
+ return [buildItem(primary, seriesLabels)];
1794
+ }
1795
+ return members.map((member) => buildItem(member, [member.series.label]));
1796
+ });
2436
1797
  }
2437
1798
  /**
2438
1799
  * Processes point data into legend items
@@ -2470,11 +1831,11 @@ function processPointData(pointData, getElementStyles, showValues, legendValueDi
2470
1831
  * @return Array of legend items ready for display
2471
1832
  */
2472
1833
  function useChartLegendItems(data, options = {}, legendShape) {
2473
- const { showValues = false, legendValueDisplay = "percentage", withGlyph = false, glyphSize = 8, renderGlyph } = options;
1834
+ const { showValues = false, legendValueDisplay = "percentage", withGlyph = false, glyphSize = 8, collapseGroups = false, renderGlyph } = options;
2474
1835
  const { getElementStyles } = useGlobalChartsContext();
2475
1836
  return useMemo(() => {
2476
1837
  if (!data || !Array.isArray(data) || data.length === 0) return [];
2477
- if ("data" in data[0]) return processSeriesData(data, getElementStyles, showValues, withGlyph, glyphSize, renderGlyph, legendShape);
1838
+ if ("data" in data[0]) return processSeriesData(data, getElementStyles, showValues, withGlyph, glyphSize, collapseGroups, renderGlyph, legendShape);
2478
1839
  return processPointData(data, getElementStyles, showValues, legendValueDisplay, withGlyph, glyphSize, renderGlyph, legendShape);
2479
1840
  }, [
2480
1841
  data,
@@ -2483,6 +1844,7 @@ function useChartLegendItems(data, options = {}, legendShape) {
2483
1844
  legendValueDisplay,
2484
1845
  withGlyph,
2485
1846
  glyphSize,
1847
+ collapseGroups,
2486
1848
  renderGlyph,
2487
1849
  legendShape
2488
1850
  ]);
@@ -2884,11 +2246,37 @@ const formatHourTick = (timestamp) => {
2884
2246
  hour12: true
2885
2247
  });
2886
2248
  };
2887
- const getFormatter = (sortedData) => {
2249
+ const formatDateOrHourTick = (timestamp) => {
2250
+ const date = new Date(timestamp);
2251
+ return date.getHours() === 0 && date.getMinutes() === 0 ? formatDateTick$1(timestamp) : formatHourTick(timestamp);
2252
+ };
2253
+ const formatMonthOrYearTick = (timestamp) => {
2254
+ const date = new Date(timestamp);
2255
+ return date.getMonth() === 0 ? formatYearTick(timestamp) : date.toLocaleDateString(void 0, { month: "short" });
2256
+ };
2257
+ const getPointSpacingInHours = (sortedData) => {
2258
+ return sortedData.reduce((spacing, datom) => datom.data.reduce((seriesSpacing, point, index) => {
2259
+ const previous = datom.data[index - 1];
2260
+ if (previous?.date === void 0 || point?.date === void 0) return seriesSpacing;
2261
+ return Math.min(seriesSpacing, Math.abs(differenceInHours(point.date, previous.date)));
2262
+ }, spacing), Number.POSITIVE_INFINITY);
2263
+ };
2264
+ const SPACING_BY_RESOLUTION = {
2265
+ hour: 1,
2266
+ day: 24,
2267
+ week: 168,
2268
+ month: 672
2269
+ };
2270
+ const getFormatter = (sortedData, tickResolution) => {
2271
+ if (tickResolution === "year") return formatYearTick;
2888
2272
  const minX = Math.min(...sortedData.map((datom) => datom.data.at(0)?.date));
2889
2273
  const maxX = Math.max(...sortedData.map((datom) => datom.data.at(-1)?.date));
2890
- if (Math.abs(differenceInHours(maxX, minX)) <= 24) return formatHourTick;
2891
- if (Math.abs(differenceInYears(maxX, minX)) <= 1) return formatDateTick$1;
2274
+ const spacingInHours = tickResolution ? SPACING_BY_RESOLUTION[tickResolution] : getPointSpacingInHours(sortedData);
2275
+ const isSubDaily = spacingInHours < 23;
2276
+ const diffInHours = Math.abs(differenceInHours(maxX, minX));
2277
+ if (diffInHours <= 24 && isSubDaily) return formatHourTick;
2278
+ if (diffInHours <= 168 && isSubDaily) return formatDateOrHourTick;
2279
+ if (Math.abs(differenceInYears(maxX, minX)) <= 1) return Number.isFinite(spacingInHours) && spacingInHours >= 672 ? formatMonthOrYearTick : formatDateTick$1;
2892
2280
  return formatYearTick;
2893
2281
  };
2894
2282
  const guessOptimalNumTicks = (data, chartWidth, tickFormatter) => {
@@ -2989,14 +2377,13 @@ function withResponsive(WrappedComponent) {
2989
2377
  };
2990
2378
  }
2991
2379
  //#endregion
2992
- //#region src/charts/private/x-zoom.module.scss
2380
+ //#region src/charts/private/x-zoom/x-zoom.module.scss
2993
2381
  var x_zoom_module_default = {
2994
- "x-zoom__reset": "a8ccharts-y6bXNq-x-zoom__reset",
2995
- "x-zoom__reset-icon": "a8ccharts-y6bXNq-x-zoom__reset-icon",
2996
- "x-zoom__selection": "a8ccharts-y6bXNq-x-zoom__selection"
2382
+ "x-zoom__reset": "a8ccharts-ur9dWW-x-zoom__reset",
2383
+ "x-zoom__selection": "a8ccharts-ur9dWW-x-zoom__selection"
2997
2384
  };
2998
2385
  //#endregion
2999
- //#region src/charts/private/x-zoom.tsx
2386
+ //#region src/charts/private/x-zoom/x-zoom.tsx
3000
2387
  const MIN_DRAG_PIXELS = 6;
3001
2388
  /**
3002
2389
  * Drag-to-zoom state + pointer handlers for an XY chart. Designed to be
@@ -3125,24 +2512,27 @@ function ZoomClip({ active, chartId, children }) {
3125
2512
  })] });
3126
2513
  }
3127
2514
  /**
3128
- * Visible icon-only reset button rendered as an HTML overlay on top of
3129
- * the chart container. The host should wrap its SVG in a `position: relative`
3130
- * container so the button anchors correctly.
2515
+ * Visible icon-only reset control rendered as an HTML overlay on top of the
2516
+ * chart container, using the WPDS `IconButton`. The host should wrap its SVG in
2517
+ * a `position: relative` container so the button anchors correctly.
3131
2518
  *
3132
2519
  * @param props - Props.
3133
2520
  * @param props.onClick - Click handler. Typically the `reset` from `useXZoom`.
3134
2521
  * @return JSX element.
3135
2522
  */
3136
2523
  function ZoomResetButton({ onClick }) {
3137
- const label = __("Reset zoom", "jetpack-charts");
3138
- return /* @__PURE__ */ jsx("button", {
3139
- type: "button",
2524
+ const stopActivationKeys = useCallback((event) => {
2525
+ if (event.key === "Enter" || event.key === " ") event.stopPropagation();
2526
+ }, []);
2527
+ return /* @__PURE__ */ jsx(IconButton, {
3140
2528
  className: x_zoom_module_default["x-zoom__reset"],
2529
+ onKeyDown: stopActivationKeys,
2530
+ label: __("Reset zoom", "jetpack-charts"),
2531
+ variant: "outline",
2532
+ tone: "neutral",
2533
+ size: "small",
3141
2534
  onClick,
3142
- "aria-label": label,
3143
- title: label,
3144
- children: /* @__PURE__ */ jsxs("svg", {
3145
- className: x_zoom_module_default["x-zoom__reset-icon"],
2535
+ icon: /* @__PURE__ */ jsx("svg", {
3146
2536
  viewBox: "0 0 24 24",
3147
2537
  fill: "none",
3148
2538
  stroke: "currentColor",
@@ -3151,25 +2541,28 @@ function ZoomResetButton({ onClick }) {
3151
2541
  strokeLinejoin: "round",
3152
2542
  "aria-hidden": "true",
3153
2543
  focusable: "false",
3154
- children: [
3155
- /* @__PURE__ */ jsx("circle", {
3156
- cx: "10",
3157
- cy: "10",
3158
- r: "6"
3159
- }),
3160
- /* @__PURE__ */ jsx("line", {
3161
- x1: "15",
3162
- y1: "15",
3163
- x2: "20",
3164
- y2: "20"
3165
- }),
3166
- /* @__PURE__ */ jsx("line", {
3167
- x1: "7",
3168
- y1: "10",
3169
- x2: "13",
3170
- y2: "10"
3171
- })
3172
- ]
2544
+ children: /* @__PURE__ */ jsxs("g", {
2545
+ transform: "translate(2.4 2.4) scale(0.8)",
2546
+ children: [
2547
+ /* @__PURE__ */ jsx("circle", {
2548
+ cx: "10",
2549
+ cy: "10",
2550
+ r: "6"
2551
+ }),
2552
+ /* @__PURE__ */ jsx("line", {
2553
+ x1: "15",
2554
+ y1: "15",
2555
+ x2: "20",
2556
+ y2: "20"
2557
+ }),
2558
+ /* @__PURE__ */ jsx("line", {
2559
+ x1: "7",
2560
+ y1: "10",
2561
+ x2: "13",
2562
+ y2: "10"
2563
+ })
2564
+ ]
2565
+ })
3173
2566
  })
3174
2567
  });
3175
2568
  }
@@ -3659,8 +3052,9 @@ const LineChartScalesRef = ({ chartRef, width, height, margin }) => {
3659
3052
  ]);
3660
3053
  return null;
3661
3054
  };
3662
- const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, renderGlyph = defaultRenderGlyph, glyphStyle = {}, withLegendGlyph = false, withGradientFill = false, smoothing = true, curveType, renderTooltip = renderDefaultTooltip, withStartGlyphs = false, withEndGlyphs = false, animation, options = {}, onPointerDown = void 0, onPointerUp = void 0, onPointerMove = void 0, onPointerOut = void 0, zoomable = false, children, gridVisibility, gap = "md" }, ref) => {
3055
+ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, renderGlyph = defaultRenderGlyph, glyphStyle = {}, withLegendGlyph = false, withGradientFill = false, smoothing = true, curveType, renderTooltip = renderDefaultTooltip, withStartGlyphs = false, withEndGlyphs = false, animation, options = {}, onPointerDown = void 0, onPointerUp = void 0, onPointerMove = void 0, onPointerOut = void 0, zoomable = false, rescaleYOnVisibilityChange = true, children, gridVisibility, gap = "md" }, ref) => {
3663
3056
  const legendInteractive = legend.interactive ?? false;
3057
+ const legendCollapseGroups = legend.collapseGroups ?? false;
3664
3058
  const legendShape = legend.shape ?? "line";
3665
3059
  const legendPosition = legend.position ?? "bottom";
3666
3060
  const providerTheme = useGlobalChartsTheme();
@@ -3715,6 +3109,23 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3715
3109
  const allSeriesHidden = useMemo(() => {
3716
3110
  return seriesWithVisibility.every(({ isVisible }) => !isVisible);
3717
3111
  }, [seriesWithVisibility]);
3112
+ const stableYDomain = useMemo(() => {
3113
+ if (!legendInteractive || rescaleYOnVisibilityChange) return;
3114
+ let min = Infinity;
3115
+ let max = -Infinity;
3116
+ for (const series of dataSorted) for (const point of series.data ?? []) {
3117
+ const value = point?.value;
3118
+ if (typeof value === "number" && Number.isFinite(value)) {
3119
+ min = Math.min(min, value);
3120
+ max = Math.max(max, value);
3121
+ }
3122
+ }
3123
+ return min < max ? [min, max] : void 0;
3124
+ }, [
3125
+ legendInteractive,
3126
+ rescaleYOnVisibilityChange,
3127
+ dataSorted
3128
+ ]);
3718
3129
  const { tooltipRef, onChartFocus, onChartBlur, onChartKeyDown } = useKeyboardNavigation({
3719
3130
  selectedIndex,
3720
3131
  setSelectedIndex,
@@ -3724,7 +3135,8 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3724
3135
  totalPoints: dataSorted[0]?.data.length || 0
3725
3136
  });
3726
3137
  const chartOptions = useMemo(() => {
3727
- const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);
3138
+ const { tickResolution, ...xAxisOptions } = options?.axis?.x ?? {};
3139
+ const formatter = xAxisOptions.tickFormat || getFormatter(dataSorted, tickResolution);
3728
3140
  return {
3729
3141
  axis: {
3730
3142
  x: {
@@ -3732,7 +3144,7 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3732
3144
  numTicks: guessOptimalNumTicks(dataSorted, width, formatter),
3733
3145
  tickFormat: formatter,
3734
3146
  display: true,
3735
- ...options?.axis?.x
3147
+ ...xAxisOptions
3736
3148
  },
3737
3149
  y: {
3738
3150
  orientation: "left",
@@ -3751,6 +3163,7 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3751
3163
  type: "linear",
3752
3164
  nice: true,
3753
3165
  zero: false,
3166
+ ...stableYDomain ? { domain: stableYDomain } : {},
3754
3167
  ...options?.yScale
3755
3168
  }
3756
3169
  };
@@ -3758,7 +3171,8 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3758
3171
  options,
3759
3172
  dataSorted,
3760
3173
  width,
3761
- zoom.domain
3174
+ zoom.domain,
3175
+ stableYDomain
3762
3176
  ]);
3763
3177
  const tooltipRenderGlyph = useMemo(() => {
3764
3178
  return (props) => {
@@ -3787,10 +3201,12 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3787
3201
  legendItems: useChartLegendItems(dataSorted, useMemo(() => ({
3788
3202
  withGlyph: withLegendGlyph,
3789
3203
  glyphSize: Math.max(0, toNumber(glyphStyle?.radius) ?? 4),
3204
+ collapseGroups: legendCollapseGroups,
3790
3205
  renderGlyph
3791
3206
  }), [
3792
3207
  withLegendGlyph,
3793
3208
  glyphStyle?.radius,
3209
+ legendCollapseGroups,
3794
3210
  renderGlyph
3795
3211
  ]), legendShape),
3796
3212
  chartType: "line",
@@ -3880,12 +3296,12 @@ const LineChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
3880
3296
  onPointerOut,
3881
3297
  pointerEventsDataKey: "nearest",
3882
3298
  children: [
3883
- gridVisibility !== "none" && /* @__PURE__ */ jsx(Grid, {
3299
+ !allSeriesHidden && gridVisibility !== "none" && /* @__PURE__ */ jsx(Grid, {
3884
3300
  columns: false,
3885
3301
  numTicks: 4
3886
3302
  }),
3887
- chartOptions.axis.x.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.x }),
3888
- chartOptions.axis.y.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.y }),
3303
+ !allSeriesHidden && chartOptions.axis.x.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.x }),
3304
+ !allSeriesHidden && chartOptions.axis.y.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.y }),
3889
3305
  allSeriesHidden ? /* @__PURE__ */ jsx(SvgEmptyState, {
3890
3306
  x: width / 2,
3891
3307
  y: chartHeight / 2,
@@ -4093,10 +3509,11 @@ const HoverGlyphs = ({ visibleSeries, stacked, stackOffset, getElementStyles, st
4093
3509
  };
4094
3510
  //#endregion
4095
3511
  //#region src/charts/area-chart/area-chart.tsx
4096
- const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, stacked = true, stackOffset = "none", smoothing = true, curveType, fillOpacity, withStroke, renderTooltip = renderDefaultTooltip, animation, options = {}, onPointerDown, onPointerUp, onPointerMove, onPointerOut, zoomable = false, rescaleYOnLegendToggle = true, children, gridVisibility, gap = "md" }, ref) => {
3512
+ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, height, className, margin, withTooltips = true, withTooltipCrosshairs, showLegend = false, legend = {}, stacked = true, stackOffset = "none", smoothing = true, curveType, fillOpacity, withStroke, renderTooltip = renderDefaultTooltip, animation, options = {}, onPointerDown, onPointerUp, onPointerMove, onPointerOut, zoomable = false, rescaleYOnVisibilityChange, rescaleYOnLegendToggle, children, gridVisibility, gap = "md" }, ref) => {
4097
3513
  const legendInteractive = legend.interactive ?? false;
4098
3514
  const legendShape = legend.shape ?? "rect";
4099
3515
  const legendPosition = legend.position ?? "bottom";
3516
+ const rescaleYOnVisibility = rescaleYOnVisibilityChange ?? rescaleYOnLegendToggle ?? true;
4100
3517
  const providerTheme = useGlobalChartsTheme();
4101
3518
  const theme = useXYChartTheme(data);
4102
3519
  const chartId = useChartId(providedChartId);
@@ -4155,7 +3572,7 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
4155
3572
  totalPoints: dataSorted[0]?.data.length || 0
4156
3573
  });
4157
3574
  const fixedYDomain = useMemo(() => {
4158
- if (rescaleYOnLegendToggle || !legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") return;
3575
+ if (rescaleYOnVisibility || !legendInteractive || !dataSorted.length || !dataSorted[0].data.length || stacked && stackOffset !== "none") return;
4159
3576
  if (stacked) {
4160
3577
  const numPoints = Math.max(...dataSorted.map((s) => s.data.length));
4161
3578
  let posMax = 0;
@@ -4190,10 +3607,11 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
4190
3607
  stacked,
4191
3608
  stackOffset,
4192
3609
  legendInteractive,
4193
- rescaleYOnLegendToggle
3610
+ rescaleYOnVisibility
4194
3611
  ]);
4195
3612
  const chartOptions = useMemo(() => {
4196
- const formatter = options?.axis?.x?.tickFormat || getFormatter(dataSorted);
3613
+ const { tickResolution, ...xAxisOptions } = options?.axis?.x ?? {};
3614
+ const formatter = xAxisOptions.tickFormat || getFormatter(dataSorted, tickResolution);
4197
3615
  return {
4198
3616
  axis: {
4199
3617
  x: {
@@ -4201,7 +3619,7 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
4201
3619
  numTicks: guessOptimalNumTicks(dataSorted, width, formatter),
4202
3620
  tickFormat: formatter,
4203
3621
  display: true,
4204
- ...options?.axis?.x
3622
+ ...xAxisOptions
4205
3623
  },
4206
3624
  y: {
4207
3625
  orientation: "left",
@@ -4239,8 +3657,9 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
4239
3657
  chartId,
4240
3658
  legendItems: useChartLegendItems(dataSorted, useMemo(() => ({
4241
3659
  withGlyph: false,
4242
- glyphSize: 0
4243
- }), []), legendShape),
3660
+ glyphSize: 0,
3661
+ collapseGroups: legend.collapseGroups ?? false
3662
+ }), [legend.collapseGroups]), legendShape),
4244
3663
  chartType: "area",
4245
3664
  isDataValid,
4246
3665
  metadata: useMemo(() => ({
@@ -4377,12 +3796,12 @@ const AreaChartInternal = forwardRef(({ data, chartId: providedChartId, width, h
4377
3796
  onPointerOut,
4378
3797
  pointerEventsDataKey: "nearest",
4379
3798
  children: [
4380
- gridVisibility !== "none" && /* @__PURE__ */ jsx(Grid, {
3799
+ !allSeriesHidden && gridVisibility !== "none" && /* @__PURE__ */ jsx(Grid, {
4381
3800
  columns: false,
4382
3801
  numTicks: 4
4383
3802
  }),
4384
- chartOptions.axis.x.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.x }),
4385
- chartOptions.axis.y.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.y }),
3803
+ !allSeriesHidden && chartOptions.axis.x.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.x }),
3804
+ !allSeriesHidden && chartOptions.axis.y.display && /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.y }),
4386
3805
  allSeriesHidden ? /* @__PURE__ */ jsx(SvgEmptyState, {
4387
3806
  x: width / 2,
4388
3807
  y: chartHeight / 2,
@@ -4851,6 +4270,7 @@ const renderTooltipRow = (label, value) => /* @__PURE__ */ jsx("div", {
4851
4270
  });
4852
4271
  const BarChartInternal = ({ data, chartId: providedChartId, width, height, className, margin, withTooltips = false, showLegend = false, legend = {}, gridVisibility: gridVisibilityProp, renderTooltip, options = {}, orientation = "vertical", withPatterns = false, showZeroValues = false, animation, children, gap = "md" }) => {
4853
4272
  const legendInteractive = legend.interactive ?? false;
4273
+ const legendCollapseGroups = legend.collapseGroups ?? false;
4854
4274
  const horizontal = orientation === "horizontal";
4855
4275
  const chartId = useChartId(providedChartId);
4856
4276
  const theme = useXYChartTheme(data);
@@ -4859,7 +4279,7 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
4859
4279
  enabled: showZeroValues,
4860
4280
  valueAxisLength: horizontal ? width : height
4861
4281
  });
4862
- const legendItems = useChartLegendItems(dataSorted);
4282
+ const legendItems = useChartLegendItems(dataSorted, useMemo(() => ({ collapseGroups: legendCollapseGroups }), [legendCollapseGroups]));
4863
4283
  const chartOptions = useBarChartOptions(dataWithVisibleZeros, horizontal, options);
4864
4284
  const defaultMargin = useChartMargin(height, chartOptions, dataSorted, theme, horizontal);
4865
4285
  const chartRef = useRef(null);
@@ -5151,7 +4571,7 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
5151
4571
  horizontal,
5152
4572
  pointerEventsDataKey: "nearest",
5153
4573
  children: [
5154
- /* @__PURE__ */ jsx(Grid, {
4574
+ !allSeriesHidden && /* @__PURE__ */ jsx(Grid, {
5155
4575
  columns: gridVisibility.includes("y"),
5156
4576
  rows: gridVisibility.includes("x"),
5157
4577
  numTicks: 4
@@ -5191,8 +4611,7 @@ const BarChartInternal = ({ data, chartId: providedChartId, width, height, class
5191
4611
  colorAccessor: getBarBackground(index)
5192
4612
  }, seriesData?.label))
5193
4613
  }),
5194
- /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.x }),
5195
- /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.y }),
4614
+ !allSeriesHidden && /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.x }), /* @__PURE__ */ jsx(Axis, { ...chartOptions.axis.y })] }),
5196
4615
  withTooltips && /* @__PURE__ */ jsx(AccessibleTooltip, {
5197
4616
  detectBounds: true,
5198
4617
  snapTooltipToDatumX: true,
@@ -6413,6 +5832,73 @@ const HeatmapChartResponsiveInner = (props) => /* @__PURE__ */ jsx(HeatmapChartW
6413
5832
  HeatmapChartResponsiveInner.displayName = "HeatmapChart";
6414
5833
  const HeatmapChartResponsive = attachSubComponents(withResponsive(HeatmapChartResponsiveInner), { Legend: HeatmapLegend });
6415
5834
  //#endregion
5835
+ //#region ../../../node_modules/.pnpm/is-plain-object@5.0.0/node_modules/is-plain-object/dist/is-plain-object.mjs
5836
+ /*!
5837
+ * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
5838
+ *
5839
+ * Copyright (c) 2014-2017, Jon Schlinkert.
5840
+ * Released under the MIT License.
5841
+ */
5842
+ function isObject(o) {
5843
+ return Object.prototype.toString.call(o) === "[object Object]";
5844
+ }
5845
+ function isPlainObject(o) {
5846
+ var ctor, prot;
5847
+ if (isObject(o) === false) return false;
5848
+ ctor = o.constructor;
5849
+ if (ctor === void 0) return true;
5850
+ prot = ctor.prototype;
5851
+ if (isObject(prot) === false) return false;
5852
+ if (prot.hasOwnProperty("isPrototypeOf") === false) return false;
5853
+ return true;
5854
+ }
5855
+ //#endregion
5856
+ //#region ../../../node_modules/.pnpm/lower-case@2.0.2/node_modules/lower-case/dist.es2015/index.js
5857
+ /**
5858
+ * Lower case as a function.
5859
+ */
5860
+ function lowerCase(str) {
5861
+ return str.toLowerCase();
5862
+ }
5863
+ //#endregion
5864
+ //#region ../../../node_modules/.pnpm/no-case@3.0.4/node_modules/no-case/dist.es2015/index.js
5865
+ var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
5866
+ var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
5867
+ /**
5868
+ * Normalize the string into something other libraries can manipulate easier.
5869
+ */
5870
+ function noCase(input, options) {
5871
+ if (options === void 0) options = {};
5872
+ 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, delimiter = _d === void 0 ? " " : _d;
5873
+ var result = replace$1(replace$1(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
5874
+ var start = 0;
5875
+ var end = result.length;
5876
+ while (result.charAt(start) === "\0") start++;
5877
+ while (result.charAt(end - 1) === "\0") end--;
5878
+ return result.slice(start, end).split("\0").map(transform).join(delimiter);
5879
+ }
5880
+ /**
5881
+ * Replace `re` in the input string with the replacement value.
5882
+ */
5883
+ function replace$1(input, re, value) {
5884
+ if (re instanceof RegExp) return input.replace(re, value);
5885
+ return re.reduce(function(input, re) {
5886
+ return input.replace(re, value);
5887
+ }, input);
5888
+ }
5889
+ //#endregion
5890
+ //#region ../../../node_modules/.pnpm/dot-case@3.0.4/node_modules/dot-case/dist.es2015/index.js
5891
+ function dotCase(input, options) {
5892
+ if (options === void 0) options = {};
5893
+ return noCase(input, __assign({ delimiter: "." }, options));
5894
+ }
5895
+ //#endregion
5896
+ //#region ../../../node_modules/.pnpm/param-case@3.0.4/node_modules/param-case/dist.es2015/index.js
5897
+ function paramCase(input, options) {
5898
+ if (options === void 0) options = {};
5899
+ return dotCase(input, __assign({ delimiter: "-" }, options));
5900
+ }
5901
+ //#endregion
6416
5902
  //#region ../../../node_modules/.pnpm/@wordpress+components@37.0.0_@types+react@18.3.28_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
6417
5903
  function useUpdateEffect(effect, deps) {
6418
5904
  const mountedRef = useRef$1(false);
@@ -8277,10 +7763,10 @@ var require_es6 = /* @__PURE__ */ __commonJSMin(((exports, module) => {
8277
7763
  };
8278
7764
  }));
8279
7765
  //#endregion
8280
- //#region ../../../node_modules/.pnpm/@wordpress+warning@3.51.0/node_modules/@wordpress/warning/build-module/utils.mjs
7766
+ //#region ../../../node_modules/.pnpm/@wordpress+warning@3.52.0/node_modules/@wordpress/warning/build-module/utils.mjs
8281
7767
  var logged = /* @__PURE__ */ new Set();
8282
7768
  //#endregion
8283
- //#region ../../../node_modules/.pnpm/@wordpress+warning@3.51.0/node_modules/@wordpress/warning/build-module/index.mjs
7769
+ //#region ../../../node_modules/.pnpm/@wordpress+warning@3.52.0/node_modules/@wordpress/warning/build-module/index.mjs
8284
7770
  function isDev() {
8285
7771
  return globalThis.SCRIPT_DEBUG === true;
8286
7772
  }