@meetreeve/ui 0.25.0 → 0.30.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.
@@ -0,0 +1,23 @@
1
+ import * as react from 'react';
2
+
3
+ /**
4
+ * Button's `asChild` + `disabled` branch (DEV-19236). An asChild child is
5
+ * usually an <a>, which has no `disabled`: the attribute is dropped and
6
+ * `disabled:` styles never match. This disables it the way an anchor can be:
7
+ * aria-disabled, out of the tab order, no clicks.
8
+ *
9
+ * It is its own "use client" entry (`@meetreeve/ui/button-client`) because
10
+ * blocking the click takes an event handler, and a server component that
11
+ * renders `<Button asChild disabled>` cannot pass a function across the RSC
12
+ * boundary. `@meetreeve/ui/button` stays server-safe and passes only
13
+ * serializable props here.
14
+ *
15
+ * The forced attributes go after {...props} so a caller's tabIndex or
16
+ * aria-disabled cannot put a disabled link back in the tab order. Slot lets
17
+ * the child's own props win, so the clone forces them too, and drops the
18
+ * child's onClick: Slot chains handlers child-first, so it would still run
19
+ * before our preventDefault.
20
+ */
21
+ declare const DisabledSlot: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
22
+
23
+ export { DisabledSlot };
@@ -0,0 +1,23 @@
1
+ import * as react from 'react';
2
+
3
+ /**
4
+ * Button's `asChild` + `disabled` branch (DEV-19236). An asChild child is
5
+ * usually an <a>, which has no `disabled`: the attribute is dropped and
6
+ * `disabled:` styles never match. This disables it the way an anchor can be:
7
+ * aria-disabled, out of the tab order, no clicks.
8
+ *
9
+ * It is its own "use client" entry (`@meetreeve/ui/button-client`) because
10
+ * blocking the click takes an event handler, and a server component that
11
+ * renders `<Button asChild disabled>` cannot pass a function across the RSC
12
+ * boundary. `@meetreeve/ui/button` stays server-safe and passes only
13
+ * serializable props here.
14
+ *
15
+ * The forced attributes go after {...props} so a caller's tabIndex or
16
+ * aria-disabled cannot put a disabled link back in the tab order. Slot lets
17
+ * the child's own props win, so the clone forces them too, and drops the
18
+ * child's onClick: Slot chains handlers child-first, so it would still run
19
+ * before our preventDefault.
20
+ */
21
+ declare const DisabledSlot: react.ForwardRefExoticComponent<Omit<react.DetailedHTMLProps<react.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> & react.RefAttributes<HTMLButtonElement>>;
22
+
23
+ export { DisabledSlot };
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ "use strict";
3
+ "use client";
4
+ var __create = Object.create;
5
+ var __defProp = Object.defineProperty;
6
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
7
+ var __getOwnPropNames = Object.getOwnPropertyNames;
8
+ var __getProtoOf = Object.getPrototypeOf;
9
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
23
+ // If the importer is in node compatibility mode or this is not an ESM
24
+ // file that has been converted to a CommonJS file using a Babel-
25
+ // compatible transform (i.e. "__esModule" has not been set), then set
26
+ // "default" to the CommonJS "module.exports" for node compatibility.
27
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
28
+ mod
29
+ ));
30
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
31
+
32
+ // src/button-client.tsx
33
+ var button_client_exports = {};
34
+ __export(button_client_exports, {
35
+ DisabledSlot: () => DisabledSlot
36
+ });
37
+ module.exports = __toCommonJS(button_client_exports);
38
+ var React = __toESM(require("react"));
39
+ var import_react_slot = require("@radix-ui/react-slot");
40
+ var import_jsx_runtime = require("react/jsx-runtime");
41
+ var DisabledSlot = React.forwardRef(
42
+ function DisabledSlot2({ children, ...props }, ref) {
43
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
44
+ import_react_slot.Slot,
45
+ {
46
+ ref,
47
+ ...props,
48
+ "aria-disabled": "true",
49
+ tabIndex: -1,
50
+ onClick: (e) => e.preventDefault(),
51
+ children: React.isValidElement(children) ? React.cloneElement(children, { onClick: void 0, tabIndex: -1, "aria-disabled": "true" }) : children
52
+ }
53
+ );
54
+ }
55
+ );
56
+ // Annotate the CommonJS export names for ESM import in node:
57
+ 0 && (module.exports = {
58
+ DisabledSlot
59
+ });
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+
4
+ // src/button-client.tsx
5
+ import * as React from "react";
6
+ import { Slot } from "@radix-ui/react-slot";
7
+ import { jsx } from "react/jsx-runtime";
8
+ var DisabledSlot = React.forwardRef(
9
+ function DisabledSlot2({ children, ...props }, ref) {
10
+ return /* @__PURE__ */ jsx(
11
+ Slot,
12
+ {
13
+ ref,
14
+ ...props,
15
+ "aria-disabled": "true",
16
+ tabIndex: -1,
17
+ onClick: (e) => e.preventDefault(),
18
+ children: React.isValidElement(children) ? React.cloneElement(children, { onClick: void 0, tabIndex: -1, "aria-disabled": "true" }) : children
19
+ }
20
+ );
21
+ }
22
+ );
23
+ export {
24
+ DisabledSlot
25
+ };
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement } from 'react';
3
3
  import { Tooltip, LabelProps } from 'recharts';
