@adsgency_npm/adsgency-ads-ui 0.1.0-alpha.32 → 0.1.0-alpha.34

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.cjs CHANGED
@@ -6118,9 +6118,7 @@ function LineChartTooltipContent({
6118
6118
  tooltipLabelFormatter,
6119
6119
  tooltipValueFormatter
6120
6120
  }) {
6121
- if (!active || !payload.length) {
6122
- return null;
6123
- }
6121
+ if (!active || !payload.length) return null;
6124
6122
  return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6125
6123
  "div",
6126
6124
  {
@@ -6132,15 +6130,30 @@ function LineChartTooltipContent({
6132
6130
  children: [
6133
6131
  tooltipLabelFormatter && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "mb-2 text-xs font-medium text-muted-foreground", children: tooltipLabelFormatter(label) }),
6134
6132
  /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("div", { className: "space-y-1.5", children: series.map((item, index) => {
6135
- const entry = payload.find((payloadItem) => payloadItem.dataKey === item.dataKey);
6133
+ const entry = payload.find(
6134
+ (payloadItem) => payloadItem.dataKey === item.dataKey
6135
+ );
6136
6136
  const value = typeof entry?.value === "number" && Number.isFinite(entry.value) ? entry.value : 0;
6137
6137
  const color = getSeriesColor(item, index);
6138
- const displayLabel = item.label ?? item.dataKey;
6139
- return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)("div", { className: "flex items-center gap-1.5 text-sm", children: [
6140
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { "aria-hidden": "true", className: "size-2 rounded-full", style: { backgroundColor: color } }),
6141
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "text-muted-foreground", children: displayLabel }),
6142
- /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "font-semibold text-popover-foreground", children: tooltipValueFormatter ? tooltipValueFormatter(value, item) : value })
6143
- ] }, item.dataKey);
6138
+ return /* @__PURE__ */ (0, import_jsx_runtime55.jsxs)(
6139
+ "div",
6140
+ {
6141
+ className: "flex items-center gap-1.5 text-sm",
6142
+ children: [
6143
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6144
+ "span",
6145
+ {
6146
+ "aria-hidden": "true",
6147
+ className: "size-2 rounded-full",
6148
+ style: { backgroundColor: color }
6149
+ }
6150
+ ),
6151
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "text-muted-foreground", children: item.label ?? item.dataKey }),
6152
+ /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("span", { className: "font-semibold text-popover-foreground", children: tooltipValueFormatter ? tooltipValueFormatter(value, item) : value })
6153
+ ]
6154
+ },
6155
+ item.dataKey
6156
+ );
6144
6157
  }) }),
6145
6158
  tooltipFooter && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)("p", { className: "mt-2 text-xs font-bold leading-[1.4]", children: tooltipFooter })
6146
6159
  ]
