iryx-ui 0.14.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 +3 -1
- package/dist/component-names.d.ts +1 -1
- package/dist/component-names.js +1 -1
- package/dist/components/AppShell.vue.d.ts +31 -6
- package/dist/components/AppShell.vue_vue_type_script_setup_true_lang.js +68 -28
- package/dist/components/BarChart.vue.d.ts +10 -0
- package/dist/components/BarChart.vue_vue_type_script_setup_true_lang.js +170 -152
- package/dist/components/DonutChart.js +5 -0
- package/dist/components/DonutChart.vue.d.ts +96 -0
- package/dist/components/DonutChart.vue_vue_type_script_setup_true_lang.js +234 -0
- package/dist/components/Drawer.vue.d.ts +1 -1
- package/dist/components/LineChart.vue.d.ts +26 -0
- package/dist/components/LineChart.vue_vue_type_script_setup_true_lang.js +205 -139
- package/dist/components/Popover.vue.d.ts +1 -1
- package/dist/components/Sparkline.vue.d.ts +9 -0
- package/dist/components/Sparkline.vue_vue_type_script_setup_true_lang.js +90 -53
- package/dist/components/Stat.vue.d.ts +1 -1
- package/dist/components/Stat.vue_vue_type_script_setup_true_lang.js +13 -13
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +140 -138
- package/dist/composables/cartesian.d.ts +17 -2
- package/dist/composables/cartesian.js +6 -1
- package/dist/composables/chart-reveal.d.ts +45 -0
- package/dist/composables/chart-reveal.js +93 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +147 -144
- package/dist/theme/app-shell.d.ts +42 -0
- package/dist/theme/app-shell.js +13 -1
- package/dist/theme/bar-chart.js +1 -1
- package/dist/theme/button.d.ts +2 -2
- package/dist/theme/button.js +1 -1
- package/dist/theme/command-palette.d.ts +3 -3
- package/dist/theme/donut-chart.d.ts +104 -0
- package/dist/theme/donut-chart.js +17 -0
- package/dist/theme/form.js +1 -1
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/line-chart.js +2 -2
- package/dist/theme/sidebar.js +1 -1
- package/dist/theme/sparkline.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import { useIryxUiConfig as e } from "../config.js";
|
|
2
|
+
import { useElementSize as t } from "../composables/element-size.js";
|
|
3
|
+
import { clampTooltip as n, seriesColor as r, slotOf as i, warnOnSlotOverflow as a } from "../composables/cartesian.js";
|
|
4
|
+
import { useChartAnimation as o, useChartProgress as s } from "../composables/chart-reveal.js";
|
|
5
|
+
import c from "./ChartLegend.js";
|
|
6
|
+
import { donutChartTheme as l } from "../theme/donut-chart.js";
|
|
7
|
+
import { Fragment as u, computed as d, createBlock as f, createCommentVNode as p, createElementBlock as m, createElementVNode as h, defineComponent as g, normalizeClass as _, normalizeStyle as v, openBlock as y, ref as b, renderList as x, renderSlot as ee, toDisplayString as S, unref as C } from "vue";
|
|
8
|
+
//#region src/components/DonutChart.vue?vue&type=script&setup=true&lang.ts
|
|
9
|
+
var te = ["role", "aria-label"], w = [
|
|
10
|
+
"width",
|
|
11
|
+
"height",
|
|
12
|
+
"viewBox"
|
|
13
|
+
], ne = [
|
|
14
|
+
"cx",
|
|
15
|
+
"cy",
|
|
16
|
+
"r",
|
|
17
|
+
"fill",
|
|
18
|
+
"stroke",
|
|
19
|
+
"stroke-width"
|
|
20
|
+
], re = ["d", "onPointerenter"], ie = { scope: "row" }, T = /*@__PURE__*/ g({
|
|
21
|
+
__name: "DonutChart",
|
|
22
|
+
props: {
|
|
23
|
+
data: { default: () => [] },
|
|
24
|
+
size: { default: 240 },
|
|
25
|
+
thickness: {},
|
|
26
|
+
pie: { type: Boolean },
|
|
27
|
+
gap: { default: 2 },
|
|
28
|
+
animate: {
|
|
29
|
+
type: [Boolean, Object],
|
|
30
|
+
default: !0
|
|
31
|
+
},
|
|
32
|
+
legend: {
|
|
33
|
+
type: Boolean,
|
|
34
|
+
default: !0
|
|
35
|
+
},
|
|
36
|
+
locale: {},
|
|
37
|
+
format: {},
|
|
38
|
+
label: {},
|
|
39
|
+
unstyled: {
|
|
40
|
+
type: Boolean,
|
|
41
|
+
default: void 0
|
|
42
|
+
},
|
|
43
|
+
class: {},
|
|
44
|
+
ui: {}
|
|
45
|
+
},
|
|
46
|
+
setup(g) {
|
|
47
|
+
let T = g, ae = e(), E = d(() => T.unstyled ?? ae.unstyled), D = b(), { width: O } = t(D), oe = d(() => new Intl.NumberFormat(T.locale, T.format));
|
|
48
|
+
function k(e) {
|
|
49
|
+
return oe.value.format(e);
|
|
50
|
+
}
|
|
51
|
+
let A = d(() => new Intl.NumberFormat(T.locale, {
|
|
52
|
+
style: "percent",
|
|
53
|
+
maximumFractionDigits: 1
|
|
54
|
+
})), j = !1;
|
|
55
|
+
function M() {
|
|
56
|
+
j || process.env.NODE_ENV === "production" || (j = !0, console.warn("[iryx-ui] IDonutChart dropped a negative value. A share of a whole cannot be negative — plot the magnitudes, or use IBarChart, which has a baseline."));
|
|
57
|
+
}
|
|
58
|
+
let N = d(() => {
|
|
59
|
+
let e = T.data.map((e, t) => ({
|
|
60
|
+
datum: e,
|
|
61
|
+
index: t
|
|
62
|
+
})).filter(({ datum: e }) => {
|
|
63
|
+
let t = e.value;
|
|
64
|
+
return typeof t != "number" || !Number.isFinite(t) || t === 0 ? !1 : t < 0 ? (M(), !1) : !0;
|
|
65
|
+
});
|
|
66
|
+
a(e.length);
|
|
67
|
+
let t = e.reduce((e, { datum: t }) => e + t.value, 0);
|
|
68
|
+
return e.map(({ datum: e, index: n }) => ({
|
|
69
|
+
label: e.label,
|
|
70
|
+
value: e.value,
|
|
71
|
+
share: t ? e.value / t : 0,
|
|
72
|
+
color: r(i(e, n)),
|
|
73
|
+
index: n
|
|
74
|
+
}));
|
|
75
|
+
}), P = d(() => N.value.reduce((e, t) => e + t.value, 0)), F = d(() => N.value.map((e) => ({
|
|
76
|
+
key: `${e.index}-${e.label}`,
|
|
77
|
+
name: e.label,
|
|
78
|
+
slot: T.data[e.index]?.slot ?? e.index
|
|
79
|
+
}))), I = d(() => T.legend && N.value.length > 0), L = d(() => ({
|
|
80
|
+
x: O.value / 2,
|
|
81
|
+
y: T.size / 2
|
|
82
|
+
})), R = d(() => Math.max(Math.min(O.value, T.size) / 2, 0)), z = d(() => {
|
|
83
|
+
if (T.pie) return 0;
|
|
84
|
+
let e = Math.min(T.thickness ?? R.value * .4, R.value);
|
|
85
|
+
return Math.max(R.value - e, 0);
|
|
86
|
+
}), B = -Math.PI / 2, V = d(() => Math.max(T.gap, 0) / 2);
|
|
87
|
+
function H(e) {
|
|
88
|
+
return Math.round(e * 100) / 100;
|
|
89
|
+
}
|
|
90
|
+
function U(e, t) {
|
|
91
|
+
return [H(L.value.x + e * Math.cos(t)), H(L.value.y + e * Math.sin(t))];
|
|
92
|
+
}
|
|
93
|
+
let W = d(() => !!(O.value && R.value && N.value.length)), { progress: G } = s(W, o(d(() => T.animate))), K = d(() => {
|
|
94
|
+
if (!W.value) return [];
|
|
95
|
+
let e = G.value, t = B;
|
|
96
|
+
return N.value.flatMap((n) => {
|
|
97
|
+
let r = n.share * Math.PI * 2, i = t;
|
|
98
|
+
t += r;
|
|
99
|
+
let a = B + (i - B) * e, o = r * e;
|
|
100
|
+
return o <= 0 ? [] : [{
|
|
101
|
+
...n,
|
|
102
|
+
mid: i + r / 2,
|
|
103
|
+
path: se(a, a + o)
|
|
104
|
+
}];
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
function q(e, t) {
|
|
108
|
+
let n = V.value;
|
|
109
|
+
return !n || e <= n ? 0 : Math.min(Math.asin(n / e), t / 3);
|
|
110
|
+
}
|
|
111
|
+
function se(e, t) {
|
|
112
|
+
let n = t - e, r = !z.value, i = N.value.length < 2 ? 0 : q(R.value, n), a = e + i, o = t - i, s = +(o - a > Math.PI), [c, l] = U(R.value, a), [u, d] = U(R.value, o);
|
|
113
|
+
if (r) {
|
|
114
|
+
let [t, r] = U(i ? Math.min(V.value / Math.sin(n / 2), R.value / 2) : 0, e + n / 2);
|
|
115
|
+
return `M${c} ${l} A${H(R.value)} ${H(R.value)} 0 ${s} 1 ${u} ${d} L${t} ${r} Z`;
|
|
116
|
+
}
|
|
117
|
+
let f = i ? q(z.value, n) : 0, p = +(n - f * 2 > Math.PI), [m, h] = U(z.value, t - f), [g, _] = U(z.value, e + f);
|
|
118
|
+
return `M${c} ${l} A${H(R.value)} ${H(R.value)} 0 ${s} 1 ${u} ${d} L${m} ${h} A${H(z.value)} ${H(z.value)} 0 ${p} 0 ${g} ${_} Z`;
|
|
119
|
+
}
|
|
120
|
+
let J = d(() => {
|
|
121
|
+
if (!(K.value.length !== 1 || !R.value || G.value < 1)) return {
|
|
122
|
+
...K.value[0],
|
|
123
|
+
radius: z.value ? (R.value + z.value) / 2 : R.value,
|
|
124
|
+
strokeWidth: R.value - z.value
|
|
125
|
+
};
|
|
126
|
+
}), ce = d(() => J.value ? [] : K.value), Y = b(), X = d(() => {
|
|
127
|
+
if (Y.value == null) return;
|
|
128
|
+
let e = K.value.find((e) => e.index === Y.value);
|
|
129
|
+
if (!e) return;
|
|
130
|
+
let t = k(e.value), r = A.value.format(e.share), [i, a] = U(z.value ? (R.value + z.value) / 2 : R.value / 2, e.mid);
|
|
131
|
+
return {
|
|
132
|
+
label: e.label,
|
|
133
|
+
value: t,
|
|
134
|
+
share: r,
|
|
135
|
+
x: n(i, `${e.label}${t}${r}`, O.value),
|
|
136
|
+
y: a
|
|
137
|
+
};
|
|
138
|
+
}), Z = d(() => l());
|
|
139
|
+
function Q(e, t) {
|
|
140
|
+
let n = T.ui?.[e];
|
|
141
|
+
return E.value ? [n, t] : Z.value[e]({ class: [n, t] });
|
|
142
|
+
}
|
|
143
|
+
function $(e) {
|
|
144
|
+
let t = Y.value != null && Y.value !== e;
|
|
145
|
+
return E.value ? [T.ui?.slice] : Z.value.slice({ class: [T.ui?.slice, t ? Z.value.faded() : void 0] });
|
|
146
|
+
}
|
|
147
|
+
return (e, t) => (y(), m("div", {
|
|
148
|
+
ref_key: "root",
|
|
149
|
+
ref: D,
|
|
150
|
+
role: T.label ? "figure" : void 0,
|
|
151
|
+
"aria-label": T.label,
|
|
152
|
+
class: _(Q("root", T.class))
|
|
153
|
+
}, [
|
|
154
|
+
I.value ? (y(), f(c, {
|
|
155
|
+
key: 0,
|
|
156
|
+
series: F.value,
|
|
157
|
+
active: Y.value == null ? void 0 : N.value.findIndex((e) => e.index === Y.value),
|
|
158
|
+
unstyled: T.unstyled
|
|
159
|
+
}, null, 8, [
|
|
160
|
+
"series",
|
|
161
|
+
"active",
|
|
162
|
+
"unstyled"
|
|
163
|
+
])) : p("", !0),
|
|
164
|
+
h("div", { class: _(E.value ? void 0 : Z.value.plot()) }, [
|
|
165
|
+
(y(), m("svg", {
|
|
166
|
+
width: C(O),
|
|
167
|
+
height: T.size,
|
|
168
|
+
viewBox: `0 0 ${C(O)} ${T.size}`,
|
|
169
|
+
"aria-hidden": "true",
|
|
170
|
+
class: _(Q("svg"))
|
|
171
|
+
}, [J.value ? (y(), m("circle", {
|
|
172
|
+
key: 0,
|
|
173
|
+
cx: L.value.x,
|
|
174
|
+
cy: L.value.y,
|
|
175
|
+
r: J.value.radius,
|
|
176
|
+
fill: z.value ? "none" : J.value.color,
|
|
177
|
+
stroke: z.value ? J.value.color : "none",
|
|
178
|
+
"stroke-width": z.value ? J.value.strokeWidth : 0,
|
|
179
|
+
class: _($(J.value.index)),
|
|
180
|
+
onPointerenter: t[0] ||= (e) => Y.value = J.value.index,
|
|
181
|
+
onPointerleave: t[1] ||= (e) => Y.value = void 0
|
|
182
|
+
}, null, 42, ne)) : p("", !0), (y(!0), m(u, null, x(ce.value, (e) => (y(), m("path", {
|
|
183
|
+
key: `slice-${e.index}`,
|
|
184
|
+
d: e.path,
|
|
185
|
+
style: v({ fill: e.color }),
|
|
186
|
+
class: _($(e.index)),
|
|
187
|
+
onPointerenter: (t) => Y.value = e.index,
|
|
188
|
+
onPointerleave: t[2] ||= (e) => Y.value = void 0
|
|
189
|
+
}, null, 46, re))), 128))], 10, w)),
|
|
190
|
+
e.$slots.center && z.value ? (y(), m("div", {
|
|
191
|
+
key: 0,
|
|
192
|
+
class: _(Q("center")),
|
|
193
|
+
style: v({
|
|
194
|
+
left: `${L.value.x}px`,
|
|
195
|
+
top: `${L.value.y}px`,
|
|
196
|
+
width: `${z.value * 2 * .82}px`,
|
|
197
|
+
transform: "translate(-50%, -50%)"
|
|
198
|
+
})
|
|
199
|
+
}, [ee(e.$slots, "center", {
|
|
200
|
+
total: P.value,
|
|
201
|
+
formatted: k(P.value)
|
|
202
|
+
})], 6)) : p("", !0),
|
|
203
|
+
X.value ? (y(), m("div", {
|
|
204
|
+
key: 1,
|
|
205
|
+
class: _(Q("tooltip")),
|
|
206
|
+
style: v({
|
|
207
|
+
left: `${X.value.x}px`,
|
|
208
|
+
top: `${X.value.y}px`,
|
|
209
|
+
transform: "translate(-50%, -50%)"
|
|
210
|
+
})
|
|
211
|
+
}, [
|
|
212
|
+
h("span", { class: _(Q("tooltipLabel")) }, S(X.value.label), 3),
|
|
213
|
+
h("span", { class: _(Q("tooltipValue")) }, S(X.value.value), 3),
|
|
214
|
+
h("span", { class: _(Q("tooltipShare")) }, S(X.value.share), 3)
|
|
215
|
+
], 6)) : p("", !0)
|
|
216
|
+
], 2),
|
|
217
|
+
h("div", { class: _(Q("table")) }, [h("table", null, [
|
|
218
|
+
h("caption", null, S(T.label), 1),
|
|
219
|
+
t[3] ||= h("thead", null, [h("tr", null, [
|
|
220
|
+
h("th", { scope: "col" }, " Category "),
|
|
221
|
+
h("th", { scope: "col" }, " Value "),
|
|
222
|
+
h("th", { scope: "col" }, " Share ")
|
|
223
|
+
])], -1),
|
|
224
|
+
h("tbody", null, [(y(!0), m(u, null, x(N.value, (e) => (y(), m("tr", { key: `row-${e.index}` }, [
|
|
225
|
+
h("th", ie, S(e.label), 1),
|
|
226
|
+
h("td", null, S(k(e.value)), 1),
|
|
227
|
+
h("td", null, S(A.value.format(e.share)), 1)
|
|
228
|
+
]))), 128))])
|
|
229
|
+
])], 2)
|
|
230
|
+
], 10, te));
|
|
231
|
+
}
|
|
232
|
+
});
|
|
233
|
+
//#endregion
|
|
234
|
+
export { T as default };
|
|
@@ -78,11 +78,11 @@ declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {
|
|
|
78
78
|
}>, {
|
|
79
79
|
unstyled: boolean;
|
|
80
80
|
closeLabel: string;
|
|
81
|
+
handle: boolean;
|
|
81
82
|
side: DrawerSide;
|
|
82
83
|
modal: boolean | "trap-focus";
|
|
83
84
|
dismissible: boolean;
|
|
84
85
|
showClose: boolean;
|
|
85
|
-
handle: boolean;
|
|
86
86
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
87
87
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
88
88
|
declare const _default: typeof __VLS_export;
|
|
@@ -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
|
|
@@ -19,12 +20,32 @@ export interface LineChartProps {
|
|
|
19
20
|
* overlapping washes muddy into a colour that belongs to neither.
|
|
20
21
|
*/
|
|
21
22
|
variant?: 'line' | 'area';
|
|
23
|
+
/**
|
|
24
|
+
* How much to curve the line, from `0` (straight segments between
|
|
25
|
+
* readings) to `1` (fully rounded). Straight by default: a curve claims the
|
|
26
|
+
* readings run continuously into each other, which is true of a temperature
|
|
27
|
+
* trace and false of six monthly totals.
|
|
28
|
+
*/
|
|
29
|
+
tension?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Carry the line and its fill flat out to the left and right edges of the
|
|
32
|
+
* plot. The readings themselves do not move — markers, labels and the
|
|
33
|
+
* tooltip stay where they are — so the chart fills its box without
|
|
34
|
+
* pretending to know a value it was never given.
|
|
35
|
+
*/
|
|
36
|
+
flush?: boolean;
|
|
22
37
|
/** Rendered height in px. Width always fills the container. */
|
|
23
38
|
height?: number;
|
|
24
39
|
/** Target tick count. The axis lands on round numbers, so this is a hint. */
|
|
25
40
|
ticks?: number;
|
|
26
41
|
/** Drop the value axis and its gridlines. */
|
|
27
42
|
axis?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Draw the line on across the plot on the first paint. Skipped for a reader
|
|
45
|
+
* who has asked for reduced motion, and played once — not again when the
|
|
46
|
+
* data changes underneath it.
|
|
47
|
+
*/
|
|
48
|
+
animate?: ChartAnimate;
|
|
28
49
|
/** Drop the legend. Only honoured for a single series. */
|
|
29
50
|
legend?: boolean;
|
|
30
51
|
/**
|
|
@@ -60,6 +81,7 @@ declare var __VLS_6: {
|
|
|
60
81
|
bandWidth: number;
|
|
61
82
|
labelStep: number;
|
|
62
83
|
bandCentre: (index: number) => number;
|
|
84
|
+
pointAt: (index: number) => number;
|
|
63
85
|
}, __VLS_8: {
|
|
64
86
|
orientation: import("..").ChartOrientation;
|
|
65
87
|
ticks: number[];
|
|
@@ -74,6 +96,7 @@ declare var __VLS_6: {
|
|
|
74
96
|
bandWidth: number;
|
|
75
97
|
labelStep: number;
|
|
76
98
|
bandCentre: (index: number) => number;
|
|
99
|
+
pointAt: (index: number) => number;
|
|
77
100
|
};
|
|
78
101
|
type __VLS_Slots = {} & {
|
|
79
102
|
underlay?: (props: typeof __VLS_6) => any;
|
|
@@ -85,9 +108,12 @@ declare const __VLS_base: import("vue").DefineComponent<LineChartProps, {}, {},
|
|
|
85
108
|
unstyled: boolean;
|
|
86
109
|
data: readonly LineChartDatum[];
|
|
87
110
|
legend: boolean;
|
|
111
|
+
animate: ChartAnimate;
|
|
112
|
+
flush: boolean;
|
|
88
113
|
height: number;
|
|
89
114
|
ticks: number;
|
|
90
115
|
axis: boolean;
|
|
116
|
+
tension: number;
|
|
91
117
|
zero: boolean;
|
|
92
118
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
93
119
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|