@leonardaustin/ui 0.28.0 → 0.29.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.
@@ -6,6 +6,8 @@ export interface BarChartDatum {
6
6
  export interface BarChartProps extends Omit<ComponentPropsWithRef<"svg">, "children" | "viewBox" | "width"> {
7
7
  /** Bars to draw top to bottom, each with a `label` and numeric `value`. */
8
8
  data: BarChartDatum[];
9
+ /** Activate a bar by click, Enter or Space. Receives the original datum and its index in data. */
10
+ onDatumActivate?: (datum: BarChartDatum, index: number) => void;
9
11
  /** Total chart height in SVG units; rows scale to fit. Defaults to the natural height from `barHeight` and `gap`. */
10
12
  height?: number;
11
13
  /** Explicit domain maximum. Defaults to the largest positive value. */
@@ -14,7 +16,7 @@ export interface BarChartProps extends Omit<ComponentPropsWithRef<"svg">, "child
14
16
  valueFormatter?: (value: number) => string;
15
17
  /** Format left-side labels before optional truncation. */
16
18
  labelFormatter?: (label: string, datum: BarChartDatum, index: number) => string;
17
- /** Maximum rendered label length. Omit to render the full formatted label. */
19
+ /** Maximum label length before fitting the text to a scaled label column. */
18
20
  maxLabelLength?: number;
19
21
  /** Width reserved for left-side labels in the SVG viewBox. */
20
22
  labelWidth?: number;
@@ -29,4 +31,4 @@ export interface BarChartProps extends Omit<ComponentPropsWithRef<"svg">, "child
29
31
  /** Extra classes for the `<svg>`. */
30
32
  className?: string;
31
33
  }
32
- export declare function BarChart({ data, height, maxValue, valueFormatter, labelFormatter, maxLabelLength, labelWidth, valueWidth, barHeight, gap, "aria-label": ariaLabel, className, ref, ...rest }: BarChartProps): import("react/jsx-runtime").JSX.Element;
34
+ export declare function BarChart({ data, onDatumActivate, height, maxValue, valueFormatter, labelFormatter, maxLabelLength, labelWidth, valueWidth, barHeight, gap, "aria-label": ariaLabel, className, ref, ...rest }: BarChartProps): import("react/jsx-runtime").JSX.Element;
@@ -1,86 +1,106 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
2
  import { clamp as t } from "../../lib/math.js";
3
3
  import { getPositiveValue as n, truncateChartLabel as r } from "./chartUtils.js";
4
- import { useState as i } from "react";
5
- import { jsx as a, jsxs as o } from "react/jsx-runtime";
4
+ import { useBarChartSize as i } from "./useChartSize.js";
5
+ import { getBarActivationProps as a } from "./barChartUtils.js";
6
+ import { useState as o } from "react";
7
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
6
8
  //#region src/components/charts/BarChart.tsx
7
- var s = [
9
+ var u = [
8
10
  1,
9
11
  .85,
10
12
  .7,
11
13
  .55,
12
14
  .45
13
- ], c = 600;
14
- function l({ data: l, height: u, maxValue: d, valueFormatter: f, labelFormatter: p, maxLabelLength: m, labelWidth: h = 160, valueWidth: g = 60, barHeight: _ = 28, gap: v = 10, "aria-label": y = "Horizontal bar chart", className: b, ref: x, ...S }) {
15
- let [C, w] = i(null), T = l.length, E = Math.max(1, _), D = Math.max(0, v), O = T > 0 ? T * E + Math.max(0, T - 1) * D : E, k = Math.max(1, u ?? O), A = u === void 0 ? 1 : k / O, j = E * A, M = D * A, N = Math.min(3, j / 3), P = Math.max(0, j - N * 2), F = d === void 0 ? Math.max(...l.map((e) => n(e.value)), 1) : Math.max(n(d), 1), I = Math.max(0, h), L = Math.max(0, g), R = Math.max(0, c - I - L), z = f ?? ((e) => e.toLocaleString());
16
- return /* @__PURE__ */ a("svg", {
17
- ref: x,
18
- ...S,
15
+ ];
16
+ function d(e, t, n, r) {
17
+ if (e) {
18
+ if (e.textContent = t, e.getComputedTextLength() > r) {
19
+ let n = Array.from(t.replace(/\.\.\.$/, "")), i = 0, a = n.length;
20
+ for (; i < a;) {
21
+ let t = Math.ceil((i + a) / 2);
22
+ e.textContent = n.slice(0, t).join("") + "…", e.getComputedTextLength() <= r ? i = t : a = t - 1;
23
+ }
24
+ e.textContent = n.slice(0, i).join("") + "…", i === 0 && e.getComputedTextLength() > r && (e.textContent = "");
25
+ }
26
+ if (e.textContent !== n) {
27
+ let t = document.createElementNS(e.namespaceURI, "title");
28
+ t.textContent = n, e.prepend(t);
29
+ }
30
+ }
31
+ }
32
+ function f({ data: f, onDatumActivate: p, height: m, maxValue: h, valueFormatter: g, labelFormatter: _, maxLabelLength: v, labelWidth: y = 160, valueWidth: b = 60, barHeight: x = 28, gap: S = 10, "aria-label": C = "Horizontal bar chart", className: w, ref: T, ...E }) {
33
+ let { rootRef: D, size: O, viewBoxWidth: k } = i(T), [A, j] = o(null), M = f.length, N = Math.max(1, x), P = Math.max(0, S), F = M > 0 ? M * N + Math.max(0, M - 1) * P : N, I = Math.max(1, m ?? F), L = O?.height ?? I, R = L / F, z = N * R, B = P * R, V = Math.min(3, z / 3), H = Math.max(0, z - V * 2), U = h === void 0 ? Math.max(...f.map((e) => n(e.value)), 1) : Math.max(n(h), 1), W = Math.max(0, y), G = W + Math.max(0, b), K = Math.min(G, k * .6), q = G > 0 ? W / G * K : 0, J = k - K, Y = g ?? ((e) => e.toLocaleString());
34
+ return /* @__PURE__ */ c("svg", {
35
+ ref: D,
36
+ ...E,
19
37
  width: "100%",
20
- viewBox: `0 0 ${c} ${k}`,
21
- className: e("select-none", b),
22
- role: "img",
23
- "aria-label": y,
24
- children: l.map((e, i) => {
25
- let l = i * (j + M), u = F > 0 ? t(n(e.value), 0, F) / F * R : 0, d = C === i, f = p?.(e.label, e, i) ?? e.label, h = r(f, m), g = h !== f, _ = z(e.value);
26
- return /* @__PURE__ */ o("g", {
27
- onMouseEnter: () => w(i),
28
- onMouseLeave: () => w(null),
29
- onPointerEnter: () => w(i),
30
- onPointerDown: () => w(i),
31
- onPointerLeave: () => w(null),
32
- onFocus: () => w(i),
33
- onBlur: () => w(null),
38
+ height: O && I,
39
+ viewBox: `0 0 ${k} ${L}`,
40
+ className: e("select-none", w),
41
+ role: p ? "group" : "img",
42
+ "aria-label": C,
43
+ children: f.map((e, i) => {
44
+ let o = i * (z + B), f = U > 0 ? t(n(e.value), 0, U) / U * J : 0, m = A === i, h = _?.(e.label, e, i) ?? e.label, g = r(h, v), y = g !== h, b = Y(e.value);
45
+ return /* @__PURE__ */ l("g", {
46
+ ...a(p, e, i),
47
+ onMouseEnter: () => j(i),
48
+ onMouseLeave: () => j(null),
49
+ onPointerEnter: () => j(i),
50
+ onPointerDown: () => j(i),
51
+ onPointerLeave: () => j(null),
52
+ onFocus: () => j(i),
53
+ onBlur: () => j(null),
34
54
  className: "cursor-pointer",
35
55
  tabIndex: 0,
36
56
  role: "button",
37
- "aria-label": `${f}: ${_}`,
57
+ "aria-label": `${h}: ${b}`,
38
58
  children: [
39
- /* @__PURE__ */ a("rect", {
59
+ /* @__PURE__ */ c("rect", {
40
60
  x: 0,
41
- y: l,
42
- width: c,
43
- height: j,
61
+ y: o,
62
+ width: k,
63
+ height: z,
44
64
  fill: "transparent"
45
65
  }),
46
- /* @__PURE__ */ o("text", {
66
+ /* @__PURE__ */ c("text", {
47
67
  x: 0,
48
- y: l + j / 2,
68
+ y: o + z / 2,
49
69
  dominantBaseline: "central",
50
- fill: d ? "var(--text-primary)" : "var(--text-secondary)",
70
+ fill: m ? "var(--text-primary)" : "var(--text-secondary)",
51
71
  fontSize: 11,
52
- fontWeight: d ? 600 : 400,
72
+ fontWeight: m ? 600 : 400,
53
73
  style: { transition: "all 150ms" },
54
- children: [g && /* @__PURE__ */ a("title", { children: f }), h]
74
+ children: O && K < G ? /* @__PURE__ */ c("tspan", { ref: (e) => d(e, g, h, q - 4) }) : /* @__PURE__ */ l(s, { children: [y && /* @__PURE__ */ c("title", { children: h }), g] })
55
75
  }),
56
- /* @__PURE__ */ a("rect", {
57
- x: I,
58
- y: l + N,
59
- width: R,
60
- height: P,
76
+ /* @__PURE__ */ c("rect", {
77
+ x: q,
78
+ y: o + V,
79
+ width: J,
80
+ height: H,
61
81
  fill: "var(--border)",
62
82
  rx: 6,
63
83
  opacity: .5
64
84
  }),
65
- /* @__PURE__ */ a("rect", {
66
- x: I,
67
- y: l + N,
68
- width: u,
69
- height: P,
85
+ /* @__PURE__ */ c("rect", {
86
+ x: q,
87
+ y: o + V,
88
+ width: f,
89
+ height: H,
70
90
  fill: "var(--accent)",
71
91
  rx: 6,
72
- opacity: d ? 1 : s[i % s.length],
92
+ opacity: m ? 1 : u[i % u.length],
73
93
  style: { transition: "all 150ms" }
74
94
  }),
75
- /* @__PURE__ */ a("text", {
76
- x: c,
77
- y: l + j / 2,
95
+ /* @__PURE__ */ c("text", {
96
+ x: k,
97
+ y: o + z / 2,
78
98
  dominantBaseline: "central",
79
99
  textAnchor: "end",
80
100
  fill: "var(--text-primary)",
81
101
  fontSize: 11,
82
102
  fontWeight: 600,
83
- children: _
103
+ children: b
84
104
  })
85
105
  ]
86
106
  }, e.label);
@@ -88,4 +108,4 @@ function l({ data: l, height: u, maxValue: d, valueFormatter: f, labelFormatter:
88
108
  });
89
109
  }
90
110
  //#endregion
91
- export { l as BarChart };
111
+ export { f as BarChart };
@@ -17,6 +17,8 @@ export interface StackedBarChartTooltipRow {
17
17
  export interface StackedBarChartProps extends Omit<ComponentPropsWithRef<"svg">, "children" | "viewBox" | "width"> {
18
18
  /** One entry per bar, with a `date` label and a numeric value for each segment `key`. */
19
19
  data: StackedBarChartDatum[];
20
+ /** Activate a bar by click, Enter or Space. Receives the original datum and its index in data. */
21
+ onDatumActivate?: (datum: StackedBarChartDatum, index: number) => void;
20
22
  /** Stack layers in order; each maps a `key` in `data` to a `label`, `color`, and optional `opacity`. */
21
23
  segments: StackedBarChartSegment[];
22
24
  /** Chart height in SVG units; the width scales to the container. Defaults to 220. */
@@ -38,4 +40,4 @@ export interface StackedBarChartProps extends Omit<ComponentPropsWithRef<"svg">,
38
40
  /** Extra classes for the `<svg>`. */
39
41
  className?: string;
40
42
  }
41
- export declare function StackedBarChart({ data, segments, height, "aria-label": ariaLabel, tooltipRows, valueFormatter, tooltipValueFormatter, xLabelCount, barGap, minBarWidth, className, ref, ...rest }: StackedBarChartProps): import("react/jsx-runtime").JSX.Element;
43
+ export declare function StackedBarChart({ data, onDatumActivate, segments, height, "aria-label": ariaLabel, tooltipRows, valueFormatter, tooltipValueFormatter, xLabelCount, barGap, minBarWidth, className, ref, ...rest }: StackedBarChartProps): import("react/jsx-runtime").JSX.Element;
@@ -1,15 +1,17 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
- import { estimateTooltipWidth as t, formatCompactValue as n, getLabelIndices as r, getSvgTooltipPosition as i } from "./chartUtils.js";
3
- import { useState as a } from "react";
4
- import { Fragment as o, jsx as s, jsxs as c } from "react/jsx-runtime";
2
+ import { estimateTooltipWidth as t, formatCompactValue as n, getSvgTooltipPosition as r } from "./chartUtils.js";
3
+ import { useBarChartSize as i } from "./useChartSize.js";
4
+ import { getBarActivationProps as a, getBarAxisLayout as o } from "./barChartUtils.js";
5
+ import { useMemo as s, useState as c } from "react";
6
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
5
7
  //#region src/components/charts/StackedBarChart.tsx
6
- var l = {
8
+ var f = {
7
9
  top: 20,
8
10
  right: 12,
9
11
  bottom: 30,
10
12
  left: 48
11
- }, u = 600, d = 4;
12
- function f(e) {
13
+ }, p = 4;
14
+ function m(e) {
13
15
  let t = /^(\d{4})-(\d{2})-(\d{2})T(\d{2})/.exec(e);
14
16
  if (t) {
15
17
  let [, e, n, r, i] = t;
@@ -29,7 +31,7 @@ function f(e) {
29
31
  timeZone: "UTC"
30
32
  });
31
33
  }
32
- function p(e, t) {
34
+ function h(e, t) {
33
35
  let n = e[t];
34
36
  if (typeof n == "number") return Number.isFinite(n) ? n : 0;
35
37
  if (typeof n == "string") {
@@ -38,10 +40,10 @@ function p(e, t) {
38
40
  }
39
41
  return 0;
40
42
  }
41
- function m(e, t) {
42
- return t.reduce((t, n) => t + Math.max(0, p(e, n.key)), 0);
43
+ function g(e, t) {
44
+ return t.reduce((t, n) => t + Math.max(0, h(e, n.key)), 0);
43
45
  }
44
- function h(e, t, n, r, i) {
46
+ function ee(e, t, n, r, i) {
45
47
  let a = Math.min(i, Math.max(0, n / 2), Math.max(0, r));
46
48
  return a <= 0 ? `M ${e} ${t} H ${e + n} V ${t + r} H ${e} Z` : [
47
49
  `M ${e} ${t + r}`,
@@ -53,146 +55,152 @@ function h(e, t, n, r, i) {
53
55
  "Z"
54
56
  ].join(" ");
55
57
  }
56
- function g({ data: g, segments: _, height: v = 220, "aria-label": y = "Stacked bar chart", tooltipRows: b, valueFormatter: x, tooltipValueFormatter: S, xLabelCount: C = 6, barGap: w, minBarWidth: T = 1, className: E, ref: D, ...O }) {
57
- let [k, A] = a(null), j = Math.max(l.top + l.bottom + 1, v), M = u - l.left - l.right, N = Math.max(1, j - l.top - l.bottom), P = g.reduce((e, t) => Math.max(e, m(t, _)), 1), F = Math.ceil(P / 2), I = F > 0 && F < P, L = w ?? (g.length > 60 ? 2 : g.length > 30 ? 3 : 6), R = Math.max(1, T), z = g.length > 1 ? Math.max(0, (M - g.length * R) / Math.max(g.length - 1, 1)) : 0, B = g.length > 1 ? Math.min(Math.max(0, L), z) : 0, V = g.length > 0 ? (M - B * Math.max(g.length - 1, 0)) / g.length : 0, H = new Set(r(g.length, C)), U = k === null ? null : g[k], W = x ?? n, G = S ?? ((e) => e.toLocaleString());
58
- function K(e) {
59
- return l.left + e * (V + B);
58
+ function _({ data: _, onDatumActivate: v, segments: y, height: b = 220, "aria-label": x = "Stacked bar chart", tooltipRows: S, valueFormatter: te, tooltipValueFormatter: ne, xLabelCount: C = 6, barGap: w, minBarWidth: T = 1, className: E, ref: D, ...O }) {
59
+ let { rootRef: k, size: A, viewBoxWidth: j } = i(D), [M, N] = c(null), P = Math.max(f.top + f.bottom + 1, b), F = A?.height ?? P, I = s(() => _.map((e) => m(e.date)), [_]), { left: L, plotWidth: R, indices: z } = s(() => o(I, C, A?.width, f), [
60
+ I,
61
+ C,
62
+ A?.width
63
+ ]), B = Math.max(1, F - f.top - f.bottom), V = _.reduce((e, t) => Math.max(e, g(t, y)), 1), H = Math.ceil(V / 2), U = H > 0 && H < V, W = w ?? (_.length > 60 ? 2 : _.length > 30 ? 3 : 6), G = Math.max(1, T), K = _.length > 1 ? Math.max(0, (R - _.length * G) / Math.max(_.length - 1, 1)) : 0, q = _.length > 1 ? Math.min(Math.max(0, W), K) : 0, J = _.length > 0 ? (R - q * Math.max(_.length - 1, 0)) / _.length : 0, Y = M === null ? null : _[M], X = te ?? n, Z = ne ?? ((e) => e.toLocaleString());
64
+ function Q(e) {
65
+ return L + e * (J + q);
60
66
  }
61
- function q(e) {
62
- return e / P * N;
67
+ function $(e) {
68
+ return e / V * B;
63
69
  }
64
- return /* @__PURE__ */ c("svg", {
65
- ref: D,
70
+ return /* @__PURE__ */ d("svg", {
71
+ ref: k,
66
72
  ...O,
67
73
  width: "100%",
68
- viewBox: `0 0 ${u} ${j}`,
74
+ height: A && P,
75
+ viewBox: `0 0 ${j} ${F}`,
69
76
  className: e("select-none", E),
70
- role: "img",
71
- "aria-label": y,
77
+ role: v ? "group" : "img",
78
+ "aria-label": x,
72
79
  children: [
73
- /* @__PURE__ */ s("text", {
74
- x: l.left - 8,
75
- y: l.top,
80
+ /* @__PURE__ */ u("text", {
81
+ x: L - 8,
82
+ y: f.top,
76
83
  textAnchor: "end",
77
84
  dominantBaseline: "central",
78
85
  fill: "var(--text-tertiary)",
79
86
  fontSize: 10,
80
- children: W(P)
87
+ children: X(V)
81
88
  }),
82
- I && /* @__PURE__ */ s("text", {
83
- x: l.left - 8,
84
- y: l.top + N / 2,
89
+ U && /* @__PURE__ */ u("text", {
90
+ x: L - 8,
91
+ y: f.top + B / 2,
85
92
  textAnchor: "end",
86
93
  dominantBaseline: "central",
87
94
  fill: "var(--text-tertiary)",
88
95
  fontSize: 10,
89
- children: W(F)
96
+ children: X(H)
90
97
  }),
91
- /* @__PURE__ */ s("text", {
92
- x: l.left - 8,
93
- y: l.top + N,
98
+ /* @__PURE__ */ u("text", {
99
+ x: L - 8,
100
+ y: f.top + B,
94
101
  textAnchor: "end",
95
102
  dominantBaseline: "central",
96
103
  fill: "var(--text-tertiary)",
97
104
  fontSize: 10,
98
105
  children: "0"
99
106
  }),
100
- /* @__PURE__ */ s("line", {
101
- x1: l.left,
102
- y1: l.top + N,
103
- x2: l.left + M,
104
- y2: l.top + N,
107
+ /* @__PURE__ */ u("line", {
108
+ x1: L,
109
+ y1: f.top + B,
110
+ x2: L + R,
111
+ y2: f.top + B,
105
112
  stroke: "var(--border)",
106
113
  strokeWidth: 1
107
114
  }),
108
- /* @__PURE__ */ s("line", {
109
- x1: l.left,
110
- y1: l.top + N / 2,
111
- x2: l.left + M,
112
- y2: l.top + N / 2,
115
+ /* @__PURE__ */ u("line", {
116
+ x1: L,
117
+ y1: f.top + B / 2,
118
+ x2: L + R,
119
+ y2: f.top + B / 2,
113
120
  stroke: "var(--border)",
114
121
  strokeWidth: 1,
115
122
  strokeDasharray: "3 3",
116
123
  opacity: .5
117
124
  }),
118
- g.map((e, t) => {
119
- let n = K(t), r = k === t, i = 0, a = _.map((t) => ({
125
+ _.map((e, t) => {
126
+ let n = Q(t), r = M === t, i = 0, o = y.map((t) => ({
120
127
  segment: t,
121
- value: Math.max(0, p(e, t.key))
128
+ value: Math.max(0, h(e, t.key))
122
129
  })).filter(({ value: e }) => e > 0);
123
- return /* @__PURE__ */ c("g", {
124
- onMouseEnter: () => A(t),
125
- onMouseLeave: () => A(null),
126
- onPointerEnter: () => A(t),
127
- onPointerDown: () => A(t),
128
- onPointerLeave: () => A(null),
129
- onFocus: () => A(t),
130
- onBlur: () => A(null),
130
+ return /* @__PURE__ */ d("g", {
131
+ ...a(v, e, t),
132
+ onMouseEnter: () => N(t),
133
+ onMouseLeave: () => N(null),
134
+ onPointerEnter: () => N(t),
135
+ onPointerDown: () => N(t),
136
+ onPointerLeave: () => N(null),
137
+ onFocus: () => N(t),
138
+ onBlur: () => N(null),
131
139
  tabIndex: 0,
132
140
  role: "button",
133
- "aria-label": `${f(e.date)}: ${G(m(e, _))}`,
141
+ "aria-label": `${I[t]}: ${Z(g(e, y))}`,
134
142
  children: [
135
- /* @__PURE__ */ s("rect", {
143
+ /* @__PURE__ */ u("rect", {
136
144
  x: n,
137
- y: l.top,
138
- width: V,
139
- height: N,
145
+ y: f.top,
146
+ width: J,
147
+ height: B,
140
148
  fill: "transparent"
141
149
  }),
142
- a.map(({ segment: e, value: t }, o) => {
143
- let c = q(t), u = l.top + N - i - c, f = o === a.length - 1;
144
- return i += c, f ? /* @__PURE__ */ s("path", {
145
- d: h(n, u, V, c, d),
150
+ o.map(({ segment: e, value: t }, a) => {
151
+ let s = $(t), c = f.top + B - i - s, l = a === o.length - 1;
152
+ return i += s, l ? /* @__PURE__ */ u("path", {
153
+ d: ee(n, c, J, s, p),
146
154
  fill: e.color,
147
155
  opacity: r ? 1 : e.opacity ?? .9
148
- }, e.key) : /* @__PURE__ */ s("rect", {
156
+ }, e.key) : /* @__PURE__ */ u("rect", {
149
157
  x: n,
150
- y: u,
151
- width: V,
152
- height: c,
158
+ y: c,
159
+ width: J,
160
+ height: s,
153
161
  fill: e.color,
154
162
  opacity: r ? 1 : e.opacity ?? .9
155
163
  }, e.key);
156
164
  }),
157
- H.has(t) && /* @__PURE__ */ s("text", {
158
- x: n + V / 2,
159
- y: j - 5,
165
+ z.has(t) && /* @__PURE__ */ u("text", {
166
+ x: n + J / 2,
167
+ y: F - 5,
160
168
  textAnchor: "middle",
161
169
  fill: "var(--text-tertiary)",
162
170
  fontSize: 10,
163
- children: f(e.date)
171
+ children: I[t]
164
172
  })
165
173
  ]
166
174
  }, `${e.date}-${t}`);
167
175
  }),
168
- U && k !== null && /* @__PURE__ */ s("g", {
176
+ Y && M !== null && /* @__PURE__ */ u("g", {
169
177
  pointerEvents: "none",
170
178
  children: (() => {
171
- let e = K(k) + V / 2, n = b?.(U) ?? _.map((e) => ({
179
+ let e = Q(M) + J / 2, n = S?.(Y) ?? y.map((e) => ({
172
180
  color: e.color,
173
181
  label: e.label,
174
- value: p(U, e.key)
175
- })), r = m(U, _), a = i(e, l.top + N - q(r), {
176
- boundsHeight: j,
177
- boundsWidth: u,
182
+ value: h(Y, e.key)
183
+ })), i = g(Y, y), a = r(e, f.top + B - $(i), {
184
+ boundsHeight: F,
185
+ boundsWidth: j,
178
186
  height: 28 + n.length * 15,
179
187
  offset: 8,
180
- width: t([f(U.date), ...n.map((e) => `${e.label} ${G(e.value)}`)], {
188
+ width: t([m(Y.date), ...n.map((e) => `${e.label} ${Z(e.value)}`)], {
181
189
  maxWidth: 240,
182
190
  minWidth: 150
183
191
  })
184
- }), d = a.x + 10, h = a.x + a.width - 10;
185
- return /* @__PURE__ */ c(o, { children: [
186
- /* @__PURE__ */ s("line", {
192
+ }), o = a.x + 10, s = a.x + a.width - 10;
193
+ return /* @__PURE__ */ d(l, { children: [
194
+ /* @__PURE__ */ u("line", {
187
195
  x1: e,
188
- y1: l.top,
196
+ y1: f.top,
189
197
  x2: e,
190
- y2: l.top + N,
198
+ y2: f.top + B,
191
199
  stroke: "var(--border-strong)",
192
200
  strokeWidth: 1,
193
201
  strokeDasharray: "3 3"
194
202
  }),
195
- /* @__PURE__ */ s("rect", {
203
+ /* @__PURE__ */ u("rect", {
196
204
  x: a.x,
197
205
  y: a.y,
198
206
  width: a.width,
@@ -202,40 +210,40 @@ function g({ data: g, segments: _, height: v = 220, "aria-label": y = "Stacked b
202
210
  stroke: "var(--border)",
203
211
  strokeWidth: 1
204
212
  }),
205
- /* @__PURE__ */ s("text", {
206
- x: d,
213
+ /* @__PURE__ */ u("text", {
214
+ x: o,
207
215
  y: a.y + 14,
208
216
  fill: "var(--text-primary)",
209
217
  fontSize: 10,
210
218
  fontWeight: 600,
211
- children: f(U.date)
219
+ children: m(Y.date)
212
220
  }),
213
221
  n.map((e, t) => {
214
222
  let n = a.y + 30 + t * 15;
215
- return /* @__PURE__ */ c("g", { children: [
216
- e.color && /* @__PURE__ */ s("rect", {
217
- x: d,
223
+ return /* @__PURE__ */ d("g", { children: [
224
+ e.color && /* @__PURE__ */ u("rect", {
225
+ x: o,
218
226
  y: n - 6,
219
227
  width: 6,
220
228
  height: 6,
221
229
  rx: 1,
222
230
  fill: e.color
223
231
  }),
224
- /* @__PURE__ */ s("text", {
225
- x: e.color ? d + 12 : d,
232
+ /* @__PURE__ */ u("text", {
233
+ x: e.color ? o + 12 : o,
226
234
  y: n,
227
235
  fill: "var(--text-secondary)",
228
236
  fontSize: 10,
229
237
  children: e.label
230
238
  }),
231
- /* @__PURE__ */ s("text", {
232
- x: h,
239
+ /* @__PURE__ */ u("text", {
240
+ x: s,
233
241
  y: n,
234
242
  textAnchor: "end",
235
243
  fill: "var(--text-primary)",
236
244
  fontSize: 10,
237
245
  fontWeight: 600,
238
- children: G(e.value)
246
+ children: Z(e.value)
239
247
  })
240
248
  ] }, e.label);
241
249
  })
@@ -246,4 +254,4 @@ function g({ data: g, segments: _, height: v = 220, "aria-label": y = "Stacked b
246
254
  });
247
255
  }
248
256
  //#endregion
249
- export { g as StackedBarChart };
257
+ export { _ as StackedBarChart };
@@ -7,6 +7,8 @@ export interface VerticalBarChartDatum {
7
7
  export interface VerticalBarChartProps extends Omit<ComponentPropsWithRef<"svg">, "children" | "viewBox" | "width"> {
8
8
  /** Bars to draw left to right, each with a `label`, numeric `value`, and optional `color`. */
9
9
  data: VerticalBarChartDatum[];
10
+ /** Activate a bar by click, Enter or Space. Receives the original datum and its index in data. */
11
+ onDatumActivate?: (datum: VerticalBarChartDatum, index: number) => void;
10
12
  /** Chart height in SVG units; the width scales to the container. Defaults to 180. */
11
13
  height?: number;
12
14
  /** Explicit domain maximum. Defaults to the largest positive value. */
@@ -30,4 +32,4 @@ export interface VerticalBarChartProps extends Omit<ComponentPropsWithRef<"svg">
30
32
  /** Extra classes for the `<svg>`. */
31
33
  className?: string;
32
34
  }
33
- export declare function VerticalBarChart({ data, height, maxValue, valueFormatter, tooltipValueFormatter, labelFormatter, maxLabelLength, xLabelCount, barGap, minBarWidth, "aria-label": ariaLabel, className, ref, ...rest }: VerticalBarChartProps): import("react/jsx-runtime").JSX.Element;
35
+ export declare function VerticalBarChart({ data, onDatumActivate, height, maxValue, valueFormatter, tooltipValueFormatter, labelFormatter, maxLabelLength, xLabelCount, barGap, minBarWidth, "aria-label": ariaLabel, className, ref, ...rest }: VerticalBarChartProps): import("react/jsx-runtime").JSX.Element;
@@ -1,10 +1,12 @@
1
1
  import { cn as e } from "../../lib/cn.js";
2
2
  import { clamp as t } from "../../lib/math.js";
3
- import { estimateTooltipWidth as n, formatCompactValue as r, getLabelIndices as i, getPositiveValue as a, getSvgTooltipPosition as o, resolveChartColor as s, truncateChartLabel as c } from "./chartUtils.js";
4
- import { useState as l } from "react";
5
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
3
+ import { estimateTooltipWidth as n, formatCompactValue as r, getPositiveValue as i, getSvgTooltipPosition as a, resolveChartColor as o, truncateChartLabel as s } from "./chartUtils.js";
4
+ import { useBarChartSize as c } from "./useChartSize.js";
5
+ import { getBarActivationProps as l, getBarAxisLayout as u } from "./barChartUtils.js";
6
+ import { useMemo as d, useState as f } from "react";
7
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
6
8
  //#region src/components/charts/VerticalBarChart.tsx
7
- var p = [
9
+ var h = [
8
10
  1,
9
11
  .85,
10
12
  .7,
@@ -12,126 +14,135 @@ var p = [
12
14
  .45,
13
15
  .35,
14
16
  .25
15
- ], m = {
17
+ ], g = {
16
18
  top: 20,
17
19
  right: 8,
18
20
  bottom: 24,
19
21
  left: 40
20
- }, h = 600;
21
- function g({ data: g, height: _ = 180, maxValue: v, valueFormatter: y, tooltipValueFormatter: b, labelFormatter: x, maxLabelLength: S, xLabelCount: C = 7, barGap: w = 6, minBarWidth: T = 4, "aria-label": E = "Vertical bar chart", className: D, ref: O, ...k }) {
22
- let [A, j] = l(null), M = Math.max(m.top + m.bottom + 1, _), N = h - m.left - m.right, P = Math.max(1, M - m.top - m.bottom), F = v === void 0 ? Math.max(...g.map((e) => a(e.value)), 1) : Math.max(a(v), 1), I = Math.max(0, w), L = Math.max(1, T), R = g.length > 1 ? Math.max(0, (N - g.length * L) / Math.max(g.length - 1, 1)) : 0, z = g.length > 1 ? Math.min(I, R) : 0, B = g.length > 0 ? Math.max(0, (N - z * Math.max(g.length - 1, 0)) / g.length) : 0, V = y ?? r, H = b ?? ((e) => e.toLocaleString()), U = new Set(i(g.length, C));
23
- return /* @__PURE__ */ f("svg", {
24
- ref: O,
25
- ...k,
22
+ };
23
+ function _({ data: _, onDatumActivate: v, height: y = 180, maxValue: b, valueFormatter: x, tooltipValueFormatter: S, labelFormatter: C, maxLabelLength: w, xLabelCount: T = 7, barGap: E = 6, minBarWidth: D = 4, "aria-label": O = "Vertical bar chart", className: k, ref: A, ...j }) {
24
+ let { rootRef: M, size: N, viewBoxWidth: P } = c(A), [F, I] = f(null), L = Math.max(g.top + g.bottom + 1, y), R = N?.height ?? L, z = d(() => _.map((e, t) => C?.(e.label, e, t) ?? e.label), [_, C]), B = d(() => z.map((e) => s(e, w)), [z, w]), { left: V, plotWidth: H, indices: U } = d(() => u(B, T, N?.width, g), [
25
+ B,
26
+ T,
27
+ N?.width
28
+ ]), W = Math.max(1, R - g.top - g.bottom), G = b === void 0 ? Math.max(..._.map((e) => i(e.value)), 1) : Math.max(i(b), 1), K = Math.max(0, E), q = Math.max(1, D), J = _.length > 1 ? Math.max(0, (H - _.length * q) / Math.max(_.length - 1, 1)) : 0, Y = _.length > 1 ? Math.min(K, J) : 0, X = _.length > 0 ? Math.max(0, (H - Y * Math.max(_.length - 1, 0)) / _.length) : 0, Z = x ?? r, Q = S ?? ((e) => e.toLocaleString());
29
+ return /* @__PURE__ */ m("svg", {
30
+ ref: M,
31
+ ...j,
26
32
  width: "100%",
27
- viewBox: `0 0 ${h} ${M}`,
28
- className: e("select-none", D),
29
- role: "img",
30
- "aria-label": E,
33
+ height: N && L,
34
+ viewBox: `0 0 ${P} ${R}`,
35
+ className: e("select-none", k),
36
+ role: v ? "group" : "img",
37
+ "aria-label": O,
31
38
  children: [
32
- /* @__PURE__ */ d("text", {
33
- x: m.left - 6,
34
- y: m.top + 4,
39
+ /* @__PURE__ */ p("text", {
40
+ x: V - 6,
41
+ y: g.top + 4,
35
42
  textAnchor: "end",
36
43
  fill: "var(--text-tertiary)",
37
44
  fontSize: 10,
38
- children: V(F)
45
+ children: Z(G)
39
46
  }),
40
- /* @__PURE__ */ d("text", {
41
- x: m.left - 6,
42
- y: m.top + P,
47
+ /* @__PURE__ */ p("text", {
48
+ x: V - 6,
49
+ y: g.top + W,
43
50
  textAnchor: "end",
44
51
  dominantBaseline: "central",
45
52
  fill: "var(--text-tertiary)",
46
53
  fontSize: 10,
47
54
  children: "0"
48
55
  }),
49
- /* @__PURE__ */ d("line", {
50
- x1: m.left,
51
- y1: m.top + P,
52
- x2: m.left + N,
53
- y2: m.top + P,
56
+ /* @__PURE__ */ p("line", {
57
+ x1: V,
58
+ y1: g.top + W,
59
+ x2: V + H,
60
+ y2: g.top + W,
54
61
  stroke: "var(--border)",
55
62
  strokeWidth: 1
56
63
  }),
57
- /* @__PURE__ */ d("line", {
58
- x1: m.left,
59
- y1: m.top + P / 2,
60
- x2: m.left + N,
61
- y2: m.top + P / 2,
64
+ /* @__PURE__ */ p("line", {
65
+ x1: V,
66
+ y1: g.top + W / 2,
67
+ x2: V + H,
68
+ y2: g.top + W / 2,
62
69
  stroke: "var(--border)",
63
70
  strokeWidth: 1,
64
71
  strokeDasharray: "3 3",
65
72
  opacity: .5
66
73
  }),
67
- g.map((e, r) => {
68
- let i = m.left + r * (B + z), l = t(a(e.value), 0, F) / F * P, g = m.top + P - l, _ = A === r, v = x?.(e.label, e, r) ?? e.label, y = c(v, S), b = y !== v, C = H(e.value);
69
- return /* @__PURE__ */ f("g", {
70
- onMouseEnter: () => j(r),
71
- onMouseLeave: () => j(null),
72
- onPointerEnter: () => j(r),
73
- onPointerDown: () => j(r),
74
- onPointerLeave: () => j(null),
75
- onFocus: () => j(r),
76
- onBlur: () => j(null),
74
+ _.map((e, r) => {
75
+ let s = V + r * (X + Y), c = t(i(e.value), 0, G) / G * W, u = g.top + W - c, d = F === r, f = z[r], _ = B[r], y = _ !== f, b = Q(e.value);
76
+ return /* @__PURE__ */ m("g", {
77
+ ...l(v, e, r),
78
+ onMouseEnter: () => I(r),
79
+ onMouseLeave: () => I(null),
80
+ onPointerEnter: () => I(r),
81
+ onPointerDown: () => I(r),
82
+ onPointerLeave: () => I(null),
83
+ onFocus: () => I(r),
84
+ onBlur: () => I(null),
77
85
  tabIndex: 0,
78
86
  role: "button",
79
- "aria-label": `${v}: ${C}`,
87
+ "aria-label": `${f}: ${b}`,
80
88
  children: [
81
- /* @__PURE__ */ d("rect", {
82
- x: i,
83
- y: m.top,
84
- width: B,
85
- height: P,
89
+ /* @__PURE__ */ p("rect", {
90
+ x: s,
91
+ y: g.top,
92
+ width: X,
93
+ height: W,
86
94
  fill: "transparent"
87
95
  }),
88
- /* @__PURE__ */ d("rect", {
89
- x: i,
90
- y: g,
91
- width: B,
92
- height: l,
93
- fill: s(e.color),
96
+ /* @__PURE__ */ p("rect", {
97
+ x: s,
98
+ y: u,
99
+ width: X,
100
+ height: c,
101
+ fill: o(e.color),
94
102
  rx: 6,
95
- opacity: _ ? 1 : p[r % p.length],
103
+ opacity: d ? 1 : h[r % h.length],
96
104
  style: { transition: "all 150ms" }
97
105
  }),
98
- U.has(r) && /* @__PURE__ */ f("text", {
99
- x: i + B / 2,
100
- y: M - 4,
106
+ U.has(r) && /* @__PURE__ */ m("text", {
107
+ x: s + X / 2,
108
+ y: R - 4,
101
109
  textAnchor: "middle",
102
110
  fill: "var(--text-tertiary)",
103
111
  fontSize: 10,
104
- children: [b && /* @__PURE__ */ d("title", { children: v }), y]
112
+ children: [y && /* @__PURE__ */ p("title", { children: f }), _]
105
113
  }),
106
- _ && (() => {
107
- let e = o(i + B / 2, g, {
108
- boundsHeight: M,
109
- boundsWidth: h,
114
+ d && (() => {
115
+ let e = a(s + X / 2, u, {
116
+ boundsHeight: R,
117
+ boundsWidth: P,
110
118
  height: 24,
111
119
  offset: 8,
112
- width: n([v, C], {
120
+ width: n([f, b], {
113
121
  maxWidth: 180,
114
122
  minWidth: 72
115
123
  })
116
124
  }), t = e.x + e.width / 2;
117
- return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("rect", {
118
- x: e.x,
119
- y: e.y,
120
- width: e.width,
121
- height: e.height,
122
- rx: 4,
123
- fill: "var(--bg-tooltip, var(--bg-tertiary))",
124
- stroke: "var(--border)",
125
- strokeWidth: 1
126
- }), /* @__PURE__ */ d("text", {
127
- x: t,
128
- y: e.y + 15,
129
- textAnchor: "middle",
130
- fill: "var(--text-primary)",
131
- fontSize: 10,
132
- fontWeight: 600,
133
- children: C
134
- })] });
125
+ return /* @__PURE__ */ m("g", {
126
+ pointerEvents: "none",
127
+ children: [/* @__PURE__ */ p("rect", {
128
+ x: e.x,
129
+ y: e.y,
130
+ width: e.width,
131
+ height: e.height,
132
+ rx: 4,
133
+ fill: "var(--bg-tooltip, var(--bg-tertiary))",
134
+ stroke: "var(--border)",
135
+ strokeWidth: 1
136
+ }), /* @__PURE__ */ p("text", {
137
+ x: t,
138
+ y: e.y + 15,
139
+ textAnchor: "middle",
140
+ fill: "var(--text-primary)",
141
+ fontSize: 10,
142
+ fontWeight: 600,
143
+ children: b
144
+ })]
145
+ });
135
146
  })()
136
147
  ]
137
148
  }, e.label);
@@ -140,4 +151,4 @@ function g({ data: g, height: _ = 180, maxValue: v, valueFormatter: y, tooltipVa
140
151
  });
141
152
  }
142
153
  //#endregion
143
- export { g as VerticalBarChart };
154
+ export { _ as VerticalBarChart };
@@ -0,0 +1,16 @@
1
+ import type { KeyboardEvent } from "react";
2
+ export declare function getBarActivationProps<T>(activate: ((datum: T, index: number) => void) | undefined, datum: T, index: number): {
3
+ onClick?: undefined;
4
+ onKeyDown?: undefined;
5
+ } | {
6
+ onClick: () => void;
7
+ onKeyDown(event: KeyboardEvent<SVGGElement>): void;
8
+ };
9
+ export declare function getBarAxisLayout(labels: string[], cap: number, measuredWidth: number | undefined, padding: {
10
+ left: number;
11
+ right: number;
12
+ }): {
13
+ left: number;
14
+ plotWidth: number;
15
+ indices: Set<number>;
16
+ };
@@ -0,0 +1,24 @@
1
+ import { estimateTextWidth as e, getFittingLabelCount as t, getLabelIndices as n } from "./chartUtils.js";
2
+ //#region src/components/charts/barChartUtils.ts
3
+ function r(e, t, n) {
4
+ return e ? {
5
+ onClick: () => e(t, n),
6
+ onKeyDown(r) {
7
+ r.key !== "Enter" && r.key !== " " || (r.preventDefault(), r.repeat || e(t, n));
8
+ }
9
+ } : {};
10
+ }
11
+ function i(r, i, a, o) {
12
+ let s = a ?? 600, c = (t, n) => a && i > 0 && t ? Math.max(n, Math.min(s / 4, e(t) / 2 + 4)) : n, l = c(r[0], o.left), u = Math.max(0, s - l - c(r.at(-1), o.right)), d = i;
13
+ if (a && r.length > 1 && i > 1) {
14
+ let n = r.reduce((t, n) => Math.max(t, e(n)), 0), a = u * (1 - 1 / r.length);
15
+ d = Math.min(i, t(r.length, a, n));
16
+ }
17
+ return {
18
+ left: l,
19
+ plotWidth: u,
20
+ indices: new Set(n(r.length, d))
21
+ };
22
+ }
23
+ //#endregion
24
+ export { r as getBarActivationProps, i as getBarAxisLayout };
@@ -1,5 +1,13 @@
1
- import { type RefObject } from "react";
1
+ import { type Ref, type RefCallback, type RefObject } from "react";
2
2
  export declare function useChartSize(ref: RefObject<SVGSVGElement | null>): {
3
3
  width: number;
4
4
  height: number;
5
5
  } | undefined;
6
+ export declare function useBarChartSize(ref: Ref<SVGSVGElement> | undefined): {
7
+ rootRef: RefCallback<SVGSVGElement>;
8
+ size: {
9
+ width: number;
10
+ height: number;
11
+ } | undefined;
12
+ viewBoxWidth: number;
13
+ };
@@ -1,18 +1,27 @@
1
- import { useEffect as e, useState as t } from "react";
1
+ import { mergeRefs as e } from "../../lib/mergeRefs.js";
2
+ import { useCallback as t, useEffect as n, useRef as r, useState as i } from "react";
2
3
  //#region src/components/charts/useChartSize.ts
3
- function n(n) {
4
- let [r, i] = t();
5
- return e(() => {
6
- if (!n.current || typeof ResizeObserver > "u") return;
7
- let e = new ResizeObserver(([e]) => {
4
+ function a(e) {
5
+ let [t, r] = i();
6
+ return n(() => {
7
+ if (!e.current || typeof ResizeObserver > "u") return;
8
+ let t = new ResizeObserver(([e]) => {
8
9
  let { width: t, height: n } = e.contentRect;
9
- t > 0 && n > 0 && i({
10
+ t > 0 && n > 0 && r({
10
11
  width: t,
11
12
  height: n
12
13
  });
13
14
  });
14
- return e.observe(n.current), () => e.disconnect();
15
- }, [n]), r;
15
+ return t.observe(e.current), () => t.disconnect();
16
+ }, [e]), t;
17
+ }
18
+ function o(n) {
19
+ let i = r(null), o = t((t) => e(i, n)(t), [n]), s = a(i);
20
+ return {
21
+ rootRef: o,
22
+ size: s,
23
+ viewBoxWidth: s?.width ?? 600
24
+ };
16
25
  }
17
26
  //#endregion
18
- export { n as useChartSize };
27
+ export { o as useBarChartSize, a as useChartSize };
@@ -0,0 +1,10 @@
1
+ import type { ComponentPropsWithRef, ReactNode } from "react";
2
+ export interface MainAsideLayoutProps extends ComponentPropsWithRef<"div"> {
3
+ /** Primary content, displayed first at every width. */
4
+ children: ReactNode;
5
+ /** Supporting content, rendered in an aside. */
6
+ aside: ReactNode;
7
+ /** Show a divider between the columns when side by side. */
8
+ divider?: boolean;
9
+ }
10
+ export declare function MainAsideLayout({ children, aside, divider, className, ...props }: MainAsideLayoutProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import { cn as e } from "../../lib/cn.js";
2
+ import { jsx as t, jsxs as n } from "react/jsx-runtime";
3
+ //#region src/components/ui/MainAsideLayout.tsx
4
+ function r({ children: r, aside: i, divider: a = !1, className: o, ...s }) {
5
+ return /* @__PURE__ */ t("div", {
6
+ ...s,
7
+ className: e("ui-main-aside", o),
8
+ children: /* @__PURE__ */ n("div", {
9
+ className: "ui-main-aside-grid",
10
+ children: [/* @__PURE__ */ t("div", { children: r }), /* @__PURE__ */ t("aside", {
11
+ className: a ? "ui-main-aside-divider" : void 0,
12
+ children: i
13
+ })]
14
+ })
15
+ });
16
+ }
17
+ //#endregion
18
+ export { r as MainAsideLayout };
package/dist/core.css CHANGED
@@ -2246,6 +2246,23 @@ select:disabled + .ui-select-placeholder {
2246
2246
  grid-template-columns: var(--ui-columns-base, repeat(1, minmax(0, 1fr)));
2247
2247
  justify-items: var(--ui-justify, stretch);
2248
2248
  }
2249
+ .ui-main-aside {
2250
+ container: ui-main-aside / inline-size;
2251
+ }
2252
+ .ui-main-aside-grid {
2253
+ display: grid;
2254
+ grid-template-columns: minmax(0, 1fr);
2255
+ gap: calc(4 * var(--spacing));
2256
+ }
2257
+ @container ui-main-aside (min-width: 56rem) {
2258
+ .ui-main-aside-grid {
2259
+ grid-template-columns: minmax(0, 2fr) minmax(20rem, 1fr);
2260
+ }
2261
+ .ui-main-aside-grid > .ui-main-aside-divider {
2262
+ border-inline-start: var(--ui-border-width) solid var(--border);
2263
+ padding-inline-start: calc(4 * var(--spacing));
2264
+ }
2265
+ }
2249
2266
  .ui-grid-item {
2250
2267
  grid-column: var(--ui-span-base, span 1 / span 1);
2251
2268
  }
package/dist/index.d.ts CHANGED
@@ -133,6 +133,7 @@ export * from "./components/ui/Stack";
133
133
  export * from "./components/ui/Inline";
134
134
  export * from "./components/ui/Grid";
135
135
  export * from "./components/ui/GridItem";
136
+ export * from "./components/ui/MainAsideLayout";
136
137
  export * from "./components/tables/Table";
137
138
  export * from "./components/ui/ActionLink";
138
139
  export * from "./components/ui/Icon";
package/dist/index.js CHANGED
@@ -131,8 +131,9 @@ import { Stack as An } from "./components/ui/Stack.js";
131
131
  import { Inline as jn } from "./components/ui/Inline.js";
132
132
  import { Grid as Mn } from "./components/ui/Grid.js";
133
133
  import { GridItem as Nn } from "./components/ui/GridItem.js";
134
- import { ActionLink as Pn } from "./components/ui/ActionLink.js";
135
- import { Icon as Fn } from "./components/ui/Icon.js";
136
- import { Text as In } from "./components/ui/Text.js";
137
- import { Meter as Ln } from "./components/ui/Meter.js";
138
- export { xe as Accordion, Pn as ActionLink, Se as Alert, de as AppShell, t as AreaChart, Sn as AttachmentItem, Cn as AttachmentList, Ce as AudioPlayer, we as AuthCard, fe as AuthLayout, Te as AuthorByline, H as Avatar, pe as BackLink, Ee as Badge, n as BarChart, x as BottomNav, Z as Breadcrumbs, ee as Button, C as COMMAND_PALETTE_EVENT, st as Calendar, ct as CalendarGrid, lt as Card, Dn as CharacterCount, me as Checkbox, ut as CodeInput, ge as ColumnPicker, dt as Combobox, D as CommandPalette, On as ControlSizeProvider, ft as CopyButton, at as DEFAULT_CALENDAR_LABELS, w as DEFAULT_COMMAND_PALETTE_SHORTCUT, pt as DangerZone, wn as DatePartsInput, mt as DatePicker, ht as DateRangePicker, gt as DateTimePicker, _t as DetailPanel, vt as Dialog, yt as DialogActions, be as Disclosure, bt as DividerLabel, r as DonutChart, xt as DropdownMenu, St as EmptyState, Ct as ErrorBoundary, _n as FieldError, vn as FieldHint, bn as Fieldset, he as FilterButton, wt as FilterDropdown, yn as FormField, Mn as Grid, Nn as GridItem, f as Heatmap, Fn as Icon, jn as Inline, Tt as Kbd, Dt as ListItemLink, Et as LoadingSpinner, Ot as MessageBubble, kt as MetadataGrid, Ln as Meter, At as MetricCard, A as MobileDrawer, En as NavTabs, jt as OAuthButton, Mt as OverlineLabel, Nt as PageHeader, Pt as PageSection, _e as Pagination, Ft as PaginationBar, It as PasswordInput, zt as PasswordRequirements, Bt as Popover, O as PortalContainerContext, Vt as ProfileHeader, kn as ProgressBar, Ht as ProseContent, Ut as QrCapacityError, Gt as QrCode, p as RadarChart, m as RadialBarChart, xn as Radio, ot as RadioPill, Kt as ReorderList, ye as ResourceTable, qt as SearchInput, te as SectionHeader, Jt as Select, re as SelectDropdown, Yt as SettingRow, B as SettingsContext, hn as SettingsProvider, Xt as SideSheet, X as Sidebar, Tn as Skeleton, ie as Slider, h as SparkLine, Zt as SplitPaneLayout, An as Stack, g as StackedBarChart, Qt as StatusDot, $t as StepProgress, se as THEME_MENU_EVENT, i as Table, a as TableBody, o as TableCell, s as TableEmptyRow, c as TableFoot, l as TableHead, u as TableHeaderCell, d as TableRow, en as Tabs, In as Text, nn as TextInput, tn as Textarea, un as ThemeContext, le as ThemeMenu, ae as ThemePreview, gn as ThemeProvider, rn as TimeInput, an as Timeline, J as ToastProvider, oe as Toggle, cn as Toolbar, sn as Tooltip, ue as TopBar, on as TranscriptLine, ln as UploadDropzone, _ as VerticalBarChart, j as accentItems, Oe as addDays, ke as addMinutes, Ae as addMonths, De as badgeColors, je as calendarDateFromParts, Me as calendarDateParts, e as cn, Ne as createCalendarDateMath, M as darkThemes, Pe as dateAtMinutes, Lt as defaultPasswordRequirements, Fe as differenceInDays, Wt as encodeQrCode, Ie as expandAvailabilityRules, N as fontOptions, fn as formatDateLong, pn as formatDateShort, Le as formatRangeTitle, mn as formatRelative, Re as formatTime, ze as formatTimeOfDay, Be as formatTimeRange, Ve as fromDateKey, He as getActiveResourceIds, Ue as getViewRange, We as getVisibleDays, v as handleAppShellNavigate, Ge as isAllDayLike, y as isAppShellPathActive, P as isLightTheme, Ke as isSameDay, qe as isTimeGridView, U as isTone, Je as layoutOverlaps, F as lightThemes, T as matchesCommandPaletteShortcut, Rt as meetsPasswordRequirements, Ye as minutesOfDay, b as navigateToPath, E as openCommandPalette, ce as openThemeMenu, Xe as parseTime, Ze as rangesOverlap, W as semanticTones, Qe as shiftDate, $e as snapDate, et as snapMinutes, ve as sortRows, tt as startOfDay, nt as startOfMonth, rt as startOfWeek, I as themeDefaults, L as themeItems, it as toDateKey, G as toneClasses, K as toneColor, q as tones, R as useAnchoredPopup, Q as useApplyTheme, $ as useControlSize, z as useDismiss, S as useFocusTrap, ne as usePopover, k as usePortalContainer, V as useSettings, dn as useTheme, Y as useToast };
134
+ import { MainAsideLayout as Pn } from "./components/ui/MainAsideLayout.js";
135
+ import { ActionLink as Fn } from "./components/ui/ActionLink.js";
136
+ import { Icon as In } from "./components/ui/Icon.js";
137
+ import { Text as Ln } from "./components/ui/Text.js";
138
+ import { Meter as Rn } from "./components/ui/Meter.js";
139
+ export { xe as Accordion, Fn as ActionLink, Se as Alert, de as AppShell, t as AreaChart, Sn as AttachmentItem, Cn as AttachmentList, Ce as AudioPlayer, we as AuthCard, fe as AuthLayout, Te as AuthorByline, H as Avatar, pe as BackLink, Ee as Badge, n as BarChart, x as BottomNav, Z as Breadcrumbs, ee as Button, C as COMMAND_PALETTE_EVENT, st as Calendar, ct as CalendarGrid, lt as Card, Dn as CharacterCount, me as Checkbox, ut as CodeInput, ge as ColumnPicker, dt as Combobox, D as CommandPalette, On as ControlSizeProvider, ft as CopyButton, at as DEFAULT_CALENDAR_LABELS, w as DEFAULT_COMMAND_PALETTE_SHORTCUT, pt as DangerZone, wn as DatePartsInput, mt as DatePicker, ht as DateRangePicker, gt as DateTimePicker, _t as DetailPanel, vt as Dialog, yt as DialogActions, be as Disclosure, bt as DividerLabel, r as DonutChart, xt as DropdownMenu, St as EmptyState, Ct as ErrorBoundary, _n as FieldError, vn as FieldHint, bn as Fieldset, he as FilterButton, wt as FilterDropdown, yn as FormField, Mn as Grid, Nn as GridItem, f as Heatmap, In as Icon, jn as Inline, Tt as Kbd, Dt as ListItemLink, Et as LoadingSpinner, Pn as MainAsideLayout, Ot as MessageBubble, kt as MetadataGrid, Rn as Meter, At as MetricCard, A as MobileDrawer, En as NavTabs, jt as OAuthButton, Mt as OverlineLabel, Nt as PageHeader, Pt as PageSection, _e as Pagination, Ft as PaginationBar, It as PasswordInput, zt as PasswordRequirements, Bt as Popover, O as PortalContainerContext, Vt as ProfileHeader, kn as ProgressBar, Ht as ProseContent, Ut as QrCapacityError, Gt as QrCode, p as RadarChart, m as RadialBarChart, xn as Radio, ot as RadioPill, Kt as ReorderList, ye as ResourceTable, qt as SearchInput, te as SectionHeader, Jt as Select, re as SelectDropdown, Yt as SettingRow, B as SettingsContext, hn as SettingsProvider, Xt as SideSheet, X as Sidebar, Tn as Skeleton, ie as Slider, h as SparkLine, Zt as SplitPaneLayout, An as Stack, g as StackedBarChart, Qt as StatusDot, $t as StepProgress, se as THEME_MENU_EVENT, i as Table, a as TableBody, o as TableCell, s as TableEmptyRow, c as TableFoot, l as TableHead, u as TableHeaderCell, d as TableRow, en as Tabs, Ln as Text, nn as TextInput, tn as Textarea, un as ThemeContext, le as ThemeMenu, ae as ThemePreview, gn as ThemeProvider, rn as TimeInput, an as Timeline, J as ToastProvider, oe as Toggle, cn as Toolbar, sn as Tooltip, ue as TopBar, on as TranscriptLine, ln as UploadDropzone, _ as VerticalBarChart, j as accentItems, Oe as addDays, ke as addMinutes, Ae as addMonths, De as badgeColors, je as calendarDateFromParts, Me as calendarDateParts, e as cn, Ne as createCalendarDateMath, M as darkThemes, Pe as dateAtMinutes, Lt as defaultPasswordRequirements, Fe as differenceInDays, Wt as encodeQrCode, Ie as expandAvailabilityRules, N as fontOptions, fn as formatDateLong, pn as formatDateShort, Le as formatRangeTitle, mn as formatRelative, Re as formatTime, ze as formatTimeOfDay, Be as formatTimeRange, Ve as fromDateKey, He as getActiveResourceIds, Ue as getViewRange, We as getVisibleDays, v as handleAppShellNavigate, Ge as isAllDayLike, y as isAppShellPathActive, P as isLightTheme, Ke as isSameDay, qe as isTimeGridView, U as isTone, Je as layoutOverlaps, F as lightThemes, T as matchesCommandPaletteShortcut, Rt as meetsPasswordRequirements, Ye as minutesOfDay, b as navigateToPath, E as openCommandPalette, ce as openThemeMenu, Xe as parseTime, Ze as rangesOverlap, W as semanticTones, Qe as shiftDate, $e as snapDate, et as snapMinutes, ve as sortRows, tt as startOfDay, nt as startOfMonth, rt as startOfWeek, I as themeDefaults, L as themeItems, it as toDateKey, G as toneClasses, K as toneColor, q as tones, R as useAnchoredPopup, Q as useApplyTheme, $ as useControlSize, z as useDismiss, S as useFocusTrap, ne as usePopover, k as usePortalContainer, V as useSettings, dn as useTheme, Y as useToast };
package/dist/styles.css CHANGED
@@ -2936,6 +2936,23 @@ select:disabled + .ui-select-placeholder {
2936
2936
  grid-template-columns: var(--ui-columns-base, repeat(1, minmax(0, 1fr)));
2937
2937
  justify-items: var(--ui-justify, stretch);
2938
2938
  }
2939
+ .ui-main-aside {
2940
+ container: ui-main-aside / inline-size;
2941
+ }
2942
+ .ui-main-aside-grid {
2943
+ display: grid;
2944
+ grid-template-columns: minmax(0, 1fr);
2945
+ gap: calc(4 * var(--spacing));
2946
+ }
2947
+ @container ui-main-aside (min-width: 56rem) {
2948
+ .ui-main-aside-grid {
2949
+ grid-template-columns: minmax(0, 2fr) minmax(20rem, 1fr);
2950
+ }
2951
+ .ui-main-aside-grid > .ui-main-aside-divider {
2952
+ border-inline-start: var(--ui-border-width) solid var(--border);
2953
+ padding-inline-start: calc(4 * var(--spacing));
2954
+ }
2955
+ }
2939
2956
  .ui-grid-item {
2940
2957
  grid-column: var(--ui-span-base, span 1 / span 1);
2941
2958
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leonardaustin/ui",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Reusable React component library and application shell for Leonard Austin projects.",
5
5
  "license": "MIT",
6
6
  "type": "module",