vlite3 1.1.7 → 1.1.9
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/components/Chart/BarChart.vue.js +369 -0
- package/components/Chart/BarChart.vue2.js +4 -0
- package/components/Chart/CircleChart.vue.js +137 -0
- package/components/Chart/CircleChart.vue2.js +4 -0
- package/components/Chart/GaugeChart.vue.js +443 -0
- package/components/Chart/GaugeChart.vue2.js +4 -0
- package/components/Chart/LineChart.vue.js +7 -0
- package/components/Chart/LineChart.vue2.js +313 -0
- package/components/Chart/PieChart.vue.js +203 -0
- package/components/Chart/PieChart.vue2.js +4 -0
- package/components/Chart/utils.js +90 -0
- package/components/CommandPalette/CommandPaletteContent.vue2.js +1 -1
- package/components/CommandPalette/{CommandPaletteItem.vue.js → CommandPaletteItem.vue2.js} +1 -1
- package/components/Dropdown/Dropdown.vue.js +63 -63
- package/components/Dropdown/DropdownMenu.vue.js +1 -1
- package/components/Dropdown/DropdownMenu.vue2.js +23 -23
- package/components/Footer/Footer.vue.js +35 -0
- package/components/Footer/Footer.vue2.js +4 -0
- package/components/Footer/Variant1.vue.js +178 -0
- package/components/Footer/Variant1.vue2.js +4 -0
- package/components/Footer/Variant2.vue.js +177 -0
- package/components/Footer/Variant2.vue2.js +4 -0
- package/components/Footer/Variant3.vue.js +82 -0
- package/components/Footer/Variant3.vue2.js +4 -0
- package/components/MultiSelect/MultiSelect.vue.d.ts +23 -1
- package/components/MultiSelect/MultiSelect.vue.js +153 -122
- package/components/NavbarCommandPalette.vue.js +1 -1
- package/components/RichTextEditor/RichTextEditor.vue.js +332 -0
- package/components/RichTextEditor/RichTextEditor.vue3.js +5 -0
- package/components/RichTextEditor/RichTextLinkPopover.vue.js +107 -0
- package/components/RichTextEditor/RichTextLinkPopover.vue3.js +5 -0
- package/components/RichTextEditor/RichTextReader.vue.js +7 -0
- package/components/RichTextEditor/RichTextReader.vue2.js +19 -0
- package/components/RichTextEditor/RichTextToolbar.vue.js +330 -0
- package/components/RichTextEditor/RichTextToolbar.vue3.js +5 -0
- package/components/RichTextEditor/composables/useRichTextImageUpload.js +77 -0
- package/components/RichTextEditor/composables/useRichTextLinks.js +120 -0
- package/core/config.d.ts +2 -2
- package/index.d.ts +3 -0
- package/index.js +332 -315
- package/package.json +1 -1
- package/style.css +1 -1
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
import { defineComponent as ne, ref as X, computed as h, onMounted as ue, watch as se, onUnmounted as re, openBlock as o, createElementBlock as n, Fragment as d, renderList as v, createElementVNode as M, normalizeStyle as F, createTextVNode as ie, toDisplayString as k, createCommentVNode as f, unref as w, createBlock as ce, Teleport as de } from "vue";
|
|
2
|
+
import { CHART_COLORS as ve, formatNumber as Y, getColor as j, niceYTicks as fe, animateProgress as he } from "./utils.js";
|
|
3
|
+
const ye = {
|
|
4
|
+
key: 0,
|
|
5
|
+
class: "flex flex-wrap gap-x-4 gap-y-1 mb-3 pl-14"
|
|
6
|
+
}, me = ["width", "height"], xe = ["id"], $e = ["stop-color"], ge = ["stop-color"], be = ["id"], pe = ["stop-color"], ke = ["stop-color"], we = ["transform"], Le = ["y1", "x2", "y2", "stroke-opacity"], Me = ["y"], Ve = ["d", "fill", "opacity"], Ce = ["x", "y"], Be = ["x", "y"], Ye = ["y1", "x2", "y2", "stroke-opacity"], Re = ["y2", "stroke-opacity"], Oe = ["transform"], ze = ["x1", "x2", "y2", "stroke-opacity"], Xe = ["x"], Ae = ["y"], Ge = ["d", "fill", "opacity"], Te = ["x", "y"], Se = ["y2", "stroke-opacity"], We = ["y1", "x2", "y2", "stroke-opacity"], Pe = { class: "font-medium text-xs mb-1.5" }, He = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "text-muted-foreground"
|
|
9
|
+
}, Ne = { class: "font-semibold" }, Ee = /* @__PURE__ */ ne({
|
|
10
|
+
__name: "BarChart",
|
|
11
|
+
props: {
|
|
12
|
+
data: {},
|
|
13
|
+
datasets: {},
|
|
14
|
+
labels: {},
|
|
15
|
+
height: { default: 300 },
|
|
16
|
+
orientation: { default: "vertical" },
|
|
17
|
+
barRadius: { default: 6 },
|
|
18
|
+
showGrid: { type: Boolean, default: !0 },
|
|
19
|
+
showLegend: { type: Boolean, default: !0 },
|
|
20
|
+
showTooltip: { type: Boolean, default: !0 },
|
|
21
|
+
showValues: { type: Boolean, default: !1 },
|
|
22
|
+
colors: { default: () => ve },
|
|
23
|
+
animate: { type: Boolean, default: !0 },
|
|
24
|
+
formatValue: {},
|
|
25
|
+
showXAxis: { type: Boolean, default: !0 },
|
|
26
|
+
showYAxis: { type: Boolean, default: !0 },
|
|
27
|
+
showXLabels: { type: Boolean, default: !0 },
|
|
28
|
+
showYLabels: { type: Boolean, default: !0 },
|
|
29
|
+
gridOpacity: { default: 0.07 },
|
|
30
|
+
axisOpacity: { default: 0.1 }
|
|
31
|
+
},
|
|
32
|
+
setup(i) {
|
|
33
|
+
const r = i, A = X(), G = X(600), g = h(() => {
|
|
34
|
+
const t = (a) => String(a).length;
|
|
35
|
+
if (r.orientation === "horizontal") {
|
|
36
|
+
const a = r.showYLabels ? Math.max(2, ...x.value.map((L) => t(L))) * 6.5 : 0, s = r.showYLabels ? Math.max(24, a + 12) : 8;
|
|
37
|
+
let u = 16;
|
|
38
|
+
if (r.showValues) {
|
|
39
|
+
const L = m.value.flatMap(($) => $.values), y = Math.max(2, ...L.map(($) => t(r.formatValue ? r.formatValue($) : Y($)))) * 6.5;
|
|
40
|
+
u = Math.max(16, y + 8);
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
// top holds the value-tick labels that float above; collapse when hidden
|
|
44
|
+
top: r.showXLabels ? 16 : 4,
|
|
45
|
+
right: u,
|
|
46
|
+
bottom: 0,
|
|
47
|
+
left: s
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
const l = r.showYLabels ? Math.max(2, ...C.value.map((a) => t(r.formatValue ? r.formatValue(a) : Y(a)))) * 6.5 : 0, e = r.showYLabels ? Math.max(24, l + 12) : 8;
|
|
51
|
+
return {
|
|
52
|
+
top: 24,
|
|
53
|
+
right: 0,
|
|
54
|
+
// Collapse bottom padding when X labels are hidden
|
|
55
|
+
bottom: r.showXLabels ? 24 : 6,
|
|
56
|
+
left: e
|
|
57
|
+
};
|
|
58
|
+
}), b = h(() => Math.max(0, G.value - g.value.left - g.value.right)), c = h(() => Math.max(0, r.height - g.value.top - g.value.bottom)), m = h(() => r.datasets?.length ? r.datasets.map((l, e) => ({
|
|
59
|
+
label: l.label,
|
|
60
|
+
color: l.color ?? j(r.colors, e),
|
|
61
|
+
values: l.data
|
|
62
|
+
})) : [
|
|
63
|
+
{
|
|
64
|
+
label: "",
|
|
65
|
+
color: "",
|
|
66
|
+
// will use per-bar color from data
|
|
67
|
+
values: (r.data ?? []).map((l) => l.value)
|
|
68
|
+
}
|
|
69
|
+
]), p = h(() => m.value.length > 1 || !!r.datasets?.length), x = h(() => r.labels?.length ? r.labels : r.datasets?.length ? m.value[0]?.values.map((t, l) => String(l + 1)) ?? [] : (r.data ?? []).map((t) => t.label)), T = h(
|
|
70
|
+
() => (r.data ?? []).map((t, l) => t.color ?? j(r.colors, l))
|
|
71
|
+
), q = h(() => m.value.flatMap((t) => t.values)), U = h(() => Math.max(...q.value) || 1), C = h(() => fe(0, U.value, 5)), V = h(() => C.value[C.value.length - 1] || U.value), S = X(r.animate ? 0 : 1);
|
|
72
|
+
let N = null;
|
|
73
|
+
function _() {
|
|
74
|
+
N?.(), S.value = 0, N = he(800, (t) => S.value = t);
|
|
75
|
+
}
|
|
76
|
+
ue(() => {
|
|
77
|
+
J(), r.animate && _();
|
|
78
|
+
}), se(() => [r.data, r.datasets], () => {
|
|
79
|
+
r.animate && _();
|
|
80
|
+
}, { deep: !0 }), re(() => {
|
|
81
|
+
N?.(), Q?.disconnect();
|
|
82
|
+
});
|
|
83
|
+
let Q = null;
|
|
84
|
+
function J() {
|
|
85
|
+
A.value && (Q = new ResizeObserver((t) => {
|
|
86
|
+
G.value = t[0].contentRect.width || 600;
|
|
87
|
+
}), Q.observe(A.value), G.value = A.value.clientWidth || 600);
|
|
88
|
+
}
|
|
89
|
+
const K = h(() => {
|
|
90
|
+
const t = x.value.length;
|
|
91
|
+
if (t === 0) return [];
|
|
92
|
+
const l = b.value / t, e = m.value.length, a = l * 0.2, s = l - a * 2, u = p.value ? s / e : s;
|
|
93
|
+
return x.value.map((L, y) => {
|
|
94
|
+
const $ = y * l + a, Z = m.value.map((W, P) => {
|
|
95
|
+
const H = W.values[y] ?? 0, z = H / V.value * c.value * S.value, E = $ + P * u, I = c.value - z, D = p.value ? W.color : T.value[y];
|
|
96
|
+
return { val: H, bh: z, x: E, y: I, w: u - (p.value ? 2 : 0), color: D };
|
|
97
|
+
});
|
|
98
|
+
return { label: L, bars: Z };
|
|
99
|
+
});
|
|
100
|
+
}), ee = h(() => {
|
|
101
|
+
const t = x.value.length;
|
|
102
|
+
if (t === 0) return [];
|
|
103
|
+
const l = c.value / t, e = m.value.length, a = l * 0.2, s = l - a * 2, u = p.value ? s / e : s, L = V.value;
|
|
104
|
+
return x.value.map((y, $) => {
|
|
105
|
+
const Z = $ * l + a, W = m.value.map((P, H) => {
|
|
106
|
+
const z = P.values[$] ?? 0, E = z / L * b.value * S.value, I = Z + H * u, D = p.value ? P.color : T.value[$];
|
|
107
|
+
return { val: z, bw: E, x: 0, y: I, h: u - (p.value ? 2 : 0), color: D };
|
|
108
|
+
});
|
|
109
|
+
return { label: y, bars: W };
|
|
110
|
+
});
|
|
111
|
+
}), B = X(null), R = X(null);
|
|
112
|
+
function te(t) {
|
|
113
|
+
if (!r.showTooltip) return;
|
|
114
|
+
const l = t.currentTarget.getBoundingClientRect(), e = t.clientX - l.left - g.value.left, a = t.clientY - l.top - g.value.top, s = x.value.length;
|
|
115
|
+
if (s === 0) return;
|
|
116
|
+
let u;
|
|
117
|
+
r.orientation === "vertical" ? u = Math.floor(e / b.value * s) : u = Math.floor(a / c.value * s), u = Math.max(0, Math.min(s - 1, u)), R.value = u;
|
|
118
|
+
const L = m.value.map((y, $) => ({
|
|
119
|
+
color: p.value ? y.color : T.value[u],
|
|
120
|
+
label: y.label,
|
|
121
|
+
value: r.formatValue ? r.formatValue(y.values[u]) : Y(y.values[u])
|
|
122
|
+
}));
|
|
123
|
+
B.value = {
|
|
124
|
+
x: t.clientX,
|
|
125
|
+
y: t.clientY,
|
|
126
|
+
label: x.value[u],
|
|
127
|
+
items: L
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function le() {
|
|
131
|
+
B.value = null, R.value = null;
|
|
132
|
+
}
|
|
133
|
+
function ae(t, l, e, a, s) {
|
|
134
|
+
const u = Math.min(s, e / 2, a / 2);
|
|
135
|
+
return u <= 0 || a <= 0 ? `M${t},${l + a} L${t},${l} L${t + e},${l} L${t + e},${l + a} Z` : `M${t},${l + a} L${t},${l + u} Q${t},${l} ${t + u},${l} L${t + e - u},${l} Q${t + e},${l} ${t + e},${l + u} L${t + e},${l + a} Z`;
|
|
136
|
+
}
|
|
137
|
+
function oe(t, l, e, a, s) {
|
|
138
|
+
const u = Math.min(s, e / 2, a / 2);
|
|
139
|
+
return u <= 0 || e <= 0 ? `M${t},${l} L${t + e},${l} L${t + e},${l + a} L${t},${l + a} Z` : `M${t},${l} L${t + e - u},${l} Q${t + e},${l} ${t + e},${l + u} L${t + e},${l + a - u} Q${t + e},${l + a} ${t + e - u},${l + a} L${t},${l + a} Z`;
|
|
140
|
+
}
|
|
141
|
+
const O = Math.random().toString(36).slice(2, 7);
|
|
142
|
+
return (t, l) => (o(), n("div", {
|
|
143
|
+
ref_key: "containerRef",
|
|
144
|
+
ref: A,
|
|
145
|
+
class: "vlite-bar-chart w-full select-none"
|
|
146
|
+
}, [
|
|
147
|
+
i.showLegend && p.value ? (o(), n("div", ye, [
|
|
148
|
+
(o(!0), n(d, null, v(m.value, (e) => (o(), n("div", {
|
|
149
|
+
key: e.label,
|
|
150
|
+
class: "flex items-center gap-1.5 text-xs text-muted-foreground"
|
|
151
|
+
}, [
|
|
152
|
+
M("span", {
|
|
153
|
+
class: "w-2.5 h-2.5 rounded-sm inline-block",
|
|
154
|
+
style: F({ backgroundColor: e.color })
|
|
155
|
+
}, null, 4),
|
|
156
|
+
ie(" " + k(e.label), 1)
|
|
157
|
+
]))), 128))
|
|
158
|
+
])) : f("", !0),
|
|
159
|
+
(o(), n("svg", {
|
|
160
|
+
width: G.value,
|
|
161
|
+
height: i.height,
|
|
162
|
+
role: "img",
|
|
163
|
+
"aria-label": "Bar chart",
|
|
164
|
+
class: "overflow-visible",
|
|
165
|
+
onMousemove: te,
|
|
166
|
+
onMouseleave: le
|
|
167
|
+
}, [
|
|
168
|
+
M("defs", null, [
|
|
169
|
+
(o(!0), n(d, null, v(m.value, (e, a) => (o(), n("linearGradient", {
|
|
170
|
+
key: a,
|
|
171
|
+
id: `bgrad-${w(O)}-${a}`,
|
|
172
|
+
x1: "0",
|
|
173
|
+
y1: "0",
|
|
174
|
+
x2: "0",
|
|
175
|
+
y2: "1"
|
|
176
|
+
}, [
|
|
177
|
+
M("stop", {
|
|
178
|
+
offset: "0%",
|
|
179
|
+
"stop-color": e.color,
|
|
180
|
+
"stop-opacity": "1"
|
|
181
|
+
}, null, 8, $e),
|
|
182
|
+
M("stop", {
|
|
183
|
+
offset: "100%",
|
|
184
|
+
"stop-color": e.color,
|
|
185
|
+
"stop-opacity": "0.7"
|
|
186
|
+
}, null, 8, ge)
|
|
187
|
+
], 8, xe))), 128)),
|
|
188
|
+
(o(!0), n(d, null, v(T.value, (e, a) => (o(), n("linearGradient", {
|
|
189
|
+
key: `sc-${a}`,
|
|
190
|
+
id: `bgrad-single-${w(O)}-${a}`,
|
|
191
|
+
x1: "0",
|
|
192
|
+
y1: "0",
|
|
193
|
+
x2: "0",
|
|
194
|
+
y2: "1"
|
|
195
|
+
}, [
|
|
196
|
+
M("stop", {
|
|
197
|
+
offset: "0%",
|
|
198
|
+
"stop-color": e,
|
|
199
|
+
"stop-opacity": "1"
|
|
200
|
+
}, null, 8, pe),
|
|
201
|
+
M("stop", {
|
|
202
|
+
offset: "100%",
|
|
203
|
+
"stop-color": e,
|
|
204
|
+
"stop-opacity": "0.7"
|
|
205
|
+
}, null, 8, ke)
|
|
206
|
+
], 8, be))), 128))
|
|
207
|
+
]),
|
|
208
|
+
i.orientation === "vertical" ? (o(), n("g", {
|
|
209
|
+
key: 0,
|
|
210
|
+
transform: `translate(${g.value.left},${g.value.top})`
|
|
211
|
+
}, [
|
|
212
|
+
i.showGrid ? (o(!0), n(d, { key: 0 }, v(C.value, (e) => (o(), n("line", {
|
|
213
|
+
key: e,
|
|
214
|
+
x1: 0,
|
|
215
|
+
y1: c.value - e / V.value * c.value,
|
|
216
|
+
x2: b.value,
|
|
217
|
+
y2: c.value - e / V.value * c.value,
|
|
218
|
+
stroke: "currentColor",
|
|
219
|
+
"stroke-opacity": i.gridOpacity,
|
|
220
|
+
"stroke-width": "1"
|
|
221
|
+
}, null, 8, Le))), 128)) : f("", !0),
|
|
222
|
+
i.showYLabels ? (o(!0), n(d, { key: 1 }, v(C.value, (e) => (o(), n("text", {
|
|
223
|
+
key: `yt-${e}`,
|
|
224
|
+
x: -10,
|
|
225
|
+
y: c.value - e / V.value * c.value,
|
|
226
|
+
"text-anchor": "end",
|
|
227
|
+
"dominant-baseline": "middle",
|
|
228
|
+
"font-size": "11",
|
|
229
|
+
class: "fill-muted-foreground"
|
|
230
|
+
}, k(i.formatValue ? i.formatValue(e) : w(Y)(e)), 9, Me))), 128)) : f("", !0),
|
|
231
|
+
(o(!0), n(d, null, v(K.value, (e, a) => (o(), n("g", { key: a }, [
|
|
232
|
+
(o(!0), n(d, null, v(e.bars, (s, u) => (o(), n("path", {
|
|
233
|
+
key: u,
|
|
234
|
+
d: ae(s.x, s.y, s.w, s.bh, i.barRadius),
|
|
235
|
+
fill: p.value ? `url(#bgrad-${w(O)}-${u})` : `url(#bgrad-single-${w(O)}-${a})`,
|
|
236
|
+
opacity: R.value !== null && R.value !== a ? 0.5 : 1,
|
|
237
|
+
class: "transition-opacity duration-150"
|
|
238
|
+
}, null, 8, Ve))), 128)),
|
|
239
|
+
i.showValues ? (o(!0), n(d, { key: 0 }, v(e.bars, (s, u) => (o(), n("text", {
|
|
240
|
+
key: `vl-${u}`,
|
|
241
|
+
x: s.x + s.w / 2,
|
|
242
|
+
y: s.y - 6,
|
|
243
|
+
"text-anchor": "middle",
|
|
244
|
+
"font-size": "10",
|
|
245
|
+
"font-weight": "600",
|
|
246
|
+
class: "fill-foreground"
|
|
247
|
+
}, k(i.formatValue ? i.formatValue(s.val) : w(Y)(s.val)), 9, Ce))), 128)) : f("", !0)
|
|
248
|
+
]))), 128)),
|
|
249
|
+
i.showXLabels ? (o(!0), n(d, { key: 2 }, v(x.value, (e, a) => (o(), n("text", {
|
|
250
|
+
key: `xl-${a}`,
|
|
251
|
+
x: (a + 0.5) * (b.value / x.value.length),
|
|
252
|
+
y: c.value + 16,
|
|
253
|
+
"text-anchor": "middle",
|
|
254
|
+
"font-size": "11",
|
|
255
|
+
class: "fill-muted-foreground"
|
|
256
|
+
}, k(e), 9, Be))), 128)) : f("", !0),
|
|
257
|
+
i.showXAxis ? (o(), n("line", {
|
|
258
|
+
key: 3,
|
|
259
|
+
x1: 0,
|
|
260
|
+
y1: c.value,
|
|
261
|
+
x2: b.value,
|
|
262
|
+
y2: c.value,
|
|
263
|
+
stroke: "currentColor",
|
|
264
|
+
"stroke-opacity": i.axisOpacity
|
|
265
|
+
}, null, 8, Ye)) : f("", !0),
|
|
266
|
+
i.showYAxis ? (o(), n("line", {
|
|
267
|
+
key: 4,
|
|
268
|
+
x1: 0,
|
|
269
|
+
y1: 0,
|
|
270
|
+
x2: 0,
|
|
271
|
+
y2: c.value,
|
|
272
|
+
stroke: "currentColor",
|
|
273
|
+
"stroke-opacity": i.axisOpacity
|
|
274
|
+
}, null, 8, Re)) : f("", !0)
|
|
275
|
+
], 8, we)) : (o(), n("g", {
|
|
276
|
+
key: 1,
|
|
277
|
+
transform: `translate(${g.value.left},${g.value.top})`
|
|
278
|
+
}, [
|
|
279
|
+
i.showGrid ? (o(!0), n(d, { key: 0 }, v(C.value, (e) => (o(), n("line", {
|
|
280
|
+
key: e,
|
|
281
|
+
x1: e / V.value * b.value,
|
|
282
|
+
y1: 0,
|
|
283
|
+
x2: e / V.value * b.value,
|
|
284
|
+
y2: c.value,
|
|
285
|
+
stroke: "currentColor",
|
|
286
|
+
"stroke-opacity": i.gridOpacity,
|
|
287
|
+
"stroke-width": "1"
|
|
288
|
+
}, null, 8, ze))), 128)) : f("", !0),
|
|
289
|
+
i.showXLabels ? (o(!0), n(d, { key: 1 }, v(C.value, (e) => (o(), n("text", {
|
|
290
|
+
key: `xt-${e}`,
|
|
291
|
+
x: e / V.value * b.value,
|
|
292
|
+
y: -8,
|
|
293
|
+
"text-anchor": "middle",
|
|
294
|
+
"font-size": "11",
|
|
295
|
+
class: "fill-muted-foreground"
|
|
296
|
+
}, k(i.formatValue ? i.formatValue(e) : w(Y)(e)), 9, Xe))), 128)) : f("", !0),
|
|
297
|
+
i.showYLabels ? (o(!0), n(d, { key: 2 }, v(x.value, (e, a) => (o(), n("text", {
|
|
298
|
+
key: `yl-${a}`,
|
|
299
|
+
x: -12,
|
|
300
|
+
y: (a + 0.5) * (c.value / x.value.length),
|
|
301
|
+
"text-anchor": "end",
|
|
302
|
+
"dominant-baseline": "middle",
|
|
303
|
+
"font-size": "11",
|
|
304
|
+
class: "fill-muted-foreground"
|
|
305
|
+
}, k(e), 9, Ae))), 128)) : f("", !0),
|
|
306
|
+
(o(!0), n(d, null, v(ee.value, (e, a) => (o(), n("g", { key: a }, [
|
|
307
|
+
(o(!0), n(d, null, v(e.bars, (s, u) => (o(), n("path", {
|
|
308
|
+
key: u,
|
|
309
|
+
d: oe(s.x, s.y, s.bw, s.h, i.barRadius),
|
|
310
|
+
fill: p.value ? `url(#bgrad-${w(O)}-${u})` : `url(#bgrad-single-${w(O)}-${a})`,
|
|
311
|
+
opacity: R.value !== null && R.value !== a ? 0.5 : 1,
|
|
312
|
+
class: "transition-opacity duration-150"
|
|
313
|
+
}, null, 8, Ge))), 128)),
|
|
314
|
+
i.showValues ? (o(!0), n(d, { key: 0 }, v(e.bars, (s, u) => (o(), n("text", {
|
|
315
|
+
key: `hvl-${u}`,
|
|
316
|
+
x: s.bw + 6,
|
|
317
|
+
y: s.y + s.h / 2,
|
|
318
|
+
"dominant-baseline": "middle",
|
|
319
|
+
"font-size": "10",
|
|
320
|
+
"font-weight": "600",
|
|
321
|
+
class: "fill-foreground"
|
|
322
|
+
}, k(i.formatValue ? i.formatValue(s.val) : w(Y)(s.val)), 9, Te))), 128)) : f("", !0)
|
|
323
|
+
]))), 128)),
|
|
324
|
+
i.showYAxis ? (o(), n("line", {
|
|
325
|
+
key: 3,
|
|
326
|
+
x1: 0,
|
|
327
|
+
y1: 0,
|
|
328
|
+
x2: 0,
|
|
329
|
+
y2: c.value,
|
|
330
|
+
stroke: "currentColor",
|
|
331
|
+
"stroke-opacity": i.axisOpacity
|
|
332
|
+
}, null, 8, Se)) : f("", !0),
|
|
333
|
+
i.showXAxis ? (o(), n("line", {
|
|
334
|
+
key: 4,
|
|
335
|
+
x1: 0,
|
|
336
|
+
y1: c.value,
|
|
337
|
+
x2: b.value,
|
|
338
|
+
y2: c.value,
|
|
339
|
+
stroke: "currentColor",
|
|
340
|
+
"stroke-opacity": i.axisOpacity
|
|
341
|
+
}, null, 8, We)) : f("", !0)
|
|
342
|
+
], 8, Oe))
|
|
343
|
+
], 40, me)),
|
|
344
|
+
(o(), ce(de, { to: "body" }, [
|
|
345
|
+
B.value ? (o(), n("div", {
|
|
346
|
+
key: 0,
|
|
347
|
+
class: "vlite-chart-tooltip",
|
|
348
|
+
style: F({ left: `${B.value.x + 12}px`, top: `${B.value.y - 10}px` })
|
|
349
|
+
}, [
|
|
350
|
+
M("div", Pe, k(B.value.label), 1),
|
|
351
|
+
(o(!0), n(d, null, v(B.value.items, (e) => (o(), n("div", {
|
|
352
|
+
key: e.label,
|
|
353
|
+
class: "flex items-center gap-1.5 text-xs"
|
|
354
|
+
}, [
|
|
355
|
+
M("span", {
|
|
356
|
+
class: "w-2 h-2 rounded-sm shrink-0",
|
|
357
|
+
style: F({ backgroundColor: e.color })
|
|
358
|
+
}, null, 4),
|
|
359
|
+
e.label ? (o(), n("span", He, k(e.label) + ":", 1)) : f("", !0),
|
|
360
|
+
M("span", Ne, k(e.value), 1)
|
|
361
|
+
]))), 128))
|
|
362
|
+
], 4)) : f("", !0)
|
|
363
|
+
]))
|
|
364
|
+
], 512));
|
|
365
|
+
}
|
|
366
|
+
});
|
|
367
|
+
export {
|
|
368
|
+
Ee as default
|
|
369
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { defineComponent as p, computed as l, ref as S, onMounted as B, watch as W, onUnmounted as P, openBlock as o, createElementBlock as r, createElementVNode as n, unref as w, normalizeStyle as z, renderSlot as j, toDisplayString as y, createCommentVNode as f } from "vue";
|
|
2
|
+
import { resolveColor as A, animateProgress as D } from "./utils.js";
|
|
3
|
+
const E = { class: "vlite-circle-chart inline-flex flex-col items-center gap-2 select-none" }, N = ["width", "height", "aria-label"], O = ["id"], G = ["stop-color"], I = ["stop-color"], U = ["cx", "cy", "r", "stroke", "stroke-width"], q = ["cx", "cy", "r", "stroke", "stroke-width", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap"], F = ["x", "y", "width", "height"], H = {
|
|
4
|
+
xmlns: "http://www.w3.org/1999/xhtml",
|
|
5
|
+
class: "w-full h-full flex flex-col items-center justify-center text-center"
|
|
6
|
+
}, J = {
|
|
7
|
+
key: 0,
|
|
8
|
+
class: "text-center"
|
|
9
|
+
}, K = {
|
|
10
|
+
key: 0,
|
|
11
|
+
class: "text-sm font-medium text-foreground"
|
|
12
|
+
}, L = {
|
|
13
|
+
key: 1,
|
|
14
|
+
class: "text-xs text-muted-foreground"
|
|
15
|
+
}, T = /* @__PURE__ */ p({
|
|
16
|
+
__name: "CircleChart",
|
|
17
|
+
props: {
|
|
18
|
+
value: {},
|
|
19
|
+
max: { default: 100 },
|
|
20
|
+
size: { default: 160 },
|
|
21
|
+
strokeWidth: { default: 12 },
|
|
22
|
+
color: { default: "primary" },
|
|
23
|
+
gradient: { type: Boolean, default: !0 },
|
|
24
|
+
label: {},
|
|
25
|
+
sublabel: {},
|
|
26
|
+
showValue: { type: Boolean, default: !0 },
|
|
27
|
+
formatValue: {},
|
|
28
|
+
animate: { type: Boolean, default: !0 },
|
|
29
|
+
trackColor: {},
|
|
30
|
+
lineCap: { default: "round" }
|
|
31
|
+
},
|
|
32
|
+
setup(e) {
|
|
33
|
+
const t = e, g = Math.random().toString(36).slice(2, 7), h = l(() => (t.size - t.strokeWidth) / 2), m = l(() => 2 * Math.PI * h.value), c = l(() => t.size / 2), u = l(() => t.size / 2), s = l(() => Math.max(0, Math.min(100, t.value / t.max * 100))), d = S(t.animate ? 0 : s.value);
|
|
34
|
+
let v = null;
|
|
35
|
+
function b() {
|
|
36
|
+
v?.();
|
|
37
|
+
const a = s.value, i = d.value;
|
|
38
|
+
v = D(1e3, (M) => {
|
|
39
|
+
d.value = i + (a - i) * M;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
B(() => {
|
|
43
|
+
t.animate && b();
|
|
44
|
+
}), W(s, () => {
|
|
45
|
+
t.animate && b();
|
|
46
|
+
}), P(() => v?.());
|
|
47
|
+
const C = l(() => {
|
|
48
|
+
const a = d.value / 100 * m.value;
|
|
49
|
+
return m.value - a;
|
|
50
|
+
}), k = l(() => A(t.color ?? "primary")), V = l(() => {
|
|
51
|
+
const a = {
|
|
52
|
+
primary: "#818cf8",
|
|
53
|
+
success: "#34d399",
|
|
54
|
+
warning: "#fbbf24",
|
|
55
|
+
danger: "#fb7185",
|
|
56
|
+
info: "#60a5fa"
|
|
57
|
+
}, i = t.color ?? "primary";
|
|
58
|
+
return a[i] ?? k.value;
|
|
59
|
+
}), x = l(() => t.formatValue ? t.formatValue(t.value, s.value) : `${Math.round(d.value)}%`), $ = l(() => t.trackColor || "var(--color-muted)");
|
|
60
|
+
return (a, i) => (o(), r("div", E, [
|
|
61
|
+
(o(), r("svg", {
|
|
62
|
+
width: e.size,
|
|
63
|
+
height: e.size,
|
|
64
|
+
role: "img",
|
|
65
|
+
"aria-label": `${x.value} progress`
|
|
66
|
+
}, [
|
|
67
|
+
n("defs", null, [
|
|
68
|
+
n("linearGradient", {
|
|
69
|
+
id: `cg-${w(g)}`,
|
|
70
|
+
x1: "1",
|
|
71
|
+
y1: "0",
|
|
72
|
+
x2: "0",
|
|
73
|
+
y2: "1"
|
|
74
|
+
}, [
|
|
75
|
+
n("stop", {
|
|
76
|
+
offset: "0%",
|
|
77
|
+
"stop-color": V.value
|
|
78
|
+
}, null, 8, G),
|
|
79
|
+
n("stop", {
|
|
80
|
+
offset: "100%",
|
|
81
|
+
"stop-color": k.value
|
|
82
|
+
}, null, 8, I)
|
|
83
|
+
], 8, O)
|
|
84
|
+
]),
|
|
85
|
+
n("circle", {
|
|
86
|
+
cx: c.value,
|
|
87
|
+
cy: u.value,
|
|
88
|
+
r: h.value,
|
|
89
|
+
fill: "none",
|
|
90
|
+
stroke: $.value,
|
|
91
|
+
"stroke-width": e.strokeWidth,
|
|
92
|
+
"stroke-linecap": "butt"
|
|
93
|
+
}, null, 8, U),
|
|
94
|
+
n("circle", {
|
|
95
|
+
cx: c.value,
|
|
96
|
+
cy: u.value,
|
|
97
|
+
r: h.value,
|
|
98
|
+
fill: "none",
|
|
99
|
+
stroke: e.gradient ? `url(#cg-${w(g)})` : k.value,
|
|
100
|
+
"stroke-width": e.strokeWidth,
|
|
101
|
+
"stroke-dasharray": m.value,
|
|
102
|
+
"stroke-dashoffset": C.value,
|
|
103
|
+
"stroke-linecap": e.lineCap,
|
|
104
|
+
transform: "rotate(-90)",
|
|
105
|
+
style: z({ transformOrigin: `${c.value}px ${u.value}px` })
|
|
106
|
+
}, null, 12, q),
|
|
107
|
+
(o(), r("foreignObject", {
|
|
108
|
+
x: c.value - e.size * 0.35,
|
|
109
|
+
y: u.value - e.size * 0.35,
|
|
110
|
+
width: e.size * 0.7,
|
|
111
|
+
height: e.size * 0.7
|
|
112
|
+
}, [
|
|
113
|
+
n("div", H, [
|
|
114
|
+
j(a.$slots, "center", {
|
|
115
|
+
value: e.value,
|
|
116
|
+
percentage: s.value,
|
|
117
|
+
displayValue: x.value
|
|
118
|
+
}, () => [
|
|
119
|
+
e.showValue ? (o(), r("span", {
|
|
120
|
+
key: 0,
|
|
121
|
+
class: "font-bold text-foreground leading-tight",
|
|
122
|
+
style: z({ fontSize: `${e.size * 0.16}px` })
|
|
123
|
+
}, y(x.value), 5)) : f("", !0)
|
|
124
|
+
])
|
|
125
|
+
])
|
|
126
|
+
], 8, F))
|
|
127
|
+
], 8, N)),
|
|
128
|
+
e.label || e.sublabel ? (o(), r("div", J, [
|
|
129
|
+
e.label ? (o(), r("p", K, y(e.label), 1)) : f("", !0),
|
|
130
|
+
e.sublabel ? (o(), r("p", L, y(e.sublabel), 1)) : f("", !0)
|
|
131
|
+
])) : f("", !0)
|
|
132
|
+
]));
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
export {
|
|
136
|
+
T as default
|
|
137
|
+
};
|