4
+ export { u as usePrefersReducedMotion } from '../use-prefers-reduced-motion-CRlBJxhu.mjs';
4
5
 
5
6
  /** Number of categorical series tokens (`--chart-1` … `--chart-8`). */
6
7
  declare const CHART_SERIES_COUNT = 8;
@@ -44,8 +45,6 @@ type ChartConfig = Record<string, {
44
45
  declare function useChart(): {
45
46
  config: ChartConfig;
46
47
  };
47
- /** True when the OS asks for reduced motion; charts then skip their entry animation. */
48
- declare function usePrefersReducedMotion(): boolean;
49
48
  interface ChartContainerProps {
50
49
  /** Optional per-key labels/colours; each colour is exposed as `--color-<key>` inside the chart. */
51
50
  config?: ChartConfig;
@@ -64,6 +63,8 @@ interface TooltipPayloadItem {
64
63
  name: string;
65
64
  value: number;
66
65
  color: string;
66
+ /** The item's `tooltipType`; "none" keeps it out of the tooltip, as in Recharts' default content. */
67
+ type?: string;
67
68
  }
68
69
  interface ChartTooltipContentProps {
69
70
  active?: boolean;
@@ -179,9 +180,18 @@ interface BarChartProps {
179
180
  * (e.g. it is read against a scale rather than per-bar values).
180
181
  */
181
182
  showYAxis?: boolean;
183
+ /**
184
+ * Funnel silhouette (DEV-19691, GA4-style): a soft, low-alpha shape behind
185
+ * the bars that slopes from each bar's top to the next bar's top, so the
186
+ * drop-off between steps reads without the numbers. The bars, value labels,
187
+ * tooltip and cursor are unchanged, and the shape has no tooltip or legend
188
+ * entry. Single series only: with more than one series it is ignored.
189
+ * Default false.
190
+ */
191
+ funnel?: boolean;
182
192
  loading?: boolean;
183
193
  }
184
- declare function BarChart({ data, xKey, series, height, showGrid, showLegend, tooltipFormatter, labelFormatter, showValueLabels, showYAxis, loading, }: BarChartProps): react.JSX.Element;
194
+ declare function BarChart({ data, xKey, series, height, showGrid, showLegend, tooltipFormatter, labelFormatter, showValueLabels, showYAxis, funnel, loading, }: BarChartProps): react.JSX.Element;
185
195
 
186
196
  interface DonutDataItem {
187
197
  name: string;
@@ -328,4 +338,4 @@ declare const DashboardGrid: typeof DashboardGridRoot & {
328
338
  Item: typeof DashboardGridItem;
329
339
  };
330
340
 
331
- export { AreaChart, type AreaChartProps, type AreaChartSeries, type AreaVariant, BAR_CATEGORY_GAP, BAR_STANDARD, BarChart, type BarChartProps, type BarChartSeries, CHART_SERIES_COUNT, ChartCard, type ChartCardProps, type ChartCardRange, type ChartCardState, type ChartConfig, ChartContainer, type ChartContainerProps, type ChartRange, ChartSkeleton, ChartTooltip, ChartTooltipContent, type ChartTooltipContentProps, type Curve, DASHBOARD_GRID_CSS, DASHBOARD_TIERS, DashboardGrid, type DashboardGridItemProps, type DashboardGridProps, type DashboardItemSize, type DeltaTone, DonutChart, type DonutChartProps, type DonutDataItem, KpiCard, type KpiCardProps, LineChart, type LineChartProps, type LineChartSeries, type ModuleState, type Polarity, RadialChart, type RadialChartItem, type RadialChartProps, Sparkline, type SparklineProps, barValueLabel, chartColor, chartConfig, chartPalette, chartTokens, dashboardSpan, deltaTone, useChart, usePrefersReducedMotion, withAlpha };
341
+ export { AreaChart, type AreaChartProps, type AreaChartSeries, type AreaVariant, BAR_CATEGORY_GAP, BAR_STANDARD, BarChart, type BarChartProps, type BarChartSeries, CHART_SERIES_COUNT, ChartCard, type ChartCardProps, type ChartCardRange, type ChartCardState, type ChartConfig, ChartContainer, type ChartContainerProps, type ChartRange, ChartSkeleton, ChartTooltip, ChartTooltipContent, type ChartTooltipContentProps, type Curve, DASHBOARD_GRID_CSS, DASHBOARD_TIERS, DashboardGrid, type DashboardGridItemProps, type DashboardGridProps, type DashboardItemSize, type DeltaTone, DonutChart, type DonutChartProps, type DonutDataItem, KpiCard, type KpiCardProps, LineChart, type LineChartProps, type LineChartSeries, type ModuleState, type Polarity, RadialChart, type RadialChartItem, type RadialChartProps, Sparkline, type SparklineProps, barValueLabel, chartColor, chartConfig, chartPalette, chartTokens, dashboardSpan, deltaTone, useChart, withAlpha };
@@ -1,6 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ReactElement } from 'react';
3
3
  import { Tooltip, LabelProps } from 'recharts';
4
+ export { u as usePrefersReducedMotion } from '../use-prefers-reduced-motion-CRlBJxhu.js';
4
5
 
5
6
  /** Number of categorical series tokens (`--chart-1` … `--chart-8`). */
6
7
  declare const CHART_SERIES_COUNT = 8;
@@ -44,8 +45,6 @@ type ChartConfig = Record<string, {
44
45
  declare function useChart(): {
45
46
  config: ChartConfig;
46
47
  };
47
- /** True when the OS asks for reduced motion; charts then skip their entry animation. */
48
- declare function usePrefersReducedMotion(): boolean;
49
48
  interface ChartContainerProps {
50
49
  /** Optional per-key labels/colours; each colour is exposed as `--color-<key>` inside the chart. */
51
50
  config?: ChartConfig;
@@ -64,6 +63,8 @@ interface TooltipPayloadItem {
64
63
  name: string;
65
64
  value: number;
66
65
  color: string;
66
+ /** The item's `tooltipType`; "none" keeps it out of the tooltip, as in Recharts' default content. */
67
+ type?: string;
67
68
  }
68
69
  interface ChartTooltipContentProps {
69
70
  active?: boolean;
@@ -179,9 +180,18 @@ interface BarChartProps {
179
180
  * (e.g. it is read against a scale rather than per-bar values).
180
181
  */
181
182
  showYAxis?: boolean;
183
+ /**
184
+ * Funnel silhouette (DEV-19691, GA4-style): a soft, low-alpha shape behind
185
+ * the bars that slopes from each bar's top to the next bar's top, so the
186
+ * drop-off between steps reads without the numbers. The bars, value labels,
187
+ * tooltip and cursor are unchanged, and the shape has no tooltip or legend
188
+ * entry. Single series only: with more than one series it is ignored.
189
+ * Default false.
190
+ */
191
+ funnel?: boolean;
182
192
  loading?: boolean;
183
193
  }
184
- declare function BarChart({ data, xKey, series, height, showGrid, showLegend, tooltipFormatter, labelFormatter, showValueLabels, showYAxis, loading, }: BarChartProps): react.JSX.Element;
194
+ declare function BarChart({ data, xKey, series, height, showGrid, showLegend, tooltipFormatter, labelFormatter, showValueLabels, showYAxis, funnel, loading, }: BarChartProps): react.JSX.Element;
185
195
 
186
196
  interface DonutDataItem {
187
197
  name: string;
@@ -328,4 +338,4 @@ declare const DashboardGrid: typeof DashboardGridRoot & {
328
338
  Item: typeof DashboardGridItem;
329
339
  };
330
340
 
331
- export { AreaChart, type AreaChartProps, type AreaChartSeries, type AreaVariant, BAR_CATEGORY_GAP, BAR_STANDARD, BarChart, type BarChartProps, type BarChartSeries, CHART_SERIES_COUNT, ChartCard, type ChartCardProps, type ChartCardRange, type ChartCardState, type ChartConfig, ChartContainer, type ChartContainerProps, type ChartRange, ChartSkeleton, ChartTooltip, ChartTooltipContent, type ChartTooltipContentProps, type Curve, DASHBOARD_GRID_CSS, DASHBOARD_TIERS, DashboardGrid, type DashboardGridItemProps, type DashboardGridProps, type DashboardItemSize, type DeltaTone, DonutChart, type DonutChartProps, type DonutDataItem, KpiCard, type KpiCardProps, LineChart, type LineChartProps, type LineChartSeries, type ModuleState, type Polarity, RadialChart, type RadialChartItem, type RadialChartProps, Sparkline, type SparklineProps, barValueLabel, chartColor, chartConfig, chartPalette, chartTokens, dashboardSpan, deltaTone, useChart, usePrefersReducedMotion, withAlpha };
341
+ export { AreaChart, type AreaChartProps, type AreaChartSeries, type AreaVariant, BAR_CATEGORY_GAP, BAR_STANDARD, BarChart, type BarChartProps, type BarChartSeries, CHART_SERIES_COUNT, ChartCard, type ChartCardProps, type ChartCardRange, type ChartCardState, type ChartConfig, ChartContainer, type ChartContainerProps, type ChartRange, ChartSkeleton, ChartTooltip, ChartTooltipContent, type ChartTooltipContentProps, type Curve, DASHBOARD_GRID_CSS, DASHBOARD_TIERS, DashboardGrid, type DashboardGridItemProps, type DashboardGridProps, type DashboardItemSize, type DeltaTone, DonutChart, type DonutChartProps, type DonutDataItem, KpiCard, type KpiCardProps, LineChart, type LineChartProps, type LineChartSeries, type ModuleState, type Polarity, RadialChart, type RadialChartItem, type RadialChartProps, Sparkline, type SparklineProps, barValueLabel, chartColor, chartConfig, chartPalette, chartTokens, dashboardSpan, deltaTone, useChart, withAlpha };
@@ -124,6 +124,12 @@ function useMediaQuery(query) {
124
124
  return (0, import_react.useSyncExternalStore)(subscribe, getSnapshot, () => false);
125
125
  }
126
126
 
127
+ // src/use-prefers-reduced-motion.ts
128
+ var REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
129
+ function usePrefersReducedMotion() {
130
+ return useMediaQuery(REDUCED_MOTION_QUERY);
131
+ }
132
+
127
133
  // src/charts/chart.tsx
128
134
  var import_jsx_runtime = require("react/jsx-runtime");
129
135
  var ChartContext = (0, import_react2.createContext)(null);
@@ -132,9 +138,6 @@ function useChart() {
132
138
  if (!ctx) throw new Error("useChart must be used within a <ChartContainer />");
133
139
  return ctx;
134
140
  }
135
- function usePrefersReducedMotion() {
136
- return useMediaQuery("(prefers-reduced-motion: reduce)");
137
- }
138
141
  function ChartContainer({ config = {}, height = 300, loading = false, className, children }) {
139
142
  const chartId = `chart-${(0, import_react2.useId)().replace(/:/g, "")}`;
140
143
  const vars = Object.fromEntries(
@@ -158,7 +161,8 @@ function ChartSkeleton({ height = 300 }) {
158
161
  );
159
162
  }
160
163
  function ChartTooltipContent({ active, payload, label, formatter }) {
161
- if (!active || !payload?.length) return null;
164
+ const entries = payload?.filter((entry) => entry.type !== "none");
165
+ if (!active || !entries?.length) return null;
162
166
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
163
167
  "div",
164
168
  {
@@ -166,7 +170,7 @@ function ChartTooltipContent({ active, payload, label, formatter }) {
166
170
  style: { background: chartConfig.tooltip.background, border: `1px solid ${chartConfig.tooltip.border}` },
167
171
  children: [
168
172
  label != null && label !== "" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: "mb-1 font-medium", style: { color: chartConfig.tooltip.label }, children: label }),
169
- payload.map((entry, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "flex items-center gap-2", style: { color: chartConfig.tooltip.text }, children: [
173
+ entries.map((entry, i) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", { className: "flex items-center gap-2", style: { color: chartConfig.tooltip.text }, children: [
170
174
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "inline-block h-2 w-2 rounded-full", style: { backgroundColor: entry.color } }),
171
175
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { style: { color: chartConfig.tooltip.label }, children: [
172
176
  entry.name,
@@ -382,6 +386,7 @@ function LineChart({
382
386
 
383
387
  // src/charts/bar-chart.tsx
384
388
  var import_recharts4 = require("recharts");
389
+ var import_react5 = require("react");
385
390
  var import_jsx_runtime5 = require("react/jsx-runtime");
386
391
  var BAR_CATEGORY_GAP = "8.33%";
387
392
  var BAR_LABEL_FONT_SIZE = chartConfig.axis.fontSize;
@@ -425,6 +430,89 @@ function barValueLabel(format = (v) => v.toLocaleString(), {
425
430
  return BarValueLabel;
426
431
  }
427
432
  var GROUPED_BAR_GAP = 4;
433
+ var FUNNEL_ALPHA = 12;
434
+ var BAR_ANIMATION_MS = 400;
435
+ var BAR_GAP_FRACTION = parseFloat(BAR_CATEGORY_GAP) / 100;
436
+ function barEdges(band) {
437
+ const inset = band * BAR_GAP_FRACTION;
438
+ const raw = band - 2 * inset;
439
+ const width = raw > 1 ? Math.floor(raw) : raw;
440
+ return { right: inset + width - band / 2, left: band / 2 - inset };
441
+ }
442
+ var funnelCurve = (context) => {
443
+ let line = NaN;
444
+ let count = 0;
445
+ let prev = [0, 0];
446
+ return {
447
+ areaStart() {
448
+ line = 0;
449
+ },
450
+ areaEnd() {
451
+ line = NaN;
452
+ },
453
+ lineStart() {
454
+ count = 0;
455
+ },
456
+ lineEnd() {
457
+ if (line || line !== 0 && count === 1) context.closePath();
458
+ line = 1 - line;
459
+ },
460
+ point(x, y) {
461
+ if (count++ === 0) {
462
+ if (line) context.lineTo(x, y);
463
+ else context.moveTo(x, y);
464
+ } else {
465
+ const [px, py] = prev;
466
+ const dir = Math.sign(x - px);
467
+ const { right, left } = barEdges(Math.abs(x - px));
468
+ context.lineTo(px + dir * right, py);
469
+ context.lineTo(x - dir * left, y);
470
+ context.lineTo(x, y);
471
+ }
472
+ prev = [x, y];
473
+ }
474
+ };
475
+ };
476
+ function BandCursor({ bands, fill, points, top = 0, width = 0, height = 0, className }) {
477
+ const x = points?.[0]?.x;
478
+ if (x == null || bands < 1) return null;
479
+ const band = width / bands;
480
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.ZIndexLayer, { zIndex: import_recharts4.DefaultZIndexes.cursorRectangle, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
481
+ import_recharts4.Rectangle,
482
+ {
483
+ x: x - band / 2,
484
+ y: top + 0.5,
485
+ width: band,
486
+ height: height - 1,
487
+ fill,
488
+ stroke: "none",
489
+ pointerEvents: "none",
490
+ className
491
+ }
492
+ ) });
493
+ }
494
+ function FunnelSilhouette({ series, animate }) {
495
+ const [entered, setEntered] = (0, import_react5.useState)(false);
496
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
497
+ import_recharts4.Area,
498
+ {
499
+ dataKey: series.dataKey,
500
+ name: series.name,
501
+ type: funnelCurve,
502
+ fill: withAlpha(series.color ?? chartColor(0), FUNNEL_ALPHA),
503
+ fillOpacity: 1,
504
+ stroke: "none",
505
+ dot: false,
506
+ activeDot: false,
507
+ tooltipType: "none",
508
+ legendType: "none",
509
+ isAnimationActive: animate,
510
+ animationBegin: entered ? 0 : BAR_ANIMATION_MS,
511
+ animationDuration: BAR_ANIMATION_MS,
512
+ onAnimationEnd: () => setEntered(true)
513
+ }
514
+ );
515
+ }
428
516
  function BarChart({
429
517
  data,
430
518
  xKey,
@@ -436,13 +524,17 @@ function BarChart({
436
524
  labelFormatter,
437
525
  showValueLabels = true,
438
526
  showYAxis = false,
527
+ funnel = false,
439
528
  loading = false
440
529
  }) {
441
530
  const animate = !usePrefersReducedMotion();
442
531
  const grouped = series.length > 1;
532
+ const silhouette = funnel && series.length === 1;
443
533
  const formatLabel = labelFormatter ?? tooltipFormatter ?? ((v) => v.toLocaleString());
534
+ const cursorFill = withAlpha(chartColor(0), 6);
535
+ const Chart = silhouette ? import_recharts4.ComposedChart : import_recharts4.BarChart;
444
536
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChartContainer, { height, loading, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
445
- import_recharts4.BarChart,
537
+ Chart,
446
538
  {
447
539
  data,
448
540
  barCategoryGap: BAR_CATEGORY_GAP,
@@ -486,10 +578,11 @@ function BarChart({
486
578
  import_recharts4.Tooltip,
487
579
  {
488
580
  content: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ChartTooltipContent, { formatter: tooltipFormatter }),
489
- cursor: { fill: withAlpha(chartColor(0), 6) }
581
+ cursor: silhouette ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BandCursor, { bands: data.length, fill: cursorFill }) : { fill: cursorFill }
490
582
  }
491
583
  ),
492
584
  showLegend && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_recharts4.Legend, { wrapperStyle: { fontSize: 12, color: chartTokens.muted, paddingTop: 8 } }),
585
+ silhouette && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FunnelSilhouette, { series: series[0], animate }),
493
586
  series.map((s, i) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
494
587
  import_recharts4.Bar,
495
588
  {
@@ -591,11 +684,11 @@ function RadialChart({ data, max = 100, height = 220, centerValue, centerLabel,
591
684
  }
592
685
 
593
686
  // src/charts/sparkline.tsx
594
- var import_react5 = require("react");
687
+ var import_react6 = require("react");
595
688
  var import_recharts7 = require("recharts");
596
689
  var import_jsx_runtime8 = require("react/jsx-runtime");
597
690
  function Sparkline({ values, color = chartColor(0), height = 32, filled = true }) {
598
- const chartId = `spark-${(0, import_react5.useId)().replace(/:/g, "")}`;
691
+ const chartId = `spark-${(0, import_react6.useId)().replace(/:/g, "")}`;
599
692
  const data = values.filter(Number.isFinite).map((v, i) => ({ i, v }));
600
693
  if (data.length < 2) return null;
601
694
  const id = fillId(chartId, "v", "gradient");
@@ -72,6 +72,12 @@ function useMediaQuery(query) {
72
72
  return useSyncExternalStore(subscribe, getSnapshot, () => false);
73
73
  }
74
74
 
75
+ // src/use-prefers-reduced-motion.ts
76
+ var REDUCED_MOTION_QUERY = "(prefers-reduced-motion: reduce)";
77
+ function usePrefersReducedMotion() {
78
+ return useMediaQuery(REDUCED_MOTION_QUERY);
79
+ }
80
+
75
81
  // src/charts/chart.tsx
76
82
  import { jsx, jsxs } from "react/jsx-runtime";
77
83
  var ChartContext = createContext(null);
@@ -80,9 +86,6 @@ function useChart() {
80
86
  if (!ctx) throw new Error("useChart must be used within a <ChartContainer />");
81
87
  return ctx;
82
88
  }
83
- function usePrefersReducedMotion() {
84
- return useMediaQuery("(prefers-reduced-motion: reduce)");
85
- }
86
89
  function ChartContainer({ config = {}, height = 300, loading = false, className, children }) {
87
90
  const chartId = `chart-${useId().replace(/:/g, "")}`;
88
91
  const vars = Object.fromEntries(
@@ -106,7 +109,8 @@ function ChartSkeleton({ height = 300 }) {
106
109
  );
107
110
  }
108
111
  function ChartTooltipContent({ active, payload, label, formatter }) {
109
- if (!active || !payload?.length) return null;
112
+ const entries = payload?.filter((entry) => entry.type !== "none");
113
+ if (!active || !entries?.length) return null;
110
114
  return /* @__PURE__ */ jsxs(
111
115
  "div",
112
116
  {
@@ -114,7 +118,7 @@ function ChartTooltipContent({ active, payload, label, formatter }) {
114
118
  style: { background: chartConfig.tooltip.background, border: `1px solid ${chartConfig.tooltip.border}` },
115
119
  children: [
116
120
  label != null && label !== "" && /* @__PURE__ */ jsx("p", { className: "mb-1 font-medium", style: { color: chartConfig.tooltip.label }, children: label }),
117
- payload.map((entry, i) => /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", style: { color: chartConfig.tooltip.text }, children: [
121
+ entries.map((entry, i) => /* @__PURE__ */ jsxs("p", { className: "flex items-center gap-2", style: { color: chartConfig.tooltip.text }, children: [
118
122
  /* @__PURE__ */ jsx("span", { className: "inline-block h-2 w-2 rounded-full", style: { backgroundColor: entry.color } }),
119
123
  /* @__PURE__ */ jsxs("span", { style: { color: chartConfig.tooltip.label }, children: [
120
124
  entry.name,
@@ -329,7 +333,22 @@ function LineChart({
329
333
  }
330
334
 
331
335
  // src/charts/bar-chart.tsx
332
- import { Bar, BarChart as RechartsBarChart, CartesianGrid as CartesianGrid3, LabelList, Legend as Legend3, Tooltip as Tooltip4, XAxis as XAxis3, YAxis as YAxis3 } from "recharts";
336
+ import {
337
+ Area as Area2,
338
+ Bar,
339
+ BarChart as RechartsBarChart,
340
+ CartesianGrid as CartesianGrid3,
341
+ ComposedChart,
342
+ DefaultZIndexes,
343
+ LabelList,
344
+ Legend as Legend3,
345
+ Rectangle,
346
+ Tooltip as Tooltip4,
347
+ XAxis as XAxis3,
348
+ YAxis as YAxis3,
349
+ ZIndexLayer
350
+ } from "recharts";
351
+ import { useState } from "react";
333
352
  import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
334
353
  var BAR_CATEGORY_GAP = "8.33%";
335
354
  var BAR_LABEL_FONT_SIZE = chartConfig.axis.fontSize;
@@ -373,6 +392,89 @@ function barValueLabel(format = (v) => v.toLocaleString(), {
373
392
  return BarValueLabel;
374
393
  }
375
394
  var GROUPED_BAR_GAP = 4;
395
+ var FUNNEL_ALPHA = 12;
396
+ var BAR_ANIMATION_MS = 400;
397
+ var BAR_GAP_FRACTION = parseFloat(BAR_CATEGORY_GAP) / 100;
398
+ function barEdges(band) {
399
+ const inset = band * BAR_GAP_FRACTION;
400
+ const raw = band - 2 * inset;
401
+ const width = raw > 1 ? Math.floor(raw) : raw;
402
+ return { right: inset + width - band / 2, left: band / 2 - inset };
403
+ }
404
+ var funnelCurve = (context) => {
405
+ let line = NaN;
406
+ let count = 0;
407
+ let prev = [0, 0];
408
+ return {
409
+ areaStart() {
410
+ line = 0;
411
+ },
412
+ areaEnd() {
413
+ line = NaN;
414
+ },
415
+ lineStart() {
416
+ count = 0;
417
+ },
418
+ lineEnd() {
419
+ if (line || line !== 0 && count === 1) context.closePath();
420
+ line = 1 - line;
421
+ },
422
+ point(x, y) {
423
+ if (count++ === 0) {
424
+ if (line) context.lineTo(x, y);
425
+ else context.moveTo(x, y);
426
+ } else {
427
+ const [px, py] = prev;
428
+ const dir = Math.sign(x - px);
429
+ const { right, left } = barEdges(Math.abs(x - px));
430
+ context.lineTo(px + dir * right, py);
431
+ context.lineTo(x - dir * left, y);
432
+ context.lineTo(x, y);
433
+ }
434
+ prev = [x, y];
435
+ }
436
+ };
437
+ };
438
+ function BandCursor({ bands, fill, points, top = 0, width = 0, height = 0, className }) {
439
+ const x = points?.[0]?.x;
440
+ if (x == null || bands < 1) return null;
441
+ const band = width / bands;
442
+ return /* @__PURE__ */ jsx5(ZIndexLayer, { zIndex: DefaultZIndexes.cursorRectangle, children: /* @__PURE__ */ jsx5(
443
+ Rectangle,
444
+ {
445
+ x: x - band / 2,
446
+ y: top + 0.5,
447
+ width: band,
448
+ height: height - 1,
449
+ fill,
450
+ stroke: "none",
451
+ pointerEvents: "none",
452
+ className
453
+ }
454
+ ) });
455
+ }
456
+ function FunnelSilhouette({ series, animate }) {
457
+ const [entered, setEntered] = useState(false);
458
+ return /* @__PURE__ */ jsx5(
459
+ Area2,
460
+ {
461
+ dataKey: series.dataKey,
462
+ name: series.name,
463
+ type: funnelCurve,
464
+ fill: withAlpha(series.color ?? chartColor(0), FUNNEL_ALPHA),
465
+ fillOpacity: 1,
466
+ stroke: "none",
467
+ dot: false,
468
+ activeDot: false,
469
+ tooltipType: "none",
470
+ legendType: "none",
471
+ isAnimationActive: animate,
472
+ animationBegin: entered ? 0 : BAR_ANIMATION_MS,
473
+ animationDuration: BAR_ANIMATION_MS,
474
+ onAnimationEnd: () => setEntered(true)
475
+ }
476
+ );
477
+ }
376
478
  function BarChart({
377
479
  data,
378
480
  xKey,
@@ -384,13 +486,17 @@ function BarChart({
384
486
  labelFormatter,
385
487
  showValueLabels = true,
386
488
  showYAxis = false,
489
+ funnel = false,
387
490
  loading = false
388
491
  }) {
389
492
  const animate = !usePrefersReducedMotion();
390
493
  const grouped = series.length > 1;
494
+ const silhouette = funnel && series.length === 1;
391
495
  const formatLabel = labelFormatter ?? tooltipFormatter ?? ((v) => v.toLocaleString());
496
+ const cursorFill = withAlpha(chartColor(0), 6);
497
+ const Chart = silhouette ? ComposedChart : RechartsBarChart;
392
498
  return /* @__PURE__ */ jsx5(ChartContainer, { height, loading, children: /* @__PURE__ */ jsxs5(
393
- RechartsBarChart,
499
+ Chart,
394
500
  {
395
501
  data,
396
502
  barCategoryGap: BAR_CATEGORY_GAP,
@@ -434,10 +540,11 @@ function BarChart({
434
540
  Tooltip4,
435
541
  {
436
542
  content: /* @__PURE__ */ jsx5(ChartTooltipContent, { formatter: tooltipFormatter }),
437
- cursor: { fill: withAlpha(chartColor(0), 6) }
543
+ cursor: silhouette ? /* @__PURE__ */ jsx5(BandCursor, { bands: data.length, fill: cursorFill }) : { fill: cursorFill }
438
544
  }
439
545
  ),
440
546
  showLegend && /* @__PURE__ */ jsx5(Legend3, { wrapperStyle: { fontSize: 12, color: chartTokens.muted, paddingTop: 8 } }),
547
+ silhouette && /* @__PURE__ */ jsx5(FunnelSilhouette, { series: series[0], animate }),
441
548
  series.map((s, i) => /* @__PURE__ */ jsx5(
442
549
  Bar,
443
550
  {
@@ -540,7 +647,7 @@ function RadialChart({ data, max = 100, height = 220, centerValue, centerLabel,
540
647
 
541
648
  // src/charts/sparkline.tsx
542
649
  import { useId as useId4 } from "react";
543
- import { Area as Area2, AreaChart as RechartsAreaChart2, YAxis as YAxis4 } from "recharts";
650
+ import { Area as Area3, AreaChart as RechartsAreaChart2, YAxis as YAxis4 } from "recharts";
544
651
  import { jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
545
652
  function Sparkline({ values, color = chartColor(0), height = 32, filled = true }) {
546
653
  const chartId = `spark-${useId4().replace(/:/g, "")}`;
@@ -551,7 +658,7 @@ function Sparkline({ values, color = chartColor(0), height = 32, filled = true }
551
658
  /* @__PURE__ */ jsx8("defs", { children: /* @__PURE__ */ jsx8(AreaFill, { id, variant: "gradient", color }) }),
552
659
  /* @__PURE__ */ jsx8(YAxis4, { hide: true, domain: ["dataMin", "dataMax"] }),
553
660
  /* @__PURE__ */ jsx8(
554
- Area2,
661
+ Area3,
555
662
  {
556
663
  type: "monotone",
557
664
  dataKey: "v",