iryx-ui 0.15.0 → 0.16.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.
package/README.md CHANGED
@@ -62,7 +62,9 @@ Components are auto-imported with the `I` prefix.
62
62
  </IFormField>
63
63
 
64
64
  <template #footer>
65
- <IButton @click="save">Save</IButton>
65
+ <IButton @click="save">
66
+ Save
67
+ </IButton>
66
68
  </template>
67
69
  </ICard>
68
70
  </IApp>
@@ -3,5 +3,5 @@
3
3
  * Consumed by the Vue plugin (global registration) and the Nuxt module
4
4
  * (auto-imports). Keep in sync with `src/components/index.ts`.
5
5
  */
6
- export declare const componentNames: readonly ["Accordion", "Alert", "App", "AppShell", "AspectRatio", "Avatar", "AvatarGroup", "Badge", "BarChart", "Banner", "Breadcrumb", "Button", "ButtonGroup", "Card", "ChartLegend", "Checkbox", "ColorPicker", "Combobox", "Collapsible", "CommandPalette", "Container", "ConfirmDialog", "ContextMenu", "DatePicker", "DateRangePicker", "Dialog", "Drawer", "DropdownMenu", "EmptyState", "FileUpload", "Form", "FormField", "Icon", "Input", "Kbd", "Label", "LineChart", "NavigationMenu", "NumberInput", "Menubar", "PageHeader", "Pagination", "PasswordInput", "PinInput", "Popover", "Progress", "RadioGroup", "ScrollArea", "ScrollFade", "Select", "Separator", "Sidebar", "SignaturePad", "Skeleton", "Slider", "Sparkline", "Splitter", "Stat", "Stepper", "Switch", "Table", "Tabs", "TagsInput", "Textarea", "Toaster", "Toggle", "ToggleGroup", "TimeField", "Timeline", "Toolbar", "Tooltip", "Tree"];
6
+ export declare const componentNames: readonly ["Accordion", "Alert", "App", "AppShell", "AspectRatio", "Avatar", "AvatarGroup", "Badge", "BarChart", "Banner", "Breadcrumb", "Button", "ButtonGroup", "Card", "ChartLegend", "Checkbox", "ColorPicker", "Combobox", "Collapsible", "CommandPalette", "Container", "ConfirmDialog", "ContextMenu", "DatePicker", "DateRangePicker", "Dialog", "DonutChart", "Drawer", "DropdownMenu", "EmptyState", "FileUpload", "Form", "FormField", "Icon", "Input", "Kbd", "Label", "LineChart", "NavigationMenu", "NumberInput", "Menubar", "PageHeader", "Pagination", "PasswordInput", "PinInput", "Popover", "Progress", "RadioGroup", "ScrollArea", "ScrollFade", "Select", "Separator", "Sidebar", "SignaturePad", "Skeleton", "Slider", "Sparkline", "Splitter", "Stat", "Stepper", "Switch", "Table", "Tabs", "TagsInput", "Textarea", "Toaster", "Toggle", "ToggleGroup", "TimeField", "Timeline", "Toolbar", "Tooltip", "Tree"];
7
7
  export type ComponentName = (typeof componentNames)[number];
@@ -1,4 +1,4 @@
1
1
  //#region src/component-names.ts
2
- var e = /* @__PURE__ */ "Accordion.Alert.App.AppShell.AspectRatio.Avatar.AvatarGroup.Badge.BarChart.Banner.Breadcrumb.Button.ButtonGroup.Card.ChartLegend.Checkbox.ColorPicker.Combobox.Collapsible.CommandPalette.Container.ConfirmDialog.ContextMenu.DatePicker.DateRangePicker.Dialog.Drawer.DropdownMenu.EmptyState.FileUpload.Form.FormField.Icon.Input.Kbd.Label.LineChart.NavigationMenu.NumberInput.Menubar.PageHeader.Pagination.PasswordInput.PinInput.Popover.Progress.RadioGroup.ScrollArea.ScrollFade.Select.Separator.Sidebar.SignaturePad.Skeleton.Slider.Sparkline.Splitter.Stat.Stepper.Switch.Table.Tabs.TagsInput.Textarea.Toaster.Toggle.ToggleGroup.TimeField.Timeline.Toolbar.Tooltip.Tree".split(".");
2
+ var e = /* @__PURE__ */ "Accordion.Alert.App.AppShell.AspectRatio.Avatar.AvatarGroup.Badge.BarChart.Banner.Breadcrumb.Button.ButtonGroup.Card.ChartLegend.Checkbox.ColorPicker.Combobox.Collapsible.CommandPalette.Container.ConfirmDialog.ContextMenu.DatePicker.DateRangePicker.Dialog.DonutChart.Drawer.DropdownMenu.EmptyState.FileUpload.Form.FormField.Icon.Input.Kbd.Label.LineChart.NavigationMenu.NumberInput.Menubar.PageHeader.Pagination.PasswordInput.PinInput.Popover.Progress.RadioGroup.ScrollArea.ScrollFade.Select.Separator.Sidebar.SignaturePad.Skeleton.Slider.Sparkline.Splitter.Stat.Stepper.Switch.Table.Tabs.TagsInput.Textarea.Toaster.Toggle.ToggleGroup.TimeField.Timeline.Toolbar.Tooltip.Tree".split(".");
3
3
  //#endregion
