@cere/cere-design-system 0.0.22 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -7463,6 +7463,12 @@ var formatYAxisValue = (value) => {
7463
7463
  }
7464
7464
  return String(value);
7465
7465
  };
7466
+ var TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1e3;
7467
+ var inferXAxisFormat = (min, max) => {
7468
+ if (!min || !max) return "do MMM";
7469
+ const spanMs = max.getTime() - min.getTime();
7470
+ return spanMs <= TWENTY_FOUR_HOURS_MS ? "HH:mm" : "do MMM";
7471
+ };
7466
7472
  var buildDataset = (series, hiddenSeries) => {
7467
7473
  const timestampMap = /* @__PURE__ */ new Map();
7468
7474
  series.forEach((s) => {
@@ -7488,7 +7494,8 @@ var TimeSeriesGraph = ({
7488
7494
  summaryItems,
7489
7495
  showSummary = true,
7490
7496
  headerAction,
7491
- loading = false
7497
+ loading = false,
7498
+ xAxisFormat
7492
7499
  }) => {
7493
7500
  const theme2 = useTheme5();
7494
7501
  const [hiddenSeries, setHiddenSeries] = useState10(/* @__PURE__ */ new Set());
@@ -7517,6 +7524,10 @@ var TimeSeriesGraph = ({
7517
7524
  max: new Date(Math.max(...timestamps))
7518
7525
  };
7519
7526
  }, [dataset]);
7527
+ const resolvedXAxisFormat = useMemo2(
7528
+ () => xAxisFormat ?? inferXAxisFormat(timeBounds.min, timeBounds.max),
7529
+ [xAxisFormat, timeBounds.min, timeBounds.max]
7530
+ );
7520
7531
  const hasData = dataset.length > 0;
7521
7532
  const shouldShowSummary = showSummary && summaryItems && summaryItems.length > 0;
7522
7533
  const headerActionElement = /* @__PURE__ */ jsxs41(Stack7, { direction: "row", spacing: 1, alignItems: "center", children: [
@@ -7584,7 +7595,7 @@ var TimeSeriesGraph = ({
7584
7595
  max: timeBounds.max,
7585
7596
  disableLine: true,
7586
7597
  disableTicks: true,
7587
- valueFormatter: (date) => format3(date, "do MMM"),
7598
+ valueFormatter: (date) => format3(date, resolvedXAxisFormat),
7588
7599
  tickLabelStyle: {
7589
7600
  fontSize: 10
7590
7601
  }