@bridge-ui/vue 0.17.3 → 0.19.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/ai/skills/bridge-ui-components/SKILL.md +36 -35
- package/ai/skills/bridge-ui-setup/SKILL.md +1 -1
- package/dist/Components/CalendarMonth/composables/useCalendarMonth.d.ts +1 -1
- package/dist/Components/ChartAxis/ChartAxis.vue_vue_type_script_setup_true_lang.js +1 -0
- package/dist/Components/ChartAxis/chartAxis.types.d.ts +17 -7
- package/dist/Components/ChartAxis/composables/useChartAxis.d.ts +2 -2
- package/dist/Components/ChartAxis/composables/useChartAxis.js +15 -10
- package/dist/Components/ChartBar/ChartBar.js +5 -0
- package/dist/Components/ChartBar/ChartBar.vue.d.ts +16 -0
- package/dist/Components/ChartBar/ChartBar.vue_vue_type_script_setup_true_lang.js +64 -0
- package/dist/Components/ChartBar/chartBar.types.d.ts +66 -0
- package/dist/Components/ChartBar/composables/useChartBar.d.ts +26 -0
- package/dist/Components/ChartBar/composables/useChartBar.js +13 -0
- package/dist/Components/ChartBar/index.d.ts +4 -0
- package/dist/Components/ChartBar/index.js +4 -0
- package/dist/Components/ChartBarSeries/ChartBarSeries.js +5 -0
- package/dist/Components/ChartBarSeries/ChartBarSeries.vue.d.ts +6 -0
- package/dist/Components/ChartBarSeries/ChartBarSeries.vue_vue_type_script_setup_true_lang.js +28 -0
- package/dist/Components/ChartBarSeries/chartBarSeries.types.d.ts +67 -0
- package/dist/Components/ChartBarSeries/composables/useChartBarSeries.d.ts +5 -0
- package/dist/Components/ChartBarSeries/composables/useChartBarSeries.js +23 -0
- package/dist/Components/ChartBarSeries/index.d.ts +4 -0
- package/dist/Components/ChartBarSeries/index.js +3 -0
- package/dist/Components/ChartFunnel/ChartFunnel.js +5 -0
- package/dist/Components/ChartFunnel/ChartFunnel.vue.d.ts +16 -0
- package/dist/Components/ChartFunnel/ChartFunnel.vue_vue_type_script_setup_true_lang.js +59 -0
- package/dist/Components/ChartFunnel/chartFunnel.types.d.ts +54 -0
- package/dist/Components/ChartFunnel/composables/useChartFunnel.d.ts +29 -0
- package/dist/Components/ChartFunnel/composables/useChartFunnel.js +68 -0
- package/dist/Components/ChartFunnel/index.d.ts +4 -0
- package/dist/Components/ChartFunnel/index.js +4 -0
- package/dist/Components/ChartLegend/ChartLegend.vue.d.ts +2 -0
- package/dist/Components/ChartLegend/ChartLegend.vue_vue_type_script_setup_true_lang.js +33 -13
- package/dist/Components/ChartLegend/chartLegend.types.d.ts +41 -5
- package/dist/Components/ChartLegend/composables/useChartLegend.d.ts +9 -5
- package/dist/Components/ChartLegend/composables/useChartLegend.js +88 -54
- package/dist/Components/ChartLine/ChartLine.js +5 -0
- package/dist/Components/ChartLine/ChartLine.vue.d.ts +20 -0
- package/dist/Components/ChartLine/ChartLine.vue_vue_type_script_setup_true_lang.js +77 -0
- package/dist/Components/ChartLine/chartLine.types.d.ts +79 -0
- package/dist/Components/ChartLine/composables/useChartLine.d.ts +26 -0
- package/dist/Components/ChartLine/composables/useChartLine.js +13 -0
- package/dist/Components/ChartLine/index.d.ts +4 -0
- package/dist/Components/ChartLine/index.js +4 -0
- package/dist/Components/ChartLineSeries/ChartLineSeries.js +5 -0
- package/dist/Components/ChartLineSeries/ChartLineSeries.vue.d.ts +10 -0
- package/dist/Components/ChartLineSeries/ChartLineSeries.vue_vue_type_script_setup_true_lang.js +45 -0
- package/dist/Components/ChartLineSeries/chartLineSeries.types.d.ts +96 -0
- package/dist/Components/ChartLineSeries/composables/useChartLineSeries.d.ts +5 -0
- package/dist/Components/ChartLineSeries/composables/useChartLineSeries.js +28 -0
- package/dist/Components/ChartLineSeries/index.d.ts +4 -0
- package/dist/Components/ChartLineSeries/index.js +3 -0
- package/dist/Components/ChartPie/ChartPie.js +5 -0
- package/dist/Components/ChartPie/ChartPie.vue.d.ts +15 -0
- package/dist/Components/ChartPie/ChartPie.vue_vue_type_script_setup_true_lang.js +76 -0
- package/dist/Components/ChartPie/chartPie.types.d.ts +92 -0
- package/dist/Components/ChartPie/composables/useChartPie.d.ts +30 -0
- package/dist/Components/ChartPie/composables/useChartPie.js +81 -0
- package/dist/Components/ChartPie/index.d.ts +4 -0
- package/dist/Components/ChartPie/index.js +4 -0
- package/dist/Components/ChartScatter/ChartScatter.js +5 -0
- package/dist/Components/{Chart/Chart.vue.d.ts → ChartScatter/ChartScatter.vue.d.ts} +3 -2
- package/dist/Components/ChartScatter/ChartScatter.vue_vue_type_script_setup_true_lang.js +49 -0
- package/dist/Components/ChartScatter/chartScatter.types.d.ts +23 -0
- package/dist/Components/ChartScatter/composables/useChartScatter.d.ts +29 -0
- package/dist/Components/ChartScatter/composables/useChartScatter.js +108 -0
- package/dist/Components/ChartScatter/index.d.ts +4 -0
- package/dist/Components/ChartScatter/index.js +4 -0
- package/dist/Components/ChartScatterSeries/ChartScatterSeries.js +5 -0
- package/dist/Components/ChartScatterSeries/ChartScatterSeries.vue.d.ts +4 -0
- package/dist/Components/ChartScatterSeries/ChartScatterSeries.vue_vue_type_script_setup_true_lang.js +22 -0
- package/dist/Components/ChartScatterSeries/chartScatterSeries.types.d.ts +45 -0
- package/dist/Components/ChartScatterSeries/composables/useChartScatterSeries.d.ts +4 -0
- package/dist/Components/ChartScatterSeries/composables/useChartScatterSeries.js +19 -0
- package/dist/Components/ChartScatterSeries/index.d.ts +4 -0
- package/dist/Components/ChartScatterSeries/index.js +3 -0
- package/dist/Components/ChartTooltip/ChartTooltip.vue_vue_type_script_setup_true_lang.js +22 -10
- package/dist/Components/ChartTooltip/chartTooltip.types.d.ts +28 -9
- package/dist/Components/ChartTooltip/composables/useChartTooltip.d.ts +4 -1
- package/dist/Components/ChartTooltip/composables/useChartTooltip.js +81 -63
- package/dist/Components/Heading/Heading.js +5 -0
- package/dist/Components/Heading/Heading.vue.d.ts +11 -0
- package/dist/Components/Heading/Heading.vue_vue_type_script_setup_true_lang.js +29 -0
- package/dist/Components/Heading/composables/useHeading.d.ts +10 -0
- package/dist/Components/Heading/composables/useHeading.js +56 -0
- package/dist/Components/Heading/heading.types.d.ts +56 -0
- package/dist/Components/Heading/index.d.ts +3 -0
- package/dist/Components/Heading/index.js +3 -0
- package/dist/Components/ResizablePanel/composables/useResizablePanel.d.ts +1 -1
- package/dist/Components/Spinner/composables/useSpinner.d.ts +1 -1
- package/dist/Components/Text/Text.js +5 -0
- package/dist/Components/Text/Text.vue.d.ts +11 -0
- package/dist/Components/Text/Text.vue_vue_type_script_setup_true_lang.js +33 -0
- package/dist/Components/Text/composables/useText.d.ts +9 -0
- package/dist/Components/Text/composables/useText.js +56 -0
- package/dist/Components/Text/index.d.ts +3 -0
- package/dist/Components/Text/index.js +3 -0
- package/dist/Components/Text/text.types.d.ts +76 -0
- package/dist/Utils/Charts/ChartFrame.js +5 -0
- package/dist/Utils/Charts/ChartFrame.vue.d.ts +24 -0
- package/dist/Utils/Charts/ChartFrame.vue_vue_type_script_setup_true_lang.js +41 -0
- package/dist/{Components/Chart → Utils/Charts}/chart.types.d.ts +33 -18
- package/dist/Utils/Charts/chartInjectionKey.d.ts +151 -0
- package/dist/{Components/Chart → Utils/Charts}/chartInjectionKey.js +2 -2
- package/dist/Utils/Charts/echarts/bar.d.ts +6 -0
- package/dist/Utils/Charts/echarts/bar.js +23 -0
- package/dist/Utils/Charts/echarts/cartesian.d.ts +15 -0
- package/dist/Utils/Charts/echarts/cartesian.js +290 -0
- package/dist/Utils/Charts/echarts/funnel.d.ts +15 -0
- package/dist/Utils/Charts/echarts/funnel.js +79 -0
- package/dist/Utils/Charts/echarts/line.d.ts +5 -0
- package/dist/Utils/Charts/echarts/line.js +20 -0
- package/dist/Utils/Charts/echarts/part.d.ts +19 -0
- package/dist/Utils/Charts/echarts/part.js +45 -0
- package/dist/Utils/Charts/echarts/pie.d.ts +14 -0
- package/dist/Utils/Charts/echarts/pie.js +76 -0
- package/dist/Utils/Charts/echarts/plot.d.ts +44 -0
- package/dist/Utils/Charts/echarts/plot.js +52 -0
- package/dist/Utils/Charts/echarts/scatter.d.ts +14 -0
- package/dist/Utils/Charts/echarts/scatter.js +161 -0
- package/dist/Utils/Charts/index.d.ts +6 -0
- package/dist/Utils/Charts/index.js +6 -0
- package/dist/Utils/Charts/useChartCartesian.d.ts +59 -0
- package/dist/Utils/Charts/useChartCartesian.js +169 -0
- package/dist/Utils/Charts/useChartPart.d.ts +45 -0
- package/dist/Utils/Charts/useChartPart.js +97 -0
- package/dist/Utils/Charts/useChartRegistry.d.ts +13 -0
- package/dist/Utils/Charts/useChartRegistry.js +40 -0
- package/dist/Utils/Charts/useChartRoot.d.ts +156 -0
- package/dist/Utils/Charts/useChartRoot.js +342 -0
- package/dist/Utils/Charts/useChartSeries.d.ts +10 -0
- package/dist/Utils/Charts/useChartSeries.js +22 -0
- package/dist/augments.d.ts +33 -7
- package/dist/index.d.ts +4 -0
- package/dist/index.js +90 -86
- package/docs/README.md +8 -1
- package/docs/components/BridgeUIProvider.md +1 -1
- package/docs/components/Card.md +15 -0
- package/docs/components/Chart.md +118 -151
- package/docs/components/ChartBar.md +190 -0
- package/docs/components/ChartFunnel.md +62 -0
- package/docs/components/ChartLine.md +192 -0
- package/docs/components/ChartPie.md +138 -0
- package/docs/components/ChartScatter.md +102 -0
- package/docs/components/Heading.md +85 -0
- package/docs/components/Text.md +118 -0
- package/package.json +2 -2
- package/dist/Components/Chart/Chart.js +0 -5
- package/dist/Components/Chart/Chart.vue_vue_type_script_setup_true_lang.js +0 -52
- package/dist/Components/Chart/chartInjectionKey.d.ts +0 -94
- package/dist/Components/Chart/composables/useChart.d.ts +0 -40
- package/dist/Components/Chart/composables/useChart.js +0 -346
- package/dist/Components/Chart/echartsChart.d.ts +0 -14
- package/dist/Components/Chart/echartsChart.js +0 -199
- package/dist/Components/Chart/index.d.ts +0 -4
- package/dist/Components/Chart/index.js +0 -4
- package/dist/Components/ChartSeries/ChartSeries.js +0 -5
- package/dist/Components/ChartSeries/ChartSeries.vue.d.ts +0 -4
- package/dist/Components/ChartSeries/ChartSeries.vue_vue_type_script_setup_true_lang.js +0 -24
- package/dist/Components/ChartSeries/chartSeries.types.d.ts +0 -37
- package/dist/Components/ChartSeries/composables/useChartSeries.d.ts +0 -10
- package/dist/Components/ChartSeries/composables/useChartSeries.js +0 -29
- package/dist/Components/ChartSeries/index.d.ts +0 -3
- package/dist/Components/ChartSeries/index.js +0 -3
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { useChartRegistry as e } from "./useChartRegistry.js";
|
|
2
|
+
import { chartRootBridgeKeys as t, toChartLegendItems as n, useChartColors as r, useChartContextValue as i, useChartFrame as a, useChartPlot as o, useChartRoot as s } from "./useChartRoot.js";
|
|
3
|
+
import { computed as c } from "vue";
|
|
4
|
+
import { isDate as l, isEmpty as u, isNil as d, isString as f } from "es-toolkit/compat";
|
|
5
|
+
import { DEFAULT_CHART_AREA_OPACITY as p, DEFAULT_CHART_BAR_RADIUS as m, formatChartValue as h, getChartCartesianRenderSeries as g, getChartCartesianSummaryParams as _, getChartCartesianTable as v, getChartCartesianTooltip as y, getChartCategoryColorItems as b, getChartCategoryLabels as x, getChartRangeColorItems as S, getChartTimeTickFormatter as C, isChartEmpty as w, isChartTimeCategories as T } from "@bridge-ui/core/Domain";
|
|
6
|
+
//#region src/Utils/Charts/useChartCartesian.ts
|
|
7
|
+
var E = [
|
|
8
|
+
...t,
|
|
9
|
+
"area",
|
|
10
|
+
"step",
|
|
11
|
+
"curve",
|
|
12
|
+
"stack",
|
|
13
|
+
"labels",
|
|
14
|
+
"radius",
|
|
15
|
+
"sparkline",
|
|
16
|
+
"categories",
|
|
17
|
+
"formatDate",
|
|
18
|
+
"showPoints",
|
|
19
|
+
"areaOpacity",
|
|
20
|
+
"formatLabel",
|
|
21
|
+
"orientation",
|
|
22
|
+
"categoryColors"
|
|
23
|
+
], D = [
|
|
24
|
+
"area",
|
|
25
|
+
"size",
|
|
26
|
+
"step",
|
|
27
|
+
"curve",
|
|
28
|
+
"height",
|
|
29
|
+
"labels",
|
|
30
|
+
"radius",
|
|
31
|
+
"classes",
|
|
32
|
+
"animation",
|
|
33
|
+
"showPoints",
|
|
34
|
+
"areaOpacity",
|
|
35
|
+
"customProps",
|
|
36
|
+
"orientation"
|
|
37
|
+
];
|
|
38
|
+
function O(e, t, n) {
|
|
39
|
+
return e.kind === "bar" ? {
|
|
40
|
+
kind: "bar",
|
|
41
|
+
id: e.id,
|
|
42
|
+
name: e.name,
|
|
43
|
+
data: e.data,
|
|
44
|
+
color: e.color,
|
|
45
|
+
tone: e.tone ?? "solid",
|
|
46
|
+
reference: e.reference ?? [],
|
|
47
|
+
colorBy: e.colorBy ?? "value",
|
|
48
|
+
stack: e.stack ?? t.stack,
|
|
49
|
+
colorRanges: e.colorRanges ?? [],
|
|
50
|
+
labels: e.labels ?? t.labels ?? !1
|
|
51
|
+
} : {
|
|
52
|
+
kind: "line",
|
|
53
|
+
id: e.id,
|
|
54
|
+
name: e.name,
|
|
55
|
+
data: e.data,
|
|
56
|
+
color: e.color,
|
|
57
|
+
dashed: e.dashed ?? !1,
|
|
58
|
+
reference: e.reference ?? [],
|
|
59
|
+
colorBy: e.colorBy ?? "value",
|
|
60
|
+
colorRanges: e.colorRanges ?? [],
|
|
61
|
+
area: e.area ?? t.area ?? !1,
|
|
62
|
+
step: e.step ?? t.step ?? !1,
|
|
63
|
+
labels: e.labels ?? t.labels ?? !1,
|
|
64
|
+
curve: e.curve ?? t.curve ?? "linear",
|
|
65
|
+
showPoints: e.showPoints ?? t.showPoints ?? !1,
|
|
66
|
+
stack: e.stack ?? (n === "line" ? t.stack : void 0),
|
|
67
|
+
areaOpacity: e.areaOpacity ?? t.areaOpacity ?? p
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
function k(t, { kind: p, mount: k, libDefaults: A, componentName: j }) {
|
|
71
|
+
let M = s({
|
|
72
|
+
props: t,
|
|
73
|
+
libDefaults: A,
|
|
74
|
+
componentName: j,
|
|
75
|
+
bridgeKeys: E,
|
|
76
|
+
registryKeys: D,
|
|
77
|
+
fallbackProps: () => t.sparkline ? { height: 48 } : {}
|
|
78
|
+
}), N = e(), { merged: P, hidden: F, locale: I, resolveMessage: L } = M, R = c(() => JSON.stringify((t.categories ?? []).map((e) => l(e) ? { time: e.getTime() } : e))), z = c(() => JSON.parse(R.value).map((e) => f(e) ? e : new Date(e.time))), B = c(() => T(z.value) ? z.value.map((e) => e.getTime()) : null), V = c(() => x({
|
|
79
|
+
locale: I.value,
|
|
80
|
+
categories: z.value,
|
|
81
|
+
formatDate: t.formatDate
|
|
82
|
+
})), H = c(() => {
|
|
83
|
+
let e = t.formatLabel, n = I.value;
|
|
84
|
+
return e ?? ((e) => h(e, n));
|
|
85
|
+
}), U = c(() => p === "bar" ? P.value.orientation ?? "vertical" : "vertical"), W = c(() => N.entries.value.map((e) => O(e, {
|
|
86
|
+
...P.value,
|
|
87
|
+
stack: t.stack
|
|
88
|
+
}, p))), G = r(M, () => [...N.entries.value, ...S(W.value)]), K = c(() => b({
|
|
89
|
+
labels: V.value,
|
|
90
|
+
categoryColors: p === "bar" ? t.categoryColors : void 0
|
|
91
|
+
})), q = r(M, () => K.value), J = c(() => g({
|
|
92
|
+
colors: G.value,
|
|
93
|
+
series: W.value,
|
|
94
|
+
theme: M.theme.value,
|
|
95
|
+
categoryColors: u(K.value) ? null : K.value.map((e) => q.value[e.id] ?? "")
|
|
96
|
+
})), Y = c(() => J.value.filter((e) => !F.value.includes(e.id))), X = c(() => Object.fromEntries(J.value.map((e) => [e.id, e.color]))), Z = c(() => {
|
|
97
|
+
let e = { ...N.axes.value.x }, t = { ...N.axes.value.y };
|
|
98
|
+
if (!d(B.value)) {
|
|
99
|
+
let n = U.value === "horizontal" ? t : e;
|
|
100
|
+
n.formatTick ??= C({
|
|
101
|
+
locale: I.value,
|
|
102
|
+
timestamps: B.value
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
xAxis: e,
|
|
107
|
+
yAxis: t
|
|
108
|
+
};
|
|
109
|
+
}), Q = c(() => {
|
|
110
|
+
let e = M.theme.value;
|
|
111
|
+
return d(e) ? null : {
|
|
112
|
+
theme: e,
|
|
113
|
+
xAxis: Z.value.xAxis,
|
|
114
|
+
yAxis: Z.value.yAxis,
|
|
115
|
+
categories: V.value,
|
|
116
|
+
series: Y.value,
|
|
117
|
+
timestamps: B.value,
|
|
118
|
+
orientation: U.value,
|
|
119
|
+
formatLabel: H.value,
|
|
120
|
+
animation: M.animation.value,
|
|
121
|
+
width: M.plotSize.value.width,
|
|
122
|
+
height: M.plotSize.value.height,
|
|
123
|
+
sparkline: t.sparkline === !0,
|
|
124
|
+
radius: P.value.radius ?? m
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
o(M, {
|
|
128
|
+
mount: k,
|
|
129
|
+
options: Q
|
|
130
|
+
});
|
|
131
|
+
let $ = c(() => {
|
|
132
|
+
let e = M.active.value.index;
|
|
133
|
+
return d(e) ? null : y({
|
|
134
|
+
index: e,
|
|
135
|
+
series: Y.value,
|
|
136
|
+
title: V.value[e] ?? ""
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
frame: a(M, c(() => ({
|
|
141
|
+
tooltip: $.value,
|
|
142
|
+
count: V.value.length,
|
|
143
|
+
isEmpty: w(W.value.flatMap((e) => e.data)),
|
|
144
|
+
table: v({
|
|
145
|
+
locale: I.value,
|
|
146
|
+
series: W.value,
|
|
147
|
+
categories: V.value,
|
|
148
|
+
categoryHeader: L(d(B.value) ? "Category" : "Date")
|
|
149
|
+
}),
|
|
150
|
+
summary: L("Chart with {{count}} series ({{names}}) across {{categories}} categories, from {{first}} to {{last}}.", _({
|
|
151
|
+
series: W.value,
|
|
152
|
+
categories: V.value
|
|
153
|
+
}))
|
|
154
|
+
}))),
|
|
155
|
+
merged: P,
|
|
156
|
+
context: i(M, c(() => ({
|
|
157
|
+
family: p,
|
|
158
|
+
tooltip: $.value,
|
|
159
|
+
setAxis: N.setAxis,
|
|
160
|
+
removeAxis: N.removeAxis,
|
|
161
|
+
upsertSeries: N.upsertSeries,
|
|
162
|
+
removeSeries: N.removeSeries,
|
|
163
|
+
legendItems: n(W.value, X.value, F.value)
|
|
164
|
+
}))),
|
|
165
|
+
options: Q
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
//#endregion
|
|
169
|
+
export { k as useChartCartesian };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ChartBaseRenderOptions, ChartHandle, ChartLabelContent, ChartMountOptions, ChartPartRenderSlice, ChartSlice, ChartSliceEntry } from '@bridge-ui/core/Domain';
|
|
2
|
+
import { ChartRootState } from './useChartRoot';
|
|
3
|
+
/**
|
|
4
|
+
* Pie / funnel root: slices from `data`, percents, plot labels, and the
|
|
5
|
+
* shared chart frame. Getters keep every input reactive.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useChartPart<Options extends ChartBaseRenderOptions & {
|
|
8
|
+
slices: ChartPartRenderSlice[];
|
|
9
|
+
}>(root: ChartRootState, { data, mount, order, family, labels, summary, percents, maxSlices, buildOptions, labelContent, positiveOnly, }: {
|
|
10
|
+
buildOptions: (base: ChartBaseRenderOptions & {
|
|
11
|
+
slices: ChartPartRenderSlice[];
|
|
12
|
+
}) => Options;
|
|
13
|
+
data: () => readonly ChartSlice[];
|
|
14
|
+
family: "pie" | "funnel";
|
|
15
|
+
labelContent: () => undefined | ChartLabelContent;
|
|
16
|
+
labels: () => boolean;
|
|
17
|
+
maxSlices?: () => number | undefined;
|
|
18
|
+
mount: (options: ChartMountOptions<Options>) => ChartHandle<Options>;
|
|
19
|
+
order?: (entries: ChartSliceEntry[]) => ChartSliceEntry[];
|
|
20
|
+
percents: (values: readonly number[]) => number[];
|
|
21
|
+
positiveOnly: boolean;
|
|
22
|
+
summary: (slices: ChartPartRenderSlice[]) => string;
|
|
23
|
+
}): {
|
|
24
|
+
frame: {
|
|
25
|
+
label: import('vue').ComputedRef<string>;
|
|
26
|
+
table: import('vue').ComputedRef<import('@bridge-ui/core/Domain').ChartTable>;
|
|
27
|
+
isEmpty: import('vue').ComputedRef<boolean>;
|
|
28
|
+
hostBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
29
|
+
plotBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
30
|
+
rootBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
31
|
+
liveBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
32
|
+
emptyBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
33
|
+
isLoading: import('vue').ComputedRef<boolean>;
|
|
34
|
+
tableBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
35
|
+
centerBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
36
|
+
loadingBind: import('vue').ComputedRef<import('vue').HTMLAttributes>;
|
|
37
|
+
announcement: import('vue').ComputedRef<string>;
|
|
38
|
+
emptyMessage: import('vue').ComputedRef<string>;
|
|
39
|
+
rootRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
40
|
+
plotRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
41
|
+
hostRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
42
|
+
};
|
|
43
|
+
context: import('vue').ComputedRef<import('./chartInjectionKey').ChartContextValue>;
|
|
44
|
+
options: import('vue').ComputedRef<Options | null>;
|
|
45
|
+
};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { toChartLegendItems as e, useChartColors as t, useChartContextValue as n, useChartFrame as r, useChartPlot as i } from "./useChartRoot.js";
|
|
2
|
+
import { computed as a } from "vue";
|
|
3
|
+
import { isNil as o } from "es-toolkit/compat";
|
|
4
|
+
import { getChartPartTable as s, getChartPartTooltip as c, isChartPartEmpty as l, resolveChartSliceLabel as u, toChartSliceEntries as d } from "@bridge-ui/core/Domain";
|
|
5
|
+
//#region src/Utils/Charts/useChartPart.ts
|
|
6
|
+
function f(f, { data: p, mount: m, order: h, family: g, labels: _, summary: v, percents: y, maxSlices: b, buildOptions: x, labelContent: S, positiveOnly: C }) {
|
|
7
|
+
let { hidden: w, locale: T, resolveMessage: E } = f, D = a(() => JSON.stringify(p() ?? [])), O = a(() => {
|
|
8
|
+
let e = d({
|
|
9
|
+
positiveOnly: C,
|
|
10
|
+
maxSlices: b?.(),
|
|
11
|
+
otherLabel: E("Other"),
|
|
12
|
+
data: JSON.parse(D.value)
|
|
13
|
+
});
|
|
14
|
+
return o(h) ? e : h(e);
|
|
15
|
+
}), k = t(f, () => O.value), A = a(() => {
|
|
16
|
+
let e = y(O.value.map((e) => e.value));
|
|
17
|
+
return O.value.map((t, n) => ({
|
|
18
|
+
id: t.id,
|
|
19
|
+
labelText: "",
|
|
20
|
+
label: t.label,
|
|
21
|
+
value: t.value,
|
|
22
|
+
percent: e[n] ?? 0,
|
|
23
|
+
color: k.value[t.id] ?? ""
|
|
24
|
+
}));
|
|
25
|
+
}), j = a(() => {
|
|
26
|
+
let e = O.value.filter((e) => !w.value.includes(e.id)), t = y(e.map((e) => e.value)), n = S() ?? "label", r = _();
|
|
27
|
+
return e.map((e, i) => {
|
|
28
|
+
let a = t[i] ?? 0;
|
|
29
|
+
return {
|
|
30
|
+
percent: a,
|
|
31
|
+
id: e.id,
|
|
32
|
+
label: e.label,
|
|
33
|
+
value: e.value,
|
|
34
|
+
color: k.value[e.id] ?? "",
|
|
35
|
+
labelText: r ? u({
|
|
36
|
+
content: n,
|
|
37
|
+
locale: T.value,
|
|
38
|
+
slice: {
|
|
39
|
+
percent: a,
|
|
40
|
+
label: e.label,
|
|
41
|
+
value: e.value
|
|
42
|
+
}
|
|
43
|
+
}) : ""
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}), M = a(() => {
|
|
47
|
+
let e = f.theme.value;
|
|
48
|
+
return o(e) ? null : x({
|
|
49
|
+
theme: e,
|
|
50
|
+
slices: j.value,
|
|
51
|
+
animation: f.animation.value,
|
|
52
|
+
width: f.plotSize.value.width,
|
|
53
|
+
height: f.plotSize.value.height
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
i(f, {
|
|
57
|
+
mount: m,
|
|
58
|
+
options: M
|
|
59
|
+
});
|
|
60
|
+
let N = a(() => {
|
|
61
|
+
let e = f.active.value.index, t = o(e) ? void 0 : j.value[e];
|
|
62
|
+
return o(t) ? null : c(t);
|
|
63
|
+
});
|
|
64
|
+
return {
|
|
65
|
+
frame: r(f, a(() => ({
|
|
66
|
+
tooltip: N.value,
|
|
67
|
+
count: j.value.length,
|
|
68
|
+
summary: v(A.value),
|
|
69
|
+
isEmpty: l(O.value),
|
|
70
|
+
table: s({
|
|
71
|
+
locale: T.value,
|
|
72
|
+
slices: A.value,
|
|
73
|
+
headers: {
|
|
74
|
+
value: E("Value"),
|
|
75
|
+
percent: E("Share"),
|
|
76
|
+
label: E("Category")
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
}))),
|
|
80
|
+
context: n(f, a(() => {
|
|
81
|
+
let t = new Map(j.value.map((e) => [e.id, e]));
|
|
82
|
+
return {
|
|
83
|
+
family: g,
|
|
84
|
+
tooltip: N.value,
|
|
85
|
+
legendItems: e(O.value.map((e) => ({
|
|
86
|
+
id: e.id,
|
|
87
|
+
name: e.label,
|
|
88
|
+
value: e.value,
|
|
89
|
+
percent: t.get(e.id)?.percent
|
|
90
|
+
})), k.value, w.value)
|
|
91
|
+
};
|
|
92
|
+
})),
|
|
93
|
+
options: M
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
//#endregion
|
|
97
|
+
export { f as useChartPart };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ChartAxisOptions, ChartAxisPosition } from '@bridge-ui/core/Domain';
|
|
2
|
+
import { ChartSeriesRegistration } from './chartInjectionKey';
|
|
3
|
+
/**
|
|
4
|
+
* Series and axes registered by chart children, in mount order.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useChartRegistry<Entry extends ChartSeriesRegistration>(): {
|
|
7
|
+
axes: import('vue').ShallowRef<Partial<Record<ChartAxisPosition, ChartAxisOptions>>, Partial<Record<ChartAxisPosition, ChartAxisOptions>>>;
|
|
8
|
+
entries: import('vue').ShallowRef<Entry[], Entry[]>;
|
|
9
|
+
setAxis: (position: ChartAxisPosition, options: ChartAxisOptions) => void;
|
|
10
|
+
removeAxis: (position: ChartAxisPosition) => void;
|
|
11
|
+
upsertSeries: (entry: ChartSeriesRegistration) => void;
|
|
12
|
+
removeSeries: (id: string) => void;
|
|
13
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { shallowRef as e } from "vue";
|
|
2
|
+
import { isEqual as t, isNil as n, omit as r } from "es-toolkit/compat";
|
|
3
|
+
import { isSameChartAxisOptions as i } from "@bridge-ui/core/Domain";
|
|
4
|
+
//#region src/Utils/Charts/useChartRegistry.ts
|
|
5
|
+
function a() {
|
|
6
|
+
let a = e([]), o = e({});
|
|
7
|
+
function s(e) {
|
|
8
|
+
let n = a.value.findIndex((t) => t.id === e.id);
|
|
9
|
+
if (n === -1) {
|
|
10
|
+
a.value = [...a.value, e];
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
if (t(a.value[n], e)) return;
|
|
14
|
+
let r = [...a.value];
|
|
15
|
+
r[n] = e, a.value = r;
|
|
16
|
+
}
|
|
17
|
+
function c(e) {
|
|
18
|
+
a.value = a.value.filter((t) => t.id !== e);
|
|
19
|
+
}
|
|
20
|
+
function l(e, t) {
|
|
21
|
+
let r = o.value[e];
|
|
22
|
+
(n(r) || !i(r, t)) && (o.value = {
|
|
23
|
+
...o.value,
|
|
24
|
+
[e]: t
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function u(e) {
|
|
28
|
+
o.value = r(o.value, [e]);
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
axes: o,
|
|
32
|
+
entries: a,
|
|
33
|
+
setAxis: l,
|
|
34
|
+
removeAxis: u,
|
|
35
|
+
upsertSeries: s,
|
|
36
|
+
removeSeries: c
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
//#endregion
|
|
40
|
+
export { a as useChartRegistry };
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { ComputedRef, HTMLAttributes } from 'vue';
|
|
2
|
+
import { BridgeUIComponentsConfig } from '@bridge-ui/core/Config';
|
|
3
|
+
import { ChartBaseRenderOptions, ChartHandle, ChartMountOptions, ChartRenderTheme, ChartTable, ChartTooltipContent } from '@bridge-ui/core/Domain';
|
|
4
|
+
import { ChartClasses, ChartRootOwnProps } from './chart.types';
|
|
5
|
+
import { ChartContextValue, ChartLegendItem, ChartLegendPosition } from './chartInjectionKey';
|
|
6
|
+
/**
|
|
7
|
+
* Registry names of the chart roots.
|
|
8
|
+
*/
|
|
9
|
+
export type ChartRootName = Extract<keyof BridgeUIComponentsConfig, "ChartBar" | "ChartPie" | "ChartLine" | "ChartFunnel" | "ChartScatter">;
|
|
10
|
+
/**
|
|
11
|
+
* Merged props every chart root resolves.
|
|
12
|
+
*/
|
|
13
|
+
export type ChartRootMerged = Pick<ChartRootOwnProps, "palette" | "customProps"> & {
|
|
14
|
+
animation: boolean;
|
|
15
|
+
height: number | string;
|
|
16
|
+
size: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Bridge keys shared by every chart root.
|
|
20
|
+
*/
|
|
21
|
+
export declare const chartRootBridgeKeys: readonly ["size", "width", "height", "classes", "loading", "palette", "summary", "animation", "customProps"];
|
|
22
|
+
type ChartActive = {
|
|
23
|
+
index: null | number;
|
|
24
|
+
source: "pointer" | "keyboard";
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Shared state for a chart root: registry merge, tokens, theme, plot size,
|
|
28
|
+
* active item, hidden items, and the mounted plot handle.
|
|
29
|
+
*/
|
|
30
|
+
export declare function useChartRoot<Merged extends ChartRootMerged>({ props, bridgeKeys, libDefaults, registryKeys, componentName, fallbackProps, }: {
|
|
31
|
+
bridgeKeys: readonly string[];
|
|
32
|
+
componentName: ChartRootName;
|
|
33
|
+
/**
|
|
34
|
+
* Props that win over registry defaults but lose to explicit props
|
|
35
|
+
* (e.g. the sparkline height).
|
|
36
|
+
*/
|
|
37
|
+
fallbackProps?: () => Partial<ChartRootOwnProps>;
|
|
38
|
+
libDefaults: Partial<Merged>;
|
|
39
|
+
props: ChartRootOwnProps;
|
|
40
|
+
registryKeys: readonly string[];
|
|
41
|
+
}): {
|
|
42
|
+
split: ComputedRef<{
|
|
43
|
+
componentProps: Record<string, unknown> & ChartRootOwnProps;
|
|
44
|
+
inheritedAttrs: HTMLAttributes & Record<string, unknown>;
|
|
45
|
+
}>;
|
|
46
|
+
theme: import('vue').ShallowRef<ChartRenderTheme | null, ChartRenderTheme | null>;
|
|
47
|
+
merged: ComputedRef<Merged>;
|
|
48
|
+
active: import('vue').ShallowRef<ChartActive, ChartActive>;
|
|
49
|
+
hidden: import('vue').Ref<string[], string[]>;
|
|
50
|
+
locale: ComputedRef<string>;
|
|
51
|
+
chartId: string;
|
|
52
|
+
palette: ComputedRef<string[]>;
|
|
53
|
+
rootRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
54
|
+
plotRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
55
|
+
hostRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
56
|
+
plotSize: import('vue').ShallowRef<{
|
|
57
|
+
width: number;
|
|
58
|
+
height: number;
|
|
59
|
+
}, {
|
|
60
|
+
width: number;
|
|
61
|
+
height: number;
|
|
62
|
+
}>;
|
|
63
|
+
sizeItem: ComputedRef<any>;
|
|
64
|
+
animation: ComputedRef<boolean>;
|
|
65
|
+
handleRef: import('vue').ShallowRef<ChartHandle<ChartBaseRenderOptions> | null, ChartHandle<ChartBaseRenderOptions> | null>;
|
|
66
|
+
getBounds: () => {
|
|
67
|
+
width: number;
|
|
68
|
+
height: number;
|
|
69
|
+
};
|
|
70
|
+
schemeTick: import('vue').Ref<number, number>;
|
|
71
|
+
toggleItem: (id: string) => void;
|
|
72
|
+
bridgeTheme: ComputedRef<string | undefined>;
|
|
73
|
+
customProps: ComputedRef<import('./chart.types').ChartCustomProps | undefined>;
|
|
74
|
+
colorClasses: ComputedRef<Partial<{
|
|
75
|
+
black: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
76
|
+
dark: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
77
|
+
error: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
78
|
+
info: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
79
|
+
primary: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
80
|
+
secondary: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
81
|
+
success: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
82
|
+
warning: import('@bridge-ui/core/Tokens').ChartColorItem;
|
|
83
|
+
}>>;
|
|
84
|
+
highlightItem: (id: null | string) => void;
|
|
85
|
+
mergedClasses: ComputedRef<Partial<ChartClasses>>;
|
|
86
|
+
legendPosition: import('vue').Ref<ChartLegendPosition | null, ChartLegendPosition | null>;
|
|
87
|
+
resolveMessage: (message: string, countOrParams?: number | import('@bridge-ui/core/Adapters').MessageParams, params?: import('@bridge-ui/core/Adapters').MessageParams) => string;
|
|
88
|
+
componentProps: ComputedRef<Record<string, unknown> & ChartRootOwnProps>;
|
|
89
|
+
getTooltipAnchor: (index: number) => {
|
|
90
|
+
y: number;
|
|
91
|
+
x: number;
|
|
92
|
+
} | null;
|
|
93
|
+
setLegendPosition: (position: null | ChartLegendPosition) => void;
|
|
94
|
+
onActiveIndexChange: (index: null | number) => void;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* State returned by {@link useChartRoot}.
|
|
98
|
+
*/
|
|
99
|
+
export type ChartRootState = ReturnType<typeof useChartRoot>;
|
|
100
|
+
/**
|
|
101
|
+
* Resolves item colors (token keys or CSS colors) to computed CSS colors.
|
|
102
|
+
* Items without `color` take palette entries in order.
|
|
103
|
+
*/
|
|
104
|
+
export declare function useChartColors(root: ChartRootState, items: () => ReadonlyArray<{
|
|
105
|
+
color?: string;
|
|
106
|
+
id: string;
|
|
107
|
+
}>): import('vue').ShallowRef<Record<string, string>, Record<string, string>>;
|
|
108
|
+
/**
|
|
109
|
+
* Mounts the plot into the host once the theme and size are known, then
|
|
110
|
+
* pushes every new options object to it.
|
|
111
|
+
*/
|
|
112
|
+
export declare function useChartPlot<Options extends ChartBaseRenderOptions>(root: ChartRootState, { mount, options, }: {
|
|
113
|
+
mount: (options: ChartMountOptions<Options>) => ChartHandle<Options>;
|
|
114
|
+
options: ComputedRef<null | Options>;
|
|
115
|
+
}): void;
|
|
116
|
+
/**
|
|
117
|
+
* Root, plot, and overlay binds plus keyboard navigation over `count` items.
|
|
118
|
+
*/
|
|
119
|
+
export declare function useChartFrame(root: ChartRootState, state: ComputedRef<{
|
|
120
|
+
count: number;
|
|
121
|
+
isEmpty: boolean;
|
|
122
|
+
summary: string;
|
|
123
|
+
table: ChartTable;
|
|
124
|
+
tooltip: null | ChartTooltipContent;
|
|
125
|
+
}>): {
|
|
126
|
+
label: ComputedRef<string>;
|
|
127
|
+
table: ComputedRef<ChartTable>;
|
|
128
|
+
isEmpty: ComputedRef<boolean>;
|
|
129
|
+
hostBind: ComputedRef<HTMLAttributes>;
|
|
130
|
+
plotBind: ComputedRef<HTMLAttributes>;
|
|
131
|
+
rootBind: ComputedRef<HTMLAttributes>;
|
|
132
|
+
liveBind: ComputedRef<HTMLAttributes>;
|
|
133
|
+
emptyBind: ComputedRef<HTMLAttributes>;
|
|
134
|
+
isLoading: ComputedRef<boolean>;
|
|
135
|
+
tableBind: ComputedRef<HTMLAttributes>;
|
|
136
|
+
centerBind: ComputedRef<HTMLAttributes>;
|
|
137
|
+
loadingBind: ComputedRef<HTMLAttributes>;
|
|
138
|
+
announcement: ComputedRef<string>;
|
|
139
|
+
emptyMessage: ComputedRef<string>;
|
|
140
|
+
rootRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
141
|
+
plotRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
142
|
+
hostRef: import('vue').ShallowRef<HTMLDivElement | null, HTMLDivElement | null>;
|
|
143
|
+
};
|
|
144
|
+
/**
|
|
145
|
+
* Frame state returned by {@link useChartFrame}.
|
|
146
|
+
*/
|
|
147
|
+
export type ChartFrameState = ReturnType<typeof useChartFrame>;
|
|
148
|
+
/**
|
|
149
|
+
* Provides the context value for the chart parts.
|
|
150
|
+
*/
|
|
151
|
+
export declare function useChartContextValue(root: ChartRootState, state: ComputedRef<Pick<ChartContextValue, "family" | "setAxis" | "tooltip" | "removeAxis" | "legendItems" | "removeSeries" | "upsertSeries">>): ComputedRef<ChartContextValue>;
|
|
152
|
+
/**
|
|
153
|
+
* Legend entries from items, their resolved colors, and the hidden ids.
|
|
154
|
+
*/
|
|
155
|
+
export declare function toChartLegendItems(items: ReadonlyArray<Pick<ChartLegendItem, "id" | "name" | "value" | "percent">>, colors: Record<string, string>, hidden: readonly string[]): ChartLegendItem[];
|
|
156
|
+
export {};
|