@@ -6150,8 +6163,8 @@ function LineChartTooltipContent({
6150
6163
  function AdsLineChart({
6151
6164
  ariaLabel,
6152
6165
  chartProps,
6153
- className,
6154
6166
  children,
6167
+ className,
6155
6168
  containerProps,
6156
6169
  curve = "linear",
6157
6170
  data,
@@ -6174,15 +6187,19 @@ function AdsLineChart({
6174
6187
  yAxis,
6175
6188
  yAxisProps
6176
6189
  }) {
6177
- const chartData = data.map((datum) => {
6178
- const safeDatum = { ...datum, [xKey]: datum[xKey] };
6179
- series.forEach((item) => {
6180
- safeDatum[item.dataKey] = getSafeValue(datum[item.dataKey]);
6181
- });
6182
- return safeDatum;
6183
- });
6184
- const safeHeight = getSafeHeight(height);
6185
- const chartConfig = getChartConfig(series);
6190
+ const [activeDataKey, setActiveDataKey] = React48.useState(null);
6191
+ const hoverHighlightDataKey = series.find((item) => item.activeColor)?.dataKey ?? null;
6192
+ const chartData = React48.useMemo(
6193
+ () => data.map((datum) => {
6194
+ const safeDatum = { ...datum, [xKey]: datum[xKey] };
6195
+ series.forEach((item) => {
6196
+ safeDatum[item.dataKey] = getSafeValue(datum[item.dataKey]);
6197
+ });
6198
+ return safeDatum;
6199
+ }),
6200
+ [data, series, xKey]
6201
+ );
6202
+ const chartConfig = React48.useMemo(() => getChartConfig(series), [series]);
6186
6203
  const {
6187
6204
  cursor: tooltipCursor,
6188
6205
  wrapperStyle: tooltipWrapperStyle,
@@ -6195,7 +6212,7 @@ function AdsLineChart({
6195
6212
  className: cn("w-full", className),
6196
6213
  "data-testid": "ads-line-chart",
6197
6214
  role: "img",
6198
- style: { height: safeHeight },
6215
+ style: { height: getSafeHeight(height) },
6199
6216
  children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6200
6217
  ChartContainer,
6201
6218
  {
@@ -6211,6 +6228,14 @@ function AdsLineChart({
6211
6228
  data: chartData,
6212
6229
  margin: chartProps?.margin ?? { bottom: 0, left: 0, right: 0, top: 0 },
6213
6230
  ...chartProps,
6231
+ onMouseLeave: (...args) => {
6232
+ setActiveDataKey(null);
6233
+ chartProps?.onMouseLeave?.(...args);
6234
+ },
6235
+ onMouseMove: (...args) => {
6236
+ setActiveDataKey(hoverHighlightDataKey);
6237
+ chartProps?.onMouseMove?.(...args);
6238
+ },
6214
6239
  children: [
6215
6240
  showGrid && /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6216
6241
  import_recharts3.CartesianGrid,
@@ -6286,10 +6311,12 @@ function AdsLineChart({
6286
6311
  import_recharts3.Area,
6287
6312
  {
6288
6313
  ...item.areaProps,
6314
+ animationDuration: item.areaProps?.animationDuration ?? 360,
6315
+ animationEasing: item.areaProps?.animationEasing ?? "ease-out",
6289
6316
  dataKey: item.dataKey,
6290
6317
  fill: item.areaProps?.fill ?? color,
6291
6318
  fillOpacity: item.areaProps?.fillOpacity ?? opacity,
6292
- isAnimationActive: item.areaProps?.isAnimationActive ?? false,
6319
+ isAnimationActive: item.areaProps?.isAnimationActive ?? true,
6293
6320
  stroke: item.areaProps?.stroke ?? "none",
6294
6321
  type: item.areaProps?.type ?? curve
6295
6322
  }
@@ -6299,10 +6326,14 @@ function AdsLineChart({
6299
6326
  {
6300
6327
  ...item.lineProps,
6301
6328
  activeDot: item.lineProps?.activeDot ?? { r: 5 },
6329
+ animationDuration: item.lineProps?.animationDuration ?? 360,
6330
+ animationEasing: item.lineProps?.animationEasing ?? "ease-out",
6302
6331
  dataKey: item.dataKey,
6303
6332
  dot: item.lineProps?.dot ?? false,
6304
- isAnimationActive: item.lineProps?.isAnimationActive ?? false,
6305
- stroke: item.lineProps?.stroke ?? color,
6333
+ isAnimationActive: item.lineProps?.isAnimationActive ?? true,
6334
+ onMouseEnter: () => setActiveDataKey(item.dataKey),
6335
+ onMouseLeave: () => setActiveDataKey(null),
6336
+ stroke: activeDataKey === item.dataKey ? item.activeColor ?? "#2196f3" : item.lineProps?.stroke ?? color,
6306
6337
  strokeWidth: item.lineProps?.strokeWidth ?? item.strokeWidth ?? 2,
6307
6338
  type: item.lineProps?.type ?? curve
6308
6339
  }
@@ -6321,6 +6352,34 @@ function AdsLineChart({
6321
6352
 
6322
6353
  // src/components/AdsSparklineChart/index.tsx
6323
6354
  var import_recharts4 = require("recharts");
6355
+
6356
+ // src/lib/chartTooltip.ts
6357
+ var ISO_TIMESTAMP_PATTERN = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;
6358
+ var DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
6359
+ function formatChartTooltipLabel(label, dateFormat = DEFAULT_DATE_FORMAT) {
6360
+ if (typeof label !== "string") {
6361
+ return String(label ?? "");
6362
+ }
6363
+ const match = label.match(ISO_TIMESTAMP_PATTERN);
6364
+ if (!match) {
6365
+ return label;
6366
+ }
6367
+ const [year, month, day] = match[1].split("-");
6368
+ const [hour, minute, second] = match[2].split(":");
6369
+ return dateFormat.replace(/YYYY|MM|DD|HH|mm|ss/g, (token) => {
6370
+ const values = {
6371
+ YYYY: year,
6372
+ MM: month,
6373
+ DD: day,
6374
+ HH: hour,
6375
+ mm: minute,
6376
+ ss: second
6377
+ };
6378
+ return values[token];
6379
+ });
6380
+ }
6381
+
6382
+ // src/components/AdsSparklineChart/index.tsx
6324
6383
  var import_jsx_runtime56 = require("react/jsx-runtime");
6325
6384
  var DEFAULT_HEIGHT2 = 40;
6326
6385
  var tooltipContentStyle2 = {
@@ -6336,6 +6395,13 @@ function getSafeHeight2(height) {
6336
6395
  function getSafeValue2(value) {
6337
6396
  return typeof value === "number" && Number.isFinite(value) ? Math.max(value, 0) : 0;
6338
6397
  }
6398
+ function getChartMargin(height, plotHeight) {
6399
+ if (!Number.isFinite(plotHeight) || !plotHeight || plotHeight >= height) {
6400
+ return { bottom: 1, left: 1, right: 1, top: 1 };
6401
+ }
6402
+ const verticalMargin = (height - Math.max(plotHeight, 1)) / 2;
6403
+ return { bottom: verticalMargin, left: 1, right: 1, top: verticalMargin };
6404
+ }
6339
6405
  function AdsSparklineChart({
6340
6406
  ariaLabel,
6341
6407
  className,
@@ -6343,7 +6409,9 @@ function AdsSparklineChart({
6343
6409
  data,
6344
6410
  dataKey,
6345
6411
  height,
6412
+ plotHeight,
6346
6413
  showTooltip = true,
6414
+ tooltipDateFormat,
6347
6415
  xKey
6348
6416
  }) {
6349
6417
  const chartData = data.map((datum) => ({
@@ -6352,6 +6420,7 @@ function AdsSparklineChart({
6352
6420
  [dataKey]: getSafeValue2(datum[dataKey])
6353
6421
  }));
6354
6422
  const safeHeight = getSafeHeight2(height);
6423
+ const chartMargin = getChartMargin(safeHeight, plotHeight);
6355
6424
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6356
6425
  "div",
6357
6426
  {
@@ -6372,10 +6441,17 @@ function AdsSparklineChart({
6372
6441
  {
6373
6442
  accessibilityLayer: false,
6374
6443
  data: chartData,
6375
- margin: { bottom: 1, left: 1, right: 1, top: 1 },
6444
+ margin: chartMargin,
6376
6445
  children: [
6377
6446
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_recharts4.XAxis, { dataKey: xKey, hide: true, type: "category" }),
6378
- showTooltip && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_recharts4.Tooltip, { contentStyle: tooltipContentStyle2, cursor: false }),
6447
+ showTooltip && /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6448
+ import_recharts4.Tooltip,
6449
+ {
6450
+ contentStyle: tooltipContentStyle2,
6451
+ cursor: false,
6452
+ labelFormatter: (label) => formatChartTooltipLabel(label, tooltipDateFormat)
6453
+ }
6454
+ ),
6379
6455
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6380
6456
  import_recharts4.Line,
6381
6457
  {
@@ -6562,6 +6638,7 @@ function AdsBarChart({
6562
6638
  highlightIndex,
6563
6639
  hoverColor,
6564
6640
  showTooltip = true,
6641
+ tooltipDateFormat,
6565
6642
  xAxis,
6566
6643
  xKey,
6567
6644
  yAxis
@@ -6621,7 +6698,14 @@ function AdsBarChart({
6621
6698
  width: yAxis.width
6622
6699
  }
6623
6700
  ),
6624
- showTooltip && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(import_recharts5.Tooltip, { contentStyle: tooltipContentStyle3, cursor: { fill: "transparent" } }),
6701
+ showTooltip && /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6702
+ import_recharts5.Tooltip,
6703
+ {
6704
+ contentStyle: tooltipContentStyle3,
6705
+ cursor: { fill: "transparent" },
6706
+ labelFormatter: (label) => formatChartTooltipLabel(label, tooltipDateFormat)
6707
+ }
6708
+ ),
6625
6709
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6626
6710
  import_recharts5.Bar,
6627
6711
  {
package/dist/index.d.cts CHANGED
@@ -771,6 +771,7 @@ interface ChartContainerProps extends React$1.ComponentPropsWithoutRef<"div"> {
771
771
  type AxisBound$1 = "auto" | "dataMax" | "dataMin" | number;
772
772
  type AdsLineChartCurve = "linear" | "monotone" | "step";
773
773
  interface AdsLineChartSeries {
774
+ activeColor?: string;
774
775
  areaOpacity?: number;
775
776
  areaProps?: Omit<React$1.ComponentProps<typeof Area>, "dataKey">;
776
777
  color?: string;
@@ -806,8 +807,8 @@ interface AdsLineChartReferenceLine {
806
807
  interface AdsLineChartProps {
807
808
  ariaLabel?: string;
808
809
  chartProps?: Omit<React$1.ComponentProps<typeof ComposedChart>, "accessibilityLayer" | "children" | "data">;
809
- className?: string;
810
810
  children?: React$1.ReactNode;
811
+ className?: string;
811
812
  containerProps?: Omit<ChartContainerProps, "children" | "config" | "height">;
812
813
  curve?: AdsLineChartCurve;
813
814
  data: AdsChartDatum[];
@@ -833,7 +834,7 @@ interface AdsLineChartProps {
833
834
  yAxis?: AdsLineChartYAxisOptions;
834
835
  yAxisProps?: React$1.ComponentProps<typeof YAxis>;
835
836
  }
836
- declare function AdsLineChart({ ariaLabel, chartProps, className, children, containerProps, curve, data, gridColor, gridProps, height, referenceLine, series, showGrid, showTooltip, tooltipContent, tooltipContentClassName, tooltipFooter, tooltipLabelFormatter, tooltipProps, tooltipValueFormatter, xAxis, xAxisProps, xKey, yAxis, yAxisProps, }: AdsLineChartProps): React$1.JSX.Element;
837
+ declare function AdsLineChart({ ariaLabel, chartProps, children, className, containerProps, curve, data, gridColor, gridProps, height, referenceLine, series, showGrid, showTooltip, tooltipContent, tooltipContentClassName, tooltipFooter, tooltipLabelFormatter, tooltipProps, tooltipValueFormatter, xAxis, xAxisProps, xKey, yAxis, yAxisProps, }: AdsLineChartProps): React$1.JSX.Element;
837
838
 
838
839
  interface AdsSparklineChartProps {
839
840
  ariaLabel?: string;
@@ -842,10 +843,12 @@ interface AdsSparklineChartProps {
842
843
  data: AdsChartDatum[];
843
844
  dataKey: string;
844
845
  height?: number;
846
+ plotHeight?: number;
845
847
  showTooltip?: boolean;
848
+ tooltipDateFormat?: string;
846
849
  xKey: string;
847
850
  }
848
- declare function AdsSparklineChart({ ariaLabel, className, color, data, dataKey, height, showTooltip, xKey, }: AdsSparklineChartProps): React$1.JSX.Element;
851
+ declare function AdsSparklineChart({ ariaLabel, className, color, data, dataKey, height, plotHeight, showTooltip, tooltipDateFormat, xKey, }: AdsSparklineChartProps): React$1.JSX.Element;
849
852
 
850
853
  interface AdsStackedBarChartProps {
851
854
  ariaLabel?: string;
@@ -887,11 +890,12 @@ interface AdsBarChartProps {
887
890
  highlightIndex?: number;
888
891
  hoverColor?: string;
889
892
  showTooltip?: boolean;
893
+ tooltipDateFormat?: string;
890
894
  xAxis?: AdsBarChartXAxisOptions;
891
895
  xKey: string;
892
896
  yAxis?: AdsBarChartYAxisOptions;
893
897
  }
894
- declare function AdsBarChart({ ariaLabel, barRadius, barSize, className, color, data, dataKey, height, highlightColor, highlightIndex, hoverColor, showTooltip, xAxis, xKey, yAxis, }: AdsBarChartProps): React$1.JSX.Element;
898
+ declare function AdsBarChart({ ariaLabel, barRadius, barSize, className, color, data, dataKey, height, highlightColor, highlightIndex, hoverColor, showTooltip, tooltipDateFormat, xAxis, xKey, yAxis, }: AdsBarChartProps): React$1.JSX.Element;
895
899
 
896
900
  declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<_radix_ui_react_radio_group.RadioGroupProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
897
901
 
package/dist/index.d.ts CHANGED
@@ -771,6 +771,7 @@ interface ChartContainerProps extends React$1.ComponentPropsWithoutRef<"div"> {
771
771
  type AxisBound$1 = "auto" | "dataMax" | "dataMin" | number;
772
772
  type AdsLineChartCurve = "linear" | "monotone" | "step";
773
773
  interface AdsLineChartSeries {
774
+ activeColor?: string;
774
775
  areaOpacity?: number;
775
776
  areaProps?: Omit<React$1.ComponentProps<typeof Area>, "dataKey">;
776
777
  color?: string;
@@ -806,8 +807,8 @@ interface AdsLineChartReferenceLine {
806
807
  interface AdsLineChartProps {
807
808
  ariaLabel?: string;
808
809
  chartProps?: Omit<React$1.ComponentProps<typeof ComposedChart>, "accessibilityLayer" | "children" | "data">;
809
- className?: string;
810
810
  children?: React$1.ReactNode;
811
+ className?: string;
811
812
  containerProps?: Omit<ChartContainerProps, "children" | "config" | "height">;
812
813
  curve?: AdsLineChartCurve;
813
814
  data: AdsChartDatum[];
@@ -833,7 +834,7 @@ interface AdsLineChartProps {
833
834
  yAxis?: AdsLineChartYAxisOptions;
834
835
  yAxisProps?: React$1.ComponentProps<typeof YAxis>;
835
836
  }
836
- declare function AdsLineChart({ ariaLabel, chartProps, className, children, containerProps, curve, data, gridColor, gridProps, height, referenceLine, series, showGrid, showTooltip, tooltipContent, tooltipContentClassName, tooltipFooter, tooltipLabelFormatter, tooltipProps, tooltipValueFormatter, xAxis, xAxisProps, xKey, yAxis, yAxisProps, }: AdsLineChartProps): React$1.JSX.Element;
837
+ declare function AdsLineChart({ ariaLabel, chartProps, children, className, containerProps, curve, data, gridColor, gridProps, height, referenceLine, series, showGrid, showTooltip, tooltipContent, tooltipContentClassName, tooltipFooter, tooltipLabelFormatter, tooltipProps, tooltipValueFormatter, xAxis, xAxisProps, xKey, yAxis, yAxisProps, }: AdsLineChartProps): React$1.JSX.Element;
837
838
 
838
839
  interface AdsSparklineChartProps {
839
840
  ariaLabel?: string;
@@ -842,10 +843,12 @@ interface AdsSparklineChartProps {
842
843
  data: AdsChartDatum[];
843
844
  dataKey: string;
844
845
  height?: number;
846
+ plotHeight?: number;
845
847
  showTooltip?: boolean;
848
+ tooltipDateFormat?: string;
846
849
  xKey: string;
847
850
  }
848
- declare function AdsSparklineChart({ ariaLabel, className, color, data, dataKey, height, showTooltip, xKey, }: AdsSparklineChartProps): React$1.JSX.Element;
851
+ declare function AdsSparklineChart({ ariaLabel, className, color, data, dataKey, height, plotHeight, showTooltip, tooltipDateFormat, xKey, }: AdsSparklineChartProps): React$1.JSX.Element;
849
852
 
850
853
  interface AdsStackedBarChartProps {
851
854
  ariaLabel?: string;
@@ -887,11 +890,12 @@ interface AdsBarChartProps {
887
890
  highlightIndex?: number;
888
891
  hoverColor?: string;
889
892
  showTooltip?: boolean;
893
+ tooltipDateFormat?: string;
890
894
  xAxis?: AdsBarChartXAxisOptions;
891
895
  xKey: string;
892
896
  yAxis?: AdsBarChartYAxisOptions;
893
897
  }
894
- declare function AdsBarChart({ ariaLabel, barRadius, barSize, className, color, data, dataKey, height, highlightColor, highlightIndex, hoverColor, showTooltip, xAxis, xKey, yAxis, }: AdsBarChartProps): React$1.JSX.Element;
898
+ declare function AdsBarChart({ ariaLabel, barRadius, barSize, className, color, data, dataKey, height, highlightColor, highlightIndex, hoverColor, showTooltip, tooltipDateFormat, xAxis, xKey, yAxis, }: AdsBarChartProps): React$1.JSX.Element;
895
899
 
896
900
  declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<_radix_ui_react_radio_group.RadioGroupProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
897
901
 
package/dist/index.js CHANGED
@@ -5955,9 +5955,7 @@ function LineChartTooltipContent({
5955
5955
  tooltipLabelFormatter,
5956
5956
  tooltipValueFormatter
5957
5957
  }) {
5958
- if (!active || !payload.length) {
5959
- return null;
5960
- }
5958
+ if (!active || !payload.length) return null;
5961
5959
  return /* @__PURE__ */ jsxs28(
5962
5960
  "div",
5963
5961
  {
@@ -5969,15 +5967,30 @@ function LineChartTooltipContent({
5969
5967
  children: [
5970
5968
  tooltipLabelFormatter && /* @__PURE__ */ jsx55("p", { className: "mb-2 text-xs font-medium text-muted-foreground", children: tooltipLabelFormatter(label) }),
5971
5969
  /* @__PURE__ */ jsx55("div", { className: "space-y-1.5", children: series.map((item, index) => {
5972
- const entry = payload.find((payloadItem) => payloadItem.dataKey === item.dataKey);
5970
+ const entry = payload.find(
5971
+ (payloadItem) => payloadItem.dataKey === item.dataKey
5972
+ );
5973
5973
  const value = typeof entry?.value === "number" && Number.isFinite(entry.value) ? entry.value : 0;
5974
5974
  const color = getSeriesColor(item, index);
5975
- const displayLabel = item.label ?? item.dataKey;
5976
- return /* @__PURE__ */ jsxs28("div", { className: "flex items-center gap-1.5 text-sm", children: [
5977
- /* @__PURE__ */ jsx55("span", { "aria-hidden": "true", className: "size-2 rounded-full", style: { backgroundColor: color } }),
5978
- /* @__PURE__ */ jsx55("span", { className: "text-muted-foreground", children: displayLabel }),
5979
- /* @__PURE__ */ jsx55("span", { className: "font-semibold text-popover-foreground", children: tooltipValueFormatter ? tooltipValueFormatter(value, item) : value })
5980
- ] }, item.dataKey);
5975
+ return /* @__PURE__ */ jsxs28(
5976
+ "div",
5977
+ {
5978
+ className: "flex items-center gap-1.5 text-sm",
5979
+ children: [
5980
+ /* @__PURE__ */ jsx55(
5981
+ "span",
5982
+ {
5983
+ "aria-hidden": "true",
5984
+ className: "size-2 rounded-full",
5985
+ style: { backgroundColor: color }
5986
+ }
5987
+ ),
5988
+ /* @__PURE__ */ jsx55("span", { className: "text-muted-foreground", children: item.label ?? item.dataKey }),
5989
+ /* @__PURE__ */ jsx55("span", { className: "font-semibold text-popover-foreground", children: tooltipValueFormatter ? tooltipValueFormatter(value, item) : value })
5990
+ ]
5991
+ },
5992
+ item.dataKey
5993
+ );
5981
5994
  }) }),
5982
5995
  tooltipFooter && /* @__PURE__ */ jsx55("p", { className: "mt-2 text-xs font-bold leading-[1.4]", children: tooltipFooter })
5983
5996
  ]
@@ -5987,8 +6000,8 @@ function LineChartTooltipContent({
5987
6000
  function AdsLineChart({
5988
6001
  ariaLabel,
5989
6002
  chartProps,
5990
- className,
5991
6003
  children,
6004
+ className,
5992
6005
  containerProps,
5993
6006
  curve = "linear",
5994
6007
  data,
@@ -6011,15 +6024,19 @@ function AdsLineChart({
6011
6024
  yAxis,
6012
6025
  yAxisProps
6013
6026
  }) {
6014
- const chartData = data.map((datum) => {
6015
- const safeDatum = { ...datum, [xKey]: datum[xKey] };
6016
- series.forEach((item) => {
6017
- safeDatum[item.dataKey] = getSafeValue(datum[item.dataKey]);
6018
- });
6019
- return safeDatum;
6020
- });
6021
- const safeHeight = getSafeHeight(height);
6022
- const chartConfig = getChartConfig(series);
6027
+ const [activeDataKey, setActiveDataKey] = React48.useState(null);
6028
+ const hoverHighlightDataKey = series.find((item) => item.activeColor)?.dataKey ?? null;
6029
+ const chartData = React48.useMemo(
6030
+ () => data.map((datum) => {
6031
+ const safeDatum = { ...datum, [xKey]: datum[xKey] };
6032
+ series.forEach((item) => {
6033
+ safeDatum[item.dataKey] = getSafeValue(datum[item.dataKey]);
6034
+ });
6035
+ return safeDatum;
6036
+ }),
6037
+ [data, series, xKey]
6038
+ );
6039
+ const chartConfig = React48.useMemo(() => getChartConfig(series), [series]);
6023
6040
  const {
6024
6041
  cursor: tooltipCursor,
6025
6042
  wrapperStyle: tooltipWrapperStyle,
@@ -6032,7 +6049,7 @@ function AdsLineChart({
6032
6049
  className: cn("w-full", className),
6033
6050
  "data-testid": "ads-line-chart",
6034
6051
  role: "img",
6035
- style: { height: safeHeight },
6052
+ style: { height: getSafeHeight(height) },
6036
6053
  children: /* @__PURE__ */ jsx55(
6037
6054
  ChartContainer,
6038
6055
  {
@@ -6048,6 +6065,14 @@ function AdsLineChart({
6048
6065
  data: chartData,
6049
6066
  margin: chartProps?.margin ?? { bottom: 0, left: 0, right: 0, top: 0 },
6050
6067
  ...chartProps,
6068
+ onMouseLeave: (...args) => {
6069
+ setActiveDataKey(null);
6070
+ chartProps?.onMouseLeave?.(...args);
6071
+ },
6072
+ onMouseMove: (...args) => {
6073
+ setActiveDataKey(hoverHighlightDataKey);
6074
+ chartProps?.onMouseMove?.(...args);
6075
+ },
6051
6076
  children: [
6052
6077
  showGrid && /* @__PURE__ */ jsx55(
6053
6078
  CartesianGrid,
@@ -6123,10 +6148,12 @@ function AdsLineChart({
6123
6148
  Area,
6124
6149
  {
6125
6150
  ...item.areaProps,
6151
+ animationDuration: item.areaProps?.animationDuration ?? 360,
6152
+ animationEasing: item.areaProps?.animationEasing ?? "ease-out",
6126
6153
  dataKey: item.dataKey,
6127
6154
  fill: item.areaProps?.fill ?? color,
6128
6155
  fillOpacity: item.areaProps?.fillOpacity ?? opacity,
6129
- isAnimationActive: item.areaProps?.isAnimationActive ?? false,
6156
+ isAnimationActive: item.areaProps?.isAnimationActive ?? true,
6130
6157
  stroke: item.areaProps?.stroke ?? "none",
6131
6158
  type: item.areaProps?.type ?? curve
6132
6159
  }
@@ -6136,10 +6163,14 @@ function AdsLineChart({
6136
6163
  {
6137
6164
  ...item.lineProps,
6138
6165
  activeDot: item.lineProps?.activeDot ?? { r: 5 },
6166
+ animationDuration: item.lineProps?.animationDuration ?? 360,
6167
+ animationEasing: item.lineProps?.animationEasing ?? "ease-out",
6139
6168
  dataKey: item.dataKey,
6140
6169
  dot: item.lineProps?.dot ?? false,
6141
- isAnimationActive: item.lineProps?.isAnimationActive ?? false,
6142
- stroke: item.lineProps?.stroke ?? color,
6170
+ isAnimationActive: item.lineProps?.isAnimationActive ?? true,
6171
+ onMouseEnter: () => setActiveDataKey(item.dataKey),
6172
+ onMouseLeave: () => setActiveDataKey(null),
6173
+ stroke: activeDataKey === item.dataKey ? item.activeColor ?? "#2196f3" : item.lineProps?.stroke ?? color,
6143
6174
  strokeWidth: item.lineProps?.strokeWidth ?? item.strokeWidth ?? 2,
6144
6175
  type: item.lineProps?.type ?? curve
6145
6176
  }
@@ -6158,6 +6189,34 @@ function AdsLineChart({
6158
6189
 
6159
6190
  // src/components/AdsSparklineChart/index.tsx
6160
6191
  import { Line as Line2, LineChart, Tooltip as Tooltip3, XAxis as XAxis2 } from "recharts";
6192
+
6193
+ // src/lib/chartTooltip.ts
6194
+ var ISO_TIMESTAMP_PATTERN = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2}:\d{2})(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?$/;
6195
+ var DEFAULT_DATE_FORMAT = "YYYY-MM-DD HH:mm:ss";
6196
+ function formatChartTooltipLabel(label, dateFormat = DEFAULT_DATE_FORMAT) {
6197
+ if (typeof label !== "string") {
6198
+ return String(label ?? "");
6199
+ }
6200
+ const match = label.match(ISO_TIMESTAMP_PATTERN);
6201
+ if (!match) {
6202
+ return label;
6203
+ }
6204
+ const [year, month, day] = match[1].split("-");
6205
+ const [hour, minute, second] = match[2].split(":");
6206
+ return dateFormat.replace(/YYYY|MM|DD|HH|mm|ss/g, (token) => {
6207
+ const values = {
6208
+ YYYY: year,
6209
+ MM: month,
6210
+ DD: day,
6211
+ HH: hour,
6212
+ mm: minute,
6213
+ ss: second
6214
+ };
6215
+ return values[token];
6216
+ });
6217
+ }
6218
+
6219
+ // src/components/AdsSparklineChart/index.tsx
6161
6220
  import { jsx as jsx56, jsxs as jsxs29 } from "react/jsx-runtime";
6162
6221
  var DEFAULT_HEIGHT2 = 40;
6163
6222
  var tooltipContentStyle2 = {
@@ -6173,6 +6232,13 @@ function getSafeHeight2(height) {
6173
6232
  function getSafeValue2(value) {
6174
6233
  return typeof value === "number" && Number.isFinite(value) ? Math.max(value, 0) : 0;
6175
6234
  }
6235
+ function getChartMargin(height, plotHeight) {
6236
+ if (!Number.isFinite(plotHeight) || !plotHeight || plotHeight >= height) {
6237
+ return { bottom: 1, left: 1, right: 1, top: 1 };
6238
+ }
6239
+ const verticalMargin = (height - Math.max(plotHeight, 1)) / 2;
6240
+ return { bottom: verticalMargin, left: 1, right: 1, top: verticalMargin };
6241
+ }
6176
6242
  function AdsSparklineChart({
6177
6243
  ariaLabel,
6178
6244
  className,
@@ -6180,7 +6246,9 @@ function AdsSparklineChart({
6180
6246
  data,
6181
6247
  dataKey,
6182
6248
  height,
6249
+ plotHeight,
6183
6250
  showTooltip = true,
6251
+ tooltipDateFormat,
6184
6252
  xKey
6185
6253
  }) {
6186
6254
  const chartData = data.map((datum) => ({
@@ -6189,6 +6257,7 @@ function AdsSparklineChart({
6189
6257
  [dataKey]: getSafeValue2(datum[dataKey])
6190
6258
  }));
6191
6259
  const safeHeight = getSafeHeight2(height);
6260
+ const chartMargin = getChartMargin(safeHeight, plotHeight);
6192
6261
  return /* @__PURE__ */ jsx56(
6193
6262
  "div",
6194
6263
  {
@@ -6209,10 +6278,17 @@ function AdsSparklineChart({
6209
6278
  {
6210
6279
  accessibilityLayer: false,
6211
6280
  data: chartData,
6212
- margin: { bottom: 1, left: 1, right: 1, top: 1 },
6281
+ margin: chartMargin,
6213
6282
  children: [
6214
6283
  /* @__PURE__ */ jsx56(XAxis2, { dataKey: xKey, hide: true, type: "category" }),
6215
- showTooltip && /* @__PURE__ */ jsx56(Tooltip3, { contentStyle: tooltipContentStyle2, cursor: false }),
6284
+ showTooltip && /* @__PURE__ */ jsx56(
6285
+ Tooltip3,
6286
+ {
6287
+ contentStyle: tooltipContentStyle2,
6288
+ cursor: false,
6289
+ labelFormatter: (label) => formatChartTooltipLabel(label, tooltipDateFormat)
6290
+ }
6291
+ ),
6216
6292
  /* @__PURE__ */ jsx56(
6217
6293
  Line2,
6218
6294
  {
@@ -6399,6 +6475,7 @@ function AdsBarChart({
6399
6475
  highlightIndex,
6400
6476
  hoverColor,
6401
6477
  showTooltip = true,
6478
+ tooltipDateFormat,
6402
6479
  xAxis,
6403
6480
  xKey,
6404
6481
  yAxis
@@ -6458,7 +6535,14 @@ function AdsBarChart({
6458
6535
  width: yAxis.width
6459
6536
  }
6460
6537
  ),
6461
- showTooltip && /* @__PURE__ */ jsx60(Tooltip5, { contentStyle: tooltipContentStyle3, cursor: { fill: "transparent" } }),
6538
+ showTooltip && /* @__PURE__ */ jsx60(
6539
+ Tooltip5,
6540
+ {
6541
+ contentStyle: tooltipContentStyle3,
6542
+ cursor: { fill: "transparent" },
6543
+ labelFormatter: (label) => formatChartTooltipLabel(label, tooltipDateFormat)
6544
+ }
6545
+ ),
6462
6546
  /* @__PURE__ */ jsx60(
6463
6547
  Bar,
6464
6548
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adsgency_npm/adsgency-ads-ui",
3
- "version": "0.1.0-alpha.32",
3
+ "version": "0.1.0-alpha.34",
4
4
  "description": "AdsGency Ads Design System React component library.",
5
5
  "private": false,
6
6
  "type": "module",
@@ -35,26 +35,6 @@
35
35
  "publishConfig": {
36
36
  "access": "public"
37
37
  },
38
- "scripts": {
39
- "build": "tsup && node scripts/copy-assets.mjs",
40
- "dev": "tsup --watch",
41
- "demo": "vite --config examples/playground/vite.config.ts --host 127.0.0.1 --port 4173",
42
- "demo:full": "pnpm build && pnpm demo",
43
- "demo:build": "pnpm build && vite build --config examples/playground/vite.config.ts",
44
- "demo:typecheck": "tsc --noEmit -p examples/playground/tsconfig.json",
45
- "verify:hygiene": "node scripts/verify-hygiene.mjs",
46
- "verify:tokens": "node scripts/verify-tokens.mjs",
47
- "verify:package": "node scripts/verify-package.mjs",
48
- "lint": "eslint src tests --max-warnings=0 && pnpm verify:hygiene && pnpm verify:tokens",
49
- "typecheck": "tsc --noEmit",
50
- "test": "vitest run",
51
- "test:watch": "vitest",
52
- "pack:dry": "pnpm build && npm pack --dry-run",
53
- "verify": "pnpm lint && pnpm typecheck && pnpm test && pnpm demo:typecheck && pnpm build && pnpm verify:package",
54
- "prepublishOnly": "pnpm verify",
55
- "prepack": "node scripts/remove-sourcemaps.mjs",
56
- "postpack": "pnpm build"
57
- },
58
38
  "peerDependencies": {
59
39
  "react": ">=18.2.0",
60
40
  "react-dom": ">=18.2.0",
@@ -118,5 +98,22 @@
118
98
  "typescript-eslint": "^8.35.1",
119
99
  "vite": "^7.3.5",
120
100
  "vitest": "^3.2.4"
101
+ },
102
+ "scripts": {
103
+ "build": "tsup && node scripts/copy-assets.mjs",
104
+ "dev": "tsup --watch",
105
+ "demo": "vite --config examples/playground/vite.config.ts --host 127.0.0.1 --port 4173",
106
+ "demo:full": "pnpm build && pnpm demo",
107
+ "demo:build": "pnpm build && vite build --config examples/playground/vite.config.ts",
108
+ "demo:typecheck": "tsc --noEmit -p examples/playground/tsconfig.json",
109
+ "verify:hygiene": "node scripts/verify-hygiene.mjs",
110
+ "verify:tokens": "node scripts/verify-tokens.mjs",
111
+ "verify:package": "node scripts/verify-package.mjs",
112
+ "lint": "eslint src tests --max-warnings=0 && pnpm verify:hygiene && pnpm verify:tokens",
113
+ "typecheck": "tsc --noEmit",
114
+ "test": "vitest run",
115
+ "test:watch": "vitest",
116
+ "pack:dry": "pnpm build && npm pack --dry-run",
117
+ "verify": "pnpm lint && pnpm typecheck && pnpm test && pnpm demo:typecheck && pnpm build && pnpm verify:package"
121
118
  }
122
- }
119
+ }