@adsgency_npm/adsgency-ads-ui 0.1.0-alpha.33 → 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,
@@ -6176,15 +6189,17 @@ function AdsLineChart({
6176
6189
  }) {
6177
6190
  const [activeDataKey, setActiveDataKey] = React48.useState(null);
6178
6191
  const hoverHighlightDataKey = series.find((item) => item.activeColor)?.dataKey ?? null;
6179
- const chartData = data.map((datum) => {
6180
- const safeDatum = { ...datum, [xKey]: datum[xKey] };
6181
- series.forEach((item) => {
6182
- safeDatum[item.dataKey] = getSafeValue(datum[item.dataKey]);
6183
- });
6184
- return safeDatum;
6185
- });
6186
- const safeHeight = getSafeHeight(height);
6187
- const chartConfig = getChartConfig(series);
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]);
6188
6203
  const {
6189
6204
  cursor: tooltipCursor,
6190
6205
  wrapperStyle: tooltipWrapperStyle,
@@ -6197,7 +6212,7 @@ function AdsLineChart({
6197
6212
  className: cn("w-full", className),
6198
6213
  "data-testid": "ads-line-chart",
6199
6214
  role: "img",
6200
- style: { height: safeHeight },
6215
+ style: { height: getSafeHeight(height) },
6201
6216
  children: /* @__PURE__ */ (0, import_jsx_runtime55.jsx)(
6202
6217
  ChartContainer,
6203
6218
  {
@@ -6296,11 +6311,11 @@ function AdsLineChart({
6296
6311
  import_recharts3.Area,
6297
6312
  {
6298
6313
  ...item.areaProps,
6314
+ animationDuration: item.areaProps?.animationDuration ?? 360,
6315
+ animationEasing: item.areaProps?.animationEasing ?? "ease-out",
6299
6316
  dataKey: item.dataKey,
6300
6317
  fill: item.areaProps?.fill ?? color,
6301
6318
  fillOpacity: item.areaProps?.fillOpacity ?? opacity,
6302
- animationDuration: item.areaProps?.animationDuration ?? 360,
6303
- animationEasing: item.areaProps?.animationEasing ?? "ease-out",
6304
6319
  isAnimationActive: item.areaProps?.isAnimationActive ?? true,
6305
6320
  stroke: item.areaProps?.stroke ?? "none",
6306
6321
  type: item.areaProps?.type ?? curve
@@ -6337,6 +6352,34 @@ function AdsLineChart({
6337
6352
 
6338
6353
  // src/components/AdsSparklineChart/index.tsx
6339
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
6340
6383
  var import_jsx_runtime56 = require("react/jsx-runtime");
6341
6384
  var DEFAULT_HEIGHT2 = 40;
6342
6385
  var tooltipContentStyle2 = {
@@ -6352,6 +6395,13 @@ function getSafeHeight2(height) {
6352
6395
  function getSafeValue2(value) {
6353
6396
  return typeof value === "number" && Number.isFinite(value) ? Math.max(value, 0) : 0;
6354
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
+ }
6355
6405
  function AdsSparklineChart({
6356
6406
  ariaLabel,
6357
6407
  className,
@@ -6359,7 +6409,9 @@ function AdsSparklineChart({
6359
6409
  data,
6360
6410
  dataKey,
6361
6411
  height,
6412
+ plotHeight,
6362
6413
  showTooltip = true,
6414
+ tooltipDateFormat,
6363
6415
  xKey
6364
6416
  }) {
6365
6417
  const chartData = data.map((datum) => ({
@@ -6368,6 +6420,7 @@ function AdsSparklineChart({
6368
6420
  [dataKey]: getSafeValue2(datum[dataKey])
6369
6421
  }));
6370
6422
  const safeHeight = getSafeHeight2(height);
6423
+ const chartMargin = getChartMargin(safeHeight, plotHeight);
6371
6424
  return /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6372
6425
  "div",
6373
6426
  {
@@ -6388,10 +6441,17 @@ function AdsSparklineChart({
6388
6441
  {
6389
6442
  accessibilityLayer: false,
6390
6443
  data: chartData,
6391
- margin: { bottom: 1, left: 1, right: 1, top: 1 },
6444
+ margin: chartMargin,
6392
6445
  children: [
6393
6446
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(import_recharts4.XAxis, { dataKey: xKey, hide: true, type: "category" }),
6394
- 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
+ ),
6395
6455
  /* @__PURE__ */ (0, import_jsx_runtime56.jsx)(
6396
6456
  import_recharts4.Line,
6397
6457
  {
@@ -6578,6 +6638,7 @@ function AdsBarChart({
6578
6638
  highlightIndex,
6579
6639
  hoverColor,
6580
6640
  showTooltip = true,
6641
+ tooltipDateFormat,
6581
6642
  xAxis,
6582
6643
  xKey,
6583
6644
  yAxis
@@ -6637,7 +6698,14 @@ function AdsBarChart({
6637
6698
  width: yAxis.width
6638
6699
  }
6639
6700
  ),
6640
- 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
+ ),
6641
6709
  /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
6642
6710
  import_recharts5.Bar,
6643
6711
  {
package/dist/index.d.cts CHANGED
@@ -807,8 +807,8 @@ interface AdsLineChartReferenceLine {
807
807
  interface AdsLineChartProps {
808
808
  ariaLabel?: string;
809
809
  chartProps?: Omit<React$1.ComponentProps<typeof ComposedChart>, "accessibilityLayer" | "children" | "data">;
810
- className?: string;
811
810
  children?: React$1.ReactNode;
811
+ className?: string;
812
812
  containerProps?: Omit<ChartContainerProps, "children" | "config" | "height">;
813
813
  curve?: AdsLineChartCurve;
814
814
  data: AdsChartDatum[];
@@ -834,7 +834,7 @@ interface AdsLineChartProps {
834
834
  yAxis?: AdsLineChartYAxisOptions;
835
835
  yAxisProps?: React$1.ComponentProps<typeof YAxis>;
836
836
  }
837
- 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;
838
838
 
839
839
  interface AdsSparklineChartProps {
840
840
  ariaLabel?: string;
@@ -843,10 +843,12 @@ interface AdsSparklineChartProps {
843
843
  data: AdsChartDatum[];
844
844
  dataKey: string;
845
845
  height?: number;
846
+ plotHeight?: number;
846
847
  showTooltip?: boolean;
848
+ tooltipDateFormat?: string;
847
849
  xKey: string;
848
850
  }
849
- 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;
850
852
 
851
853
  interface AdsStackedBarChartProps {
852
854
  ariaLabel?: string;
@@ -888,11 +890,12 @@ interface AdsBarChartProps {
888
890
  highlightIndex?: number;
889
891
  hoverColor?: string;
890
892
  showTooltip?: boolean;
893
+ tooltipDateFormat?: string;
891
894
  xAxis?: AdsBarChartXAxisOptions;
892
895
  xKey: string;
893
896
  yAxis?: AdsBarChartYAxisOptions;
894
897
  }
895
- 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;
896
899
 
897
900
  declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<_radix_ui_react_radio_group.RadioGroupProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
898
901
 
package/dist/index.d.ts CHANGED
@@ -807,8 +807,8 @@ interface AdsLineChartReferenceLine {
807
807
  interface AdsLineChartProps {
808
808
  ariaLabel?: string;
809
809
  chartProps?: Omit<React$1.ComponentProps<typeof ComposedChart>, "accessibilityLayer" | "children" | "data">;
810
- className?: string;
811
810
  children?: React$1.ReactNode;
811
+ className?: string;
812
812
  containerProps?: Omit<ChartContainerProps, "children" | "config" | "height">;
813
813
  curve?: AdsLineChartCurve;
814
814
  data: AdsChartDatum[];
@@ -834,7 +834,7 @@ interface AdsLineChartProps {
834
834
  yAxis?: AdsLineChartYAxisOptions;
835
835
  yAxisProps?: React$1.ComponentProps<typeof YAxis>;
836
836
  }
837
- 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;
838
838
 
839
839
  interface AdsSparklineChartProps {
840
840
  ariaLabel?: string;
@@ -843,10 +843,12 @@ interface AdsSparklineChartProps {
843
843
  data: AdsChartDatum[];
844
844
  dataKey: string;
845
845
  height?: number;
846
+ plotHeight?: number;
846
847
  showTooltip?: boolean;
848
+ tooltipDateFormat?: string;
847
849
  xKey: string;
848
850
  }
849
- 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;
850
852
 
851
853
  interface AdsStackedBarChartProps {
852
854
  ariaLabel?: string;
@@ -888,11 +890,12 @@ interface AdsBarChartProps {
888
890
  highlightIndex?: number;
889
891
  hoverColor?: string;
890
892
  showTooltip?: boolean;
893
+ tooltipDateFormat?: string;
891
894
  xAxis?: AdsBarChartXAxisOptions;
892
895
  xKey: string;
893
896
  yAxis?: AdsBarChartYAxisOptions;
894
897
  }
895
- 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;
896
899
 
897
900
  declare const RadioGroup: React$1.ForwardRefExoticComponent<Omit<_radix_ui_react_radio_group.RadioGroupProps & React$1.RefAttributes<HTMLDivElement>, "ref"> & React$1.RefAttributes<HTMLDivElement>>;
898
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,
@@ -6013,15 +6026,17 @@ function AdsLineChart({
6013
6026
  }) {
6014
6027
  const [activeDataKey, setActiveDataKey] = React48.useState(null);
6015
6028
  const hoverHighlightDataKey = series.find((item) => item.activeColor)?.dataKey ?? null;
6016
- const chartData = data.map((datum) => {
6017
- const safeDatum = { ...datum, [xKey]: datum[xKey] };
6018
- series.forEach((item) => {
6019
- safeDatum[item.dataKey] = getSafeValue(datum[item.dataKey]);
6020
- });
6021
- return safeDatum;
6022
- });
6023
- const safeHeight = getSafeHeight(height);
6024
- const chartConfig = getChartConfig(series);
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]);
6025
6040
  const {
6026
6041
  cursor: tooltipCursor,
6027
6042
  wrapperStyle: tooltipWrapperStyle,
@@ -6034,7 +6049,7 @@ function AdsLineChart({
6034
6049
  className: cn("w-full", className),
6035
6050
  "data-testid": "ads-line-chart",
6036
6051
  role: "img",
6037
- style: { height: safeHeight },
6052
+ style: { height: getSafeHeight(height) },
6038
6053
  children: /* @__PURE__ */ jsx55(
6039
6054
  ChartContainer,
6040
6055
  {
@@ -6133,11 +6148,11 @@ function AdsLineChart({
6133
6148
  Area,
6134
6149
  {
6135
6150
  ...item.areaProps,
6151
+ animationDuration: item.areaProps?.animationDuration ?? 360,
6152
+ animationEasing: item.areaProps?.animationEasing ?? "ease-out",
6136
6153
  dataKey: item.dataKey,
6137
6154
  fill: item.areaProps?.fill ?? color,
6138
6155
  fillOpacity: item.areaProps?.fillOpacity ?? opacity,
6139
- animationDuration: item.areaProps?.animationDuration ?? 360,
6140
- animationEasing: item.areaProps?.animationEasing ?? "ease-out",
6141
6156
  isAnimationActive: item.areaProps?.isAnimationActive ?? true,
6142
6157
  stroke: item.areaProps?.stroke ?? "none",
6143
6158
  type: item.areaProps?.type ?? curve
@@ -6174,6 +6189,34 @@ function AdsLineChart({
6174
6189
 
6175
6190
  // src/components/AdsSparklineChart/index.tsx
6176
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
6177
6220
  import { jsx as jsx56, jsxs as jsxs29 } from "react/jsx-runtime";
6178
6221
  var DEFAULT_HEIGHT2 = 40;
6179
6222
  var tooltipContentStyle2 = {
@@ -6189,6 +6232,13 @@ function getSafeHeight2(height) {
6189
6232
  function getSafeValue2(value) {
6190
6233
  return typeof value === "number" && Number.isFinite(value) ? Math.max(value, 0) : 0;
6191
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
+ }
6192
6242
  function AdsSparklineChart({
6193
6243
  ariaLabel,
6194
6244
  className,
@@ -6196,7 +6246,9 @@ function AdsSparklineChart({
6196
6246
  data,
6197
6247
  dataKey,
6198
6248
  height,
6249
+ plotHeight,
6199
6250
  showTooltip = true,
6251
+ tooltipDateFormat,
6200
6252
  xKey
6201
6253
  }) {
6202
6254
  const chartData = data.map((datum) => ({
@@ -6205,6 +6257,7 @@ function AdsSparklineChart({
6205
6257
  [dataKey]: getSafeValue2(datum[dataKey])
6206
6258
  }));
6207
6259
  const safeHeight = getSafeHeight2(height);
6260
+ const chartMargin = getChartMargin(safeHeight, plotHeight);
6208
6261
  return /* @__PURE__ */ jsx56(
6209
6262
  "div",
6210
6263
  {
@@ -6225,10 +6278,17 @@ function AdsSparklineChart({
6225
6278
  {
6226
6279
  accessibilityLayer: false,
6227
6280
  data: chartData,
6228
- margin: { bottom: 1, left: 1, right: 1, top: 1 },
6281
+ margin: chartMargin,
6229
6282
  children: [
6230
6283
  /* @__PURE__ */ jsx56(XAxis2, { dataKey: xKey, hide: true, type: "category" }),
6231
- 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
+ ),
6232
6292
  /* @__PURE__ */ jsx56(
6233
6293
  Line2,
6234
6294
  {
@@ -6415,6 +6475,7 @@ function AdsBarChart({
6415
6475
  highlightIndex,
6416
6476
  hoverColor,
6417
6477
  showTooltip = true,
6478
+ tooltipDateFormat,
6418
6479
  xAxis,
6419
6480
  xKey,
6420
6481
  yAxis
@@ -6474,7 +6535,14 @@ function AdsBarChart({
6474
6535
  width: yAxis.width
6475
6536
  }
6476
6537
  ),
6477
- 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
+ ),
6478
6546
  /* @__PURE__ */ jsx60(
6479
6547
  Bar,
6480
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.33",
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",
@@ -111,8 +111,8 @@
111
111
  "verify:package": "node scripts/verify-package.mjs",
112
112
  "lint": "eslint src tests --max-warnings=0 && pnpm verify:hygiene && pnpm verify:tokens",
113
113
  "typecheck": "tsc --noEmit",
114
- "test": "NODE_OPTIONS=--max-old-space-size=1536 vitest run",
115
- "test:watch": "NODE_OPTIONS=--max-old-space-size=1536 vitest",
114
+ "test": "vitest run",
115
+ "test:watch": "vitest",
116
116
  "pack:dry": "pnpm build && npm pack --dry-run",
117
117
  "verify": "pnpm lint && pnpm typecheck && pnpm test && pnpm demo:typecheck && pnpm build && pnpm verify:package"
118
118
  }