v-nuxt-ui 0.1.33 → 0.1.35
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/dist/module.json +1 -1
- package/dist/runtime/assets/css/main.css +1 -1
- package/dist/runtime/components/EChart.client.vue +13 -6
- package/dist/runtime/components/SqlEditor.d.vue.ts +1 -1
- package/dist/runtime/components/SqlEditor.vue.d.ts +1 -1
- package/dist/runtime/components/table/query/order/Item.d.vue.ts +2 -2
- package/dist/runtime/components/table/query/order/Item.vue.d.ts +2 -2
- package/dist/runtime/composables/useEChart.d.ts +1 -3
- package/dist/runtime/composables/useEChart.js +155 -33
- package/dist/runtime/types/storage.d.ts +2 -1
- package/dist/runtime/types/storage.js +1 -0
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
:root{--ui-header-height:3.5rem;--ui-table-header-height:3rem;--ui-footer-height:3rem}::-webkit-scrollbar{height:.25rem;width:.25rem}::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.dark ::-webkit-scrollbar-thumb{background-color:#404040}
|
|
1
|
+
:root{--ui-header-height:3.5rem;--ui-table-header-height:3rem;--ui-footer-height:3rem}::-webkit-scrollbar{height:.25rem;width:.25rem}::-webkit-scrollbar-thumb{background-color:#e5e7eb;border-radius:9999px}.dark ::-webkit-scrollbar-thumb{background-color:#404040}input[type=number]{-moz-appearance:textfield;-webkit-appearance:textfield;appearance:textfield}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}:focus-visible{outline:none!important}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { ref, useTemplateRef, watch } from "vue";
|
|
3
|
-
import { useTheme } from "#v/composables/useTheme";
|
|
4
|
-
import { useApp } from "#v/composables/useApp";
|
|
5
|
-
import { useEChart } from "#v/composables/useEChart";
|
|
6
2
|
import { use } from "echarts/core";
|
|
7
3
|
import { CanvasRenderer } from "echarts/renderers";
|
|
8
4
|
import { BarChart, PieChart, LineChart } from "echarts/charts";
|
|
@@ -14,7 +10,10 @@ import {
|
|
|
14
10
|
ToolboxComponent
|
|
15
11
|
} from "echarts/components";
|
|
16
12
|
import VChart from "vue-echarts";
|
|
17
|
-
import {
|
|
13
|
+
import { useTheme, useApp, useEChart } from "#v/composables";
|
|
14
|
+
import { useColorMode, useLocalStorage } from "@vueuse/core";
|
|
15
|
+
import { ref, useTemplateRef, watch } from "vue";
|
|
16
|
+
import { StorageKey } from "#v/types";
|
|
18
17
|
const props = defineProps({
|
|
19
18
|
option: { type: null, required: true },
|
|
20
19
|
useBar: { type: Boolean, required: false, default: false },
|
|
@@ -47,13 +46,21 @@ const theme = useTheme();
|
|
|
47
46
|
const colorMode = useColorMode();
|
|
48
47
|
const app = useApp();
|
|
49
48
|
const echart = useEChart();
|
|
49
|
+
const rotateXAxisLabel = useLocalStorage(StorageKey.ECHART_ROTATE_X_AXIS_LABEL, false);
|
|
50
50
|
const finalOption = ref({});
|
|
51
51
|
const updateOption = () => {
|
|
52
52
|
finalOption.value = echart.mergeOption(props.option);
|
|
53
53
|
};
|
|
54
54
|
const chartRef = useTemplateRef("v-chart");
|
|
55
55
|
watch(
|
|
56
|
-
[
|
|
56
|
+
[
|
|
57
|
+
() => props.option,
|
|
58
|
+
colorMode,
|
|
59
|
+
() => theme.primary.value,
|
|
60
|
+
() => theme.neutral.value,
|
|
61
|
+
() => app.appConfig.value.radius,
|
|
62
|
+
() => rotateXAxisLabel.value
|
|
63
|
+
],
|
|
57
64
|
() => setTimeout(() => {
|
|
58
65
|
updateOption();
|
|
59
66
|
}, 1),
|
|
@@ -16,8 +16,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
16
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
17
17
|
"onUpdate:modelValue"?: ((value: string | null | undefined) => any) | undefined;
|
|
18
18
|
}>, {
|
|
19
|
-
tables: string[];
|
|
20
19
|
columns: Record<string, string[]>;
|
|
20
|
+
tables: string[];
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -16,8 +16,8 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
16
16
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
17
17
|
"onUpdate:modelValue"?: ((value: string | null | undefined) => any) | undefined;
|
|
18
18
|
}>, {
|
|
19
|
-
tables: string[];
|
|
20
19
|
columns: Record<string, string[]>;
|
|
20
|
+
tables: string[];
|
|
21
21
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
22
22
|
declare const _default: typeof __VLS_export;
|
|
23
23
|
export default _default;
|
|
@@ -7,15 +7,15 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
7
7
|
orderOptions: OrderQueryOption<T>[];
|
|
8
8
|
unselectedFields: string[];
|
|
9
9
|
} & {
|
|
10
|
-
onChange?: ((args_0: string, args_1: OrderQueryOpr) => any) | undefined;
|
|
11
10
|
onRemove?: (() => any) | undefined;
|
|
11
|
+
onChange?: ((args_0: string, args_1: OrderQueryOpr) => any) | undefined;
|
|
12
12
|
}> & (typeof globalThis extends {
|
|
13
13
|
__VLS_PROPS_FALLBACK: infer P;
|
|
14
14
|
} ? P : {});
|
|
15
15
|
expose: (exposed: {}) => void;
|
|
16
16
|
attrs: any;
|
|
17
17
|
slots: {};
|
|
18
|
-
emit: ((evt: "
|
|
18
|
+
emit: ((evt: "remove") => void) & ((evt: "change", args_0: string, args_1: OrderQueryOpr) => void);
|
|
19
19
|
}>) => import("vue").VNode & {
|
|
20
20
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
21
21
|
};
|
|
@@ -7,15 +7,15 @@ declare const __VLS_export: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_se
|
|
|
7
7
|
orderOptions: OrderQueryOption<T>[];
|
|
8
8
|
unselectedFields: string[];
|
|
9
9
|
} & {
|
|
10
|
-
onChange?: ((args_0: string, args_1: OrderQueryOpr) => any) | undefined;
|
|
11
10
|
onRemove?: (() => any) | undefined;
|
|
11
|
+
onChange?: ((args_0: string, args_1: OrderQueryOpr) => any) | undefined;
|
|
12
12
|
}> & (typeof globalThis extends {
|
|
13
13
|
__VLS_PROPS_FALLBACK: infer P;
|
|
14
14
|
} ? P : {});
|
|
15
15
|
expose: (exposed: {}) => void;
|
|
16
16
|
attrs: any;
|
|
17
17
|
slots: {};
|
|
18
|
-
emit: ((evt: "
|
|
18
|
+
emit: ((evt: "remove") => void) & ((evt: "change", args_0: string, args_1: OrderQueryOpr) => void);
|
|
19
19
|
}>) => import("vue").VNode & {
|
|
20
20
|
__ctx?: Awaited<typeof __VLS_setup>;
|
|
21
21
|
};
|
|
@@ -22,7 +22,6 @@ export declare const useEChart: () => {
|
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
getCommonXAxisOption: () => {
|
|
25
|
-
color: string[];
|
|
26
25
|
xAxis: {
|
|
27
26
|
nameTextStyle: {
|
|
28
27
|
color: string;
|
|
@@ -37,6 +36,7 @@ export declare const useEChart: () => {
|
|
|
37
36
|
color: string;
|
|
38
37
|
interval: () => boolean;
|
|
39
38
|
hideOverlap: boolean;
|
|
39
|
+
rotate: number;
|
|
40
40
|
};
|
|
41
41
|
axisTick: {
|
|
42
42
|
show: boolean;
|
|
@@ -78,7 +78,6 @@ export declare const useEChart: () => {
|
|
|
78
78
|
focus: string;
|
|
79
79
|
};
|
|
80
80
|
label: {
|
|
81
|
-
color: string;
|
|
82
81
|
distance: number;
|
|
83
82
|
};
|
|
84
83
|
};
|
|
@@ -87,7 +86,6 @@ export declare const useEChart: () => {
|
|
|
87
86
|
focus: string;
|
|
88
87
|
};
|
|
89
88
|
label: {
|
|
90
|
-
color: string;
|
|
91
89
|
distance: number;
|
|
92
90
|
};
|
|
93
91
|
};
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { createSharedComposable } from "@vueuse/core";
|
|
1
|
+
import { useLocalStorage, createSharedComposable } from "@vueuse/core";
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { useApp } from "./useApp.js";
|
|
4
|
-
import {
|
|
4
|
+
import { StorageKey } from "#v/types";
|
|
5
5
|
import { triggerFileDownloadFromUrl } from "#v/utils";
|
|
6
6
|
const _useEChart = () => {
|
|
7
7
|
const app = useApp();
|
|
8
|
-
const
|
|
8
|
+
const rotateXAxisLabel = useLocalStorage(StorageKey.ECHART_ROTATE_X_AXIS_LABEL, false);
|
|
9
9
|
const parseCSSVariableColor = (colorStr) => {
|
|
10
|
-
if (!colorStr?.startsWith("var("))
|
|
10
|
+
if (!colorStr?.startsWith("var(")) {
|
|
11
|
+
return colorStr;
|
|
12
|
+
}
|
|
11
13
|
const varName = colorStr.match(/var\((--[^,)]+)/)?.[1];
|
|
12
14
|
if (!varName) return colorStr;
|
|
13
15
|
const value = getComputedStyle(document.documentElement).getPropertyValue(varName).trim();
|
|
@@ -16,9 +18,14 @@ const _useEChart = () => {
|
|
|
16
18
|
const getNormedUiTextColor = () => parseCSSVariableColor("var(--ui-text-muted)");
|
|
17
19
|
const getNormedUiBorderColor = () => parseCSSVariableColor("var(--ui-border)");
|
|
18
20
|
const getNormedRadius = () => Math.round((app.appConfig.value.radius ?? 0.25) * 16);
|
|
19
|
-
const getNormedChartColors = () => theme.chartColorVars.value.map((colorVar) => parseCSSVariableColor(colorVar));
|
|
20
21
|
const getCommonGridOption = () => ({
|
|
21
|
-
grid: {
|
|
22
|
+
grid: {
|
|
23
|
+
left: "0",
|
|
24
|
+
right: "0",
|
|
25
|
+
bottom: "32",
|
|
26
|
+
top: "20",
|
|
27
|
+
containLabel: true
|
|
28
|
+
}
|
|
22
29
|
});
|
|
23
30
|
const getCommonLegendOption = () => ({
|
|
24
31
|
legend: {
|
|
@@ -27,45 +34,95 @@ const _useEChart = () => {
|
|
|
27
34
|
itemGap: 12,
|
|
28
35
|
itemWidth: 12,
|
|
29
36
|
itemHeight: 12,
|
|
30
|
-
textStyle: {
|
|
37
|
+
textStyle: {
|
|
38
|
+
color: getNormedUiTextColor()
|
|
39
|
+
},
|
|
31
40
|
icon: "circle"
|
|
32
41
|
}
|
|
33
42
|
});
|
|
34
43
|
const getCommonXAxisOption = () => ({
|
|
35
|
-
color: getNormedChartColors(),
|
|
36
44
|
xAxis: {
|
|
37
|
-
nameTextStyle: {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
nameTextStyle: {
|
|
46
|
+
color: getNormedUiTextColor()
|
|
47
|
+
},
|
|
48
|
+
axisLine: {
|
|
49
|
+
show: true,
|
|
50
|
+
lineStyle: {
|
|
51
|
+
color: getNormedUiBorderColor()
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
axisLabel: {
|
|
55
|
+
color: getNormedUiTextColor(),
|
|
56
|
+
interval: () => true,
|
|
57
|
+
// 始终显示所有标签,
|
|
58
|
+
hideOverlap: true,
|
|
59
|
+
rotate: rotateXAxisLabel.value ? 90 : 0
|
|
60
|
+
},
|
|
61
|
+
axisTick: {
|
|
62
|
+
show: true,
|
|
63
|
+
interval: () => true,
|
|
64
|
+
// 始终显示所有刻度线
|
|
65
|
+
lineStyle: {
|
|
66
|
+
color: getNormedUiBorderColor()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
41
69
|
}
|
|
42
70
|
});
|
|
43
71
|
const getCommonYAxisOption = () => ({
|
|
44
72
|
yAxis: {
|
|
45
|
-
nameTextStyle: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
73
|
+
nameTextStyle: {
|
|
74
|
+
color: getNormedUiTextColor()
|
|
75
|
+
},
|
|
76
|
+
axisLine: {
|
|
77
|
+
show: true,
|
|
78
|
+
lineStyle: {
|
|
79
|
+
color: getNormedUiBorderColor()
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
axisLabel: {
|
|
83
|
+
color: getNormedUiTextColor()
|
|
84
|
+
},
|
|
85
|
+
splitLine: {
|
|
86
|
+
show: false,
|
|
87
|
+
lineStyle: {
|
|
88
|
+
color: getNormedUiBorderColor(),
|
|
89
|
+
type: "dashed"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
49
92
|
}
|
|
50
93
|
});
|
|
51
94
|
const getCommonBarOption = () => ({
|
|
52
|
-
itemStyle: {
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
itemStyle: {
|
|
96
|
+
borderRadius: [getNormedRadius(), getNormedRadius(), 0, 0]
|
|
97
|
+
},
|
|
98
|
+
emphasis: {
|
|
99
|
+
focus: "series"
|
|
100
|
+
},
|
|
101
|
+
label: {
|
|
102
|
+
distance: 2
|
|
103
|
+
}
|
|
55
104
|
});
|
|
56
|
-
const getCommonBarOptionWithColor = (
|
|
57
|
-
|
|
58
|
-
|
|
105
|
+
const getCommonBarOptionWithColor = (_idx) => {
|
|
106
|
+
return defu(getCommonBarOption(), {
|
|
107
|
+
emphasis: {
|
|
108
|
+
itemStyle: {}
|
|
109
|
+
}
|
|
110
|
+
});
|
|
59
111
|
};
|
|
60
112
|
const getCommonLineOption = () => ({
|
|
61
|
-
emphasis: {
|
|
62
|
-
|
|
113
|
+
emphasis: {
|
|
114
|
+
focus: "series"
|
|
115
|
+
},
|
|
116
|
+
label: {
|
|
117
|
+
distance: 2
|
|
118
|
+
}
|
|
63
119
|
});
|
|
64
|
-
const getCommonLineOptionWithColor = (
|
|
65
|
-
const colors = getNormedChartColors();
|
|
120
|
+
const getCommonLineOptionWithColor = (_idx) => {
|
|
66
121
|
return defu(getCommonLineOption(), {
|
|
67
|
-
emphasis: {
|
|
68
|
-
|
|
122
|
+
emphasis: {
|
|
123
|
+
lineStyle: {}
|
|
124
|
+
},
|
|
125
|
+
lineStyle: {}
|
|
69
126
|
});
|
|
70
127
|
};
|
|
71
128
|
const getChartDataURL = (chart, options = {}) => {
|
|
@@ -75,7 +132,7 @@ const _useEChart = () => {
|
|
|
75
132
|
try {
|
|
76
133
|
return chart.getDataURL({ type: echartsType, backgroundColor, pixelRatio });
|
|
77
134
|
} catch (e) {
|
|
78
|
-
console.error("
|
|
135
|
+
console.error("\u83B7\u53D6 EChart \u56FE\u8868 dataURL \u5931\u8D25\uFF1A", e);
|
|
79
136
|
return null;
|
|
80
137
|
}
|
|
81
138
|
};
|
|
@@ -86,10 +143,75 @@ const _useEChart = () => {
|
|
|
86
143
|
triggerFileDownloadFromUrl(dataURL, `${filename}.${type}`);
|
|
87
144
|
};
|
|
88
145
|
const mergeSeries = (series) => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (
|
|
92
|
-
return
|
|
146
|
+
if (!series?.length) return [];
|
|
147
|
+
const getDataValue = (item) => {
|
|
148
|
+
if (item == null) return 0;
|
|
149
|
+
if (typeof item === "number") return item;
|
|
150
|
+
if (Array.isArray(item)) return Number(item[item.length - 1]) || 0;
|
|
151
|
+
if (typeof item === "object") {
|
|
152
|
+
const v = item.value;
|
|
153
|
+
return (Array.isArray(v) ? Number(v[v.length - 1]) : Number(v)) || 0;
|
|
154
|
+
}
|
|
155
|
+
return Number(item) || 0;
|
|
156
|
+
};
|
|
157
|
+
const stackDetails = /* @__PURE__ */ new Map();
|
|
158
|
+
series.forEach((s, idx) => {
|
|
159
|
+
if (s?.type === "bar" && s?.stack) {
|
|
160
|
+
if (!stackDetails.has(s.stack)) {
|
|
161
|
+
stackDetails.set(s.stack, { indices: [], maxLen: 0 });
|
|
162
|
+
}
|
|
163
|
+
const group = stackDetails.get(s.stack);
|
|
164
|
+
group.indices.push(idx);
|
|
165
|
+
const len = Array.isArray(s.data) ? s.data.length : 0;
|
|
166
|
+
if (len > group.maxLen) group.maxLen = len;
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const stackRadiusOwners = /* @__PURE__ */ new Map();
|
|
170
|
+
for (const [stack, { indices, maxLen }] of stackDetails) {
|
|
171
|
+
const owners = new Array(maxLen).fill(-1);
|
|
172
|
+
for (let i = 0; i < maxLen; i++) {
|
|
173
|
+
for (let j = indices.length - 1; j >= 0; j--) {
|
|
174
|
+
const sIdx = indices[j];
|
|
175
|
+
const val = getDataValue(series[sIdx]?.data?.[i]);
|
|
176
|
+
if (val !== 0) {
|
|
177
|
+
owners[i] = sIdx;
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
stackRadiusOwners.set(stack, owners);
|
|
183
|
+
}
|
|
184
|
+
const radius = getNormedRadius();
|
|
185
|
+
const radiusStyle = { borderRadius: [radius, radius, 0, 0] };
|
|
186
|
+
const noRadiusStyle = { borderRadius: 0 };
|
|
187
|
+
return series.map((s, idx) => {
|
|
188
|
+
if (!s) return s;
|
|
189
|
+
if (s.type === "line") {
|
|
190
|
+
return defu(s, getCommonLineOptionWithColor(idx));
|
|
191
|
+
}
|
|
192
|
+
if (s.type !== "bar") return s;
|
|
193
|
+
const isStack = !!s.stack;
|
|
194
|
+
const baseOption = getCommonBarOptionWithColor(idx);
|
|
195
|
+
if (isStack) {
|
|
196
|
+
baseOption.itemStyle = { ...baseOption.itemStyle, ...noRadiusStyle };
|
|
197
|
+
}
|
|
198
|
+
const merged = defu(s, baseOption);
|
|
199
|
+
if (isStack && Array.isArray(merged.data)) {
|
|
200
|
+
const owners = stackRadiusOwners.get(s.stack);
|
|
201
|
+
if (owners) {
|
|
202
|
+
merged.data = merged.data.map((item, i) => {
|
|
203
|
+
if (i < owners.length && owners[i] === idx) {
|
|
204
|
+
const itemObj = item !== null && typeof item === "object" && !Array.isArray(item) ? item : { value: item };
|
|
205
|
+
return {
|
|
206
|
+
...itemObj,
|
|
207
|
+
itemStyle: { ...itemObj.itemStyle, ...radiusStyle }
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return item;
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return merged;
|
|
93
215
|
});
|
|
94
216
|
};
|
|
95
217
|
const mergeOption = (option) => {
|
|
@@ -6,7 +6,8 @@ export declare enum StorageKey {
|
|
|
6
6
|
FLOW_EDGE_STROKE_WIDTH = "flow_edge_stroke_width",
|
|
7
7
|
FLOW_EDGE_MARKER_START = "flow_edge_marker_start",
|
|
8
8
|
FLOW_EDGE_MARKER_END = "flow_edge_marker_end",
|
|
9
|
-
FLOW_NODE_BORDER_WIDTH = "flow_node_border_width"
|
|
9
|
+
FLOW_NODE_BORDER_WIDTH = "flow_node_border_width",
|
|
10
|
+
ECHART_ROTATE_X_AXIS_LABEL = "echart_rotate_x_axis_label"
|
|
10
11
|
}
|
|
11
12
|
export type Column = {
|
|
12
13
|
accessorKey: string;
|
|
@@ -7,5 +7,6 @@ export var StorageKey = /* @__PURE__ */ ((StorageKey2) => {
|
|
|
7
7
|
StorageKey2["FLOW_EDGE_MARKER_START"] = "flow_edge_marker_start";
|
|
8
8
|
StorageKey2["FLOW_EDGE_MARKER_END"] = "flow_edge_marker_end";
|
|
9
9
|
StorageKey2["FLOW_NODE_BORDER_WIDTH"] = "flow_node_border_width";
|
|
10
|
+
StorageKey2["ECHART_ROTATE_X_AXIS_LABEL"] = "echart_rotate_x_axis_label";
|
|
10
11
|
return StorageKey2;
|
|
11
12
|
})(StorageKey || {});
|
package/package.json
CHANGED