@almanaclabs/blaze-ui 0.14.0 → 0.15.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"metric-tile.d.ts","sourceRoot":"","sources":["../../../src/components/metric-tile/metric-tile.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAIjE,QAAA,MAAM,kBAAkB;;8EActB,CAAA;AAEF,QAAA,MAAM,uBAAuB;;8EAU3B,CAAA;AAEF,MAAM,WAAW,eAAe;IAC9B,mDAAmD;IACnD,KAAK,EAAE,IAAI,GAAG,MAAM,CAAA;IACpB,gEAAgE;IAChE,IAAI,CAAC,EAAE,UAAU,GAAG,UAAU,CAAA;IAC9B,0DAA0D;IAC1D,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;CACvB;AAED,MAAM,WAAW,eACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,EAC7C,YAAY,CAAC,OAAO,kBAAkB,CAAC,EACvC,YAAY,CAAC,OAAO,uBAAuB,CAAC;IAC9C,mFAAmF;IACnF,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,qEAAqE;IACrE,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,4CAA4C;IAC5C,KAAK,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,2DAA2D;IAC3D,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,uDAAuD;IACvD,IAAI,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;IACtB,gEAAgE;IAChE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACxB;AAED,gFAAgF;AAChF,iBAAS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;IACtB,gEAAgE;IAChE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CACxB;AAED,gFAAgF;AAChF,iBAAS,UAAU,CAAC,EAClB,KAAK,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,KAAK,EACT,EAAE,eAAe,qBA8HjB;AAED,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,CAAA"}
@@ -8,7 +8,7 @@ var s = t("flex min-w-0 flex-col", {
8
8
  variants: { variant: {
9
9
  subtle: "rounded-xl bg-surface-subtle px-4 py-3",
10
10
  plain: "",
11
- card: "rounded-xl border border-border-subtle bg-card px-4 py-3.5"
11
+ card: "@container/metric-tile relative gap-1 rounded-lg border border-border-subtle bg-card px-[18px] pt-4 pb-3.5"
12
12
  } },
13
13
  defaultVariants: { variant: "subtle" }
14
14
  }), c = t("tabular-nums", {
@@ -22,11 +22,11 @@ function l({ label: t, icon: l, value: u, unit: d, delta: f, note: p, chart: m,
22
22
  let y = h === "card", b = f?.tone ?? (f?.trend === "down" ? "negative" : "positive"), x = f?.trend === "down" ? a : o, S = f ? /* @__PURE__ */ i("p", {
23
23
  "data-slot": "metric-tile-delta",
24
24
  "data-trend": f.trend,
25
- className: e("type-meta flex items-center gap-1", y ? e("mt-1.5 w-fit rounded-full px-1.5 py-px font-medium whitespace-nowrap", b === "positive" ? "bg-success-soft text-success" : "bg-warning-soft text-warning-foreground") : "mt-0.5 text-muted-foreground"),
25
+ className: e("type-meta flex items-center gap-1", y ? e("mt-0.5 w-fit max-w-full gap-0.5 self-start rounded-[6px] px-[7px] py-px font-medium tabular-nums", b === "positive" ? "bg-success-soft text-success" : "bg-destructive-soft text-destructive") : "mt-0.5 text-muted-foreground"),
26
26
  children: [
27
27
  /* @__PURE__ */ r(x, {
28
28
  "aria-hidden": "true",
29
- className: e("icon-optical-14 shrink-0", y ? "text-current" : b === "positive" ? "text-success" : "text-warning")
29
+ className: e("shrink-0", y ? "icon-optical-12 text-current" : b === "positive" ? "icon-optical-14 text-success" : "icon-optical-14 text-warning")
30
30
  }),
31
31
  /* @__PURE__ */ i("span", {
32
32
  className: "sr-only",
@@ -36,7 +36,7 @@ function l({ label: t, icon: l, value: u, unit: d, delta: f, note: p, chart: m,
36
36
  ]
37
37
  }) : null, C = p ? /* @__PURE__ */ r("div", {
38
38
  "data-slot": "metric-tile-note",
39
- className: "type-meta text-muted-foreground",
39
+ className: e(y ? "type-label min-w-0 truncate font-normal text-muted-foreground" : "type-meta text-muted-foreground"),
40
40
  children: p
41
41
  }) : null;
42
42
  return /* @__PURE__ */ i("div", {
@@ -51,19 +51,26 @@ function l({ label: t, icon: l, value: u, unit: d, delta: f, note: p, chart: m,
51
51
  children: [l, t]
52
52
  }) : /* @__PURE__ */ r("p", {
53
53
  "data-slot": "metric-tile-label",
54
- className: "type-meta text-muted-foreground",
54
+ className: e(y ? "type-label font-normal" : "type-meta", "text-muted-foreground"),
55
55
  children: t
56
56
  }),
57
57
  /* @__PURE__ */ r("p", {
58
58
  "data-slot": "metric-tile-value",
59
- className: e(c({ size: g }), l ? "mt-5" : g === "md" && "mt-0.5"),
59
+ className: e(y ? "type-stat tabular-nums" : c({ size: g }), l ? "mt-5" : !y && g === "md" && "mt-0.5"),
60
60
  children: u
61
61
  }),
62
62
  d ? /* @__PURE__ */ r("div", {
63
63
  className: "type-meta text-muted-foreground",
64
64
  children: d
65
65
  }) : null,
66
- m ? /* @__PURE__ */ i("div", {
66
+ y ? /* @__PURE__ */ i(n, { children: [/* @__PURE__ */ i("div", {
67
+ className: e("flex min-w-0 flex-col gap-1", m && "@min-[11rem]/metric-tile:pr-24"),
68
+ children: [S, C]
69
+ }), m ? /* @__PURE__ */ r("div", {
70
+ "data-slot": "metric-tile-chart",
71
+ className: "mt-1 self-end @min-[11rem]/metric-tile:absolute @min-[11rem]/metric-tile:right-4 @min-[11rem]/metric-tile:bottom-3.5 @min-[11rem]/metric-tile:mt-0",
72
+ children: m
73
+ }) : null] }) : m ? /* @__PURE__ */ i("div", {
67
74
  className: "flex flex-wrap items-end justify-between gap-x-3 gap-y-1",
68
75
  children: [/* @__PURE__ */ i("div", {
69
76
  className: "min-w-0",
@@ -1,19 +1,26 @@
1
1
  import * as React from 'react';
2
2
  type SparklineProps = Omit<React.ComponentProps<'svg'>, 'values'> & {
3
- /** The points, oldest first. Null leaves a point out. */
3
+ /** The points, oldest first. Null leaves a gap in the line. */
4
4
  values: readonly (number | null)[];
5
5
  /** Any CSS color. Defaults to the text color, so a `text-*` class sets it. */
6
6
  color?: string;
7
- /** Rendered width and height in pixels. */
7
+ /** Rendered width and height in pixels. Defaults to builder's 90 by 28. */
8
8
  width?: number;
9
9
  height?: number;
10
+ /** The line's width in pixels. */
11
+ strokeWidth?: number;
12
+ /** Fills under the line with a fading tint. */
13
+ area?: boolean;
14
+ /** Marks the last point with a dot. */
15
+ dot?: boolean;
10
16
  /** Names the chart for assistive tech. Leave it out when nearby text says the value. */
11
17
  label?: string;
12
18
  };
13
19
  /**
14
- * A small line with no axes, under a tint, ending on a dot: the trend beside a
15
- * number in a metric card. Decorative unless given a `label`.
20
+ * A small trend line with no axes, as in builder's stat tiles: a 2px round
21
+ * stroke, with an optional tint under it and a dot on the last point.
22
+ * Decorative unless given a `label`.
16
23
  */
17
- declare function Sparkline({ values, color, width, height, label, className, style, ...props }: SparklineProps): React.JSX.Element;
24
+ declare function Sparkline({ values, color, width, height, strokeWidth, area, dot, label, className, style, ...props }: SparklineProps): React.JSX.Element;
18
25
  export { Sparkline, type SparklineProps };
19
26
  //# sourceMappingURL=sparkline.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sparkline.d.ts","sourceRoot":"","sources":["../../../src/components/sparkline/sparkline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,KAAK,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG;IAClE,yDAAyD;IACzD,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IAClC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;GAGG;AACH,iBAAS,SAAS,CAAC,EACjB,MAAM,EACN,KAAK,EACL,KAAU,EACV,MAAW,EACX,KAAK,EACL,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,qBAkEhB;AAED,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,CAAA"}
1
+ {"version":3,"file":"sparkline.d.ts","sourceRoot":"","sources":["../../../src/components/sparkline/sparkline.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAI9B,KAAK,cAAc,GAAG,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,GAAG;IAClE,+DAA+D;IAC/D,MAAM,EAAE,SAAS,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,CAAA;IAClC,8EAA8E;IAC9E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,2EAA2E;IAC3E,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,kCAAkC;IAClC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,+CAA+C;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,uCAAuC;IACvC,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,wFAAwF;IACxF,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAID;;;;GAIG;AACH,iBAAS,SAAS,CAAC,EACjB,MAAM,EACN,KAAK,EACL,KAAU,EACV,MAAW,EACX,WAAe,EACf,IAAY,EACZ,GAAW,EACX,KAAK,EACL,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACT,EAAE,cAAc,qBAqFhB;AAED,OAAO,EAAE,SAAS,EAAE,KAAK,cAAc,EAAE,CAAA"}
@@ -1,69 +1,74 @@
1
1
  import { cn as e } from "../../lib/utils.js";
2
2
  import * as t from "react";
3
- import { Fragment as n, jsx as r, jsxs as i } from "react/jsx-runtime";
3
+ import { jsx as n, jsxs as r } from "react/jsx-runtime";
4
4
  //#region src/components/sparkline/sparkline.tsx
5
- function a({ values: a, color: o, width: s = 64, height: c = 24, label: l, className: u, style: d, ...f }) {
6
- let p = `sparkline${t.useId().replace(/:/g, "")}`, m = a.flatMap((e, t) => e === null || !Number.isFinite(e) ? [] : [{
7
- index: t,
8
- value: e
9
- }]), h = Math.min(...m.map((e) => e.value)), g = Math.max(...m.map((e) => e.value)) - h || 1, _ = a.length > 1 ? (s - 4) / (a.length - 1) : 0, v = m.map(({ index: e, value: t }) => ({
10
- x: 2 + e * _,
11
- y: 2 + (1 - (t - h) / g) * (c - 4)
12
- })), y = v.map(({ x: e, y: t }) => `${e.toFixed(2)},${t.toFixed(2)}`).join(" "), b = v[v.length - 1], x = v[0];
13
- return /* @__PURE__ */ i("svg", {
5
+ function i({ values: i, color: a, width: o = 90, height: s = 28, strokeWidth: c = 2, area: l = !1, dot: u = !1, label: d, className: f, style: p, ...m }) {
6
+ let h = `sparkline${t.useId().replace(/:/g, "")}`, g = i.filter((e) => e !== null && Number.isFinite(e)), _ = c, v = Math.min(...g), y = Math.max(...g), b = y - v || 1, x = i.length > 1 ? (o - _ * 2) / (i.length - 1) : 0, S = [[]];
7
+ i.forEach((e, t) => {
8
+ if (e === null || !Number.isFinite(e)) {
9
+ S[S.length - 1].length && S.push([]);
10
+ return;
11
+ }
12
+ S[S.length - 1].push({
13
+ x: _ + t * x,
14
+ y: y === v ? s / 2 : _ + (1 - (e - v) / b) * (s - _ * 2)
15
+ });
16
+ });
17
+ let C = S.filter((e) => e.length > 0), w = C[C.length - 1]?.at(-1), T = (e) => e.map(({ x: e, y: t }) => `${e.toFixed(2)},${t.toFixed(2)}`).join(" ");
18
+ return /* @__PURE__ */ r("svg", {
14
19
  "data-slot": "sparkline",
15
- viewBox: `0 0 ${s} ${c}`,
16
- width: s,
17
- height: c,
18
- className: e("flex-none overflow-visible", u),
19
- style: o ? {
20
- color: o,
21
- ...d
22
- } : d,
23
- ...l ? {
20
+ viewBox: `0 0 ${o} ${s}`,
21
+ width: o,
22
+ height: s,
23
+ className: e("flex-none overflow-visible", f),
24
+ style: a ? {
25
+ color: a,
26
+ ...p
27
+ } : p,
28
+ ...d ? {
24
29
  role: "img",
25
- "aria-label": l
30
+ "aria-label": d
26
31
  } : { "aria-hidden": !0 },
27
- ...f,
28
- children: [v.length > 1 && x && b ? /* @__PURE__ */ i(n, { children: [
29
- /* @__PURE__ */ r("defs", { children: /* @__PURE__ */ i("linearGradient", {
30
- id: p,
32
+ ...m,
33
+ children: [
34
+ l ? /* @__PURE__ */ n("defs", { children: /* @__PURE__ */ r("linearGradient", {
35
+ id: h,
31
36
  x1: "0",
32
37
  y1: "0",
33
38
  x2: "0",
34
39
  y2: "1",
35
- children: [/* @__PURE__ */ r("stop", {
40
+ children: [/* @__PURE__ */ n("stop", {
36
41
  offset: "0",
37
42
  stopColor: "currentColor",
38
43
  stopOpacity: "0.18"
39
- }), /* @__PURE__ */ r("stop", {
44
+ }), /* @__PURE__ */ n("stop", {
40
45
  offset: "1",
41
46
  stopColor: "currentColor",
42
47
  stopOpacity: "0"
43
48
  })]
44
- }) }),
45
- /* @__PURE__ */ r("polygon", {
49
+ }) }) : null,
50
+ C.map((e, i) => e.length > 1 ? /* @__PURE__ */ r(t.Fragment, { children: [l ? /* @__PURE__ */ n("polygon", {
46
51
  "data-slot": "sparkline-area",
47
- fill: `url(#${p})`,
48
- points: `${x.x},${c} ${y} ${b.x},${c}`
49
- }),
50
- /* @__PURE__ */ r("polyline", {
52
+ fill: `url(#${h})`,
53
+ points: `${e[0].x},${s} ${T(e)} ${e[e.length - 1].x},${s}`
54
+ }) : null, /* @__PURE__ */ n("polyline", {
51
55
  "data-slot": "sparkline-line",
52
56
  fill: "none",
53
57
  stroke: "currentColor",
54
- strokeWidth: "1.5",
58
+ strokeWidth: c,
55
59
  strokeLinejoin: "round",
56
60
  strokeLinecap: "round",
57
- points: y
58
- })
59
- ] }) : null, b ? /* @__PURE__ */ r("circle", {
60
- "data-slot": "sparkline-end",
61
- cx: b.x,
62
- cy: b.y,
63
- r: "2",
64
- fill: "currentColor"
65
- }) : null]
61
+ points: T(e)
62
+ })] }, i) : null),
63
+ u && w ? /* @__PURE__ */ n("circle", {
64
+ "data-slot": "sparkline-end",
65
+ cx: w.x,
66
+ cy: w.y,
67
+ r: c + .5,
68
+ fill: "currentColor"
69
+ }) : null
70
+ ]
66
71
  });
67
72
  }
68
73
  //#endregion
69
- export { a as Sparkline };
74
+ export { i as Sparkline };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almanaclabs/blaze-ui",
3
- "version": "0.14.0",
3
+ "version": "0.15.1",
4
4
  "description": "Shared React components and design tokens for Blaze",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -165,6 +165,10 @@
165
165
  --type-metric-size: 1.375rem;
166
166
  --type-metric-line-height: 1.2;
167
167
  --type-metric-letter-spacing: -0.02em;
168
+ /* The number in builder's stat tile (ADR 0027): 30px medium, set tight. */
169
+ --type-stat-size: 1.875rem;
170
+ --type-stat-line-height: 1.2;
171
+ --type-stat-letter-spacing: -0.02em;
168
172
  --type-accent-title-size: 1.5625rem;
169
173
  --type-accent-title-line-height: 1.12;
170
174
  --type-content-size: 1rem;
@@ -692,6 +696,13 @@
692
696
  font-weight: 400;
693
697
  }
694
698
 
699
+ .type-stat {
700
+ font-size: var(--type-stat-size);
701
+ line-height: var(--type-stat-line-height);
702
+ letter-spacing: var(--type-stat-letter-spacing);
703
+ font-weight: 500;
704
+ }
705
+
695
706
  .type-accent-title {
696
707
  font-family: var(--font-accent);
697
708
  font-size: var(--type-accent-title-size);