x-next 1.6.0 → 1.8.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_USAGE.md +182 -4
- package/CHANGELOG.md +74 -0
- package/dist/_hooks/use-chart-size.d.ts +25 -0
- package/dist/_utils/chart/index.d.ts +6 -0
- package/dist/_utils/chart/padding.d.ts +15 -0
- package/dist/_utils/chart/path.d.ts +34 -0
- package/dist/_utils/chart/scale.d.ts +55 -0
- package/dist/components/_components/chart/ChartAxis.d.ts +85 -0
- package/dist/components/_components/chart/ChartLegend.d.ts +26 -0
- package/dist/components/_components/chart/ChartTooltip.d.ts +76 -0
- package/dist/components/_components/chart/colors.d.ts +10 -0
- package/dist/components/_components/chart/interface.d.ts +38 -0
- package/dist/components/bar-chart/BarChart.d.ts +278 -0
- package/dist/components/bar-chart/helpers/layout.d.ts +55 -0
- package/dist/components/bar-chart/index.d.ts +600 -0
- package/dist/components/bar-chart/interface.d.ts +74 -0
- package/dist/components/bar-chart/props.d.ts +145 -0
- package/dist/components/date-picker/DatePicker.vue.d.ts +3 -3
- package/dist/components/date-picker/index.d.ts +6 -6
- package/dist/components/draggable/Draggable.d.ts +1 -1
- package/dist/components/draggable/index.d.ts +2 -2
- package/dist/components/drawer/index.d.ts +6 -6
- package/dist/components/drawer/src/Drawer.vue.d.ts +3 -3
- package/dist/components/dropdown/Dropdown.vue.d.ts +4 -4
- package/dist/components/dropdown/DropdownButton.vue.d.ts +5 -5
- package/dist/components/dropdown/DropdownSubmenu.vue.d.ts +4 -4
- package/dist/components/dropdown/index.d.ts +29 -29
- package/dist/components/form/FormItem.vue.d.ts +12 -12
- package/dist/components/form/form-item-label.vue.d.ts +3 -3
- package/dist/components/form/index.d.ts +24 -24
- package/dist/components/form-select/Select.d.ts +3 -3
- package/dist/components/form-select/index.d.ts +6 -6
- package/dist/components/form-slider/Slider.vue.d.ts +3 -3
- package/dist/components/form-slider/index.d.ts +6 -6
- package/dist/components/form-slider/slider-button.vue.d.ts +3 -3
- package/dist/components/grid/Row.vue.d.ts +3 -3
- package/dist/components/grid/index.d.ts +9 -9
- package/dist/components/heatmap/Heatmap.d.ts +10 -0
- package/dist/components/heatmap/index.d.ts +30 -0
- package/dist/components/image/Image.vue.d.ts +125 -17
- package/dist/components/image/ImagePreview.vue.d.ts +97 -7
- package/dist/components/image/ImagePreviewAction.d.ts +3 -3
- package/dist/components/image/ImagePreviewGroup.vue.d.ts +100 -7
- package/dist/components/image/hooks/use-image-drag.d.ts +2 -2
- package/dist/components/image/index.d.ts +712 -124
- package/dist/components/image/interface.d.ts +9 -1
- package/dist/components/image/preview-toolbar.vue.d.ts +3 -3
- package/dist/components/index.d.ts +4 -0
- package/dist/components/line-chart/LineChart.d.ts +295 -0
- package/dist/components/line-chart/helpers/layout.d.ts +74 -0
- package/dist/components/line-chart/index.d.ts +614 -0
- package/dist/components/line-chart/interface.d.ts +76 -0
- package/dist/components/line-chart/props.d.ts +173 -0
- package/dist/components/menu/sub-menu-pop.vue.d.ts +3 -3
- package/dist/components/pagination/page-options.vue.d.ts +6 -6
- package/dist/components/pie-chart/PieChart.d.ts +219 -0
- package/dist/components/pie-chart/index.d.ts +470 -0
- package/dist/components/pie-chart/interface.d.ts +58 -0
- package/dist/components/pie-chart/props.d.ts +107 -0
- package/dist/components/popconfirm/src/popup.vue.d.ts +3 -3
- package/dist/components/popover/Popover.d.ts +1 -1
- package/dist/components/popover/index.d.ts +3 -3
- package/dist/components/popup/Popup.d.ts +1 -1
- package/dist/components/popup/index.d.ts +3 -3
- package/dist/components/space/Space.d.ts +1 -1
- package/dist/components/space/index.d.ts +3 -3
- package/dist/components/tabs/Tabs.d.ts +1 -1
- package/dist/components/tabs/index.d.ts +3 -3
- package/dist/components/time-picker/TimePicker.vue.d.ts +3 -3
- package/dist/components/time-picker/index.d.ts +6 -6
- package/dist/components/tooltip/Tooltip.vue.d.ts +1 -1
- package/dist/components/tooltip/index.d.ts +3 -3
- package/dist/components/trend-chart/components/TrendChart.d.ts +19 -96
- package/dist/components/trend-chart/index.d.ts +33 -187
- package/dist/components/trend-chart/props.d.ts +9 -78
- package/dist/components/trend-chart/themes.d.ts +0 -1
- package/dist/components/trigger/Trigger.d.ts +1 -1
- package/dist/components/trigger/index.d.ts +3 -3
- package/dist/components/upload/Upload.d.ts +372 -0
- package/dist/components/upload/context.d.ts +28 -0
- package/dist/components/upload/index.d.ts +656 -0
- package/dist/components/upload/interface.d.ts +110 -0
- package/dist/components/upload/props.d.ts +321 -0
- package/dist/components/upload/upload-list-item.d.ts +15 -0
- package/dist/components/upload/upload-list.d.ts +11 -0
- package/dist/components/upload/upload-picture-item.d.ts +20 -0
- package/dist/components/upload/upload-trigger.d.ts +8 -0
- package/dist/components/upload/utils.d.ts +48 -0
- package/dist/es/_hooks/use-chart-size.js +25 -0
- package/dist/es/_styles/palette-aliases.js +7 -4
- package/dist/es/_utils/chart/padding.js +22 -0
- package/dist/es/_utils/chart/path.js +69 -0
- package/dist/es/_utils/chart/scale.js +77 -0
- package/dist/es/components/_components/chart/ChartAxis.js +79 -0
- package/dist/es/components/_components/chart/ChartLegend.js +53 -0
- package/dist/es/components/_components/chart/ChartTooltip.js +64 -0
- package/dist/es/components/_components/chart/colors.js +12 -0
- package/dist/es/components/bar-chart/BarChart.js +470 -0
- package/dist/es/components/bar-chart/helpers/layout.js +53 -0
- package/dist/es/components/bar-chart/index.js +8 -0
- package/dist/es/components/bar-chart/props.js +148 -0
- package/dist/es/components/heatmap/Heatmap.js +244 -169
- package/dist/es/components/image/Image.vue.js +55 -45
- package/dist/es/components/image/Image.vue2.js +113 -92
- package/dist/es/components/image/ImagePreview.vue.js +66 -53
- package/dist/es/components/image/ImagePreview.vue2.js +219 -171
- package/dist/es/components/image/ImagePreviewAction.js +12 -15
- package/dist/es/components/image/ImagePreviewGroup.vue.js +21 -20
- package/dist/es/components/image/ImagePreviewGroup.vue2.js +45 -39
- package/dist/es/components/image/hooks/use-image-drag.js +16 -14
- package/dist/es/components/index.js +136 -128
- package/dist/es/components/line-chart/LineChart.js +532 -0
- package/dist/es/components/line-chart/helpers/layout.js +80 -0
- package/dist/es/components/line-chart/index.js +8 -0
- package/dist/es/components/line-chart/props.js +178 -0
- package/dist/es/components/pie-chart/PieChart.js +397 -0
- package/dist/es/components/pie-chart/index.js +8 -0
- package/dist/es/components/pie-chart/props.js +104 -0
- package/dist/es/components/trend-chart/components/TrendChart.js +143 -183
- package/dist/es/components/trend-chart/components/trend-chart-curve.js +85 -81
- package/dist/es/components/trend-chart/props.js +28 -74
- package/dist/es/components/trend-chart/themes.js +30 -31
- package/dist/es/components/upload/Upload.js +420 -0
- package/dist/es/components/upload/context.js +4 -0
- package/dist/es/components/upload/index.js +8 -0
- package/dist/es/components/upload/props.js +321 -0
- package/dist/es/components/upload/upload-list-item.js +138 -0
- package/dist/es/components/upload/upload-list.js +48 -0
- package/dist/es/components/upload/upload-picture-item.js +109 -0
- package/dist/es/components/upload/upload-trigger.js +89 -0
- package/dist/es/components/upload/utils.js +195 -0
- package/dist/es/icons/_self/upload-icons.js +103 -0
- package/dist/es/index.js +197 -189
- package/dist/es/locale/en-US.js +30 -1
- package/dist/es/locale/zh-CN.js +30 -1
- package/dist/es/style.css +1 -1
- package/dist/icons/_self/upload-icons.d.ts +523 -0
- package/dist/index.cjs +4 -4
- package/dist/index.umd.js +4 -4
- package/dist/locale/interface.d.ts +45 -0
- package/dist/style/bar-chart.css +1 -0
- package/dist/style/bar-chart.js +2 -0
- package/dist/style/base.css +1 -1
- package/dist/style/heatmap.css +1 -1
- package/dist/style/image.css +1 -1
- package/dist/style/line-chart.css +1 -0
- package/dist/style/line-chart.js +2 -0
- package/dist/style/pie-chart.css +1 -0
- package/dist/style/pie-chart.js +2 -0
- package/dist/style/upload.css +1 -0
- package/dist/style/upload.js +2 -0
- package/dist/style.css +1 -1
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
- package/volar.d.ts +4 -0
- package/dist/components/trend-chart/components/trend-chart-grid.d.ts +0 -55
- package/dist/components/trend-chart/components/trend-chart-labels.d.ts +0 -26
- package/dist/components/trend-chart/helpers/genPath.d.ts +0 -8
- package/dist/components/trend-chart/helpers/getPadding.d.ts +0 -8
- package/dist/components/trend-chart/helpers/validatePadding.d.ts +0 -2
- package/dist/es/_hooks/use-popup-overflow-hidden.js +0 -29
- package/dist/es/components/trend-chart/components/trend-chart-grid.js +0 -62
- package/dist/es/components/trend-chart/components/trend-chart-labels.js +0 -75
- package/dist/es/components/trend-chart/helpers/genPath.js +0 -22
- package/dist/es/components/trend-chart/helpers/getPadding.js +0 -21
- package/dist/es/components/trend-chart/helpers/validatePadding.js +0 -7
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { definePropType as t } from "../../_utils/vue-eco.js";
|
|
2
|
-
import r from "
|
|
3
|
-
const
|
|
2
|
+
import { validatePadding as r } from "../../_utils/chart/padding.js";
|
|
3
|
+
const u = {
|
|
4
4
|
// 数据集
|
|
5
5
|
dataset: {
|
|
6
6
|
required: !0,
|
|
@@ -21,16 +21,6 @@ const o = {
|
|
|
21
21
|
type: [Number, String],
|
|
22
22
|
default: "100%"
|
|
23
23
|
},
|
|
24
|
-
// 网格属性
|
|
25
|
-
grid: {
|
|
26
|
-
default: null,
|
|
27
|
-
type: t(Object)
|
|
28
|
-
},
|
|
29
|
-
// 标签属性
|
|
30
|
-
labels: {
|
|
31
|
-
default: null,
|
|
32
|
-
type: t(Object)
|
|
33
|
-
},
|
|
34
24
|
// 最大值,传入后锁定数据域上界,超出部分被裁剪
|
|
35
25
|
max: {
|
|
36
26
|
type: Number
|
|
@@ -39,9 +29,15 @@ const o = {
|
|
|
39
29
|
min: {
|
|
40
30
|
type: Number
|
|
41
31
|
},
|
|
42
|
-
|
|
32
|
+
/*
|
|
33
|
+
* 绘制边距,支持 1-4 个非负数字字符串或单个非负数字。
|
|
34
|
+
*
|
|
35
|
+
* 默认 3 是最小的安全值:激活态数据点半径为 3px,圆心落在边界上时
|
|
36
|
+
* 圆的顶端恰好与画布边缘相切;再小就会被画布裁掉。默认值取这个下界,
|
|
37
|
+
* 让曲线尽可能贴近画布顶部(迷你图重在形态,不需要多余的留白)。
|
|
38
|
+
*/
|
|
43
39
|
padding: {
|
|
44
|
-
default: "
|
|
40
|
+
default: "3",
|
|
45
41
|
type: [String, Number],
|
|
46
42
|
validator(e) {
|
|
47
43
|
return typeof e == "number" ? Number.isFinite(e) && e >= 0 : r(e);
|
|
@@ -89,6 +85,23 @@ const o = {
|
|
|
89
85
|
ariaLabel: {
|
|
90
86
|
type: String
|
|
91
87
|
},
|
|
88
|
+
/*
|
|
89
|
+
* 已废弃:网格与坐标轴标签。
|
|
90
|
+
*
|
|
91
|
+
* 这两个能力在 1.7.0 发布过,但从定位上就不属于迷你图——带网格和坐标文字的
|
|
92
|
+
* 图是「读数的图」,应该用 LineChart。1.8.0 起不再渲染任何内容,
|
|
93
|
+
* 保留声明只为避免既有代码在升级时编译或运行报错。
|
|
94
|
+
*
|
|
95
|
+
* 保留一个次要版本后(2.0.0)彻底移除。
|
|
96
|
+
*/
|
|
97
|
+
grid: {
|
|
98
|
+
default: null,
|
|
99
|
+
type: t(Object)
|
|
100
|
+
},
|
|
101
|
+
labels: {
|
|
102
|
+
default: null,
|
|
103
|
+
type: t(Object)
|
|
104
|
+
},
|
|
92
105
|
// 主题
|
|
93
106
|
theme: {
|
|
94
107
|
type: t(Object),
|
|
@@ -162,67 +175,8 @@ const o = {
|
|
|
162
175
|
theme: {
|
|
163
176
|
type: t(Object)
|
|
164
177
|
}
|
|
165
|
-
}, i = {
|
|
166
|
-
boundary: {
|
|
167
|
-
required: !0,
|
|
168
|
-
type: t(Object),
|
|
169
|
-
default: () => {
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
verticalLines: {
|
|
173
|
-
default: !1,
|
|
174
|
-
type: Boolean
|
|
175
|
-
},
|
|
176
|
-
verticalLinesNumber: {
|
|
177
|
-
default: 0,
|
|
178
|
-
type: Number
|
|
179
|
-
},
|
|
180
|
-
horizontalLines: {
|
|
181
|
-
default: !1,
|
|
182
|
-
type: Boolean
|
|
183
|
-
},
|
|
184
|
-
horizontalLinesNumber: {
|
|
185
|
-
default: 0,
|
|
186
|
-
type: Number
|
|
187
|
-
}
|
|
188
|
-
}, n = {
|
|
189
|
-
boundary: {
|
|
190
|
-
required: !0,
|
|
191
|
-
type: t(Object),
|
|
192
|
-
default: () => {
|
|
193
|
-
}
|
|
194
|
-
},
|
|
195
|
-
minValue: {
|
|
196
|
-
type: Number,
|
|
197
|
-
required: !0
|
|
198
|
-
},
|
|
199
|
-
maxValue: {
|
|
200
|
-
type: Number,
|
|
201
|
-
required: !0
|
|
202
|
-
},
|
|
203
|
-
xLabels: {
|
|
204
|
-
type: Array
|
|
205
|
-
},
|
|
206
|
-
yLabels: {
|
|
207
|
-
type: Number,
|
|
208
|
-
required: !0
|
|
209
|
-
},
|
|
210
|
-
yLabelsTextFormatter: {
|
|
211
|
-
default: (e) => e,
|
|
212
|
-
type: Function
|
|
213
|
-
},
|
|
214
|
-
// 标签字号,默认按绘图区高度自适应
|
|
215
|
-
fontSize: {
|
|
216
|
-
type: Number
|
|
217
|
-
},
|
|
218
|
-
// 标签颜色
|
|
219
|
-
color: {
|
|
220
|
-
type: String
|
|
221
|
-
}
|
|
222
178
|
};
|
|
223
179
|
export {
|
|
224
180
|
l as trendChartCurveProps,
|
|
225
|
-
|
|
226
|
-
n as trendChartLabelsProps,
|
|
227
|
-
o as trendChartProps
|
|
181
|
+
u as trendChartProps
|
|
228
182
|
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const o = "var(--x-color-danger-solid)",
|
|
1
|
+
const o = "var(--x-color-danger-solid)", i = "var(--x-color-strong-solid)", r = "var(--x-color-warning-solid)", c = "var(--x-color-text-secondary)", t = "var(--x-color-success-solid)", l = "var(--x-color-primary-solid)", a = {
|
|
2
2
|
DANGER: {
|
|
3
3
|
// 主题色
|
|
4
4
|
color: o,
|
|
5
5
|
// 点
|
|
6
6
|
point: {
|
|
7
|
-
width:
|
|
7
|
+
width: 2,
|
|
8
8
|
color: o
|
|
9
9
|
},
|
|
10
10
|
// 描边
|
|
11
11
|
stroke: {
|
|
12
|
-
width:
|
|
12
|
+
width: 1.5,
|
|
13
13
|
color: o,
|
|
14
14
|
opacity: 1
|
|
15
15
|
},
|
|
@@ -20,53 +20,53 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
20
20
|
},
|
|
21
21
|
axisLine: {
|
|
22
22
|
color: o,
|
|
23
|
-
width:
|
|
23
|
+
width: 1,
|
|
24
24
|
opacity: 0.9
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
27
|
STRONG: {
|
|
28
28
|
// 主题色
|
|
29
|
-
color:
|
|
29
|
+
color: i,
|
|
30
30
|
// 点
|
|
31
31
|
point: {
|
|
32
|
-
width:
|
|
33
|
-
color:
|
|
32
|
+
width: 2,
|
|
33
|
+
color: i
|
|
34
34
|
},
|
|
35
35
|
stroke: {
|
|
36
|
-
width:
|
|
37
|
-
color:
|
|
36
|
+
width: 1.5,
|
|
37
|
+
color: i,
|
|
38
38
|
opacity: 1
|
|
39
39
|
},
|
|
40
40
|
fill: {
|
|
41
|
-
color:
|
|
41
|
+
color: i,
|
|
42
42
|
opacity: 0.1
|
|
43
43
|
},
|
|
44
44
|
axisLine: {
|
|
45
|
-
color:
|
|
46
|
-
width:
|
|
45
|
+
color: i,
|
|
46
|
+
width: 1,
|
|
47
47
|
opacity: 0.9
|
|
48
48
|
}
|
|
49
49
|
},
|
|
50
50
|
WARNING: {
|
|
51
51
|
// 主题色
|
|
52
|
-
color:
|
|
52
|
+
color: r,
|
|
53
53
|
// 点
|
|
54
54
|
point: {
|
|
55
|
-
width:
|
|
56
|
-
color:
|
|
55
|
+
width: 2,
|
|
56
|
+
color: r
|
|
57
57
|
},
|
|
58
58
|
stroke: {
|
|
59
|
-
width:
|
|
60
|
-
color:
|
|
59
|
+
width: 1.5,
|
|
60
|
+
color: r,
|
|
61
61
|
opacity: 1
|
|
62
62
|
},
|
|
63
63
|
fill: {
|
|
64
|
-
color:
|
|
64
|
+
color: r,
|
|
65
65
|
opacity: 0.1
|
|
66
66
|
},
|
|
67
67
|
axisLine: {
|
|
68
|
-
color:
|
|
69
|
-
width:
|
|
68
|
+
color: r,
|
|
69
|
+
width: 1,
|
|
70
70
|
opacity: 0.9
|
|
71
71
|
}
|
|
72
72
|
},
|
|
@@ -75,11 +75,11 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
75
75
|
color: t,
|
|
76
76
|
// 点
|
|
77
77
|
point: {
|
|
78
|
-
width:
|
|
78
|
+
width: 2,
|
|
79
79
|
color: t
|
|
80
80
|
},
|
|
81
81
|
stroke: {
|
|
82
|
-
width:
|
|
82
|
+
width: 1.5,
|
|
83
83
|
color: t,
|
|
84
84
|
opacity: 1
|
|
85
85
|
},
|
|
@@ -89,7 +89,7 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
89
89
|
},
|
|
90
90
|
axisLine: {
|
|
91
91
|
color: t,
|
|
92
|
-
width:
|
|
92
|
+
width: 1,
|
|
93
93
|
opacity: 0.9
|
|
94
94
|
}
|
|
95
95
|
},
|
|
@@ -98,11 +98,11 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
98
98
|
color: c,
|
|
99
99
|
// 点
|
|
100
100
|
point: {
|
|
101
|
-
width:
|
|
101
|
+
width: 2,
|
|
102
102
|
color: c
|
|
103
103
|
},
|
|
104
104
|
stroke: {
|
|
105
|
-
width:
|
|
105
|
+
width: 1.5,
|
|
106
106
|
color: c,
|
|
107
107
|
opacity: 1
|
|
108
108
|
},
|
|
@@ -112,7 +112,7 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
112
112
|
},
|
|
113
113
|
axisLine: {
|
|
114
114
|
color: c,
|
|
115
|
-
width:
|
|
115
|
+
width: 1,
|
|
116
116
|
opacity: 0.9
|
|
117
117
|
}
|
|
118
118
|
},
|
|
@@ -121,11 +121,11 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
121
121
|
color: l,
|
|
122
122
|
// 点
|
|
123
123
|
point: {
|
|
124
|
-
width:
|
|
124
|
+
width: 2,
|
|
125
125
|
color: l
|
|
126
126
|
},
|
|
127
127
|
stroke: {
|
|
128
|
-
width:
|
|
128
|
+
width: 1.5,
|
|
129
129
|
color: l,
|
|
130
130
|
opacity: 1
|
|
131
131
|
},
|
|
@@ -135,12 +135,11 @@ const o = "var(--x-color-danger-solid)", r = "var(--x-color-strong-solid)", i =
|
|
|
135
135
|
},
|
|
136
136
|
axisLine: {
|
|
137
137
|
color: l,
|
|
138
|
-
width:
|
|
138
|
+
width: 1,
|
|
139
139
|
opacity: 0.9
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
143
|
export {
|
|
144
|
-
a as
|
|
145
|
-
s as TrendChartTheme
|
|
144
|
+
a as TrendChartTheme
|
|
146
145
|
};
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
import { defineComponent as Me, computed as p, ref as E, watch as Ce, provide as je, onBeforeUnmount as Te, createVNode as R, mergeProps as Z, reactive as Ae } from "vue";
|
|
2
|
+
import { getClassNameMixin as _e } from "../../_utils/config.js";
|
|
3
|
+
import { useFormItem as Be } from "../../_hooks/use-form-item.js";
|
|
4
|
+
import { useLocale as De } from "../../locale/index.js";
|
|
5
|
+
import { isString as j, isFunction as z } from "../../_utils/is.js";
|
|
6
|
+
import { getValueByPath as Oe } from "../../_utils/get-value-by-path.js";
|
|
7
|
+
import ke from "../image/ImagePreviewGroup.vue.js";
|
|
8
|
+
import { uploadProps as ze } from "./props.js";
|
|
9
|
+
import { uploadInjectionKey as Ne } from "./context.js";
|
|
10
|
+
import Se from "./upload-list.js";
|
|
11
|
+
import qe from "./upload-trigger.js";
|
|
12
|
+
import { normalizeFileList as ee, isImageItem as te, revokeThumbUrl as T, collectDropFiles as Ve, collectPasteFiles as Ge, createThumbUrl as re, matchAccept as He, uploadRequest as Ke, resolveAbortHandle as We, isPromiseLike as $e, genUid as Je, normalizePromiseResponse as Qe } from "./utils.js";
|
|
13
|
+
const vt = /* @__PURE__ */ Me({
|
|
14
|
+
name: "Upload",
|
|
15
|
+
inheritAttrs: !1,
|
|
16
|
+
props: ze,
|
|
17
|
+
emits: {
|
|
18
|
+
"update:fileList": (n) => !0,
|
|
19
|
+
change: (n) => !0,
|
|
20
|
+
progress: (n) => !0,
|
|
21
|
+
success: (n) => !0,
|
|
22
|
+
error: (n) => !0,
|
|
23
|
+
remove: (n) => !0,
|
|
24
|
+
exceed: (n) => !0,
|
|
25
|
+
reject: (n) => !0,
|
|
26
|
+
preview: (n) => !0,
|
|
27
|
+
download: (n) => !0
|
|
28
|
+
},
|
|
29
|
+
slots: Object,
|
|
30
|
+
setup(n, {
|
|
31
|
+
attrs: H,
|
|
32
|
+
emit: c,
|
|
33
|
+
expose: ne,
|
|
34
|
+
slots: ae
|
|
35
|
+
}) {
|
|
36
|
+
const b = _e("upload"), {
|
|
37
|
+
t: U
|
|
38
|
+
} = De(), {
|
|
39
|
+
mergedDisabled: s,
|
|
40
|
+
eventHandlers: oe
|
|
41
|
+
} = Be({
|
|
42
|
+
disabled: p(() => n.disabled ?? !1)
|
|
43
|
+
}), K = E(), m = E(ee(n.defaultFileList)), d = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map(), _ = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new Map();
|
|
44
|
+
let f = !1;
|
|
45
|
+
const ie = E(!1), W = E(""), N = (e) => {
|
|
46
|
+
const t = Ae(e);
|
|
47
|
+
return d.set(t.uid, t), t;
|
|
48
|
+
};
|
|
49
|
+
m.value = m.value.map(N);
|
|
50
|
+
const F = (e) => {
|
|
51
|
+
var o;
|
|
52
|
+
const t = I.delete(e.uid), r = A.get(e.uid);
|
|
53
|
+
A.delete(e.uid);
|
|
54
|
+
const a = _.get(e.uid);
|
|
55
|
+
_.delete(e.uid);
|
|
56
|
+
try {
|
|
57
|
+
(o = r == null ? void 0 : r.abort) == null || o.call(r);
|
|
58
|
+
} catch {
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
a == null || a.abort();
|
|
62
|
+
} catch {
|
|
63
|
+
}
|
|
64
|
+
return t || !!r || !!a;
|
|
65
|
+
}, le = (e) => {
|
|
66
|
+
const t = ee(e).map((a) => {
|
|
67
|
+
const o = d.get(a.uid);
|
|
68
|
+
return o ? (o.thumbUrl !== a.thumbUrl && T(o.thumbUrl), Object.assign(o, a), o) : N(a);
|
|
69
|
+
}), r = new Set(t.map((a) => a.uid));
|
|
70
|
+
[...d.keys()].forEach((a) => {
|
|
71
|
+
if (r.has(a)) return;
|
|
72
|
+
const o = d.get(a);
|
|
73
|
+
o && F(o), T(o == null ? void 0 : o.thumbUrl), d.delete(a);
|
|
74
|
+
}), m.value = t;
|
|
75
|
+
};
|
|
76
|
+
Ce(() => n.fileList, (e) => {
|
|
77
|
+
e !== void 0 && le(e);
|
|
78
|
+
}, {
|
|
79
|
+
immediate: !0,
|
|
80
|
+
deep: !0
|
|
81
|
+
});
|
|
82
|
+
const i = p(() => m.value), y = () => {
|
|
83
|
+
m.value = m.value.slice();
|
|
84
|
+
}, h = (e, t) => {
|
|
85
|
+
var a, o;
|
|
86
|
+
const r = t.map((u) => ({
|
|
87
|
+
...u
|
|
88
|
+
}));
|
|
89
|
+
c("update:fileList", r), c("change", {
|
|
90
|
+
file: e,
|
|
91
|
+
fileList: r
|
|
92
|
+
}), (o = (a = oe.value) == null ? void 0 : a.onChange) == null || o.call(a);
|
|
93
|
+
}, $ = p(() => n.limit > 0 && i.value.length >= n.limit), J = p(() => {
|
|
94
|
+
const e = n.showUploadButton;
|
|
95
|
+
return e === !0 || e === void 0 ? !0 : e === !1 ? !1 : !$.value || e.showOnExceedLimit === !0;
|
|
96
|
+
}), Q = p(() => n.imagePreview), S = p(() => i.value.filter((e) => te(e)).map((e) => e.url || e.thumbUrl).filter((e) => !!e)), q = E(!1), V = E(0), se = (e) => {
|
|
97
|
+
const t = e.error;
|
|
98
|
+
if (t instanceof Error) return t.message;
|
|
99
|
+
if (j(t)) return t;
|
|
100
|
+
const r = e.response;
|
|
101
|
+
if (r && j(r.message)) return r.message;
|
|
102
|
+
}, L = (e) => {
|
|
103
|
+
W.value = e;
|
|
104
|
+
}, ue = async (e) => {
|
|
105
|
+
const t = n.action;
|
|
106
|
+
return z(t) ? await t(e.file) || void 0 : t || void 0;
|
|
107
|
+
}, ce = async (e) => {
|
|
108
|
+
const t = n.data;
|
|
109
|
+
return z(t) ? t(e) : t;
|
|
110
|
+
}, de = (e) => {
|
|
111
|
+
const t = n.name;
|
|
112
|
+
return z(t) ? t(e) || "file" : t || "file";
|
|
113
|
+
}, fe = (e, t) => {
|
|
114
|
+
const r = n.responseUrlKey;
|
|
115
|
+
if (!r) return;
|
|
116
|
+
if (z(r)) {
|
|
117
|
+
const o = r(e, t);
|
|
118
|
+
j(o) && (e.url = o);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const a = Oe(t, r);
|
|
122
|
+
j(a) && (e.url = a);
|
|
123
|
+
}, B = async (e) => {
|
|
124
|
+
const t = d.get(e.uid);
|
|
125
|
+
if (f || s.value || !(t != null && t.file) || I.has(t.uid) || !n.customRequest && !n.action)
|
|
126
|
+
return;
|
|
127
|
+
const r = Symbol();
|
|
128
|
+
let a = !1;
|
|
129
|
+
const o = typeof AbortController < "u" ? new AbortController() : void 0;
|
|
130
|
+
I.set(t.uid, r), o && _.set(t.uid, o);
|
|
131
|
+
const u = () => !f && I.get(t.uid) === r && d.get(t.uid) === t, l = () => {
|
|
132
|
+
a = !0, I.delete(t.uid), A.delete(t.uid), _.delete(t.uid);
|
|
133
|
+
};
|
|
134
|
+
t.status = "uploading", t.percent = 0, t.error = void 0, y(), h(t, i.value);
|
|
135
|
+
const g = (v) => {
|
|
136
|
+
u() && (l(), t.status = "error", t.percent = 0, t.error = v, y(), c("error", t), h(t, i.value), L(U("upload.fileFailed", {
|
|
137
|
+
name: t.name
|
|
138
|
+
})));
|
|
139
|
+
}, w = async (v, C) => {
|
|
140
|
+
if (!u() || a) return;
|
|
141
|
+
if (C) {
|
|
142
|
+
g(v);
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
let O;
|
|
146
|
+
try {
|
|
147
|
+
O = await Qe(v);
|
|
148
|
+
} catch (P) {
|
|
149
|
+
g(P);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
!u() || a || Y(O);
|
|
153
|
+
}, Y = (v) => {
|
|
154
|
+
if (u()) {
|
|
155
|
+
t.response = v;
|
|
156
|
+
try {
|
|
157
|
+
fe(t, v);
|
|
158
|
+
} catch (C) {
|
|
159
|
+
g(C);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
l(), t.status = "done", t.percent = 1, y(), c("success", t), h(t, i.value), L(U("upload.fileUploaded", {
|
|
163
|
+
name: t.name
|
|
164
|
+
}));
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
try {
|
|
168
|
+
const v = await ue(t);
|
|
169
|
+
if (!u()) return;
|
|
170
|
+
const C = await ce(t);
|
|
171
|
+
if (!u()) return;
|
|
172
|
+
if (s.value) {
|
|
173
|
+
F(t), t.status = "init", y(), h(t, i.value);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
if (!n.customRequest && !v) throw new Error("Upload action resolved to an empty URL");
|
|
177
|
+
const O = {
|
|
178
|
+
action: v ?? "",
|
|
179
|
+
method: n.method,
|
|
180
|
+
name: de(t),
|
|
181
|
+
file: t.file,
|
|
182
|
+
fileItem: t,
|
|
183
|
+
data: C,
|
|
184
|
+
headers: n.headers,
|
|
185
|
+
withCredentials: n.withCredentials,
|
|
186
|
+
timeout: n.timeout,
|
|
187
|
+
signal: o == null ? void 0 : o.signal,
|
|
188
|
+
onProgress: (x, Re) => {
|
|
189
|
+
if (!u()) return;
|
|
190
|
+
t.status = "uploading", t.percent = Number.isFinite(x) ? Math.max(0, Math.min(1, x)) : 0, y();
|
|
191
|
+
const Ie = {
|
|
192
|
+
file: t,
|
|
193
|
+
fileList: i.value,
|
|
194
|
+
percent: t.percent,
|
|
195
|
+
event: Re
|
|
196
|
+
};
|
|
197
|
+
c("progress", Ie), h(t, i.value);
|
|
198
|
+
},
|
|
199
|
+
onSuccess: Y,
|
|
200
|
+
onError: g
|
|
201
|
+
}, P = (n.customRequest ?? Ke)(O), k = We(P);
|
|
202
|
+
k && u() ? A.set(t.uid, {
|
|
203
|
+
abort: k
|
|
204
|
+
}) : k && !a && k(), $e(P) && (!a && u() ? Promise.resolve(P).then((x) => void w(x, !1), (x) => void w(x, !0)) : Promise.resolve(P).catch(() => {
|
|
205
|
+
}));
|
|
206
|
+
} catch (v) {
|
|
207
|
+
g(v);
|
|
208
|
+
}
|
|
209
|
+
}, ve = (e) => N({
|
|
210
|
+
uid: Je(),
|
|
211
|
+
name: e.name,
|
|
212
|
+
size: e.size,
|
|
213
|
+
type: e.type,
|
|
214
|
+
lastModified: e.lastModified,
|
|
215
|
+
status: "init",
|
|
216
|
+
percent: 0,
|
|
217
|
+
file: e,
|
|
218
|
+
thumbUrl: re(e)
|
|
219
|
+
}), me = async (e, t) => {
|
|
220
|
+
if (!n.beforeUpload) return e;
|
|
221
|
+
const r = await n.beforeUpload(e, t);
|
|
222
|
+
return r === !1 ? null : r === !0 || r === void 0 || r === null ? e : r instanceof File ? r : r instanceof Blob ? new File([r], e.name, {
|
|
223
|
+
type: r.type || e.type
|
|
224
|
+
}) : j(r) ? new File([r], e.name, {
|
|
225
|
+
type: e.type
|
|
226
|
+
}) : e;
|
|
227
|
+
}, he = (e) => {
|
|
228
|
+
n.autoUpload && B(e);
|
|
229
|
+
}, M = (e, t) => {
|
|
230
|
+
e.length && c("reject", {
|
|
231
|
+
files: e,
|
|
232
|
+
reason: t
|
|
233
|
+
});
|
|
234
|
+
}, D = async (e) => {
|
|
235
|
+
if (f || s.value || !e.length) return;
|
|
236
|
+
const t = n.multiple || n.directory ? e : e.slice(0, 1), r = [], a = [];
|
|
237
|
+
t.forEach((l) => {
|
|
238
|
+
He(l, n.accept) ? r.push(l) : a.push(l);
|
|
239
|
+
}), M(a, "accept");
|
|
240
|
+
const o = [], u = [];
|
|
241
|
+
if (r.forEach((l) => {
|
|
242
|
+
if (n.limit > 0 && i.value.length + u.length >= n.limit) {
|
|
243
|
+
o.push(l);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
u.push(l);
|
|
247
|
+
}), o.length) {
|
|
248
|
+
const l = {
|
|
249
|
+
files: o,
|
|
250
|
+
fileList: i.value
|
|
251
|
+
};
|
|
252
|
+
c("exceed", l), M(o, "limit"), L(U("upload.exceed", {
|
|
253
|
+
count: o.length
|
|
254
|
+
}));
|
|
255
|
+
}
|
|
256
|
+
for (const l of u) {
|
|
257
|
+
if (f || s.value) return;
|
|
258
|
+
let g = null;
|
|
259
|
+
try {
|
|
260
|
+
g = await me(l, u);
|
|
261
|
+
} catch {
|
|
262
|
+
if (f || s.value) return;
|
|
263
|
+
M([l], "beforeUpload");
|
|
264
|
+
continue;
|
|
265
|
+
}
|
|
266
|
+
if (f || s.value) return;
|
|
267
|
+
if (!g) {
|
|
268
|
+
M([l], "beforeUpload");
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (f || s.value) return;
|
|
272
|
+
if (n.limit > 0 && i.value.length >= n.limit) {
|
|
273
|
+
c("exceed", {
|
|
274
|
+
files: [l],
|
|
275
|
+
fileList: i.value
|
|
276
|
+
}), M([l], "limit"), L(U("upload.exceed", {
|
|
277
|
+
count: 1
|
|
278
|
+
}));
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
const w = ve(g);
|
|
282
|
+
m.value = [...m.value, w], h(w, i.value), L(U("upload.fileAdded", {
|
|
283
|
+
name: w.name
|
|
284
|
+
})), he(w);
|
|
285
|
+
}
|
|
286
|
+
}, ge = () => {
|
|
287
|
+
var e;
|
|
288
|
+
s.value || (e = K.value) == null || e.click();
|
|
289
|
+
}, pe = (e) => {
|
|
290
|
+
const t = e.target, r = Array.from(t.files ?? []);
|
|
291
|
+
t.value = "", D(r);
|
|
292
|
+
}, be = (e) => {
|
|
293
|
+
if (s.value || !e.dataTransfer) return;
|
|
294
|
+
const t = Array.from(e.dataTransfer.files ?? []);
|
|
295
|
+
(n.directory ? Ve(e.dataTransfer) : Promise.resolve(t)).then((a) => D(a)).catch(() => {
|
|
296
|
+
!f && !s.value && c("reject", {
|
|
297
|
+
files: t,
|
|
298
|
+
reason: "read"
|
|
299
|
+
});
|
|
300
|
+
});
|
|
301
|
+
}, ye = (e) => {
|
|
302
|
+
if (!n.paste || s.value) return;
|
|
303
|
+
const t = Ge(e.clipboardData);
|
|
304
|
+
t.length && (e.preventDefault(), D(t));
|
|
305
|
+
}, G = (e) => {
|
|
306
|
+
e = d.get(e.uid) ?? e, F(e) && (e.status = "init", e.percent = 0, y(), h(e, i.value));
|
|
307
|
+
}, X = (e) => {
|
|
308
|
+
B(e);
|
|
309
|
+
}, we = (e) => {
|
|
310
|
+
F(e), T(e.thumbUrl), d.delete(e.uid), m.value = m.value.filter((t) => t.uid !== e.uid), c("remove", e), h(e, i.value), L(U("upload.fileRemoved", {
|
|
311
|
+
name: e.name
|
|
312
|
+
}));
|
|
313
|
+
}, Ue = async (e) => {
|
|
314
|
+
if (!(f || s.value || d.get(e.uid) !== e)) {
|
|
315
|
+
if (n.beforeRemove) {
|
|
316
|
+
let t;
|
|
317
|
+
try {
|
|
318
|
+
t = await n.beforeRemove(e);
|
|
319
|
+
} catch {
|
|
320
|
+
t = !1;
|
|
321
|
+
}
|
|
322
|
+
if (t === !1) return;
|
|
323
|
+
}
|
|
324
|
+
f || s.value || d.get(e.uid) !== e || we(e);
|
|
325
|
+
}
|
|
326
|
+
}, Fe = (e) => {
|
|
327
|
+
if (Q.value && te(e)) {
|
|
328
|
+
const t = e.url || e.thumbUrl, r = t ? S.value.indexOf(t) : -1;
|
|
329
|
+
r >= 0 && (V.value = r, q.value = !0);
|
|
330
|
+
}
|
|
331
|
+
c("preview", e);
|
|
332
|
+
}, Le = (e) => {
|
|
333
|
+
const t = e.url || e.thumbUrl;
|
|
334
|
+
if (t) {
|
|
335
|
+
const r = document.createElement("a");
|
|
336
|
+
r.href = t, r.download = e.name, r.rel = "noopener", r.click();
|
|
337
|
+
}
|
|
338
|
+
c("download", e);
|
|
339
|
+
};
|
|
340
|
+
ne({
|
|
341
|
+
submit: (e) => {
|
|
342
|
+
if (e) {
|
|
343
|
+
B(e);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
i.value.filter((t) => t.status === "init" && !!t.file).forEach((t) => void B(t));
|
|
347
|
+
},
|
|
348
|
+
abort: (e) => {
|
|
349
|
+
if (e) {
|
|
350
|
+
G(e);
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
i.value.forEach((t) => {
|
|
354
|
+
t.status === "uploading" && G(t);
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
retry: X,
|
|
358
|
+
upload: (e) => {
|
|
359
|
+
D(e);
|
|
360
|
+
},
|
|
361
|
+
updateFile: (e, t) => {
|
|
362
|
+
const r = d.get(e);
|
|
363
|
+
f || s.value || !r || (F(r), T(r.thumbUrl), r.file = t, r.name = t.name, r.size = t.size, r.type = t.type, r.lastModified = t.lastModified, r.url = void 0, r.response = void 0, r.thumbUrl = re(t), r.status = "init", r.percent = 0, r.error = void 0, y(), h(r, i.value));
|
|
364
|
+
},
|
|
365
|
+
fileList: i
|
|
366
|
+
});
|
|
367
|
+
const Pe = {
|
|
368
|
+
props: n,
|
|
369
|
+
slots: ae,
|
|
370
|
+
disabled: s,
|
|
371
|
+
listType: p(() => n.listType),
|
|
372
|
+
fileList: i,
|
|
373
|
+
isMax: $,
|
|
374
|
+
showTrigger: J,
|
|
375
|
+
dragging: ie,
|
|
376
|
+
inputRef: K,
|
|
377
|
+
openFileDialog: ge,
|
|
378
|
+
onFileChange: pe,
|
|
379
|
+
onDropFiles: be,
|
|
380
|
+
handleRemove: Ue,
|
|
381
|
+
handleRetry: X,
|
|
382
|
+
handleCancel: G,
|
|
383
|
+
handlePreview: Fe,
|
|
384
|
+
handleDownload: Le,
|
|
385
|
+
getErrorText: se,
|
|
386
|
+
getTriggerAttrs: () => Object.fromEntries(Object.entries(H).filter(([e]) => e === "id" || e.startsWith("aria-")))
|
|
387
|
+
};
|
|
388
|
+
je(Ne, Pe), Te(() => {
|
|
389
|
+
f = !0, i.value.forEach((e) => {
|
|
390
|
+
F(e), T(e.thumbUrl);
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
const xe = p(() => [b.block, b.modifier(`list-type-${n.listType}`), n.draggable && b.modifier("draggable"), s.value && b.is("disabled")]), Ee = p(() => ({
|
|
394
|
+
srcList: S.value,
|
|
395
|
+
current: V.value,
|
|
396
|
+
visible: q.value,
|
|
397
|
+
infinite: !0
|
|
398
|
+
}));
|
|
399
|
+
return () => R("div", Z(Object.fromEntries(Object.entries(H).filter(([e]) => e !== "id" && !e.startsWith("aria-"))), {
|
|
400
|
+
class: xe.value,
|
|
401
|
+
onPaste: n.paste ? ye : void 0
|
|
402
|
+
}), [n.showFileList ? R(Se, null, null) : J.value && R("span", {
|
|
403
|
+
class: [b.element("entry"), n.draggable && b.is("entry-block")]
|
|
404
|
+
}, [R(qe, null, null)]), Q.value && S.value.length > 0 && R(ke, Z(Ee.value, {
|
|
405
|
+
"onUpdate:visible": (e) => {
|
|
406
|
+
q.value = e;
|
|
407
|
+
},
|
|
408
|
+
"onUpdate:current": (e) => {
|
|
409
|
+
V.value = e;
|
|
410
|
+
}
|
|
411
|
+
}), null), R("span", {
|
|
412
|
+
class: b.element("announcement"),
|
|
413
|
+
role: "status",
|
|
414
|
+
"aria-live": "polite"
|
|
415
|
+
}, [W.value])]);
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
export {
|
|
419
|
+
vt as default
|
|
420
|
+
};
|