4
4
  export { e as componentNames };
@@ -1,4 +1,5 @@
1
1
  import type { ChartSeries } from '../composables/cartesian';
2
+ import type { ChartAnimate } from '../composables/chart-reveal';
2
3
  import type { SparseValue } from '../composables/scale';
3
4
  /**
4
5
  * A row. `value` is the single-series shortcut; with `series` set, each entry
@@ -37,6 +38,12 @@ export interface BarChartProps {
37
38
  ticks?: number;
38
39
  /** Drop the value axis and its gridlines. */
39
40
  axis?: boolean;
41
+ /**
42
+ * Grow the bars out of the baseline on the first paint. Skipped for a
43
+ * reader who has asked for reduced motion, and played once — not again when
44
+ * the data changes underneath it.
45
+ */
46
+ animate?: ChartAnimate;
40
47
  /** Drop the legend. Only honoured for a single series — see below. */
41
48
  legend?: boolean;
42
49
  /** Word for the stacked tooltip's sum — override for non-English apps. */
@@ -95,6 +102,7 @@ declare const __VLS_base: import("vue").DefineComponent<BarChartProps, {}, {}, {
95
102
  orientation: "vertical" | "horizontal";
96
103
  data: readonly BarChartDatum[];
97
104
  legend: boolean;
105
+ animate: ChartAnimate;
98
106
  height: number;
99
107
  ticks: number;
100
108
  axis: boolean;
@@ -1,39 +1,40 @@
1
1
  import { useIryxUiConfig as e } from "../config.js";
2
2
  import { useElementSize as t } from "../composables/element-size.js";
3
3
  import { cartesianLayout as n, clampTooltip as r, seriesColor as i, slotOf as a, tooltipHalfWidth as o, warnOnSlotOverflow as s } from "../composables/cartesian.js";
4
- import { barChartTheme as c } from "../theme/bar-chart.js";
5
- import l from "./ChartLegend.js";
6
- import { Fragment as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, defineComponent as g, guardReactiveProps as _, normalizeClass as v, normalizeProps as y, normalizeStyle as b, openBlock as x, ref as S, renderList as C, renderSlot as w, toDisplayString as T, unref as E } from "vue";
4
+ import { useChartAnimation as c, useChartReveal as l } from "../composables/chart-reveal.js";
5
+ import { barChartTheme as u } from "../theme/bar-chart.js";
6
+ import d from "./ChartLegend.js";
7
+ import { Fragment as f, computed as p, createBlock as m, createCommentVNode as h, createElementBlock as g, createElementVNode as _, defineComponent as v, guardReactiveProps as y, normalizeClass as b, normalizeProps as x, normalizeStyle as S, openBlock as C, ref as w, renderList as T, renderSlot as E, toDisplayString as D, unref as O } from "vue";
7
8
  //#region src/components/BarChart.vue?vue&type=script&setup=true&lang.ts
8
- var ee = ["role", "aria-label"], D = [
9
+ var ee = ["role", "aria-label"], te = [
9
10
  "width",
10
11
  "height",
11
12
  "viewBox"
12
- ], te = [
13
+ ], ne = [
13
14
  "x1",
14
15
  "y1",
15
16
  "x2",
16
17
  "y2"
17
- ], O = [
18
+ ], re = [
18
19
  "x",
19
20
  "y",
20
21
  "text-anchor",
21
22
  "dominant-baseline"
22
- ], k = ["d"], A = [
23
+ ], ie = ["d"], k = [
23
24
  "x",
24
25
  "y",
25
26
  "text-anchor",
26
27
  "dominant-baseline"
27
- ], ne = [
28
+ ], ae = [
28
29
  "x",
29
30
  "y",
30
31
  "width",
31
32
  "height",
32
33
  "onPointerenter"
33
- ], re = {
34
+ ], oe = {
34
35
  key: 2,
35
36
  class: "flex items-center gap-1.5 border-t border-border pt-1"
36
- }, ie = { scope: "row" }, ae = .7, j = /*@__PURE__*/ g({
37
+ }, se = { scope: "row" }, ce = .7, A = /*@__PURE__*/ v({
37
38
  __name: "BarChart",
38
39
  props: {
39
40
  data: { default: () => [] },
@@ -46,6 +47,10 @@ var ee = ["role", "aria-label"], D = [
46
47
  type: Boolean,
47
48
  default: !0
48
49
  },
50
+ animate: {
51
+ type: [Boolean, Object],
52
+ default: !0
53
+ },
49
54
  legend: {
50
55
  type: Boolean,
51
56
  default: !0
@@ -61,60 +66,60 @@ var ee = ["role", "aria-label"], D = [
61
66
  class: {},
62
67
  ui: {}
63
68
  },
64
- setup(g) {
65
- let j = g, M = e(), N = d(() => j.unstyled ?? M.unstyled), P = S(), { width: F } = t(P), I = d(() => new Intl.NumberFormat(j.locale, j.format));
66
- function L(e) {
67
- return I.value.format(e);
69
+ setup(v) {
70
+ let A = v, j = e(), M = p(() => A.unstyled ?? j.unstyled), N = w(), { width: P } = t(N), le = p(() => new Intl.NumberFormat(A.locale, A.format));
71
+ function F(e) {
72
+ return le.value.format(e);
68
73
  }
69
- let R = d(() => {
70
- let e = j.series?.length ? [...j.series] : [{ key: "value" }];
74
+ let I = p(() => {
75
+ let e = A.series?.length ? [...A.series] : [{ key: "value" }];
71
76
  return s(e.length), e;
72
- }), z = d(() => R.value.length > 1), oe = d(() => z.value || j.legend && R.value[0].name != null);
73
- function B(e, t) {
77
+ }), L = p(() => I.value.length > 1), ue = p(() => L.value || A.legend && I.value[0].name != null);
78
+ function R(e, t) {
74
79
  let n = e[t];
75
80
  return typeof n == "number" && Number.isFinite(n) ? n : null;
76
81
  }
77
- let V = d(() => j.orientation === "horizontal"), H = d(() => j.stacked && z.value);
78
- function U(e) {
82
+ let z = p(() => A.orientation === "horizontal"), B = p(() => A.stacked && L.value);
83
+ function V(e) {
79
84
  let t = 0, n = 0;
80
- for (let r of R.value) {
81
- let i = B(e, r.key);
85
+ for (let r of I.value) {
86
+ let i = R(e, r.key);
82
87
  i != null && (i >= 0 ? t += i : n += i);
83
88
  }
84
89
  return [t, n];
85
90
  }
86
- let W = d(() => n({
87
- orientation: j.orientation,
88
- values: H.value ? j.data.flatMap(U) : j.data.flatMap((e) => R.value.map((t) => B(e, t.key))),
89
- categories: j.data.length,
90
- longestLabel: Math.max(...j.data.map((e) => e.label.length), 1),
91
- width: F.value,
92
- height: j.height,
93
- tickCount: j.ticks,
94
- showAxis: j.axis,
95
- formatTick: L,
91
+ let H = p(() => n({
92
+ orientation: A.orientation,
93
+ values: B.value ? A.data.flatMap(V) : A.data.flatMap((e) => I.value.map((t) => R(e, t.key))),
94
+ categories: A.data.length,
95
+ longestLabel: Math.max(...A.data.map((e) => e.label.length), 1),
96
+ width: P.value,
97
+ height: A.height,
98
+ tickCount: A.ticks,
99
+ showAxis: A.axis,
100
+ formatTick: F,
96
101
  includeZero: !0
97
- })), G = d(() => W.value.plot), K = d(() => W.value.y), q = d(() => W.value.bandWidth), J = d(() => q.value * ae), Y = d(() => Math.max(2, Math.min(24, J.value / (H.value ? 1 : R.value.length)))), se = d(() => {
98
- if (!F.value || !j.data.length) return [];
99
- let e = W.value.value(0), t = R.value.length, n = +(t > 1 && !H.value);
100
- return j.data.flatMap((r, i) => {
101
- let a = 0, o = 0, s = R.value.reduce((e, t, n) => {
102
- let i = B(r, t.key);
102
+ })), U = p(() => H.value.plot), W = p(() => H.value.y), G = p(() => H.value.bandWidth), de = p(() => G.value * ce), K = p(() => Math.max(2, Math.min(24, de.value / (B.value ? 1 : I.value.length)))), q = p(() => {
103
+ if (!P.value || !A.data.length) return [];
104
+ let e = H.value.value(0), t = I.value.length, n = +(t > 1 && !B.value);
105
+ return A.data.flatMap((r, i) => {
106
+ let a = 0, o = 0, s = I.value.reduce((e, t, n) => {
107
+ let i = R(r, t.key);
103
108
  return i != null && i >= 0 ? n : e;
104
- }, -1), c = R.value.reduce((e, t, n) => {
105
- let i = B(r, t.key);
109
+ }, -1), c = I.value.reduce((e, t, n) => {
110
+ let i = R(r, t.key);
106
111
  return i != null && i < 0 ? n : e;
107
112
  }, -1);
108
- return R.value.flatMap((l, u) => {
109
- let d = B(r, l.key);
113
+ return I.value.flatMap((l, u) => {
114
+ let d = R(r, l.key);
110
115
  if (d == null) return [];
111
116
  let f = e, p;
112
- if (H.value) {
117
+ if (B.value) {
113
118
  let e = d >= 0 ? a : o, t = e + d;
114
- f = W.value.value(e), p = W.value.value(t), d >= 0 ? a = t : o = t;
115
- } else p = W.value.value(d);
116
- let m = H.value ? Y.value : Y.value * t, h = W.value.bandCentre(i) - m / 2 + (H.value ? 0 : Y.value * u) + n, g = Math.max(Y.value - n * 2, 1), _ = H.value ? Math.min(2, Math.abs(p - f) / 2) : 0, v = Math.max(Math.abs(p - f) - _, 0), y = p < f ? p + _ : f, b = !H.value || u === (d >= 0 ? s : c);
117
- return [V.value ? {
119
+ f = H.value.value(e), p = H.value.value(t), d >= 0 ? a = t : o = t;
120
+ } else p = H.value.value(d);
121
+ let m = B.value ? K.value : K.value * t, h = H.value.bandCentre(i) - m / 2 + (B.value ? 0 : K.value * u) + n, g = Math.max(K.value - n * 2, 1), _ = B.value ? Math.min(2, Math.abs(p - f) / 2) : 0, v = Math.max(Math.abs(p - f) - _, 0), y = p < f ? p + _ : f, b = !B.value || u === (d >= 0 ? s : c);
122
+ return [z.value ? {
118
123
  x: y,
119
124
  y: h,
120
125
  width: v,
@@ -136,7 +141,7 @@ var ee = ["role", "aria-label"], D = [
136
141
  });
137
142
  });
138
143
  });
139
- function ce(e) {
144
+ function fe(e) {
140
145
  let { x: t, y: n, width: r, height: i } = e, a = t + r;
141
146
  if (!e.capped) return `M${t} ${n} L${a} ${n} L${a} ${n + i} L${t} ${n + i} Z`;
142
147
  let o = n + i, s = Math.min(4, r / 2, i / 2, e.direction === "up" || e.direction === "down" ? i : r);
@@ -147,154 +152,167 @@ var ee = ["role", "aria-label"], D = [
147
152
  default: return `M${a} ${n} L${t + s} ${n} Q${t} ${n} ${t} ${n + s} L${t} ${o - s} Q${t} ${o} ${t + s} ${o} L${a} ${o} Z`;
148
153
  }
149
154
  }
150
- let le = d(() => W.value.labelStep), X = S(), Z = d(() => {
151
- if (X.value == null) return;
152
- let e = j.data[X.value];
155
+ let J = p(() => H.value.labelStep), Y = w(), X = p(() => {
156
+ if (Y.value == null) return;
157
+ let e = A.data[Y.value];
153
158
  if (!e) return;
154
- let t = R.value.map((t, n) => ({
159
+ let t = I.value.map((t, n) => ({
155
160
  name: t.name ?? t.key,
156
161
  color: i(a(t, n)),
157
- value: B(e, t.key)
162
+ value: R(e, t.key)
158
163
  })).filter((e) => e.value != null).map((e) => ({
159
164
  ...e,
160
- value: L(e.value)
165
+ value: F(e.value)
161
166
  }));
162
167
  if (!t.length) return;
163
- let n = H.value ? L(U(e).reduce((e, t) => e + t, 0)) : void 0, s = z.value ? Math.max(e.label.length, n ? n.length + 6 : 0, ...t.map((e) => e.name.length + e.value.length + 3)) : e.label.length + t[0].value.length + 2, c = W.value.bandCentre(X.value);
164
- if (V.value) {
165
- let i = H.value ? W.value.value(U(e)[0]) : Math.max(...R.value.map((t) => {
166
- let n = B(e, t.key);
167
- return n == null ? -Infinity : W.value.value(n);
168
- })), a = "x".repeat(s), l = o(a), u = i + l + 8, d = u + l <= F.value;
168
+ let n = B.value ? F(V(e).reduce((e, t) => e + t, 0)) : void 0, s = L.value ? Math.max(e.label.length, n ? n.length + 6 : 0, ...t.map((e) => e.name.length + e.value.length + 3)) : e.label.length + t[0].value.length + 2, c = H.value.bandCentre(Y.value);
169
+ if (z.value) {
170
+ let i = B.value ? H.value.value(V(e)[0]) : Math.max(...I.value.map((t) => {
171
+ let n = R(e, t.key);
172
+ return n == null ? -Infinity : H.value.value(n);
173
+ })), a = "x".repeat(s), l = o(a), u = i + l + 8, d = u + l <= P.value;
169
174
  return {
170
175
  label: e.label,
171
176
  rows: t,
172
177
  total: n,
173
- multi: z.value,
174
- x: r(d ? u : i - l - 8, a, F.value),
178
+ multi: L.value,
179
+ x: r(d ? u : i - l - 8, a, P.value),
175
180
  y: c
176
181
  };
177
182
  }
178
- let l = H.value ? W.value.value(U(e)[0]) : Math.min(...R.value.map((t) => {
179
- let n = B(e, t.key);
180
- return n == null ? Infinity : Math.min(W.value.value(n), W.value.value(0));
183
+ let l = B.value ? H.value.value(V(e)[0]) : Math.min(...I.value.map((t) => {
184
+ let n = R(e, t.key);
185
+ return n == null ? Infinity : Math.min(H.value.value(n), H.value.value(0));
181
186
  }));
182
187
  return {
183
188
  label: e.label,
184
189
  rows: t,
185
190
  total: n,
186
- multi: z.value,
187
- x: r(c, "x".repeat(s), F.value),
191
+ multi: L.value,
192
+ x: r(c, "x".repeat(s), P.value),
188
193
  y: l
189
194
  };
190
- }), Q = d(() => c());
191
- function $(e, t) {
192
- let n = j.ui?.[e];
193
- return N.value ? [n, t] : Q.value[e]({ class: [n, t] });
195
+ }), Z = p(() => u());
196
+ function Q(e, t) {
197
+ let n = A.ui?.[e];
198
+ return M.value ? [n, t] : Z.value[e]({ class: [n, t] });
199
+ }
200
+ let pe = p(() => !!(P.value && q.value.length)), $ = c(p(() => A.animate)), { revealed: me } = l(pe, $);
201
+ function he(e) {
202
+ let t = H.value.value(0), n = z.value ? e.y + e.height / 2 : e.x + e.width / 2, r = z.value ? "scaleX" : "scaleY";
203
+ return {
204
+ transformOrigin: z.value ? `${t}px ${n}px` : `${n}px ${t}px`,
205
+ transform: `${r}(${+!!me.value})`,
206
+ transition: `transform ${$.value.duration}ms ${$.value.css}`,
207
+ transitionDelay: `${Math.min(e.categoryIndex * 30, 200)}ms`
208
+ };
194
209
  }
195
- function ue(e) {
196
- let t = X.value != null && X.value !== e.categoryIndex;
197
- return N.value ? [j.ui?.bar] : Q.value.bar({ class: [j.ui?.bar, t ? Q.value.faded() : void 0] });
210
+ function ge(e) {
211
+ let t = Y.value != null && Y.value !== e.categoryIndex;
212
+ return M.value ? [A.ui?.bar] : Z.value.bar({ class: [A.ui?.bar, t ? Z.value.faded() : void 0] });
198
213
  }
199
- return (e, t) => (x(), m("div", {
214
+ return (e, t) => (C(), g("div", {
200
215
  ref_key: "root",
201
- ref: P,
202
- role: j.label ? "figure" : void 0,
203
- "aria-label": j.label,
204
- class: v($("root", j.class))
216
+ ref: N,
217
+ role: A.label ? "figure" : void 0,
218
+ "aria-label": A.label,
219
+ class: b(Q("root", A.class))
205
220
  }, [
206
- oe.value ? (x(), f(l, {
221
+ ue.value ? (C(), m(d, {
207
222
  key: 0,
208
- series: R.value,
209
- unstyled: j.unstyled
210
- }, null, 8, ["series", "unstyled"])) : p("", !0),
211
- h("div", { class: v(N.value ? void 0 : Q.value.plot()) }, [(x(), m("svg", {
212
- width: E(F),
213
- height: j.height,
214
- viewBox: `0 0 ${E(F)} ${j.height}`,
223
+ series: I.value,
224
+ unstyled: A.unstyled
225
+ }, null, 8, ["series", "unstyled"])) : h("", !0),
226
+ _("div", { class: b(M.value ? void 0 : Z.value.plot()) }, [(C(), g("svg", {
227
+ width: O(P),
228
+ height: A.height,
229
+ viewBox: `0 0 ${O(P)} ${A.height}`,
215
230
  "aria-hidden": "true",
216
- class: v($("svg"))
231
+ class: b(Q("svg"))
217
232
  }, [
218
- j.axis ? (x(!0), m(u, { key: 0 }, C(W.value.ticks, (e) => (x(), m("g", { key: `tick-${e}` }, [h("line", {
219
- x1: V.value ? W.value.value(e) : G.value.left,
220
- y1: V.value ? G.value.top : K.value(e),
221
- x2: V.value ? W.value.value(e) : G.value.left + G.value.width,
222
- y2: V.value ? G.value.top + G.value.height : K.value(e),
233
+ A.axis ? (C(!0), g(f, { key: 0 }, T(H.value.ticks, (e) => (C(), g("g", { key: `tick-${e}` }, [_("line", {
234
+ x1: z.value ? H.value.value(e) : U.value.left,
235
+ y1: z.value ? U.value.top : W.value(e),
236
+ x2: z.value ? H.value.value(e) : U.value.left + U.value.width,
237
+ y2: z.value ? U.value.top + U.value.height : W.value(e),
223
238
  "stroke-width": "1",
224
- class: v($("grid"))
225
- }, null, 10, te), h("text", {
226
- x: V.value ? W.value.value(e) : G.value.left - E(8),
227
- y: V.value ? G.value.top + G.value.height + 14 : K.value(e),
228
- "text-anchor": V.value ? "middle" : "end",
229
- "dominant-baseline": V.value ? void 0 : "middle",
230
- class: v($("tick"))
231
- }, T(L(e)), 11, O)]))), 128)) : p("", !0),
232
- w(e.$slots, "underlay", y(_(W.value))),
233
- (x(!0), m(u, null, C(se.value, (e, t) => (x(), m("path", {
239
+ class: b(Q("grid"))
240
+ }, null, 10, ne), _("text", {
241
+ x: z.value ? H.value.value(e) : U.value.left - O(8),
242
+ y: z.value ? U.value.top + U.value.height + 14 : W.value(e),
243
+ "text-anchor": z.value ? "middle" : "end",
244
+ "dominant-baseline": z.value ? void 0 : "middle",
245
+ class: b(Q("tick"))
246
+ }, D(F(e)), 11, re)]))), 128)) : h("", !0),
247
+ E(e.$slots, "underlay", x(y(H.value))),
248
+ (C(!0), g(f, null, T(q.value, (e, t) => (C(), g("path", {
234
249
  key: `bar-${e.categoryIndex}-${e.seriesIndex}-${t}`,
235
- d: ce(e),
236
- style: b({ fill: E(i)(E(a)(R.value[e.seriesIndex], e.seriesIndex)) }),
237
- class: v(ue(e))
238
- }, null, 14, k))), 128)),
239
- (x(!0), m(u, null, C(j.data, (e, t) => (x(), m(u, { key: `label-${e.label}-${t}` }, [t % le.value === 0 ? (x(), m("text", {
250
+ d: fe(e),
251
+ style: S({
252
+ fill: O(i)(O(a)(I.value[e.seriesIndex], e.seriesIndex)),
253
+ ...he(e)
254
+ }),
255
+ class: b(ge(e))
256
+ }, null, 14, ie))), 128)),
257
+ (C(!0), g(f, null, T(A.data, (e, t) => (C(), g(f, { key: `label-${e.label}-${t}` }, [t % J.value === 0 ? (C(), g("text", {
240
258
  key: 0,
241
- x: V.value ? G.value.left - E(8) : W.value.bandCentre(t),
242
- y: V.value ? W.value.bandCentre(t) : G.value.top + G.value.height + 14,
243
- "text-anchor": V.value ? "end" : "middle",
244
- "dominant-baseline": V.value ? "middle" : void 0,
245
- class: v($("category"))
246
- }, T(e.label), 11, A)) : p("", !0)], 64))), 128)),
247
- w(e.$slots, "overlay", y(_(W.value))),
248
- (x(!0), m(u, null, C(j.data, (e, n) => (x(), m("rect", {
259
+ x: z.value ? U.value.left - O(8) : H.value.bandCentre(t),
260
+ y: z.value ? H.value.bandCentre(t) : U.value.top + U.value.height + 14,
261
+ "text-anchor": z.value ? "end" : "middle",
262
+ "dominant-baseline": z.value ? "middle" : void 0,
263
+ class: b(Q("category"))
264
+ }, D(e.label), 11, k)) : h("", !0)], 64))), 128)),
265
+ E(e.$slots, "overlay", x(y(H.value))),
266
+ (C(!0), g(f, null, T(A.data, (e, n) => (C(), g("rect", {
249
267
  key: `hit-${e.label}-${n}`,
250
- x: V.value ? G.value.left : G.value.left + q.value * n,
251
- y: V.value ? G.value.top + q.value * n : G.value.top,
252
- width: V.value ? G.value.width : q.value,
253
- height: V.value ? q.value : G.value.height,
254
- class: v(N.value ? void 0 : Q.value.hit()),
255
- onPointerenter: (e) => X.value = n,
256
- onPointerleave: t[0] ||= (e) => X.value = void 0
257
- }, null, 42, ne))), 128))
258
- ], 10, D)), Z.value ? (x(), m("div", {
268
+ x: z.value ? U.value.left : U.value.left + G.value * n,
269
+ y: z.value ? U.value.top + G.value * n : U.value.top,
270
+ width: z.value ? U.value.width : G.value,
271
+ height: z.value ? G.value : U.value.height,
272
+ class: b(M.value ? void 0 : Z.value.hit()),
273
+ onPointerenter: (e) => Y.value = n,
274
+ onPointerleave: t[0] ||= (e) => Y.value = void 0
275
+ }, null, 42, ae))), 128))
276
+ ], 10, te)), X.value ? (C(), g("div", {
259
277
  key: 0,
260
- class: v($("tooltip", Z.value.multi ? "flex-col items-start gap-1" : void 0)),
261
- style: b({
262
- left: `${Z.value.x}px`,
263
- top: `${Z.value.y}px`,
264
- transform: V.value ? "translate(-50%, -50%)" : "translate(-50%, -100%) translateY(-8px)"
278
+ class: b(Q("tooltip", X.value.multi ? "flex-col items-start gap-1" : void 0)),
279
+ style: S({
280
+ left: `${X.value.x}px`,
281
+ top: `${X.value.y}px`,
282
+ transform: z.value ? "translate(-50%, -50%)" : "translate(-50%, -100%) translateY(-8px)"
265
283
  })
266
284
  }, [
267
- h("span", { class: v($("tooltipLabel")) }, T(Z.value.label), 3),
268
- Z.value.multi ? (x(!0), m(u, { key: 0 }, C(Z.value.rows, (e) => (x(), m("span", {
285
+ _("span", { class: b(Q("tooltipLabel")) }, D(X.value.label), 3),
286
+ X.value.multi ? (C(!0), g(f, { key: 0 }, T(X.value.rows, (e) => (C(), g("span", {
269
287
  key: e.name,
270
288
  class: "flex items-center gap-1.5"
271
289
  }, [
272
- h("span", {
290
+ _("span", {
273
291
  class: "size-2 shrink-0 rounded-full",
274
- style: b({ background: e.color })
292
+ style: S({ background: e.color })
275
293
  }, null, 4),
276
- h("span", { class: v($("tooltipLabel")) }, T(e.name), 3),
277
- h("span", { class: v($("tooltipValue")) }, T(e.value), 3)
278
- ]))), 128)) : (x(), m("span", {
294
+ _("span", { class: b(Q("tooltipLabel")) }, D(e.name), 3),
295
+ _("span", { class: b(Q("tooltipValue")) }, D(e.value), 3)
296
+ ]))), 128)) : (C(), g("span", {
279
297
  key: 1,
280
- class: v($("tooltipValue"))
281
- }, T(Z.value.rows[0].value), 3)),
282
- Z.value.total ? (x(), m("span", re, [
283
- t[1] ||= h("span", { class: "size-2 shrink-0" }, null, -1),
284
- h("span", { class: v($("tooltipLabel")) }, T(j.totalLabel), 3),
285
- h("span", { class: v($("tooltipValue")) }, T(Z.value.total), 3)
286
- ])) : p("", !0)
287
- ], 6)) : p("", !0)], 2),
288
- h("div", { class: v($("table")) }, [h("table", null, [
289
- h("caption", null, T(j.label), 1),
290
- h("thead", null, [h("tr", null, [t[2] ||= h("th", { scope: "col" }, " Category ", -1), (x(!0), m(u, null, C(R.value, (e) => (x(), m("th", {
298
+ class: b(Q("tooltipValue"))
299
+ }, D(X.value.rows[0].value), 3)),
300
+ X.value.total ? (C(), g("span", oe, [
301
+ t[1] ||= _("span", { class: "size-2 shrink-0" }, null, -1),
302
+ _("span", { class: b(Q("tooltipLabel")) }, D(A.totalLabel), 3),
303
+ _("span", { class: b(Q("tooltipValue")) }, D(X.value.total), 3)
304
+ ])) : h("", !0)
305
+ ], 6)) : h("", !0)], 2),
306
+ _("div", { class: b(Q("table")) }, [_("table", null, [
307
+ _("caption", null, D(A.label), 1),
308
+ _("thead", null, [_("tr", null, [t[2] ||= _("th", { scope: "col" }, " Category ", -1), (C(!0), g(f, null, T(I.value, (e) => (C(), g("th", {
291
309
  key: e.key,
292
310
  scope: "col"
293
- }, T(e.name ?? "Value"), 1))), 128))])]),
294
- h("tbody", null, [(x(!0), m(u, null, C(j.data, (e, t) => (x(), m("tr", { key: `row-${e.label}-${t}` }, [h("th", ie, T(e.label), 1), (x(!0), m(u, null, C(R.value, (t) => (x(), m("td", { key: t.key }, T(B(e, t.key) == null ? "—" : L(B(e, t.key))), 1))), 128))]))), 128))])
311
+ }, D(e.name ?? "Value"), 1))), 128))])]),
312
+ _("tbody", null, [(C(!0), g(f, null, T(A.data, (e, t) => (C(), g("tr", { key: `row-${e.label}-${t}` }, [_("th", se, D(e.label), 1), (C(!0), g(f, null, T(I.value, (t) => (C(), g("td", { key: t.key }, D(R(e, t.key) == null ? "—" : F(R(e, t.key))), 1))), 128))]))), 128))])
295
313
  ])], 2)
296
314
  ], 10, ee));
297
315
  }
298
316
  });
299
317
  //#endregion
300
- export { j as default };
318
+ export { A as default };
@@ -0,0 +1,5 @@
1
+ import e from "./DonutChart.vue_vue_type_script_setup_true_lang.js";
2
+ //#region src/components/DonutChart.vue
3
+ var t = e;
4
+ //#endregion
5
+ export { t as default };
@@ -0,0 +1,96 @@
1
+ import type { ChartAnimate } from '../composables/chart-reveal';
2
+ import type { SparseValue } from '../composables/scale';
3
+ /**
4
+ * One slice. Unlike the cartesian charts there is no second axis to hold a
5
+ * series, so the row *is* the identity: its `label` names it and its `slot`
6
+ * pins its colour.
7
+ */
8
+ export interface DonutChartDatum {
9
+ label: string;
10
+ /** `null` is a missing reading — the slice is dropped, which is not a zero. */
11
+ value?: SparseValue;
12
+ /**
13
+ * Pin this slice to a palette slot (0-based) instead of taking its position
14
+ * in the array. Pin every slice that can be filtered out, so the survivors
15
+ * keep the colours the reader already learned.
16
+ */
17
+ slot?: number;
18
+ }
19
+ export interface DonutChartProps {
20
+ data?: readonly DonutChartDatum[];
21
+ /**
22
+ * Rendered height in px. The ring is a circle centred in whatever width the
23
+ * container gives, so this is also its diameter once the box is wide enough.
24
+ */
25
+ size?: number;
26
+ /**
27
+ * Ring thickness in px. Defaults to two fifths of the radius, which keeps
28
+ * the hole large enough to hold a total at every size. Ignored when `pie`.
29
+ */
30
+ thickness?: number;
31
+ /**
32
+ * Fill the middle in and draw a pie instead.
33
+ *
34
+ * The ring is the better default: a pie asks the reader to compare angles
35
+ * and areas, a donut only arc lengths, and the hole is somewhere to put the
36
+ * total the slices add up to.
37
+ */
38
+ pie?: boolean;
39
+ /**
40
+ * The gap between neighbouring slices, in px. `0` closes it and lets them
41
+ * touch.
42
+ *
43
+ * A width rather than an angle, and held the same all the way across: each
44
+ * edge is pushed half a gap off its own radius, so the divider reads as a
45
+ * line instead of a wedge that widens towards the rim. In a pie that is
46
+ * also why a slice stops a hair short of the centre — two parallel edges
47
+ * meet before they reach it.
48
+ */
49
+ gap?: number;
50
+ /**
51
+ * Sweep the ring open on the first paint. Skipped for a reader who has
52
+ * asked for reduced motion, and played once — not again when the data
53
+ * changes underneath it.
54
+ */
55
+ animate?: ChartAnimate;
56
+ /** Drop the legend. */
57
+ legend?: boolean;
58
+ /** Locale and options for every number shown — the total and the tooltip. */
59
+ locale?: string;
60
+ format?: Intl.NumberFormatOptions;
61
+ /**
62
+ * Accessible name for the figure. The slices are hidden from assistive tech
63
+ * and the data is exposed as a table instead, so this names what that is.
64
+ */
65
+ label?: string;
66
+ /** Skip built-in classes; you take over styling entirely. */
67
+ unstyled?: boolean;
68
+ class?: string;
69
+ ui?: Partial<Record<'root' | 'svg' | 'slice' | 'center' | 'tooltip' | 'tooltipLabel' | 'tooltipValue' | 'tooltipShare' | 'table', string>>;
70
+ }
71
+ type __VLS_Slots = {
72
+ /**
73
+ * The hole. Given the total and its formatted form, so the usual figure
74
+ * plus caption is one line of markup.
75
+ */
76
+ center?: (props: {
77
+ total: number;
78
+ formatted: string;
79
+ }) => unknown;
80
+ };
81
+ declare const __VLS_base: import("vue").DefineComponent<DonutChartProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<DonutChartProps> & Readonly<{}>, {
82
+ size: number;
83
+ unstyled: boolean;
84
+ data: readonly DonutChartDatum[];
85
+ legend: boolean;
86
+ animate: ChartAnimate;
87
+ gap: number;
88
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
89
+ declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
90
+ declare const _default: typeof __VLS_export;
91
+ export default _default;
92
+ type __VLS_WithSlots<T, S> = T & {
93
+ new (): {
94
+ $slots: S;
95
+ };
96
+ };