@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.d.mts CHANGED
@@ -1939,6 +1939,13 @@ interface TimeSeriesGraphProps {
1939
1939
  * while the header remains visible and interactive.
1940
1940
  */
1941
1941
  loading?: boolean;
1942
+ /**
1943
+ * Override the x-axis date format string (date-fns format tokens).
1944
+ * When omitted, the format is auto-detected from the data's time span:
1945
+ * - <= 24 hours → `'HH:mm'`
1946
+ * - > 24 hours → `'do MMM'`
1947
+ */
1948
+ xAxisFormat?: string;
1942
1949
  }
1943
1950
  /**
1944
1951
  * A reusable time series graph component that displays one or more data lines
@@ -1973,7 +1980,7 @@ interface TimeSeriesGraphProps {
1973
1980
  *
1974
1981
  * Figma reference: [ROB Design - Node 162:1172](https://www.figma.com/design/xky11VbkkFcgZLwZE8BdCN/ROB?node-id=162-1172&m=dev)
1975
1982
  */
1976
- declare const TimeSeriesGraph: ({ title, series, timeRangeOptions, selectedTimeRange, onTimeRangeChange, summaryItems, showSummary, headerAction, loading, }: TimeSeriesGraphProps) => react_jsx_runtime.JSX.Element;
1983
+ declare const TimeSeriesGraph: ({ title, series, timeRangeOptions, selectedTimeRange, onTimeRangeChange, summaryItems, showSummary, headerAction, loading, xAxisFormat, }: TimeSeriesGraphProps) => react_jsx_runtime.JSX.Element;
1977
1984
 
1978
1985
  interface FlowEditorProps extends Omit<ReactFlowProps, 'nodes' | 'edges'> {
1979
1986
  /**
package/dist/index.d.ts CHANGED
@@ -1939,6 +1939,13 @@ interface TimeSeriesGraphProps {
1939
1939
  * while the header remains visible and interactive.
1940
1940
  */
1941
1941
  loading?: boolean;
1942
+ /**
1943
+ * Override the x-axis date format string (date-fns format tokens).
1944
+ * When omitted, the format is auto-detected from the data's time span:
1945
+ * - <= 24 hours → `'HH:mm'`
1946
+ * - > 24 hours → `'do MMM'`
1947
+ */
1948
+ xAxisFormat?: string;
1942
1949
  }
1943
1950
  /**
1944
1951
  * A reusable time series graph component that displays one or more data lines
@@ -1973,7 +1980,7 @@ interface TimeSeriesGraphProps {
1973
1980
  *
1974
1981
  * Figma reference: [ROB Design - Node 162:1172](https://www.figma.com/design/xky11VbkkFcgZLwZE8BdCN/ROB?node-id=162-1172&m=dev)
1975
1982
  */
1976
- declare const TimeSeriesGraph: ({ title, series, timeRangeOptions, selectedTimeRange, onTimeRangeChange, summaryItems, showSummary, headerAction, loading, }: TimeSeriesGraphProps) => react_jsx_runtime.JSX.Element;
1983
+ declare const TimeSeriesGraph: ({ title, series, timeRangeOptions, selectedTimeRange, onTimeRangeChange, summaryItems, showSummary, headerAction, loading, xAxisFormat, }: TimeSeriesGraphProps) => react_jsx_runtime.JSX.Element;
1977
1984
 
1978
1985
  interface FlowEditorProps extends Omit<ReactFlowProps, 'nodes' | 'edges'> {
1979
1986
  /**
package/dist/index.js CHANGED
@@ -7492,6 +7492,12 @@ var formatYAxisValue = (value) => {
7492
7492
  }
7493
7493
  return String(value);
7494
7494
  };
7495
+ var TWENTY_FOUR_HOURS_MS = 24 * 60 * 60 * 1e3;
7496
+ var inferXAxisFormat = (min, max) => {
7497
+ if (!min || !max) return "do MMM";
7498
+ const spanMs = max.getTime() - min.getTime();
7499
+ return spanMs <= TWENTY_FOUR_HOURS_MS ? "HH:mm" : "do MMM";
7500
+ };
7495
7501
  var buildDataset = (series, hiddenSeries) => {
7496
7502
  const timestampMap = /* @__PURE__ */ new Map();
7497
7503
  series.forEach((s) => {
@@ -7517,7 +7523,8 @@ var TimeSeriesGraph = ({
7517
7523
  summaryItems,
7518
7524
  showSummary = true,
7519
7525
  headerAction,
7520
- loading = false
7526
+ loading = false,
7527
+ xAxisFormat
7521
7528
  }) => {
7522
7529
  const theme2 = (0, import_material67.useTheme)();
7523
7530
  const [hiddenSeries, setHiddenSeries] = (0, import_react33.useState)(/* @__PURE__ */ new Set());
@@ -7546,6 +7553,10 @@ var TimeSeriesGraph = ({
7546
7553
  max: new Date(Math.max(...timestamps))
7547
7554
  };
7548
7555
  }, [dataset]);
7556
+ const resolvedXAxisFormat = (0, import_react33.useMemo)(
7557
+ () => xAxisFormat ?? inferXAxisFormat(timeBounds.min, timeBounds.max),
7558
+ [xAxisFormat, timeBounds.min, timeBounds.max]
7559
+ );
7549
7560
  const hasData = dataset.length > 0;
7550
7561
  const shouldShowSummary = showSummary && summaryItems && summaryItems.length > 0;
7551
7562
  const headerActionElement = /* @__PURE__ */ (0, import_jsx_runtime89.jsxs)(import_material67.Stack, { direction: "row", spacing: 1, alignItems: "center", children: [
@@ -7613,7 +7624,7 @@ var TimeSeriesGraph = ({
7613
7624
  max: timeBounds.max,
7614
7625
  disableLine: true,
7615
7626
  disableTicks: true,
7616
- valueFormatter: (date) => (0, import_date_fns3.format)(date, "do MMM"),
7627
+ valueFormatter: (date) => (0, import_date_fns3.format)(date, resolvedXAxisFormat),
7617
7628
  tickLabelStyle: {
7618
7629
  fontSize: 10
7619
7630
  }